use of javax.management.openmbean.OpenDataException in project nhin-d by DirectProject.
the class RDBMSAuditor method registerMBean.
/*
* Register the MBean
*/
private void registerMBean() {
LOGGER.info("Registering RDBMSAuditor MBean");
try {
itemNames = new String[] { "Event Id", "Event Time", "Event Principal", "Event Name", "Event Type", "Contexts" };
OpenType<?>[] types = { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, ArrayType.getArrayType(SimpleType.STRING) };
eventType = new CompositeType("AuditEvent", "Direct Auditable Event", itemNames, itemNames, types);
} catch (OpenDataException e) {
LOGGER.error("Failed to create settings composite type: " + e.getLocalizedMessage(), e);
return;
}
final Class<?> clazz = this.getClass();
final StringBuilder objectNameBuilder = new StringBuilder(clazz.getPackage().getName());
objectNameBuilder.append(":type=").append(clazz.getSimpleName());
objectNameBuilder.append(",name=").append(UUID.randomUUID());
try {
final StandardMBean mbean = new StandardMBean(this, AuditorMBean.class);
final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
mbeanServer.registerMBean(mbean, new ObjectName(objectNameBuilder.toString()));
} catch (JMException e) {
LOGGER.error("Unable to register the RDBMSAuditors MBean", e);
}
}
use of javax.management.openmbean.OpenDataException in project nhin-d by DirectProject.
the class RDBMSAuditor method getEvents.
/**
* {@inheritDoc}
*/
@Override
public CompositeData[] getEvents(Integer eventCount) {
if (eventType == null || eventCount == 0)
return null;
final Vector<CompositeData> retVal = new Vector<CompositeData>();
final Collection<org.nhindirect.common.audit.impl.entity.AuditEvent> rs = this.dao.getRDBMSEvents(eventCount);
if (rs.size() == 0)
return null;
for (org.nhindirect.common.audit.impl.entity.AuditEvent event : rs) {
String[] contexts = null;
if (event.getAuditContexts() != null && !event.getAuditContexts().isEmpty()) {
contexts = new String[event.getAuditContexts().size()];
int idx = 0;
for (org.nhindirect.common.audit.impl.entity.AuditContext ctx : event.getAuditContexts()) {
contexts[idx++] = ctx.getContextName() + ":" + ctx.getContextValue();
}
}
if (contexts == null)
contexts = new String[] { " " };
try {
final Object[] eventValues = { event.getUUID(), event.getEventTime().toString(), event.getPrincipal(), event.getEventName(), event.getEventType(), contexts };
retVal.add(new CompositeDataSupport(eventType, itemNames, eventValues));
} catch (OpenDataException e) {
LOGGER.error("Error create composit data for audit event.", e);
}
}
return retVal.toArray(new CompositeData[retVal.size()]);
}
use of javax.management.openmbean.OpenDataException in project geode by apache.
the class Region method listRegionAttributes.
@Override
public CompositeData listRegionAttributes() {
String value = JMXProperties.getInstance().getProperty(getKey("listRegionAttributes"), "");
String[] itemValues = value.split(",");
Map<String, Object> itemValuesHM = new HashMap<String, Object>();
// compressionCodec
if (null != itemValues[0]) {
itemValuesHM.put(regAttItemNames[0], itemValues[0]);
}
// enableOffHeapMemory
if (null != itemValues[1]) {
itemValuesHM.put(regAttItemNames[1], Boolean.parseBoolean(itemValues[1]));
}
// scope
if (null != itemValues[3]) {
itemValuesHM.put(regAttItemNames[3], itemValues[3]);
}
// diskStoreName
if (null != itemValues[4]) {
itemValuesHM.put(regAttItemNames[4], itemValues[4]);
}
// diskSynchronous
if (null != itemValues[5]) {
itemValuesHM.put(regAttItemNames[5], Boolean.parseBoolean(itemValues[5]));
}
CompositeData lraCompData;
try {
lraCompData = new CompositeDataSupport(listRegionAttributesCompData, itemValuesHM);
} catch (OpenDataException e) {
e.printStackTrace();
lraCompData = null;
}
return lraCompData;
}
use of javax.management.openmbean.OpenDataException in project jdk8u_jdk by JetBrains.
the class NotCompliantCauseTest method test1.
/**
* Test that NotCompliantMBeanException has a cause in case of
* type mapping problems.
**/
void test1() {
try {
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
ObjectName oname = new ObjectName("domain:type=test");
mbs.createMBean(NotCompliant.class.getName(), oname);
System.err.println("ERROR: expected " + "NotCompliantMBeanException not thrown");
throw new RuntimeTestException("NotCompliantMBeanException not thrown");
} catch (RuntimeTestException e) {
throw e;
} catch (NotCompliantMBeanException e) {
Throwable cause = e.getCause();
if (cause == null)
throw new RuntimeTestException("NotCompliantMBeanException " + "doesn't have any cause.", e);
while (cause.getCause() != null) {
if (cause instanceof OpenDataException)
break;
cause = cause.getCause();
}
if (!(cause instanceof OpenDataException))
throw new RuntimeTestException("NotCompliantMBeanException " + "doesn't have expected cause (" + OpenDataException.class.getName() + "): " + cause, e);
System.err.println("SUCCESS: Found expected cause: " + cause);
} catch (Exception e) {
System.err.println("Unexpected exception: " + e);
throw new RuntimeException("Unexpected exception: " + e, e);
}
}
use of javax.management.openmbean.OpenDataException in project jackrabbit-oak by apache.
the class ConsolidatedDataStoreCacheStats method getCacheStats.
@Override
public TabularData getCacheStats() {
TabularDataSupport tds;
try {
TabularType tt = new TabularType(CacheStatsData.class.getName(), "Consolidated DataStore Cache Stats", CacheStatsData.TYPE, new String[] { "name" });
tds = new TabularDataSupport(tt);
for (DataStoreCacheStatsMBean stats : cacheStats) {
tds.put(new CacheStatsData(stats).toCompositeData());
}
} catch (OpenDataException e) {
throw new IllegalStateException(e);
}
return tds;
}
Aggregations