本文整理汇总了Java中javax.management.openmbean.CompositeDataSupport.get方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeDataSupport.get方法的具体用法?Java CompositeDataSupport.get怎么用?Java CompositeDataSupport.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.openmbean.CompositeDataSupport
的用法示例。
在下文中一共展示了CompositeDataSupport.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapInnerAttribute
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
protected Optional<?> mapInnerAttribute(final CompositeDataSupport compositeData, final String jmxName,
final String description) {
Object innerValue = compositeData.get(jmxName);
AttributeMappingStrategy<?, ? extends OpenType<?>> attributeMappingStrategy = innerStrategies.get(jmxName);
return attributeMappingStrategy.mapAttribute(innerValue);
}
示例2: compare
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
private void compare(NetworkServerNestedConnectionStats expected, CompositeDataSupport actual, boolean actualCanBeGreater, boolean isAggregated) {
if(expected == null || actual == null) {
saveError("NetworkServerNestedConnectionStats ConnectionStatsType not match, Actual : " + actual + " and Expected : " + expected);
}
String connectionStateType = (String) actual.get("connectionStatsType");
if (!expected.getConnectionStatsType().equals(connectionStateType)) {
saveError(getAggregatePrefix(isAggregated) + "NetworkServerNestedConnectionStats ConnectionStatsType not match, Actual : "
+ connectionStateType + " and Expected : "
+ expected.getConnectionStatsType());
}
Log.getLogWriter().info("Verifing " + getAggregatePrefix(isAggregated) + "Network Connection Stat of " + connectionStateType);
Log.getLogWriter().info("Expected " + getAggregatePrefix(isAggregated) + "Network conn stat : " + expected);
Log.getLogWriter().info("Actual " + getAggregatePrefix(isAggregated) + "Network conn stat : " + actual);
long connectionsOpened = (Long) actual.get("connectionsOpened");
if (actualCanBeGreater ? expected.getConnectionsOpened() > connectionsOpened : expected.getConnectionsOpened() != connectionsOpened) {
saveError(
getAggregatePrefix(isAggregated) + "NetworkServerNestedConnectionStats connectionsOpened not match, Actual : "
+ connectionsOpened + " and Expected : "
+ expected.getConnectionsOpened());
}
long connectionsClosed = (Long)actual.get("connectionsClosed");
if(actualCanBeGreater ? expected.getConnectionsClosed() > connectionsClosed : expected.getConnectionsClosed() != connectionsClosed) {
saveError(getAggregatePrefix(isAggregated) + "NetworkServerNestedConnectionStats connectionsClosed not match, Actual : "
+ connectionsClosed
+ " and Expected : " + expected.getConnectionsClosed());
}
long connectionsActive = (Long)actual.get("connectionsActive");
if(actualCanBeGreater ? expected.getConnectionsActive() > connectionsActive : expected.getConnectionsActive() != connectionsActive) {
saveError(getAggregatePrefix(isAggregated) +"NetworkServerNestedConnectionStats connectionsActive not match, Actual : " + connectionsActive + " and Expected : " + expected.getConnectionsActive());
}
}
示例3: gatherAttributes
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
private List<String> gatherAttributes( final MBeanServerConnection mBeanServer, final ObjectName objectName )
throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
MBeanInfo info = mBeanServer.getMBeanInfo( objectName );
MBeanAttributeInfo[] attrInfo = info.getAttributes();
List<String> attributes = new ArrayList<>();
for( MBeanAttributeInfo attr : attrInfo ) {
try {
Object obj = mBeanServer.getAttribute( objectName, attr.getName() );
if( obj instanceof Number ) {
attributes.add( String.format( "%s=%s", attr.getName(), obj ) );
}
if( obj instanceof CompositeDataSupport ) {
CompositeDataSupport cd = (CompositeDataSupport) obj;
for( String item : cd.getCompositeType().keySet() ) {
Object obj1 = cd.get( item );
if( obj1 instanceof Number ) {
attributes.add( String.format( "%s.%s=%s", attr.getName(), item, obj1 ) );
}
}
}
} catch( Exception e ) {
attributes.add( String.format( "%s=(error: %s)", attr.getName(), e.getMessage() ) );
}
}
return ImmutableList.copyOf( attributes );
}
示例4: getValue
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
@Override
public Number getValue(Object object, MBeanAttribute attribute) {
Number value;
CompositeDataSupport cData = (CompositeDataSupport)object;
value = (Number)cData.get(attribute.getKey());
return value;
}
示例5: getValue
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
/**
*
* @param obj MBean attribute
* @param attr {@link MBeanAttribute}
* @return {@link Number}
*/
public Number getValue(Object obj,MBeanAttribute attr) throws NullPointerException {
Number value = 0;
String type = attr.getDataType();
switch (type) {
case "int":
value = ((int) obj) * attr.getScale();
break;
case "long":
value = ((long) obj) * attr.getScale();
break;
case "double":
value = ((double) obj) * attr.getScale();
break;
case "float":
value = ((float) obj) * attr.getScale();
break;
case "java.lang.Object":
value = ((double) obj) * attr.getScale();
break;
case "javax.management.openmbean.CompositeData":
CompositeDataSupport cData = (CompositeDataSupport)obj;
value = ((long) cData.get(attr.getKey())) * attr.getScale();
break;
default:
LOG.error("Unknown Type");
}
return value;
}
示例6: transformToMap
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
/**
* Transform an openMBean composite data to a Map
*
* @param data - composite data to transform
* @return map object
*/
protected Map transformToMap(CompositeDataSupport data) {
Properties props = new Properties();
String typeName = data.getCompositeType().getTypeName();
// Retrieve text message
if (typeName.equals(ActiveMQTextMessage.class.getName())) {
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "Text", data.get("Text").toString());
// Retrieve byte preview
} else if (typeName.equals(ActiveMQBytesMessage.class.getName())) {
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "BodyLength", data.get("BodyLength").toString());
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "BodyPreview", new String((byte[])data.get("BodyPreview")));
// Expand content map
} else if (typeName.equals(ActiveMQMapMessage.class.getName())) {
Map contentMap = (Map)data.get("ContentMap");
for (Iterator i = contentMap.keySet().iterator(); i.hasNext();) {
String key = (String)i.next();
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + key, contentMap.get(key).toString());
}
// Do nothing
} else if (typeName.equals(ActiveMQObjectMessage.class.getName()) || typeName.equals(ActiveMQStreamMessage.class.getName()) || typeName.equals(ActiveMQMessage.class.getName())) {
// Unrecognized composite data. Throw exception.
} else {
throw new IllegalArgumentException("Unrecognized composite data to transform. composite type: " + typeName);
}
// Process the JMS message header values
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSCorrelationID", "" + data.get("JMSCorrelationID"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDestination", "" + data.get("JMSDestination"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSMessageID", "" + data.get("JMSMessageID"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSReplyTo", "" + data.get("JMSReplyTo"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSType", "" + data.get("JMSType"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDeliveryMode", "" + data.get("JMSDeliveryMode"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSExpiration", "" + data.get("JMSExpiration"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSPriority", "" + data.get("JMSPriority"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSRedelivered", "" + data.get("JMSRedelivered"));
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSTimestamp", "" + data.get("JMSTimestamp"));
// Process the JMS custom message properties
props.setProperty(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX + "Properties", "" + data.get("Properties"));
return props;
}
示例7: handleNotification
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
@Override
public void handleNotification(Notification not, Object handback) {
if (not.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
CompositeDataSupport data=(CompositeDataSupport) not.getUserData();
String poolName = (String) data.get("poolName");
MemoryType type = types.get(poolName);
if(type==MemoryType.HEAP){
// clear heap
aprint.e("Clear heap!");
}
else if(type==MemoryType.NON_HEAP) {
// clear none-heap
((Config) handback).checkPermGenSpace(false);
}
/*CompositeDataSupport usage=(CompositeDataSupport) data.get("usage");
print.e(poolName);
print.e(types.get(poolName));
print.e(data.get("count"));
print.e(usage.get("committed"));
print.e(usage.get("init"));
print.e(usage.get("max"));
print.e(usage.get("used"));
long max=Caster.toLongValue(usage.get("max"),0);
long used=Caster.toLongValue(usage.get("used"),0);
long free=max-used;
print.o("m:"+max);
print.o("f:"+free);
print.o("%:"+(100L*used/max));
//not.*/
}
/*
javax.management.openmbean.CompositeDataSupport(
compositeType=javax.management.openmbean.CompositeType(
name=java.lang.management.MemoryUsage,
items=(
(itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
(itemName=init,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
(itemName=used,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)))),contents={committed=101580800, init=65404928, max=110362624, used=101085960})
javax.management.openmbean.CompositeDataSupport(
compositeType=javax.management.openmbean.CompositeType(
name=java.lang.management.MemoryNotificationInfo,
items=(
(itemName=count,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
(itemName=poolName,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),
(itemName=usage,itemType=javax.management.openmbean.CompositeType(name=java.lang.management.MemoryUsage,items=((itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=init,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=used,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long))))))),contents={count=1, poolName=CMS Old Gen, usage=javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=java.lang.management.MemoryUsage,items=((itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=init,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=used,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)))),contents={committed=101580800, init=65404928, max=110362624, used=101085944})})
*/
/*
print.e(data.getCompositeType());
print.e(not.getSource().getClass().getName());
print.e(not.getSource());
ObjectName on=(ObjectName) not.getSource();
print.e(on.getKeyPropertyList());
*/
/*
print.e(not.getUserData().getClass().getName());
print.e(not.getUserData());
print.e(not.getMessage());
print.e(not.getSequenceNumber());
print.e(not.getTimeStamp());
print.e(not.getType());*/
}
示例8: readJmx
import javax.management.openmbean.CompositeDataSupport; //导入方法依赖的package包/类
/**
* Read from JMX.
*
* @param type
* the type
* @param key
* the key
* @return the long
* @throws MBeanException
* the MBean exception
* @throws AttributeNotFoundException
* the attribute not found exception
* @throws ReflectionException
* the reflection exception
*/
private long readJmx(String type, String key)
throws MBeanException, AttributeNotFoundException, ReflectionException {
final CompositeDataSupport composite = (CompositeDataSupport) reporter.getAttribute(type);
return (long) composite.get(key);
}