List of usage examples for javax.management.openmbean TabularDataSupport put
public void put(CompositeData value)
From source file:org.xmatthew.spy2servers.jmx.AbstractComponentViewMBean.java
protected TabularData tabularDataWrapFromMessages(List<Message> messages) throws OpenDataException { if (CollectionUtils.isBlankCollection(messages)) { return null; }//from w w w . java 2 s . c o m messages = Collections.synchronizedList(messages); String[] itemNames = Message.getKeys().toArray(new String[Message.getKeys().size()]); String[] itemDescriptions = itemNames; OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING }; CompositeType compositeType = new CompositeType("MessageList", "list spyed messages", itemNames, itemDescriptions, itemTypes); TabularType tt = new TabularType("MessageList", "MessageList", compositeType, itemNames); TabularDataSupport rc = new TabularDataSupport(tt); for (Message message : messages) { try { rc.put(new CompositeDataSupport(compositeType, message.getFileds())); } catch (Exception e) { throw new OpenDataException(e.getMessage()); } } return rc; }
From source file:org.jolokia.converter.object.TabularDataConverter.java
private TabularData convertTabularDataFromFullRepresentation(JSONObject pValue, TabularType pType) { JSONAware jsonVal;//from w ww . jav a 2s . co m jsonVal = (JSONAware) pValue.get("values"); if (!(jsonVal instanceof JSONArray)) { throw new IllegalArgumentException("Values for tabular data of type " + pType + " must given as JSON array, not " + jsonVal.getClass()); } TabularDataSupport tabularData = new TabularDataSupport(pType); for (Object val : (JSONArray) jsonVal) { if (!(val instanceof JSONObject)) { throw new IllegalArgumentException( "Tabular-Data values must be given as JSON objects, not " + val.getClass()); } tabularData.put((CompositeData) getDispatcher().convertToObject(pType.getRowType(), val)); } return tabularData; }
From source file:com.adobe.acs.commons.util.impl.AbstractGuavaCacheMBean.java
@Override @SuppressWarnings("squid:S1192") public final TabularData getCacheStats() throws OpenDataException { // Exposing all google guava stats. final CompositeType cacheEntryType = new CompositeType("Cache Stats", "Cache Stats", new String[] { "Stat", "Value" }, new String[] { "Stat", "Value" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING }); final TabularDataSupport tabularData = new TabularDataSupport( new TabularType("Cache Stats", "Cache Stats", cacheEntryType, new String[] { "Stat" })); CacheStats cacheStats = getCache().stats(); final Map<String, Object> row = new HashMap<String, Object>(); row.put("Stat", "Request Count"); row.put("Value", String.valueOf(cacheStats.requestCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Hit Count"); row.put("Value", String.valueOf(cacheStats.hitCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Hit Rate"); row.put("Value", String.format("%.0f%%", cacheStats.hitRate() * 100)); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Miss Count"); row.put("Value", String.valueOf(cacheStats.missCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Miss Rate"); row.put("Value", String.format("%.0f%%", cacheStats.missRate() * 100)); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Eviction Count"); row.put("Value", String.valueOf(cacheStats.evictionCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Count"); row.put("Value", String.valueOf(cacheStats.loadCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Exception Count"); row.put("Value", String.valueOf(cacheStats.loadExceptionCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Exception Rate"); row.put("Value", String.format("%.0f%%", cacheStats.loadExceptionRate() * 100)); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Success Count"); row.put("Value", String.valueOf(cacheStats.loadSuccessCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Average Load Penalty"); row.put("Value", String.valueOf(cacheStats.averageLoadPenalty())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Total Load Time"); row.put("Value", String.valueOf(cacheStats.totalLoadTime())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); return tabularData; }
From source file:com.adobe.acs.commons.util.impl.AbstractCacheMBean.java
@Override public final TabularData getCacheContents() throws CacheMBeanException { try {//from w w w . j a va 2s. c o m final CompositeType cacheEntryType = getCacheEntryType(); final TabularDataSupport tabularData = new TabularDataSupport(new TabularType("Cache Entries", "Cache Entries", cacheEntryType, new String[] { JMX_PN_CACHEKEY })); Map<K, V> cacheAsMap = getCacheAsMap(); for (final Map.Entry<K, V> entry : cacheAsMap.entrySet()) { final Map<String, Object> data = new HashMap<String, Object>(); data.put(JMX_PN_CACHEKEY, entry.getKey().toString()); V cacheObj = entry.getValue(); if (cacheObj != null) { addCacheData(data, cacheObj); } tabularData.put(new CompositeDataSupport(cacheEntryType, data)); } return tabularData; } catch (OpenDataException ex) { throw new CacheMBeanException("Error getting the cache contents", ex); } }
From source file:com.adobe.acs.commons.util.impl.AbstractGuavaCacheMBean.java
@Override public final TabularData getCacheContents() throws OpenDataException { final CompositeType cacheEntryType = getCacheEntryType(); final TabularDataSupport tabularData = new TabularDataSupport( new TabularType("Cache Entries", "Cache Entries", cacheEntryType, new String[] { "Cache Key" })); ConcurrentMap<K, V> cacheAsMap = getCache().asMap(); for (final Map.Entry<K, V> entry : cacheAsMap.entrySet()) { final Map<String, Object> data = new HashMap<String, Object>(); data.put("Cache Key", entry.getKey().toString()); V cacheObj = entry.getValue();/*from w w w . j ava 2 s. c om*/ if (cacheObj != null) { addCacheData(data, cacheObj); } tabularData.put(new CompositeDataSupport(cacheEntryType, data)); } return tabularData; }
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 w w w. j av a 2 s. c o m CompositeData compositeData = new CompositeDataSupport(rowType, map); tabularData.put(compositeData); } catch (OpenDataException e) { throw new IllegalArgumentException(e.getMessage(), e); } } return tabularData; }
From source file:com.adobe.acs.commons.oak.impl.EnsureOakIndexManagerImpl.java
/** * Method for displaying Ensure Oak Index state in in the MBean * * @return the Ensure Oak Index data in a Tabular Format for the MBean * @throws OpenDataException/*w w w . j a v a 2 s . c om*/ */ @Override @SuppressWarnings("squid:S1192") public final TabularData getEnsureOakIndexes() throws OpenDataException { final CompositeType configType = new CompositeType("Ensure Oak Index Configurations", "Ensure Oak Index Configurations", new String[] { "Ensure Definitions Path", "Oak Indexes Path", "Applied", "Immediate" }, new String[] { "Ensure Definitions Path", "Oak Indexes Path", "Applied", "Immediate" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN }); final TabularDataSupport tabularData = new TabularDataSupport( new TabularType("Ensure Oak Index Configuration", "Ensure Oak Index Configuration", configType, new String[] { "Ensure Definitions Path", "Oak Indexes Path" })); for (final AppliableEnsureOakIndex index : this.ensureIndexes) { final Map<String, Object> data = new HashMap<String, Object>(); data.put("Ensure Definitions Path", index.getEnsureDefinitionsPath()); data.put("Oak Indexes Path", index.getOakIndexesPath()); data.put("Applied", index.isApplied()); data.put("Immediate", index.isImmediate()); tabularData.put(new CompositeDataSupport(configType, data)); } return tabularData; }
From source file:org.jolokia.converter.object.TabularDataConverter.java
private void putRowsToTabularData(TabularDataSupport pTabularData, JSONObject pValue, int pLevel) { TabularType type = pTabularData.getTabularType(); for (Object value : pValue.values()) { if (!(value instanceof JSONObject)) { throw new IllegalArgumentException( "Cannot convert " + pValue + " to type " + type + " because the object values provided (" + value.getClass() + ") is not of the expected type JSONObject at level " + pLevel); }// ww w . j a v a2s .co m JSONObject jsonValue = (JSONObject) value; if (pLevel > 1) { putRowsToTabularData(pTabularData, jsonValue, pLevel - 1); } else { pTabularData.put((CompositeData) getDispatcher().convertToObject(type.getRowType(), jsonValue)); } } }
From source file:com.adobe.acs.commons.errorpagehandler.cache.impl.ErrorPageCacheImpl.java
@SuppressWarnings("squid:S1192") public final TabularData getCacheEntries() throws OpenDataException { final CompositeType cacheEntryType = new CompositeType("cacheEntry", "Cache Entry", new String[] { "errorPage", "hit", "miss", "hitRate", "missRate", "sizeInKB" }, new String[] { "Error Page", "Hit", "Miss", "Hit Rate", "Miss Rate", "Size in KB" }, new OpenType[] { SimpleType.STRING, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.FLOAT, SimpleType.FLOAT, SimpleType.INTEGER }); final TabularDataSupport tabularData = new TabularDataSupport( new TabularType("cacheEntries", "Cache Entries", cacheEntryType, new String[] { "errorPage" })); for (final Map.Entry<String, CacheEntry> entry : this.cache.entrySet()) { final CacheEntry cacheEntry = entry.getValue(); final Map<String, Object> data = new HashMap<String, Object>(); data.put("errorPage", entry.getKey()); data.put("hit", cacheEntry.getHits()); data.put("miss", cacheEntry.getMisses()); data.put("hitRate", cacheEntry.getHitRate()); data.put("missRate", cacheEntry.getMissRate()); data.put("sizeInKB", cacheEntry.getBytes() / KB_IN_BYTES); tabularData.put(new CompositeDataSupport(cacheEntryType, data)); }/*from www .j ava 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)); }/*from w w w . j ava2 s .co m*/ return tabularData; }