use of javax.management.openmbean.OpenDataException in project spf4j by zolyfarkas.
the class SpecificRecordOpenTypeMapping method typeFromSpecificRecord.
private static CompositeType typeFromSpecificRecord(final SpecificRecordBase r, final JMXBeanMappingSupplier typeMapper) throws NotSerializableException {
Schema schema = r.getSchema();
List<Schema.Field> fields = schema.getFields();
int size = fields.size();
String[] names = new String[size];
String[] descriptions = new String[size];
OpenType<?>[] types = new OpenType<?>[size];
for (Schema.Field field : fields) {
int pos = field.pos();
names[pos] = field.name();
descriptions[pos] = field.doc();
types[pos] = typeMapper.get(getGenericType(field.schema())).getOpenType();
}
try {
return new CompositeType(schema.getFullName(), schema.getDoc(), names, descriptions, types);
} catch (OpenDataException ex) {
throw new UncheckedExecutionException(ex);
}
}
use of javax.management.openmbean.OpenDataException in project acs-aem-commons by Adobe-Consulting-Services.
the class AbstractCacheMBean method getCacheContents.
@Override
public final TabularData getCacheContents() throws CacheMBeanException {
try {
final CompositeType cacheEntryType = getCacheEntryType();
final TabularDataSupport tabularData = new TabularDataSupport(new TabularType("Cache Entries", "Cache Entries", cacheEntryType, new String[] { JMX_PN_CACHEKEY }));
Map<K, V> cacheAsMap = getCacheAsMap();
for (final Map.Entry<K, V> entry : cacheAsMap.entrySet()) {
final Map<String, Object> data = new HashMap<String, Object>();
data.put(JMX_PN_CACHEKEY, entry.getKey().toString());
V cacheObj = entry.getValue();
if (cacheObj != null) {
addCacheData(data, cacheObj);
}
tabularData.put(new CompositeDataSupport(cacheEntryType, data));
}
return tabularData;
} catch (OpenDataException ex) {
throw new CacheMBeanException("Error getting the cache contents", ex);
}
}
use of javax.management.openmbean.OpenDataException in project acs-aem-commons by Adobe-Consulting-Services.
the class ThrottledTaskRunnerImpl method getStatistics.
@Override
public TabularDataSupport getStatistics() {
try {
TabularDataSupport stats = new TabularDataSupport(RunningStatistic.getStaticsTableType());
stats.put(waitTime.getStatistics());
stats.put(throttleTime.getStatistics());
stats.put(processingTime.getStatistics());
return stats;
} catch (OpenDataException ex) {
LOG.error("Error generating statistics", ex);
return null;
}
}
use of javax.management.openmbean.OpenDataException in project motech by motech.
the class MBeanService method getQueueMessages.
/**
* Retrieves a list of messages for the given JMS queue.
*
* @param queueName The name of the queue for which messages should be retrieved.
* @return {@link List} of messages for the given queue.
*/
@PreAuthorize(SecurityConstants.MANAGE_ACTIVEMQ)
public List<QueueMessage> getQueueMessages(String queueName) {
try {
ArrayList<QueueMessage> queueMessages = new ArrayList<>();
QueueViewMBean queueViewMBean = mBeanServer.getQueueViewMBean(queueName);
for (CompositeData compositeData : queueViewMBean.browse()) {
if (compositeData != null) {
String messageId = (String) compositeData.get(JMS_MESSAGE_ID);
Boolean redelivered = (Boolean) compositeData.get(JMS_REDELIVERED);
Date timestamp = (Date) compositeData.get(JMS_TIMESTAMP);
queueMessages.add(new QueueMessage(messageId, redelivered, DateUtil.newDateTime(timestamp)));
}
}
return queueMessages;
} catch (OpenDataException openDataException) {
throw new MotechException(String.format("Could not Browse MBean for queue %s", queueName), openDataException);
} catch (IOException ioException) {
throw new MotechException(String.format("Could not access MBean for queue %s", queueName), ioException);
}
}
use of javax.management.openmbean.OpenDataException in project tomee by apache.
the class LocalMBeanServer method tabularData.
public static TabularData tabularData(final String typeName, final String typeDescription, final String[] names, final Object[] values) {
if (names.length == 0) {
return null;
}
final OpenType<?>[] types = new OpenType<?>[names.length];
for (int i = 0; i < types.length; i++) {
types[i] = SimpleType.STRING;
}
try {
final CompositeType ct = new CompositeType(typeName, typeDescription, names, names, types);
final TabularType type = new TabularType(typeName, typeDescription, ct, names);
final TabularDataSupport data = new TabularDataSupport(type);
final CompositeData line = new CompositeDataSupport(ct, names, values);
data.put(line);
return data;
} catch (final OpenDataException e) {
return null;
}
}
Aggregations