use of javax.management.openmbean.CompositeDataSupport in project aries by apache.
the class PropertyDataTest method testFromCompositeDataForWrapperTypes.
@Test
public void testFromCompositeDataForWrapperTypes() throws Exception {
Map<String, Object> items = new HashMap<String, Object>();
items.put(KEY, "key");
items.put(VALUE, "1");
items.put(TYPE, INTEGER);
CompositeData compositeData = new CompositeDataSupport(PROPERTY_TYPE, items);
PropertyData<Integer> intData = PropertyData.from(compositeData);
assertEquals("key", intData.getKey());
assertEquals(new Integer(1), intData.getValue());
assertEquals(INTEGER, intData.getEncodedType());
assertFalse(intData.isEncodingPrimitive());
items.clear();
items.put(KEY, "key");
items.put(VALUE, "1.0");
items.put(TYPE, DOUBLE);
compositeData = new CompositeDataSupport(PROPERTY_TYPE, items);
PropertyData<Double> doubleData = PropertyData.from(compositeData);
assertEquals("key", doubleData.getKey());
assertEquals(Double.valueOf(1.0), doubleData.getValue());
assertEquals(DOUBLE, doubleData.getEncodedType());
assertFalse(doubleData.isEncodingPrimitive());
items.clear();
items.put(KEY, "key");
items.put(VALUE, "a");
items.put(TYPE, CHARACTER);
compositeData = new CompositeDataSupport(PROPERTY_TYPE, items);
PropertyData<Character> charData = PropertyData.from(compositeData);
assertEquals("key", charData.getKey());
assertEquals(Character.valueOf('a'), charData.getValue());
assertEquals(CHARACTER, charData.getEncodedType());
assertFalse(charData.isEncodingPrimitive());
items.clear();
items.put(KEY, "key");
items.put(VALUE, "true");
items.put(TYPE, BOOLEAN);
compositeData = new CompositeDataSupport(PROPERTY_TYPE, items);
PropertyData<Boolean> booleanData = PropertyData.from(compositeData);
assertEquals("key", booleanData.getKey());
assertTrue(booleanData.getValue());
assertEquals(BOOLEAN, booleanData.getEncodedType());
assertFalse(booleanData.isEncodingPrimitive());
}
use of javax.management.openmbean.CompositeDataSupport in project aries by apache.
the class BundleEventData method toCompositeData.
/**
* Returns CompositeData representing a BundleEvent typed by {@link BundleStateMBean#BUNDLE_EVENT_TYPE}
*
* @return
*/
public CompositeData toCompositeData() {
CompositeData result = null;
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, this.bundleId);
items.put(SYMBOLIC_NAME, this.bundleSymbolicName);
items.put(LOCATION, this.location);
items.put(EVENT, this.eventType);
try {
result = new CompositeDataSupport(BUNDLE_EVENT_TYPE, items);
} catch (OpenDataException e) {
throw new IllegalStateException("Failed to create CompositeData for BundleEvent for Bundle [" + this.bundleId + "]", e);
}
return result;
}
use of javax.management.openmbean.CompositeDataSupport in project aries by apache.
the class ServiceData method toCompositeData.
public CompositeData toCompositeData(Collection<String> itemNames) {
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, this.serviceId);
if (itemNames.contains(BUNDLE_IDENTIFIER))
items.put(BUNDLE_IDENTIFIER, this.bundleId);
if (itemNames.contains(OBJECT_CLASS))
items.put(OBJECT_CLASS, this.serviceInterfaces);
TabularData propertiesTable = new TabularDataSupport(JmxConstants.PROPERTIES_TYPE);
for (PropertyData<? extends Object> propertyData : this.properties) {
propertiesTable.put(propertyData.toCompositeData());
}
items.put(PROPERTIES, propertiesTable);
if (itemNames.contains(USING_BUNDLES))
items.put(USING_BUNDLES, toLong(this.usingBundles));
String[] allItemNames = SERVICE_TYPE.keySet().toArray(new String[] {});
Object[] itemValues = new Object[allItemNames.length];
for (int i = 0; i < allItemNames.length; i++) {
itemValues[i] = items.get(allItemNames[i]);
}
try {
return new CompositeDataSupport(SERVICE_TYPE, allItemNames, itemValues);
} catch (OpenDataException e) {
throw new IllegalStateException("Failed to create CompositeData for ServiceReference with " + Constants.SERVICE_ID + " [" + this.serviceId + "]", e);
}
}
use of javax.management.openmbean.CompositeDataSupport in project druid by alibaba.
the class DataSourceProxyImpl method getCompositeData.
public CompositeDataSupport getCompositeData() throws JMException {
JdbcDataSourceStat stat = this.getDataSourceStat();
Map<String, Object> map = new HashMap<String, Object>();
map.put("ID", id);
map.put("URL", this.getUrl());
map.put("Name", this.getName());
map.put("FilterClasses", getFilterClasses());
map.put("CreatedTime", getCreatedTime());
map.put("RawDriverClassName", getRawDriverClassName());
map.put("RawUrl", getRawUrl());
map.put("RawDriverMajorVersion", getRawDriverMajorVersion());
map.put("RawDriverMinorVersion", getRawDriverMinorVersion());
map.put("Properties", getProperties());
if (stat != null) {
map.put("ConnectionActiveCount", stat.getConnectionActiveCount());
map.put("ConnectionActiveCountMax", stat.getConnectionStat().getActiveMax());
map.put("ConnectionCloseCount", stat.getConnectionStat().getCloseCount());
map.put("ConnectionCommitCount", stat.getConnectionStat().getCommitCount());
map.put("ConnectionRollbackCount", stat.getConnectionStat().getRollbackCount());
map.put("ConnectionConnectLastTime", stat.getConnectionStat().getConnectLastTime());
map.put("ConnectionConnectErrorCount", stat.getConnectionStat().getConnectErrorCount());
Throwable lastConnectionConnectError = stat.getConnectionStat().getConnectErrorLast();
if (lastConnectionConnectError != null) {
map.put("ConnectionConnectErrorLastTime", stat.getConnectionStat().getErrorLastTime());
map.put("ConnectionConnectErrorLastMessage", lastConnectionConnectError.getMessage());
map.put("ConnectionConnectErrorLastStackTrace", Utils.getStackTrace(lastConnectionConnectError));
} else {
map.put("ConnectionConnectErrorLastTime", null);
map.put("ConnectionConnectErrorLastMessage", null);
map.put("ConnectionConnectErrorLastStackTrace", null);
}
map.put("StatementCreateCount", stat.getStatementStat().getCreateCount());
map.put("StatementPrepareCount", stat.getStatementStat().getPrepareCount());
map.put("StatementPreCallCount", stat.getStatementStat().getPrepareCallCount());
map.put("StatementExecuteCount", stat.getStatementStat().getExecuteCount());
map.put("StatementRunningCount", stat.getStatementStat().getRunningCount());
map.put("StatementConcurrentMax", stat.getStatementStat().getConcurrentMax());
map.put("StatementCloseCount", stat.getStatementStat().getCloseCount());
map.put("StatementErrorCount", stat.getStatementStat().getErrorCount());
Throwable lastStatementError = stat.getStatementStat().getLastException();
if (lastStatementError != null) {
map.put("StatementLastErrorTime", stat.getStatementStat().getLastErrorTime());
map.put("StatementLastErrorMessage", lastStatementError.getMessage());
map.put("StatementLastErrorStackTrace", Utils.getStackTrace(lastStatementError));
} else {
map.put("StatementLastErrorTime", null);
map.put("StatementLastErrorMessage", null);
map.put("StatementLastErrorStackTrace", null);
}
map.put("StatementExecuteMillisTotal", stat.getStatementStat().getMillisTotal());
map.put("StatementExecuteLastTime", stat.getStatementStat().getExecuteLastTime());
map.put("ConnectionConnectingCount", stat.getConnectionStat().getConnectingCount());
map.put("ResultSetCloseCount", stat.getResultSetStat().getCloseCount());
map.put("ResultSetOpenCount", stat.getResultSetStat().getOpenCount());
map.put("ResultSetOpenningCount", stat.getResultSetStat().getOpeningCount());
map.put("ResultSetOpenningMax", stat.getResultSetStat().getOpeningMax());
map.put("ResultSetFetchRowCount", stat.getResultSetStat().getFetchRowCount());
map.put("ResultSetLastOpenTime", stat.getResultSetStat().getLastOpenTime());
map.put("ResultSetErrorCount", stat.getResultSetStat().getErrorCount());
map.put("ResultSetOpenningMillisTotal", stat.getResultSetStat().getAliveMillisTotal());
map.put("ResultSetLastErrorTime", stat.getResultSetStat().getLastErrorTime());
Throwable lastResultSetError = stat.getResultSetStat().getLastError();
if (lastResultSetError != null) {
map.put("ResultSetLastErrorMessage", lastResultSetError.getMessage());
map.put("ResultSetLastErrorStackTrace", Utils.getStackTrace(lastResultSetError));
} else {
map.put("ResultSetLastErrorMessage", null);
map.put("ResultSetLastErrorStackTrace", null);
}
map.put("ConnectionConnectCount", stat.getConnectionStat().getConnectCount());
Throwable lastConnectionError = stat.getConnectionStat().getErrorLast();
if (lastConnectionError != null) {
map.put("ConnectionErrorLastMessage", lastConnectionError.getMessage());
map.put("ConnectionErrorLastStackTrace", Utils.getStackTrace(lastConnectionError));
} else {
map.put("ConnectionErrorLastMessage", null);
map.put("ConnectionErrorLastStackTrace", null);
}
map.put("ConnectionConnectMillisTotal", stat.getConnectionStat().getConnectMillis());
map.put("ConnectionConnectingCountMax", stat.getConnectionStat().getConnectingMax());
map.put("ConnectionConnectMillisMax", stat.getConnectionStat().getConnectMillisMax());
map.put("ConnectionErrorLastTime", stat.getConnectionStat().getErrorLastTime());
map.put("ConnectionAliveMillisMax", stat.getConnectionConnectAliveMillisMax());
map.put("ConnectionAliveMillisMin", stat.getConnectionConnectAliveMillisMin());
map.put("ConnectionHistogram", stat.getConnectionHistogramValues());
map.put("StatementHistogram", stat.getStatementStat().getHistogramValues());
} else {
map.put("ConnectionActiveCount", null);
map.put("ConnectionActiveCountMax", null);
map.put("ConnectionCloseCount", null);
map.put("ConnectionCommitCount", null);
map.put("ConnectionRollbackCount", null);
map.put("ConnectionConnectLastTime", null);
map.put("ConnectionConnectErrorCount", null);
map.put("ConnectionConnectErrorLastTime", null);
map.put("ConnectionConnectErrorLastMessage", null);
map.put("ConnectionConnectErrorLastStackTrace", null);
map.put("StatementCreateCount", null);
map.put("StatementPrepareCount", null);
map.put("StatementPreCallCount", null);
map.put("StatementExecuteCount", null);
map.put("StatementRunningCount", null);
map.put("StatementConcurrentMax", null);
map.put("StatementCloseCount", null);
map.put("StatementErrorCount", null);
map.put("StatementLastErrorTime", null);
map.put("StatementLastErrorMessage", null);
map.put("StatementLastErrorStackTrace", null);
map.put("StatementExecuteMillisTotal", null);
map.put("ConnectionConnectingCount", null);
map.put("StatementExecuteLastTime", null);
map.put("ResultSetCloseCount", null);
map.put("ResultSetOpenCount", null);
map.put("ResultSetOpenningCount", null);
map.put("ResultSetOpenningMax", null);
map.put("ResultSetFetchRowCount", null);
map.put("ResultSetLastOpenTime", null);
map.put("ResultSetErrorCount", null);
map.put("ResultSetOpenningMillisTotal", null);
map.put("ResultSetLastErrorTime", null);
map.put("ResultSetLastErrorMessage", null);
map.put("ResultSetLastErrorStackTrace", null);
map.put("ConnectionConnectCount", null);
map.put("ConnectionErrorLastMessage", null);
map.put("ConnectionErrorLastStackTrace", null);
map.put("ConnectionConnectMillisTotal", null);
map.put("ConnectionConnectingCountMax", null);
map.put("ConnectionConnectMillisMax", null);
map.put("ConnectionErrorLastTime", null);
map.put("ConnectionAliveMillisMax", null);
map.put("ConnectionAliveMillisMin", null);
map.put("ConnectionHistogram", new long[0]);
map.put("StatementHistogram", new long[0]);
}
return new CompositeDataSupport(JdbcStatManager.getDataSourceCompositeType(), map);
}
use of javax.management.openmbean.CompositeDataSupport in project druid by alibaba.
the class DruidAbstractDataSource method getCompositeData.
public CompositeDataSupport getCompositeData() throws JMException {
JdbcDataSourceStat stat = this.getDataSourceStat();
Map<String, Object> map = new HashMap<String, Object>();
map.put("ID", getID());
map.put("URL", this.getUrl());
map.put("Name", this.getName());
map.put("FilterClasses", getFilterClasses());
map.put("CreatedTime", getCreatedTime());
map.put("RawDriverClassName", getDriverClassName());
map.put("RawUrl", getUrl());
map.put("RawDriverMajorVersion", getRawDriverMajorVersion());
map.put("RawDriverMinorVersion", getRawDriverMinorVersion());
map.put("Properties", getProperties());
// 0 - 4
map.put("ConnectionActiveCount", (long) getActiveCount());
map.put("ConnectionActiveCountMax", getActivePeak());
map.put("ConnectionCloseCount", getCloseCount());
map.put("ConnectionCommitCount", getCommitCount());
map.put("ConnectionRollbackCount", getRollbackCount());
// 5 - 9
map.put("ConnectionConnectLastTime", stat.getConnectionStat().getConnectLastTime());
map.put("ConnectionConnectErrorCount", this.getCreateCount());
if (createError != null) {
map.put("ConnectionConnectErrorLastTime", getLastCreateErrorTime());
map.put("ConnectionConnectErrorLastMessage", createError.getMessage());
map.put("ConnectionConnectErrorLastStackTrace", Utils.getStackTrace(createError));
} else {
map.put("ConnectionConnectErrorLastTime", null);
map.put("ConnectionConnectErrorLastMessage", null);
map.put("ConnectionConnectErrorLastStackTrace", null);
}
// 10 - 14
map.put("StatementCreateCount", stat.getStatementStat().getCreateCount());
map.put("StatementPrepareCount", stat.getStatementStat().getPrepareCount());
map.put("StatementPreCallCount", stat.getStatementStat().getPrepareCallCount());
map.put("StatementExecuteCount", stat.getStatementStat().getExecuteCount());
map.put("StatementRunningCount", stat.getStatementStat().getRunningCount());
// 15 - 19
map.put("StatementConcurrentMax", stat.getStatementStat().getConcurrentMax());
map.put("StatementCloseCount", stat.getStatementStat().getCloseCount());
map.put("StatementErrorCount", stat.getStatementStat().getErrorCount());
map.put("StatementLastErrorTime", null);
map.put("StatementLastErrorMessage", null);
// 20 - 24
map.put("StatementLastErrorStackTrace", null);
map.put("StatementExecuteMillisTotal", stat.getStatementStat().getMillisTotal());
map.put("StatementExecuteLastTime", stat.getStatementStat().getExecuteLastTime());
map.put("ConnectionConnectingCount", stat.getConnectionStat().getConnectingCount());
map.put("ResultSetCloseCount", stat.getResultSetStat().getCloseCount());
// 25 - 29
map.put("ResultSetOpenCount", stat.getResultSetStat().getOpenCount());
map.put("ResultSetOpenningCount", stat.getResultSetStat().getOpeningCount());
map.put("ResultSetOpenningMax", stat.getResultSetStat().getOpeningMax());
map.put("ResultSetFetchRowCount", stat.getResultSetStat().getFetchRowCount());
map.put("ResultSetLastOpenTime", stat.getResultSetStat().getLastOpenTime());
// 30 - 34
map.put("ResultSetErrorCount", stat.getResultSetStat().getErrorCount());
map.put("ResultSetOpenningMillisTotal", stat.getResultSetStat().getAliveMillisTotal());
map.put("ResultSetLastErrorTime", stat.getResultSetStat().getLastErrorTime());
map.put("ResultSetLastErrorMessage", null);
map.put("ResultSetLastErrorStackTrace", null);
// 35 - 39
map.put("ConnectionConnectCount", this.getConnectCount());
if (createError != null) {
map.put("ConnectionErrorLastMessage", createError.getMessage());
map.put("ConnectionErrorLastStackTrace", Utils.getStackTrace(createError));
} else {
map.put("ConnectionErrorLastMessage", null);
map.put("ConnectionErrorLastStackTrace", null);
}
map.put("ConnectionConnectMillisTotal", stat.getConnectionStat().getConnectMillis());
map.put("ConnectionConnectingCountMax", stat.getConnectionStat().getConnectingMax());
// 40 - 44
map.put("ConnectionConnectMillisMax", stat.getConnectionStat().getConnectMillisMax());
map.put("ConnectionErrorLastTime", stat.getConnectionStat().getErrorLastTime());
map.put("ConnectionAliveMillisMax", stat.getConnectionConnectAliveMillisMax());
map.put("ConnectionAliveMillisMin", stat.getConnectionConnectAliveMillisMin());
map.put("ConnectionHistogram", stat.getConnectionHistogramValues());
map.put("StatementHistogram", stat.getStatementStat().getHistogramValues());
return new CompositeDataSupport(JdbcStatManager.getDataSourceCompositeType(), map);
}
Aggregations