Merge pull request #15509 from jasontedor/simpler-compressed-oops-representation

Simpler using compressed oops flag representation
This commit is contained in:
Jason Tedor 2015-12-17 12:21:24 -05:00
commit c867c7c699
2 changed files with 20 additions and 22 deletions

View File

@ -296,10 +296,10 @@ public class NodeEnvironment extends AbstractComponent implements Closeable {
} }
private void maybeLogHeapDetails() { private void maybeLogHeapDetails() {
ByteSizeValue maxHeapSize = JvmInfo.jvmInfo().getMem().getHeapMax(); JvmInfo jvmInfo = JvmInfo.jvmInfo();
Boolean usingCompressedOops = JvmInfo.jvmInfo().usingCompressedOops(); ByteSizeValue maxHeapSize = jvmInfo.getMem().getHeapMax();
String usingCompressedOopsStatus = usingCompressedOops == null ? "unknown" : Boolean.toString(usingCompressedOops); String useCompressedOops = jvmInfo.useCompressedOops();
logger.info("heap size [{}], compressed ordinary object pointers [{}]", maxHeapSize, usingCompressedOopsStatus); logger.info("heap size [{}], compressed ordinary object pointers [{}]", maxHeapSize, useCompressedOops);
} }
private static String toString(Collection<String> items) { private static String toString(Collection<String> items) {

View File

@ -116,11 +116,10 @@ public class JvmInfo implements Streamable, ToXContent {
Method vmOptionMethod = clazz.getMethod("getVMOption", String.class); Method vmOptionMethod = clazz.getMethod("getVMOption", String.class);
Object useCompressedOopsVmOption = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "UseCompressedOops"); Object useCompressedOopsVmOption = vmOptionMethod.invoke(hotSpotDiagnosticMXBean, "UseCompressedOops");
Method valueMethod = vmOptionClazz.getMethod("getValue"); Method valueMethod = vmOptionClazz.getMethod("getValue");
String value = (String)valueMethod.invoke(useCompressedOopsVmOption); info.useCompressedOops = (String)valueMethod.invoke(useCompressedOopsVmOption);
info.usingCompressedOops = Boolean.parseBoolean(value);
} catch (Throwable t) { } catch (Throwable t) {
// unable to deduce the state of compressed oops // unable to deduce the state of compressed oops
// usingCompressedOops will hold its default value of null info.useCompressedOops = "unknown";
} }
INSTANCE = info; INSTANCE = info;
@ -157,7 +156,7 @@ public class JvmInfo implements Streamable, ToXContent {
String[] gcCollectors = Strings.EMPTY_ARRAY; String[] gcCollectors = Strings.EMPTY_ARRAY;
String[] memoryPools = Strings.EMPTY_ARRAY; String[] memoryPools = Strings.EMPTY_ARRAY;
private Boolean usingCompressedOops; private String useCompressedOops;
private JvmInfo() { private JvmInfo() {
} }
@ -282,8 +281,16 @@ public class JvmInfo implements Streamable, ToXContent {
return this.systemProperties; return this.systemProperties;
} }
public Boolean usingCompressedOops() { /**
return this.usingCompressedOops; * The value of the JVM flag UseCompressedOops, if available otherwise
* "unknown". The value "unknown" indicates that an attempt was
* made to obtain the value of the flag on this JVM and the attempt
* failed.
*
* @return the value of the JVM flag UseCompressedOops or "unknown"
*/
public String useCompressedOops() {
return this.useCompressedOops;
} }
@Override @Override
@ -307,7 +314,7 @@ public class JvmInfo implements Streamable, ToXContent {
builder.field(Fields.GC_COLLECTORS, gcCollectors); builder.field(Fields.GC_COLLECTORS, gcCollectors);
builder.field(Fields.MEMORY_POOLS, memoryPools); builder.field(Fields.MEMORY_POOLS, memoryPools);
builder.field(Fields.USING_COMPRESSED_OOPS, usingCompressedOops == null ? "unknown" : Boolean.toString(usingCompressedOops)); builder.field(Fields.USING_COMPRESSED_OOPS, useCompressedOops);
builder.endObject(); builder.endObject();
return builder; return builder;
@ -368,11 +375,7 @@ public class JvmInfo implements Streamable, ToXContent {
mem.readFrom(in); mem.readFrom(in);
gcCollectors = in.readStringArray(); gcCollectors = in.readStringArray();
memoryPools = in.readStringArray(); memoryPools = in.readStringArray();
if (in.readBoolean()) { useCompressedOops = in.readString();
usingCompressedOops = in.readBoolean();
} else {
usingCompressedOops = null;
}
} }
@Override @Override
@ -397,12 +400,7 @@ public class JvmInfo implements Streamable, ToXContent {
mem.writeTo(out); mem.writeTo(out);
out.writeStringArray(gcCollectors); out.writeStringArray(gcCollectors);
out.writeStringArray(memoryPools); out.writeStringArray(memoryPools);
if (usingCompressedOops != null) { out.writeString(useCompressedOops);
out.writeBoolean(true);
out.writeBoolean(usingCompressedOops);
} else {
out.writeBoolean(false);
}
} }
public static class Mem implements Streamable { public static class Mem implements Streamable {