Search in sources :

Example 81 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class ProvisioningServiceTest method testAddInformationWithTabularData.

@Test
@SuppressWarnings("unchecked")
public void testAddInformationWithTabularData() throws Exception {
    org.osgi.service.provisioning.ProvisioningService provService = mock(org.osgi.service.provisioning.ProvisioningService.class);
    ProvisioningService mbean = new ProvisioningService(provService);
    TabularData data = new TabularDataSupport(PROPERTIES_TYPE);
    PropertyData<byte[]> p1 = PropertyData.newInstance(PROVISIONING_AGENT_CONFIG, new byte[] { 20, 30, 40 });
    data.put(p1.toCompositeData());
    PropertyData<String> p2 = PropertyData.newInstance(PROVISIONING_SPID, "x.test");
    data.put(p2.toCompositeData());
    mbean.addInformation(data);
    ArgumentCaptor<Dictionary> dictionaryArgument = ArgumentCaptor.forClass(Dictionary.class);
    verify(provService).addInformation(dictionaryArgument.capture());
    Dictionary<String, Object> info = dictionaryArgument.getValue();
    assertEquals(2, info.size());
    assertArrayEquals(new byte[] { 20, 30, 40 }, (byte[]) info.get(PROVISIONING_AGENT_CONFIG));
    assertEquals("x.test", info.get(PROVISIONING_SPID));
}
Also used : Dictionary(java.util.Dictionary) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Test(org.junit.Test)

Example 82 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class ProvisioningServiceTest method testSetInformation.

@Test
@SuppressWarnings("unchecked")
public void testSetInformation() throws Exception {
    org.osgi.service.provisioning.ProvisioningService provService = mock(org.osgi.service.provisioning.ProvisioningService.class);
    ProvisioningService mbean = new ProvisioningService(provService);
    TabularData data = new TabularDataSupport(PROPERTIES_TYPE);
    PropertyData<String> p1 = PropertyData.newInstance(PROVISIONING_REFERENCE, "rsh://0.0.0.0/provX");
    data.put(p1.toCompositeData());
    PropertyData<String> p2 = PropertyData.newInstance(PROVISIONING_SPID, "x.test");
    data.put(p2.toCompositeData());
    mbean.setInformation(data);
    ArgumentCaptor<Dictionary> dictionaryArgument = ArgumentCaptor.forClass(Dictionary.class);
    verify(provService).setInformation(dictionaryArgument.capture());
    Dictionary<String, Object> info = dictionaryArgument.getValue();
    assertEquals(2, info.size());
    assertEquals("rsh://0.0.0.0/provX", info.get(PROVISIONING_REFERENCE));
    assertEquals("x.test", info.get(PROVISIONING_SPID));
}
Also used : Dictionary(java.util.Dictionary) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularData(javax.management.openmbean.TabularData) Test(org.junit.Test)

Example 83 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project deltaspike by apache.

the class DynamicMBeanWrapper method toTabularData.

private TabularData toTabularData(final String typeName, final String description, final Table table) {
    final OpenType<?>[] types = new OpenType<?>[table.getColumnNames().size()];
    for (int i = 0; i < types.length; i++) {
        types[i] = SimpleType.STRING;
    }
    try {
        final String[] keys = table.getColumnNames().toArray(new String[table.getColumnNames().size()]);
        final CompositeType ct = new CompositeType(typeName, description, keys, keys, types);
        final TabularType type = new TabularType(typeName, description, ct, keys);
        final TabularDataSupport data = new TabularDataSupport(type);
        for (final Collection<String> line : table.getLines()) {
            data.put(new CompositeDataSupport(ct, keys, line.toArray(new Object[line.size()])));
        }
        return data;
    } catch (final OpenDataException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 84 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project jackrabbit by apache.

the class QueryStatManager method asTabularData.

private TabularData asTabularData(QueryStatDto[] data) {
    TabularDataSupport tds = null;
    try {
        CompositeType ct = QueryStatCompositeTypeFactory.getCompositeType();
        TabularType tt = new TabularType(QueryStatDto.class.getName(), "Query History", ct, QueryStatCompositeTypeFactory.index);
        tds = new TabularDataSupport(tt);
        for (QueryStatDto q : data) {
            tds.put(new CompositeDataSupport(ct, QueryStatCompositeTypeFactory.names, QueryStatCompositeTypeFactory.getValues(q)));
        }
        return tds;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : QueryStatDto(org.apache.jackrabbit.api.stats.QueryStatDto) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) OpenDataException(javax.management.openmbean.OpenDataException) CompositeType(javax.management.openmbean.CompositeType)

Example 85 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport 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

TabularDataSupport (javax.management.openmbean.TabularDataSupport)103 TabularData (javax.management.openmbean.TabularData)67 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)60 CompositeData (javax.management.openmbean.CompositeData)51 CompositeType (javax.management.openmbean.CompositeType)50 TabularType (javax.management.openmbean.TabularType)36 Map (java.util.Map)27 OpenDataException (javax.management.openmbean.OpenDataException)24 HashMap (java.util.HashMap)11 Bundle (org.osgi.framework.Bundle)10 IOException (java.io.IOException)7 ObjectName (javax.management.ObjectName)7 OpenType (javax.management.openmbean.OpenType)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 Test (org.junit.Test)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4 Dictionary (java.util.Dictionary)4