Search in sources :

Example 66 with OpenDataException

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);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) StandardMBean(javax.management.StandardMBean) JMException(javax.management.JMException) CompositeType(javax.management.openmbean.CompositeType) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 67 with OpenDataException

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()]);
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) OpenDataException(javax.management.openmbean.OpenDataException) AuditEvent(org.nhindirect.common.audit.AuditEvent) Vector(java.util.Vector)

Example 68 with OpenDataException

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;
}
Also used : HashMap(java.util.HashMap) OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport)

Example 69 with OpenDataException

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);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) OpenDataException(javax.management.openmbean.OpenDataException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 70 with OpenDataException

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;
}
Also used : ConsolidatedDataStoreCacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.ConsolidatedDataStoreCacheStatsMBean) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType)

Aggregations

OpenDataException (javax.management.openmbean.OpenDataException)139 CompositeType (javax.management.openmbean.CompositeType)94 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)67 CompositeData (javax.management.openmbean.CompositeData)54 OpenType (javax.management.openmbean.OpenType)52 TabularType (javax.management.openmbean.TabularType)33 TabularDataSupport (javax.management.openmbean.TabularDataSupport)32 HashMap (java.util.HashMap)14 Map (java.util.Map)12 TabularData (javax.management.openmbean.TabularData)11 ObjectName (javax.management.ObjectName)8 ArrayType (javax.management.openmbean.ArrayType)8 Type (java.lang.reflect.Type)5 ArrayList (java.util.ArrayList)5 Method (java.lang.reflect.Method)4 Comparator (java.util.Comparator)4 MBeanServer (javax.management.MBeanServer)4 SimpleType (javax.management.openmbean.SimpleType)4 IOException (java.io.IOException)3 InvalidObjectException (java.io.InvalidObjectException)3