/**
* 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;
}
java类javax.management.openmbean.CompositeData的实例源码
SlowQueryReportJmx.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 27
收藏 0
点赞 0
评论 0
TriggerSupport.java 文件源码
项目:lams
阅读 37
收藏 0
点赞 0
评论 0
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);
}
}
Main.java 文件源码
项目:otus_java_2017_06
阅读 19
收藏 0
点赞 0
评论 0
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);
}
}
OpenTypeConverter.java 文件源码
项目:monarch
阅读 33
收藏 0
点赞 0
评论 0
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;
}
MemoryUsageCompositeData.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
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);
}
}
GenericArrayTypeTest.java 文件源码
项目:openjdk-jdk10
阅读 27
收藏 0
点赞 0
评论 0
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);
}
}
GarbageCollectionNotifInfoCompositeData.java 文件源码
项目:openjdk-jdk10
阅读 34
收藏 0
点赞 0
评论 0
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);
}
}
LockInfoCompositeData.java 文件源码
项目:jdk8u-jdk
阅读 27
收藏 0
点赞 0
评论 0
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);
}
}
ValidateOpenTypes.java 文件源码
项目:jdk8u-jdk
阅读 27
收藏 0
点赞 0
评论 0
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);
}
}
JobDetailSupport.java 文件源码
项目:lams
阅读 25
收藏 0
点赞 0
评论 0
/**
* @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);
}
}
JobExecutionContextSupport.java 文件源码
项目:lams
阅读 33
收藏 0
点赞 0
评论 0
/**
* @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);
}
}
DefaultMXBeanMappingFactory.java 文件源码
项目:OpenJSharp
阅读 31
收藏 0
点赞 0
评论 0
@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;
}
CollectionUsageThreshold.java 文件源码
项目:jdk8u-jdk
阅读 22
收藏 0
点赞 0
评论 0
@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();
}
}
JobDetailSupport.java 文件源码
项目:asura
阅读 36
收藏 0
点赞 0
评论 0
/**
* @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;
}
JobDetailSupport.java 文件源码
项目:asura
阅读 30
收藏 0
点赞 0
评论 0
/**
* @param jobDetail
* @return CompositeData
*/
public static CompositeData toCompositeData(JobDetail jobDetail) {
try {
return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
new Object[] {
jobDetail.getName(),
jobDetail.getGroup(),
jobDetail.getDescription(),
jobDetail.getJobClass().getName(),
JobDataMapSupport.toTabularData(jobDetail
.getJobDataMap()), jobDetail.isVolatile(),
jobDetail.isDurable(),
jobDetail.requestsRecovery(), });
} catch (OpenDataException e) {
throw new RuntimeException(e);
}
}
DefaultMXBeanMappingFactory.java 文件源码
项目:OpenJSharp
阅读 30
收藏 0
点赞 0
评论 0
Object fromCompositeData(CompositeData cd,
String[] itemNames,
MXBeanMapping[] converters)
throws InvalidObjectException {
Object o;
try {
final Class<?> targetClass = getTargetClass();
ReflectUtil.checkPackageAccess(targetClass);
o = targetClass.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);
MethodUtil.invoke(setters[i], o, new Object[] {javaItem});
}
}
} catch (Exception e) {
throw invalidObjectException(e);
}
return o;
}
BaseOpenMBean.java 文件源码
项目:ChronoBike
阅读 28
收藏 0
点赞 0
评论 0
protected void addOpenAttribute(String csDescription, Class cls, String csMethodName, CompositeType compositeType)
{
Method methodGet = MethodFinder.getMethod(cls, "get"+csMethodName);
boolean bCanGet = true;
if(methodGet == null)
bCanGet = false;
Method methodSet = MethodFinder.getMethod(cls, "set"+csMethodName, CompositeData.class);
boolean bCanSet = true;
if(methodSet == null)
bCanSet = false;
OpenMBeanAttributeInfoSupport attrOpen = new OpenMBeanAttributeInfoSupport(csMethodName, csDescription, compositeType, bCanGet, bCanSet, false);
OpenMBeanAttributeInfoWrapper attr = new OpenMBeanAttributeInfoWrapper(csMethodName, csDescription, attrOpen, methodGet, methodSet);
if(m_arrOpenMBeanAttributeInfosWrapper == null)
m_arrOpenMBeanAttributeInfosWrapper = new ArrayList<OpenMBeanAttributeInfoWrapper>();
m_arrOpenMBeanAttributeInfosWrapper.add(attr);
}
StackTraceElementCompositeData.java 文件源码
项目:jdk8u-jdk
阅读 38
收藏 0
点赞 0
评论 0
/** Validate if the input CompositeData has the expected
* CompositeType (i.e. contain all attributes with expected
* names and types).
*/
public static void validateCompositeData(CompositeData cd) {
if (cd == null) {
throw new NullPointerException("Null CompositeData");
}
if (!isTypeMatched(stackTraceElementCompositeType, cd.getCompositeType())) {
throw new IllegalArgumentException(
"Unexpected composite type for StackTraceElement");
}
}
GcInfoCompositeData.java 文件源码
项目:jdk8u-jdk
阅读 23
收藏 0
点赞 0
评论 0
public static Map<String, MemoryUsage>
getMemoryUsageBeforeGc(CompositeData cd) {
try {
TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC);
return cast(memoryUsageMapType.toJavaTypeData(td));
} catch (InvalidObjectException | OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
MonitorInfoCompositeData.java 文件源码
项目:OpenJSharp
阅读 23
收藏 0
点赞 0
评论 0
public static StackTraceElement getLockedStackFrame(CompositeData cd) {
CompositeData ste = (CompositeData) cd.get(LOCKED_STACK_FRAME);
if (ste != null) {
return StackTraceElementCompositeData.from(ste);
} else {
return null;
}
}
MemoryNotifInfoCompositeData.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
public static String getPoolName(CompositeData cd) {
String poolname = getString(cd, POOL_NAME);
if (poolname == null) {
throw new IllegalArgumentException("Invalid composite data: " +
"Attribute " + POOL_NAME + " has null value");
}
return poolname;
}
MonitorInfoCompositeData.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
public static StackTraceElement getLockedStackFrame(CompositeData cd) {
CompositeData ste = (CompositeData) cd.get(LOCKED_STACK_FRAME);
if (ste != null) {
return StackTraceElementCompositeData.from(ste);
} else {
return null;
}
}
TestRawJmx.java 文件源码
项目:csap-core
阅读 27
收藏 0
点赞 0
评论 0
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 );
}
}
ValidateOpenTypes.java 文件源码
项目:jdk8u-jdk
阅读 27
收藏 0
点赞 0
评论 0
private static void printThreadInfo(CompositeData cd) {
ThreadInfo info = ThreadInfo.from(cd);
if (info == null) {
throw new RuntimeException("TEST FAILED: " +
" Null ThreadInfo");
}
System.out.print(info.getThreadName());
System.out.print(" id=" + info.getThreadId());
System.out.println(" " + info.getThreadState());
for (StackTraceElement s : info.getStackTrace()) {
System.out.println(s);
}
}
GarbageCollectionNotifInfoCompositeData.java 文件源码
项目:jdk8u-jdk
阅读 22
收藏 0
点赞 0
评论 0
public static String getGcAction(CompositeData cd) {
String gcaction = getString(cd, GC_ACTION);
if (gcaction == null) {
throw new IllegalArgumentException("Invalid composite data: " +
"Attribute " + GC_ACTION + " has null value");
}
return gcaction;
}
GcInfoCompositeData.java 文件源码
项目:openjdk-jdk10
阅读 29
收藏 0
点赞 0
评论 0
public static Map<String, MemoryUsage>
getMemoryUsageBeforeGc(CompositeData cd) {
try {
TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC);
return cast(memoryUsageMapType.toJavaTypeData(td));
} catch (InvalidObjectException | OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
MerlinMXBean.java 文件源码
项目:jdk8u-jdk
阅读 25
收藏 0
点赞 0
评论 0
public CompositeData toCompositeData(CompositeType ct) {
try {
return new CompositeDataSupport(ct, new String[] {"whatsit"},
new String[] {"!" + whatsit});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
AtsJvmMonitor.java 文件源码
项目:ats-framework
阅读 50
收藏 0
点赞 0
评论 0
private JvmReadingInstance getHeapCodeCache(
MBeanServerConnection connection,
ReadingBean reading ) {
String jvmPort = reading.getParameter("JMX_PORT");
final MBeanWrapper mbeanWrapper = mbeanWrappers.get(jvmPort);
return new JvmReadingInstance(connection,
String.valueOf(reading.getDbId()),
reading.getMonitorName(),
getName(reading, jvmPort),
reading.getUnit(),
0) {
private static final long serialVersionUID = 1L;
@Override
public void init() {
applyMemoryNormalizationFactor();
mBeanName = mbeanWrapper.getObjectName("java.lang:name=Code Cache,type=MemoryPool");
}
@Override
public float poll() {
CompositeData attribute = (CompositeData) mbeanWrapper.getMBeanAttribute(mBeanName,
"Usage");
return fixLongValue(Long.valueOf( (attribute).get("used").toString()))
* normalizationFactor;
}
};
}
MonitorInfoCompositeData.java 文件源码
项目:OpenJSharp
阅读 148
收藏 0
点赞 0
评论 0
/** Validate if the input CompositeData has the expected
* CompositeType (i.e. contain all attributes with expected
* names and types).
*/
public static void validateCompositeData(CompositeData cd) {
if (cd == null) {
throw new NullPointerException("Null CompositeData");
}
if (!isTypeMatched(monitorInfoCompositeType, cd.getCompositeType())) {
throw new IllegalArgumentException(
"Unexpected composite type for MonitorInfo");
}
}
RemoteMBeanScheduler.java 文件源码
项目:lams
阅读 27
收藏 0
点赞 0
评论 0
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public JobDetail getJobDetail(JobKey jobKey) throws SchedulerException {
try {
return JobDetailSupport.newJobDetail((CompositeData)invoke(
"getJobDetail",
new Object[] { jobKey.getName(), jobKey.getGroup() },
new String[] { String.class.getName(), String.class.getName() }));
} catch (ClassNotFoundException e) {
throw new SchedulerException("Unable to resolve job class", e);
}
}