use of javax.management.openmbean.CompositeType in project jdk8u_jdk by JetBrains.
the class GarbageCollectionNotifInfoCompositeData method getBaseGcNotifInfoCompositeType.
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
if (baseGcNotifInfoCompositeType == null) {
try {
OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, GcInfoCompositeData.getBaseGcInfoCompositeType() };
baseGcNotifInfoCompositeType = new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType", "CompositeType for Base GarbageCollectionNotificationInfo", gcNotifInfoItemNames, gcNotifInfoItemNames, baseGcNotifInfoItemTypes);
} catch (OpenDataException e) {
// shouldn't reach here
throw Util.newException(e);
}
}
return baseGcNotifInfoCompositeType;
}
use of javax.management.openmbean.CompositeType in project jdk8u_jdk by JetBrains.
the class GcInfoBuilder method getGcInfoCompositeType.
// Returns the CompositeType for the GcInfo including
// the extension attributes
synchronized CompositeType getGcInfoCompositeType() {
if (gcInfoCompositeType != null)
return gcInfoCompositeType;
// First, fill with the attributes in the GcInfo
String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames();
OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes();
int numGcInfoItems = gcInfoItemNames.length;
int itemCount = numGcInfoItems + gcExtItemCount;
allItemNames = new String[itemCount];
String[] allItemDescs = new String[itemCount];
OpenType<?>[] allItemTypes = new OpenType<?>[itemCount];
System.arraycopy(gcInfoItemNames, 0, allItemNames, 0, numGcInfoItems);
System.arraycopy(gcInfoItemNames, 0, allItemDescs, 0, numGcInfoItems);
System.arraycopy(gcInfoItemTypes, 0, allItemTypes, 0, numGcInfoItems);
// Then fill with the extension GC-specific attributes, if any.
if (gcExtItemCount > 0) {
fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames, gcExtItemTypes, gcExtItemDescs);
System.arraycopy(gcExtItemNames, 0, allItemNames, numGcInfoItems, gcExtItemCount);
System.arraycopy(gcExtItemDescs, 0, allItemDescs, numGcInfoItems, gcExtItemCount);
for (int i = numGcInfoItems, j = 0; j < gcExtItemCount; i++, j++) {
switch(gcExtItemTypes[j]) {
case 'Z':
allItemTypes[i] = SimpleType.BOOLEAN;
break;
case 'B':
allItemTypes[i] = SimpleType.BYTE;
break;
case 'C':
allItemTypes[i] = SimpleType.CHARACTER;
break;
case 'S':
allItemTypes[i] = SimpleType.SHORT;
break;
case 'I':
allItemTypes[i] = SimpleType.INTEGER;
break;
case 'J':
allItemTypes[i] = SimpleType.LONG;
break;
case 'F':
allItemTypes[i] = SimpleType.FLOAT;
break;
case 'D':
allItemTypes[i] = SimpleType.DOUBLE;
break;
default:
throw new AssertionError("Unsupported type [" + gcExtItemTypes[i] + "]");
}
}
}
CompositeType gict = null;
try {
final String typeName = "sun.management." + gc.getName() + ".GcInfoCompositeType";
gict = new CompositeType(typeName, "CompositeType for GC info for " + gc.getName(), allItemNames, allItemDescs, allItemTypes);
} catch (OpenDataException e) {
// shouldn't reach here
throw Util.newException(e);
}
gcInfoCompositeType = gict;
return gcInfoCompositeType;
}
use of javax.management.openmbean.CompositeType in project jdk8u_jdk by JetBrains.
the class GarbageCollectionNotifInfoCompositeData method getCompositeData.
protected CompositeData getCompositeData() {
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// gcNotifInfoItemNames!
final Object[] gcNotifInfoItemValues;
gcNotifInfoItemValues = new Object[] { gcNotifInfo.getGcName(), gcNotifInfo.getGcAction(), gcNotifInfo.getGcCause(), GcInfoCompositeData.toCompositeData(gcNotifInfo.getGcInfo()) };
CompositeType gict = getCompositeTypeByBuilder();
try {
return new CompositeDataSupport(gict, gcNotifInfoItemNames, gcNotifInfoItemValues);
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
use of javax.management.openmbean.CompositeType in project jdk8u_jdk by JetBrains.
the class GarbageCollectionNotifInfoCompositeData method getCompositeTypeByBuilder.
private CompositeType getCompositeTypeByBuilder() {
final GcInfoBuilder builder = AccessController.doPrivileged(new PrivilegedAction<GcInfoBuilder>() {
public GcInfoBuilder run() {
try {
Class cl = Class.forName("com.sun.management.GcInfo");
Field f = cl.getDeclaredField("builder");
f.setAccessible(true);
return (GcInfoBuilder) f.get(gcNotifInfo.getGcInfo());
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
return null;
}
}
});
CompositeType gict = null;
synchronized (compositeTypeByBuilder) {
gict = compositeTypeByBuilder.get(builder);
if (gict == null) {
OpenType<?>[] gcNotifInfoItemTypes = new OpenType<?>[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, builder.getGcInfoCompositeType() };
try {
final String typeName = "sun.management.GarbageCollectionNotifInfoCompositeType";
gict = new CompositeType(typeName, "CompositeType for GC notification info", gcNotifInfoItemNames, gcNotifInfoItemNames, gcNotifInfoItemTypes);
compositeTypeByBuilder.put(builder, gict);
} catch (OpenDataException e) {
// shouldn't reach here
throw Util.newException(e);
}
}
}
return gict;
}
use of javax.management.openmbean.CompositeType in project ddf by codice.
the class UndeliveredMessages method getMessages.
@Override
public List<CompositeData> getMessages(String address, String module) {
List<CompositeData> undeliveredMessages = new ArrayList<>();
Object compositeDatas = invokeMbean(createArtemisObjectName(address, module), GET_MESSAGES_OPERATION, new Object[] { "" }, new String[] { String.class.getName() });
if (!(compositeDatas instanceof CompositeData[])) {
return undeliveredMessages;
}
CompositeData[] messages = (CompositeData[]) compositeDatas;
for (CompositeData message : messages) {
Set<String> setMessageKeys = message.getCompositeType().keySet();
String[] messageKeysArray = setMessageKeys.toArray(new String[setMessageKeys.size()]);
Object[] messageValues = message.getAll(messageKeysArray);
CompositeType messageCompositeType = message.getCompositeType();
String[] itemDescription = new String[messageKeysArray.length];
OpenType<?>[] itemTypes = new OpenType[messageKeysArray.length];
try {
for (int i = 0; i < messageKeysArray.length; i++) {
String messageKey = messageKeysArray[i];
itemDescription[i] = messageCompositeType.getDescription(messageKey);
if (messageKeysArray[i].equals("body")) {
byte[] messageBodyBytes = (byte[]) message.get("body");
// Remove unprintable characters from the beginning of the string
messageValues[i] = removeNullCharacters(new String(Arrays.copyOfRange(messageBodyBytes, 5, messageBodyBytes.length), StandardCharsets.UTF_8));
itemTypes[i] = SimpleType.STRING;
} else {
itemTypes[i] = messageCompositeType.getType(messageKey);
}
}
undeliveredMessages.add(new CompositeDataSupport(new CompositeType(messageCompositeType.getTypeName(), messageCompositeType.getDescription(), messageKeysArray, itemDescription, itemTypes), messageKeysArray, messageValues));
} catch (OpenDataException e) {
LOGGER.warn("Unable to retrieve messages from the broker. For more information, set " + "logging level to DEBUG.");
LOGGER.debug("Unable to retrieve messages from the broker.", e);
}
}
return undeliveredMessages;
}
Aggregations