List of usage examples for javax.management.openmbean TabularDataSupport TabularDataSupport
public TabularDataSupport(TabularType tabularType)
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 ww w . jav a2s . c o m if (cacheObj != null) { addCacheData(data, cacheObj); } tabularData.put(new CompositeDataSupport(cacheEntryType, data)); } return tabularData; }
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 w w w . j a v a2 s . c om*/ return tabularData; }
From source file:com.adobe.acs.commons.mcp.impl.ControlledProcessManagerImpl.java
@Override public TabularDataSupport getStatistics() throws OpenDataException { TabularDataSupport stats = new TabularDataSupport(ProcessInstanceImpl.getStaticsTableType()); activeProcesses.values().stream().map(ProcessInstance::getStatistics).forEach(stats::put); return stats; }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
@Test void extractGenericTabularDataWithJsonEmpty() throws OpenDataException, AttributeNotFoundException { CompositeTypeAndJson ctj = new CompositeTypeAndJson(STRING, "name", null, STRING, "firstname", null, INTEGER, "age", null, BOOLEAN, "male", null); TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "name", "firstname" }, ctj); TabularData data = new TabularDataSupport(taj.getType()); JSONObject result = (JSONObject) extract(true, data); assertTrue(result.isEmpty());/* w w w. ja v a2 s.c o m*/ }
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/*from w w w. j av a 2s .c o m*/ */ @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 TabularData convertTabularDataFromFullRepresentation(JSONObject pValue, TabularType pType) { JSONAware jsonVal;//w w w.j a va 2 s. c o 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:org.jolokia.converter.json.TabularDataExtractorTest.java
@Test void extractGenericTabularDataWithIntegerAndObjectNamePath() throws OpenDataException, AttributeNotFoundException, MalformedObjectNameException { TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "bundleId", "oName" }, new CompositeTypeAndJson(LONG, "bundleId", null, OBJECTNAME, "oName", null, BOOLEAN, "active", null));//w ww.j ava 2s .c o m TabularData data = new TabularDataSupport(taj.getType()); data.put( new CompositeDataSupport(taj.getType().getRowType(), new String[] { "bundleId", "oName", "active" }, new Object[] { 10L, new ObjectName("test:type=bundle"), false })); JSONObject result = (JSONObject) extract(true, data, "10", "test:type=bundle"); assertEquals(result.size(), 3); assertEquals(result.get("bundleId"), 10L); assertEquals(result.get("active"), false); }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
@Test public void extractWithWildCardPath() throws OpenDataException, MalformedObjectNameException, AttributeNotFoundException { TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "id" }, new CompositeTypeAndJson(LONG, "id", null, OBJECTNAME, "oName", null, BOOLEAN, "flag", null)); TabularData data = new TabularDataSupport(taj.getType()); data.put(new CompositeDataSupport(taj.getType().getRowType(), new String[] { "id", "oName", "flag" }, new Object[] { 10L, new ObjectName("test:type=bundle"), false })); data.put(new CompositeDataSupport(taj.getType().getRowType(), new String[] { "id", "oName", "flag" }, new Object[] { 20L, new ObjectName("java.lang:type=Memory"), true })); // Path: */*/domain --> 1. Level: 10, 20 -- 2. Level: CD key-value (e.g {id: 10, oName: test=type...}), -- 3. level: Objects // Here: Only ObjetNames should be picked JSONObject result = (JSONObject) extract(true, data, null, null, "domain"); assertEquals(result.size(), 2); // 10 & 20 JSONObject inner = (JSONObject) result.get(10L); assertEquals(inner.size(), 1);//from w ww . jav a 2s .co m assertEquals(inner.get("oName"), "test"); inner = (JSONObject) result.get(20L); assertEquals(inner.size(), 1); assertEquals(inner.get("oName"), "java.lang"); // Path: */oName --> 1. Level: 10,20 -- 2. Level: { oName : { 10 vals}} result = (JSONObject) extract(true, data, null, "oName"); assertEquals(result.size(), 2); inner = (JSONObject) result.get(10L); assertEquals(inner.get("domain"), "test"); inner = (JSONObject) result.get(20L); assertEquals(inner.get("domain"), "java.lang"); }
From source file:org.eclipse.gyrex.monitoring.internal.mbeans.MetricSetMBean.java
private void initialize() { final List<OpenMBeanAttributeInfoSupport> attributes = new ArrayList<OpenMBeanAttributeInfoSupport>(); final OpenMBeanConstructorInfoSupport[] constructors = new OpenMBeanConstructorInfoSupport[0]; final List<OpenMBeanOperationInfoSupport> operations = new ArrayList<OpenMBeanOperationInfoSupport>(1); final MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[0]; // common attribute attributes/*from ww w. j a v a 2 s . c o m*/ .add(new OpenMBeanAttributeInfoSupport(ID, "MetricSet Id", SimpleType.STRING, true, false, false)); attributes.add(new OpenMBeanAttributeInfoSupport(DESCRIPTION, "MetricSet Description", SimpleType.STRING, true, false, false)); // service property attributes try { final String[] propertyTypeNames = new String[] { "key", "value" }; propertyType = new CompositeType("property", "A property with name and value.", propertyTypeNames, new String[] { "Name", "Value" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING }); propertyTableType = new TabularType(PROPERTIES, "A lst of properties.", propertyType, new String[] { "key" }); attributes.add(new OpenMBeanAttributeInfoSupport(PROPERTIES, "MetricSet Properties", propertyTableType, true, false, false)); // pre-build service properties properties = new TabularDataSupport(propertyTableType); final String[] propertyKeys = reference.getPropertyKeys(); for (final String serviceProperty : propertyKeys) { if (serviceProperty.startsWith("gyrex.") || serviceProperty.equals(Constants.SERVICE_DESCRIPTION) || serviceProperty.equals(Constants.SERVICE_VENDOR)) { final Object value = reference.getProperty(serviceProperty); if (value == null) { continue; } if (isConvertibleToString(value.getClass())) { final Object[] values = { serviceProperty, String.valueOf(value) }; properties.put(new CompositeDataSupport(propertyType, propertyTypeNames, values)); } } } } catch (final OpenDataException e) { attributes.add(new OpenMBeanAttributeInfoSupport("propertiesError", "Exception occured while determining properties. " + e.toString(), SimpleType.STRING, true, false, false)); } // metrics final List<BaseMetric> metrics = metricSet.getMetrics(); metricTypesByAttributeName = new HashMap<String, CompositeType>(metrics.size()); metricByAttributeName = new HashMap<String, BaseMetric>(metrics.size()); for (final BaseMetric metric : metrics) { final String attributeName = StringUtils.removeStart(metric.getId(), metricSet.getId() + "."); try { final CompositeType type = getType(metric); if (type != null) { metricTypesByAttributeName.put(attributeName, type); metricByAttributeName.put(attributeName, metric); attributes.add(new OpenMBeanAttributeInfoSupport(attributeName, metric.getId(), type, true, false, false)); } } catch (final OpenDataException e) { attributes.add(new OpenMBeanAttributeInfoSupport(attributeName + "Error", "Exception occured while determining properties. " + e.toString(), SimpleType.STRING, true, false, false)); } } // reset operation for metric operations.add(new OpenMBeanOperationInfoSupport(RESET_STATS, "reset the metric statistics", null, SimpleType.VOID, MBeanOperationInfo.ACTION)); // build the info beanInfo = new OpenMBeanInfoSupport(this.getClass().getName(), metricSet.getDescription(), attributes.toArray(new OpenMBeanAttributeInfoSupport[attributes.size()]), constructors, operations.toArray(new OpenMBeanOperationInfoSupport[operations.size()]), notifications); }
From source file:org.apache.qpid.server.jmx.mbeans.QueueMBean.java
public TabularData viewMessages(long startPosition, long endPosition) throws IOException, JMException { if ((startPosition > endPosition) || (startPosition < 1)) { throw new OperationsException("From Index = " + startPosition + ", To Index = " + endPosition + "\n\"From Index\" should be greater than 0 and less than \"To Index\""); }// ww w. ja v a 2 s . c o m if ((endPosition - startPosition) > Integer.MAX_VALUE) { throw new OperationsException( "Specified MessageID interval is too large. Intervals must be less than 2^31 in size"); } List<QueueEntry> messages = getMessages(startPosition, endPosition); TabularDataSupport messageTable = new TabularDataSupport(MSG_LIST_DATA_TYPE); // Create the tabular list of message header contents long position = startPosition; for (QueueEntry queueEntry : messages) { ServerMessage serverMsg = queueEntry.getMessage(); AMQMessageHeader header = serverMsg.getMessageHeader(); String[] headerAttributes = { "reply-to = " + header.getReplyTo(), "propertyFlags = ", "ApplicationID = " + header.getAppId(), "ClusterID = ", "UserId = " + header.getUserId(), "JMSMessageID = " + header.getMessageId(), "JMSCorrelationID = " + header.getCorrelationId(), "JMSDeliveryMode = " + (serverMsg.isPersistent() ? "Persistent" : "Non_Persistent"), "JMSPriority = " + header.getPriority(), "JMSType = " + header.getType(), "JMSExpiration = " + (header.getExpiration() == 0 ? null : FAST_DATE_FORMAT.format(header.getExpiration())), "JMSTimestamp = " + (header.getTimestamp() == 0 ? null : FAST_DATE_FORMAT.format(header.getTimestamp())) }; Object[] itemValues = new Object[] { serverMsg.getMessageNumber(), headerAttributes, serverMsg.getSize(), queueEntry.isRedelivered(), position, queueEntry.getDeliveryCount() }; position++; CompositeData messageData = new CompositeDataSupport(MSG_DATA_TYPE, VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC_ARRAY, itemValues); messageTable.put(messageData); } return messageTable; }