本文整理匯總了Java中javax.management.openmbean.CompositeData類的典型用法代碼示例。如果您正苦於以下問題:Java CompositeData類的具體用法?Java CompositeData怎麽用?Java CompositeData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CompositeData類屬於javax.management.openmbean包,在下文中一共展示了CompositeData類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSlowQueriesCD
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
/**
* JMX operation - returns all the queries we have collected.
* @return - the slow query report as composite data.
*/
@Override
public CompositeData[] getSlowQueriesCD() throws OpenDataException {
CompositeDataSupport[] result = null;
ConcurrentHashMap<String,QueryStats> queries = perPoolStats.get(poolName);
if (queries!=null) {
Set<Map.Entry<String,QueryStats>> stats = queries.entrySet();
if (stats!=null) {
result = new CompositeDataSupport[stats.size()];
Iterator<Map.Entry<String,QueryStats>> it = stats.iterator();
int pos = 0;
while (it.hasNext()) {
Map.Entry<String,QueryStats> entry = it.next();
QueryStats qs = entry.getValue();
result[pos++] = qs.getCompositeData(getCompositeType());
}
}
}
return result;
}
示例2: main
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
public static void main(String[] args) {
try {
String host = "localhost"; host = "csseredapp-dev-03";
String port = "8356"; //port = "8356";
String mbeanName = "java.lang:type=Memory";
String attributeName = "HeapMemoryUsage";
JMXServiceURL jmxUrl = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi" );
// jmxUrl = new JMXServiceURL(
// "service:jmx:rmi://localhost/jndi/rmi://" + host + ":" + port + "/jmxrmi" );
logger.info("Target: " + jmxUrl ) ;
JMXConnector jmxConnection = JMXConnectorFactory.connect( jmxUrl );
logger.info("Got connections") ;
CompositeData resultData = (CompositeData) jmxConnection.getMBeanServerConnection()
.getAttribute( new ObjectName(mbeanName), attributeName) ;
logger.log(Level.INFO, "Got mbean: heapUsed: {0}", resultData.get( "used")) ;
Thread.sleep( 5000 );
} catch ( Exception ex ) {
logger.log( Level.SEVERE, "Failed connection", ex );
}
}
示例3: installGCMonitoring
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
private static void installGCMonitoring() {
List<GarbageCollectorMXBean> gcbeans = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean gcbean : gcbeans) {
NotificationEmitter emitter = (NotificationEmitter) gcbean;
System.out.println(gcbean.getName());
NotificationListener listener = (notification, handback) -> {
if (notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData) notification.getUserData());
long duration = info.getGcInfo().getDuration();
String gctype = info.getGcAction();
System.out.println(gctype + ": - "
+ info.getGcInfo().getId() + ", "
+ info.getGcName()
+ " (from " + info.getGcCause() + ") " + duration + " milliseconds");
}
};
emitter.addNotificationListener(listener, null, null);
}
}
示例4: fromCompositeData
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
Object fromCompositeData(CompositeData cd, String[] itemNames, OpenTypeConverter[] converters)
throws InvalidObjectException {
Object o;
try {
o = getTargetClass().newInstance();
for (int i = 0; i < itemNames.length; i++) {
if (cd.containsKey(itemNames[i])) {
Object openItem = cd.get(itemNames[i]);
Object javaItem = converters[i].fromOpenValue(openItem);
setters[i].invoke(o, javaItem);
}
}
} catch (Exception e) {
throw invalidObjectException(e);
}
return o;
}
示例5: getCompositeData
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
protected CompositeData getCompositeData() {
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// memoryUsageItemNames!
final Object[] memoryUsageItemValues = {
usage.getInit(),
usage.getUsed(),
usage.getCommitted(),
usage.getMax(),
};
try {
return new CompositeDataSupport(memoryUsageCompositeType,
memoryUsageItemNames,
memoryUsageItemValues);
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
示例6: from
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
public static MonitorInfo from(CompositeData cd) {
try {
CompositeData stecd = (CompositeData) cd.get("lockedStackFrame");
StackTraceElement ste = new StackTraceElement(
(String) stecd.get("className"),
(String) stecd.get("methodName"),
(String) stecd.get("fileName"),
(Integer) stecd.get("lineNumber"));
return new MonitorInfo(
(String) cd.get("className"),
(Integer) cd.get("identityHashCode"),
(Integer) cd.get("lockedStackDepth"),
ste);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例7: getCompositeData
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
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);
}
}
示例8: getCompositeData
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
protected CompositeData getCompositeData() {
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// lockInfoItemNames!
final Object[] lockInfoItemValues = {
new String(lock.getClassName()),
new Integer(lock.getIdentityHashCode()),
};
try {
return new CompositeDataSupport(lockInfoCompositeType,
lockInfoItemNames,
lockInfoItemValues);
} catch (OpenDataException e) {
// Should never reach here
throw Util.newException(e);
}
}
示例9: printGcInfo
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
private static void printGcInfo(CompositeData cd) throws Exception {
GcInfo info = GcInfo.from(cd);
System.out.print("GC #" + info.getId());
System.out.print(" start:" + info.getStartTime());
System.out.print(" end:" + info.getEndTime());
System.out.println(" (" + info.getDuration() + "ms)");
Map<String,MemoryUsage> usage = info.getMemoryUsageBeforeGc();
for (Map.Entry<String,MemoryUsage> entry : usage.entrySet()) {
String poolname = entry.getKey();
MemoryUsage busage = entry.getValue();
MemoryUsage ausage = info.getMemoryUsageAfterGc().get(poolname);
if (ausage == null) {
throw new RuntimeException("After Gc Memory does not exist" +
" for " + poolname);
}
System.out.println("Usage for pool " + poolname);
System.out.println(" Before GC: " + busage);
System.out.println(" After GC: " + ausage);
}
}
示例10: toCompositeData
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
/**
* @param jobDetail
* @return CompositeData
*/
public static CompositeData toCompositeData(JobDetail jobDetail) {
try {
return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
new Object[] {
jobDetail.getKey().getName(),
jobDetail.getKey().getGroup(),
jobDetail.getDescription(),
jobDetail.getJobClass().getName(),
JobDataMapSupport.toTabularData(jobDetail
.getJobDataMap()),
jobDetail.isDurable(),
jobDetail.requestsRecovery(), });
} catch (OpenDataException e) {
throw new RuntimeException(e);
}
}
示例11: toCompositeData
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
/**
* @return composite data
*/
public static CompositeData toCompositeData(JobExecutionContext jec)
throws SchedulerException {
try {
return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
new Object[] {
jec.getScheduler().getSchedulerName(),
jec.getTrigger().getKey().getName(),
jec.getTrigger().getKey().getGroup(),
jec.getJobDetail().getKey().getName(),
jec.getJobDetail().getKey().getGroup(),
JobDataMapSupport.toTabularData(jec
.getMergedJobDataMap()),
jec.getTrigger().getCalendarName(),
jec.isRecovering(),
jec.getRefireCount(),
jec.getFireTime(), jec.getScheduledFireTime(),
jec.getPreviousFireTime(), jec.getNextFireTime(),
jec.getJobRunTime(),
jec.getFireInstanceId() });
} catch (OpenDataException e) {
throw new RuntimeException(e);
}
}
示例12: fromNonNullOpenValue
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
@Override
final Object fromNonNullOpenValue(Object openValue)
throws InvalidObjectException {
final TabularData table = (TabularData) openValue;
final Collection<CompositeData> rows = cast(table.values());
final Map<Object, Object> valueMap =
sortedMap ? newSortedMap() : newInsertionOrderMap();
for (CompositeData row : rows) {
final Object key =
keyMapping.fromOpenValue(row.get("key"));
final Object value =
valueMapping.fromOpenValue(row.get("value"));
if (valueMap.put(key, value) != null) {
final String msg =
"Duplicate entry in TabularData: key=" + key;
throw new InvalidObjectException(msg);
}
}
return valueMap;
}
示例13: toCompositeData
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
public static CompositeData toCompositeData(Trigger trigger) {
try {
return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
new Object[] {
trigger.getKey().getName(),
trigger.getKey().getGroup(),
trigger.getJobKey().getName(),
trigger.getJobKey().getGroup(),
trigger.getDescription(),
JobDataMapSupport.toTabularData(trigger
.getJobDataMap()),
trigger.getCalendarName(),
((OperableTrigger)trigger).getFireInstanceId(),
trigger.getMisfireInstruction(),
trigger.getPriority(), trigger.getStartTime(),
trigger.getEndTime(), trigger.getNextFireTime(),
trigger.getPreviousFireTime(),
trigger.getFinalFireTime() });
} catch (OpenDataException e) {
throw new RuntimeException(e);
}
}
示例14: handleNotification
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
@Override
public void handleNotification(Notification notif, Object handback) {
String type = notif.getType();
if (MEMORY_THRESHOLD_EXCEEDED.equals(type) ||
MEMORY_COLLECTION_THRESHOLD_EXCEEDED.equals(type)) {
MemoryNotificationInfo minfo = MemoryNotificationInfo.
from((CompositeData) notif.getUserData());
MemoryUtil.printMemoryNotificationInfo(minfo, type);
PoolRecord pr = (PoolRecord) result.get(minfo.getPoolName());
if (pr == null) {
throw new RuntimeException("Pool " + minfo.getPoolName() +
" is not selected");
}
if (!MEMORY_COLLECTION_THRESHOLD_EXCEEDED.equals(type)) {
throw new RuntimeException("Pool " + minfo.getPoolName() +
" got unexpected notification type: " +
type);
}
pr.addNotification(minfo);
System.out.println("notifying the checker thread to check result");
signals.release();
}
}
示例15: newJobDetail
import javax.management.openmbean.CompositeData; //導入依賴的package包/類
/**
* @param cData
* @return JobDetail
*/
public static JobDetail newJobDetail(CompositeData cData) {
JobDetail jobDetail = new JobDetail();
int i = 0;
jobDetail.setName((String) cData.get(ITEM_NAMES[i++]));
jobDetail.setGroup((String) cData.get(ITEM_NAMES[i++]));
jobDetail.setDescription((String) cData.get(ITEM_NAMES[i++]));
try {
Class c = Class.forName((String) cData.get(ITEM_NAMES[i++]));
jobDetail.setJobClass(c);
} catch (ClassNotFoundException cnfe) {
/**/
}
jobDetail.setJobDataMap(JobDataMapSupport
.newJobDataMap((TabularData) cData.get(ITEM_NAMES[i++])));
jobDetail.setVolatility((Boolean) cData.get(ITEM_NAMES[i++]));
jobDetail.setDurability((Boolean) cData.get(ITEM_NAMES[i++]));
jobDetail.setRequestsRecovery((Boolean) cData.get(ITEM_NAMES[i++]));
return jobDetail;
}