-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[server] Validate block-cache config against system memory #1508
base: main
Are you sure you want to change the base?
Changes from all commits
2861744
f3ecda2
f7b9681
bc574b7
70246a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.lang.management.ManagementFactory; | ||
import java.lang.management.OperatingSystemMXBean; | ||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
import java.nio.file.Files; | ||
|
@@ -1141,4 +1142,16 @@ public static long parseDateTimeToEpoch(String dateTime, String dateTimeFormat, | |
dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone)); | ||
return dateFormat.parse(dateTime).getTime(); | ||
} | ||
|
||
public static long getOSMemorySize() { | ||
OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean(); | ||
|
||
if (osBean instanceof com.sun.management.OperatingSystemMXBean) { | ||
com.sun.management.OperatingSystemMXBean extendedOsBean = (com.sun.management.OperatingSystemMXBean) osBean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tested this function in Mac or Linux with OpenJDK? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this works in mac, and linux container/helix code uses same mechanism to fetch system memory. |
||
return extendedOsBean.getTotalPhysicalMemorySize(); | ||
} else { | ||
System.out.println("OS Bean not available."); | ||
} | ||
return -1; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @m-nagarajan mentioned, it is better to make the ratio configurable.