Example usage for javax.management.openmbean OpenDataException getMessage

List of usage examples for javax.management.openmbean OpenDataException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.jolokia.converter.object.CompositeTypeConverter.java

/** {@inheritDoc} */
@Override/*www  .j a  v a 2 s  .  co  m*/
Object convertToObject(CompositeType pType, Object pFrom) {
    // break down the composite type to its field and recurse for converting each field
    JSONAware value = toJSON(pFrom);
    if (!(value instanceof JSONObject)) {
        throw new IllegalArgumentException("Conversion of " + value + " to " + pType
                + " failed because provided JSON type " + value.getClass() + " is not a JSONObject");
    }

    Map<String, Object> givenValues = (JSONObject) value;
    Map<String, Object> compositeValues = new HashMap<String, Object>();

    fillCompositeWithGivenValues(pType, compositeValues, givenValues);
    completeCompositeValuesWithDefaults(pType, compositeValues);

    try {
        return new CompositeDataSupport(pType, compositeValues);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException("Internal error: " + e.getMessage(), e);
    }
}

From source file:org.jolokia.converter.object.TabularDataConverter.java

private TabularData convertToTabularTypeFromMap(TabularType pType, JSONObject pValue) {
    CompositeType rowType = pType.getRowType();

    // A TabularData is requested for mapping a map for the call to an MXBean
    // as described in http://download.oracle.com/javase/6/docs/api/javax/management/MXBean.html
    // This means, we will convert a JSONObject to the required format
    TabularDataSupport tabularData = new TabularDataSupport(pType);

    @SuppressWarnings("unchecked")
    Map<String, String> jsonObj = (Map<String, String>) pValue;
    for (Map.Entry<String, String> entry : jsonObj.entrySet()) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("key", getDispatcher().convertToObject(rowType.getType("key"), entry.getKey()));
        map.put("value", getDispatcher().convertToObject(rowType.getType("value"), entry.getValue()));

        try {/*from  www.j  av  a  2s  . c  om*/
            CompositeData compositeData = new CompositeDataSupport(rowType, map);
            tabularData.put(compositeData);
        } catch (OpenDataException e) {
            throw new IllegalArgumentException(e.getMessage(), e);
        }
    }

    return tabularData;
}

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

@Override
protected CompositeData getCompositeData() {
    try {//from  w ww  .j a  v a 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:org.trpr.platform.servicefw.impl.ServiceStatisticsGatherer.java

/**
 * Wraps the service statistics into JMX types
 *///from   w  w w.  j a v  a 2  s . co m
private void populateServiceStatistics(boolean clearCollectedStats) {
    // clear existing stats in the TabularDataSupport and re-populate it with current data extracted from service framework classes
    serviceInvocationStatistics.clear();
    ServiceStatistics[] stats = getStats(clearCollectedStats);
    for (ServiceStatistics stat : stats) {
        Object[] statValues = new Object[attributeNames.length];
        statValues[0] = stat.getServiceName();
        statValues[1] = stat.getServiceVersion();
        statValues[2] = stat.getStartupTimeStamp().getTime();
        statValues[3] = stat.getLastCalledTimestamp() == null ? null : stat.getLastCalledTimestamp().getTime();
        statValues[4] = stat.getActiveRequestsCount();
        statValues[5] = stat.getTotalRequestsCount();
        statValues[6] = stat.getAverageResponseTime();
        statValues[7] = stat.getMinimumResponseTime();
        statValues[8] = stat.getMaximumResponseTime();
        statValues[9] = stat.getLastServiceRequestResponseTime();
        statValues[10] = stat.getErrorRequestsCount();
        statValues[11] = stat.getSuccessRequestsCount();
        CompositeData compositeData;
        try {
            compositeData = new CompositeDataSupport(compositeType, attributeNames, statValues);
            serviceInvocationStatistics.put(compositeData);
        } catch (OpenDataException e) {
            // ideally we should not get this exception
            LOGGER.error(
                    "Error constructing JMX data type from service statistics. Error is : " + e.getMessage(),
                    e);
        }
    }
}

From source file:org.trpr.platform.batch.impl.spring.jmx.JobAdministrator.java

/**
 * Wraps the job statistics into JMX types
 *///from  www  .  j a va  2  s  .c  om
private void populateJobStatistics() {
    // clear existing stats in the TabularDataSupport and re-populate it with current data extracted from batch framework classes
    batchInvocationStatistics.clear();
    JobStatistics[] stats = getStats();
    for (JobStatistics stat : stats) {
        Object[] statValues = new Object[ATTRIBUTE_NAMES.length];
        statValues[0] = stat.getHostIP();
        statValues[1] = stat.getHostStartTimeStamp().getTime();
        statValues[2] = stat.getJobName();
        statValues[3] = stat.getJobStatus();
        statValues[4] = stat.getJobSteps().toArray(new String[0]);
        statValues[5] = stat.getJobStepInError();
        statValues[6] = stat.getJobMessage();
        statValues[7] = stat.getJobStartTimeStamp() == null ? null : stat.getJobStartTimeStamp().getTime();
        statValues[8] = stat.getJobEndTimestamp() == null ? null : stat.getJobEndTimestamp().getTime();
        CompositeData compositeData;
        try {
            compositeData = new CompositeDataSupport(compositeType, ATTRIBUTE_NAMES, statValues);
            batchInvocationStatistics.put(compositeData);
        } catch (OpenDataException e) {
            // ideally we should not get this exception
            LOGGER.error("Error constructing JMX data type from job statistics. Error is : " + e.getMessage(),
                    e);
        }
    }
}