Example usage for javax.management.openmbean CompositeDataSupport CompositeDataSupport

List of usage examples for javax.management.openmbean CompositeDataSupport CompositeDataSupport

Introduction

In this page you can find the example usage for javax.management.openmbean CompositeDataSupport CompositeDataSupport.

Prototype

private CompositeDataSupport(SortedMap<String, Object> items, CompositeType compositeType)
            throws OpenDataException 

Source Link

Usage

From source file:com.alibaba.dragoon.stat.SpringIbatisStatementStats.java

@Override
protected CompositeData getCompositeData() {
    try {//from ww w  .  java  2  s . c o  m
        Map<String, Object> items = new HashMap<String, Object>();

        items.put("id", getId());
        items.put("resource", getResource());
        items.put("executeCount", getExecuteCount());
        items.put("errorCount", getErrorCount());
        items.put("totalTime", getTotalTime());

        items.put("lastTime", getLastTime());
        items.put("updateCount", getUpdateCount());
        items.put("fetchObjectCount", getFetchRowCount());
        items.put("effectedRowCount", getEffectedRowCount());
        items.put("concurrentMax", getConcurrentMax());

        items.put("runningCount", getRunningCount());

        return new CompositeDataSupport(getCompositeTypeInternal(), items);
    } catch (OpenDataException ex) {
        LOG.error(ex.getMessage(), ex);
        return null;
    }
}

From source file:com.alibaba.dragoon.client.DragoonClient.java

public CompositeData getSessionInfo() throws JMException {
    DragoonSession session = this.connectorFilter.getSession();

    if (session == null) {
        return null;
    }//from ww w . j  av  a2  s.c  o m

    CompositeType rowType = getSessionType();

    Map<String, Object> items = new HashMap<String, Object>();

    items.put("createdDate", session.getCreatedDate());
    items.put("localAddress", session.getLocalAddress() != null ? session.getLocalAddress().toString() : null);
    items.put("remoteAddress",
            session.getRemoteAddress() != null ? session.getRemoteAddress().toString() : null);
    items.put("receivedMessageCount", session.getReceivedMessageCount());
    items.put("sentMessageCount", session.getSentMessageCount());

    return new CompositeDataSupport(rowType, items);
}

From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java

/**
 * {@inheritDoc}/*ww w . j  a v  a2 s  .co  m*/
 */
@Override
public CompositeData getMessageCountOfQueuesAsCompositeData() {
    CompositeDataSupport support;
    try {
        Map<String, java.lang.Integer> messageCounts = getAllQueueCounts();

        OpenType[] messageCountAttributeTypes = new OpenType[messageCounts.size()];
        String[] itemNames = messageCounts.keySet().toArray(new String[0]);
        String[] itemDescriptions = messageCounts.keySet().toArray(new String[0]);
        for (int count = 0; count < messageCounts.size(); count++) {
            messageCountAttributeTypes[count] = SimpleType.INTEGER;
        }
        CompositeType messageCountCompositeType = new CompositeType("Message Count of Queues",
                "Message count of queues", itemNames, itemDescriptions, messageCountAttributeTypes);
        support = new CompositeDataSupport(messageCountCompositeType, messageCounts);
    } catch (OpenDataException e) {
        log.error("Error in accessing retrieving message count information", e);
        throw new RuntimeException("Error in accessing retrieving message count information", e);
    }
    return support;
}

From source file:com.adobe.acs.commons.httpcache.engine.impl.HttpCacheEngineImpl.java

@Override
public TabularData getRegisteredHttpCacheRules() throws OpenDataException {
    // @formatter:off
    final CompositeType cacheEntryType = new CompositeType(JMX_HTTPCACHE_HANDLING_RULE,
            JMX_HTTPCACHE_HANDLING_RULE, new String[] { JMX_HTTPCACHE_HANDLING_RULE },
            new String[] { JMX_HTTPCACHE_HANDLING_RULE }, new OpenType[] { SimpleType.STRING });

    final TabularDataSupport tabularData = new TabularDataSupport(
            new TabularType(JMX_PN_HTTPCACHE_HANDLING_RULES, JMX_PN_HTTPCACHE_HANDLING_RULES, cacheEntryType,
                    new String[] { JMX_HTTPCACHE_HANDLING_RULE }));
    // @formatter:on

    for (final Map.Entry<String, HttpCacheHandlingRule> entry : cacheHandlingRules.entrySet()) {
        final Map<String, Object> row = new HashMap<String, Object>();

        row.put(JMX_HTTPCACHE_HANDLING_RULE, entry.getValue().getClass().getName());
        tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    }/*from  w w w .  j  a  va 2 s. c  o  m*/

    return tabularData;
}

From source file:com.adobe.acs.commons.httpcache.engine.impl.HttpCacheEngineImpl.java

@Override
public TabularData getRegisteredHttpCacheConfigs() throws OpenDataException {
    // @formatter:off
    // Exposing all google guava stats.
    final CompositeType cacheEntryType = new CompositeType(JMX_PN_HTTPCACHE_CONFIG, JMX_PN_HTTPCACHE_CONFIG,
            new String[] { JMX_PN_ORDER, JMX_PN_OSGICOMPONENT },
            new String[] { JMX_PN_ORDER, JMX_PN_OSGICOMPONENT },
            new OpenType[] { SimpleType.INTEGER, SimpleType.STRING });

    final TabularDataSupport tabularData = new TabularDataSupport(new TabularType(JMX_PN_HTTPCACHE_CONFIGS,
            JMX_PN_HTTPCACHE_CONFIGS, cacheEntryType, new String[] { JMX_PN_OSGICOMPONENT }));

    // @formatter:on

    for (HttpCacheConfig cacheConfig : this.cacheConfigs) {
        final Map<String, Object> row = new HashMap<String, Object>();

        Map<String, Object> osgiConfig = cacheConfigConfigs.get(cacheConfig);

        row.put(JMX_PN_ORDER, cacheConfig.getOrder());
        row.put(JMX_PN_OSGICOMPONENT, (String) osgiConfig.get(Constants.SERVICE_PID));

        tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    }//from   w  ww .  j  a  va 2  s. c om

    return tabularData;
}

From source file:com.adobe.acs.commons.httpcache.engine.impl.HttpCacheEngineImpl.java

@Override
public TabularData getRegisteredPersistenceStores() throws OpenDataException {
    // @formatter:off
    final CompositeType cacheEntryType = new CompositeType(JMX_PN_HTTPCACHE_STORE, JMX_PN_HTTPCACHE_STORE,
            new String[] { JMX_PN_HTTPCACHE_STORE }, new String[] { JMX_PN_HTTPCACHE_STORE },
            new OpenType[] { SimpleType.STRING });

    final TabularDataSupport tabularData = new TabularDataSupport(new TabularType(JMX_PN_HTTPCACHE_STORES,
            JMX_PN_HTTPCACHE_STORES, cacheEntryType, new String[] { JMX_PN_HTTPCACHE_STORE }));
    // @formatter:on

    Enumeration<String> storeNames = cacheStoresMap.keys();
    while (storeNames.hasMoreElements()) {
        final String storeName = storeNames.nextElement();
        final Map<String, Object> row = new HashMap<String, Object>();

        row.put(JMX_PN_HTTPCACHE_STORE, storeName);
        tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    }// w  ww.  ja  v  a  2s  .c o m

    return tabularData;
}

From source file:com.alibaba.dragoon.stat.WebURIStatistic.java

public CompositeDataSupport getCompositeData() throws JMException {
    Map<String, Object> map = new HashMap<String, Object>();

    map.put("ID", getId());
    map.put("URI", getURI());
    map.put("RunningCount", getRunningCount());
    map.put("ConcurrentMax", getConcurrentMax());
    map.put("Count", getCount());

    map.put("ErrorCount", getErrorCount());
    map.put("TotalTime", getNanoTotal() / (1000 * 1000));
    map.put("MaxTime", getNanoMax() / (1000 * 1000));

    Throwable lastError = getLastError();
    if (lastError != null) {
        if (lastErrorMessage != null) {
            map.put("LastErrorMessage", lastErrorMessage);
        } else {/*from   w  ww .j ava  2s . co m*/
            map.put("LastErrorMessage", lastError.getMessage());
        }
        map.put("LastErrorClass", lastError.getClass().getName());

        StringWriter buf = new StringWriter();
        lastError.printStackTrace(new PrintWriter(buf));
        map.put("LastErrorStackTrace", buf.toString());
    } else {
        map.put("LastErrorMessage", lastErrorMessage);
        map.put("LastErrorClass", null);
        map.put("LastErrorStackTrace", null);
    }

    map.put("LastErrorTime", getLastErrorTime());

    map.put("LastErrorReferer", getLastErrorReferer());
    map.put("LastAccessedTime", getLastAccessTime());
    map.put("LastErrorUser", getLastErrorUser());
    map.put("LastErrorUrl", getLastErrorUrl());// added by wangye

    map.put("JdbcExecuteCount", getJdbcExecuteCount());
    map.put("JdbcFetchRowCount", getJdbcFetchRowCount());
    map.put("JdbcFetchRowPeak", getJdbcFetchRowPeak());
    map.put("JdbcUpdateCount", getJdbcUpdateCount());
    map.put("JdbcCommitCount", getJdbcCommitCount());
    map.put("JdbcRollbackCount", getJdbcRollbackCount());
    map.put("Histogram", histogram.toArray());

    EntryStatistic[] profilerEntryStatArray = this.profilerEntryStatMap.values()
            .toArray(new EntryStatistic[this.profilerEntryStatMap.values().size()]);
    List<CompositeDataSupport> profilerEntryStatCompositeDataList = new ArrayList<CompositeDataSupport>();
    for (int i = 0; i < profilerEntryStatArray.length; ++i) {
        if (profilerEntryStatArray[i].getCount() == 0) {
            continue;
        }
        profilerEntryStatCompositeDataList.add(profilerEntryStatArray[i].getCompositeData());
    }

    CompositeDataSupport[] profilerEntryStatCompositeDataArray = new CompositeDataSupport[profilerEntryStatCompositeDataList
            .size()];
    profilerEntryStatCompositeDataList.toArray(profilerEntryStatCompositeDataArray);

    map.put("ProfileEntries", profilerEntryStatCompositeDataArray);

    map.put("OSMacOSXCount", getOSMacOSX());
    map.put("OSWindowsCount", getOSWindowsCount());
    map.put("OSLinuxCount", getOSLinuxCount());

    map.put("BrowserIE6Count", getBrowserIE6Count());
    map.put("BrowserIE7Count", getBrowserIE7Count());
    map.put("BrowserIE8Count", getBrowserIE8Count());
    map.put("BrowserIE9Count", getBrowserIE9Count());
    map.put("BrowserIE10Count", getBrowserIE10Count());

    map.put("BrowserIECount", getBrowserIECount());
    map.put("BrowserFirefoxCount", getBrowserFirefoxCount());
    map.put("BrowserChromeCount", getBrowserChromeCount());
    map.put("BrowserSafariCount", getBrowserSafariCount());
    map.put("BrowserOperaCount", getBrowserOperaCount());

    map.put("DeviceAndroidCount", getDeviceAdndroidCount());
    map.put("DeviceIpadCount", getDeviceIpadCount());
    map.put("DeviceIphoneCount", getDeviceIphoneCount());
    map.put("DeviceWindowsPhoneCount", getDeviceWindowsPhoneCount());
    map.put("IP", getIP());
    map.put("JdbcTransactionMillis", getJdbcTransactionTimeMillis());

    return new CompositeDataSupport(getCompositeType(), map);
}