List of usage examples for javax.management.openmbean TabularData get
public CompositeData get(Object[] key);
From source file:com.zenoss.jmx.ValueExtractor.java
private static Object getDataByTableIndex(TabularData tData, String[] tableIndex) throws JmxException { _logger.debug("TablularData is: " + tData); _logger.debug("extracting composite data from tabulardata with index " + Arrays.toString(tableIndex)); CompositeData composite = (CompositeData) tData.get(tableIndex); if (composite == null) { throw new JmxException( Arrays.toString(tableIndex) + " is not an existing Index for this tabular data "); }//from www . j av a2 s . c o m _logger.debug("extracted composite data: " + composite); return composite; }
From source file:com.proofpoint.jmx.JmxHttpModule.java
@SuppressWarnings("unchecked") private static List<Map<String, Object>> toList(TabularData data) { ImmutableList.Builder<Map<String, Object>> builder = ImmutableList.builder(); // never trust JMX to do the right thing Set<List<?>> keySet = (Set<List<?>>) data.keySet(); if (keySet != null) { for (List<?> key : keySet) { if (key != null && !key.isEmpty()) { Object[] index = key.toArray(new Object[key.size()]); CompositeData value = data.get(index); if (value != null) { builder.add(toMap(value)); }/* w w w . j a v a2s. co m*/ } } } return builder.build(); }
From source file:org.apache.aries.jmx.test.blueprint.BlueprintMBeanTest.java
@Test public void testBlueprintStateMBean() throws Exception { BlueprintStateMBean stateProxy = getMBean(BlueprintStateMBean.OBJECTNAME, BlueprintStateMBean.class); // test getBlueprintBundleIds long[] bpBundleIds = stateProxy.getBlueprintBundleIds(); assertEquals("The blueprint bundle ids are: " + Arrays.toString(bpBundleIds), 3, bpBundleIds.length); // test getLastEvent BlueprintEventValidator sampleValidator = new BlueprintEventValidator(sample.getBundleId(), extender.getBundleId(), 2);/*from www.j av a 2s . co m*/ sampleValidator.validate(stateProxy.getLastEvent(sample.getBundleId())); // test getLastEvents TabularData lastEvents = stateProxy.getLastEvents(); assertEquals(BlueprintStateMBean.OSGI_BLUEPRINT_EVENTS_TYPE, lastEvents.getTabularType()); sampleValidator.validate(lastEvents.get(new Long[] { sample.getBundleId() })); }
From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java
@Test public void multipleLevleTabularData() throws OpenDataException { JSONObject map = new JSONObject(); JSONObject inner = new JSONObject(); map.put("fcn", inner); JSONObject innerinner = new JSONObject(); inner.put("franconia", innerinner); innerinner.put("verein", "fcn"); innerinner.put("region", "franconia"); innerinner.put("absteiger", false); TabularType type = new TabularType("soccer", "soccer", new CompositeType("row", "row", new String[] { "verein", "region", "absteiger" }, new String[] { "verein", "region", "absteiger" }, new OpenType[] { STRING, STRING, BOOLEAN }), new String[] { "verein", "region" }); TabularData data = (TabularData) converter.convertToObject(type, map); CompositeData row = data.get(new Object[] { "fcn", "franconia" }); assertNotNull(row);/*from www . j av a 2 s . com*/ assertFalse((Boolean) row.get("absteiger")); }
From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java
@Test public void tabularTypeForMXBeanMaps() throws OpenDataException { TabularTypeAndJson taj = getSampleTabularTypeForMXBeanMap(); String json = "{ \"keyOne\" : \"valueOne\", \"keyTwo\" : \"valueTwo\"}"; TabularData data = (TabularData) converter.convertToObject(taj.getType(), json); CompositeData col1 = data.get(new String[] { "keyOne" }); assertEquals(col1.get("key"), "keyOne"); assertEquals(col1.get("value"), "valueOne"); CompositeData col2 = data.get(new String[] { "keyTwo" }); assertEquals(col2.get("key"), "keyTwo"); assertEquals(col2.get("value"), "valueTwo"); }
From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java
@Test public void tabularTypeForMXBeanMapsComplex() throws OpenDataException { TabularTypeAndJson inner = getSampleTabularTypeForMXBeanMap(); TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "key" }, new CompositeTypeAndJson(STRING, "key", null, inner.getType(), "value", null)); String json = "{ \"keyOne\" : { \"innerKeyOne\" : \"valueOne\" }, \"keyTwo\" : { \"innerKeyTwo\" : \"valueTwo\"}}"; TabularData data = (TabularData) converter.convertToObject(taj.getType(), json); CompositeData col1 = data.get(new String[] { "keyOne" }); assertEquals(col1.get("key"), "keyOne"); TabularData innerCol1 = (TabularData) col1.get("value"); CompositeData col1inner = innerCol1.get(new String[] { "innerKeyOne" }); assertEquals(col1inner.get("key"), "innerKeyOne"); assertEquals(col1inner.get("value"), "valueOne"); }
From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java
@Test public void tabularType() throws OpenDataException { TabularTypeAndJson taj = getSampleTabularType(); TabularData data = (TabularData) converter.convertToObject(taj.getType(), taj.getJsonAsString()); assertEquals(data.get(new String[] { "fcn" }).get("absteiger"), false); assertEquals(data.get(new String[] { "fcb" }).get("absteiger"), true); }
From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java
@Test public void tabularTypeInFullRepresentation() throws OpenDataException, MalformedObjectNameException { TabularType type = getSampleTabularTypeForComplexTabularData(); String json = "{ \"indexNames\" : [ \"user\", \"street\" ], " + " \"values\" : [ " + " { \"user\" : { \"name\" : \"roland\", \"age\" : 44 }, " + " \"street\" : \"homestreet\", " + " \"oname\" : \"java.lang:type=Memory\" " + " }]" + "}"; TabularData data = (TabularData) converter.convertToObject(type, json); assertNotNull(data);//from w w w .ja va 2s . c o m Set keySet = data.keySet(); assertEquals(keySet.size(), 1); List keys = (List) keySet.iterator().next(); assertEquals(keys.size(), 2); assertTrue(keys.contains("homestreet")); CompositeData cd = checkCompositeKey(keys); CompositeData row = data.get(new Object[] { cd, "homestreet" }); assertEquals(row.get("user"), cd); assertEquals(row.get("street"), "homestreet"); assertEquals(row.get("oname"), new ObjectName("java.lang:type=Memory")); }
From source file:org.jolokia.converter.json.TabularDataExtractor.java
private CompositeData extractCompositeDataFromPath(TabularData pTd, Stack<String> pPathStack) throws AttributeNotFoundException { // We first try it as a key TabularType type = pTd.getTabularType(); List<String> indexNames = type.getIndexNames(); checkPathFitsIndexNames(pPathStack, indexNames); Object keys[] = new Object[indexNames.size()]; CompositeType rowType = type.getRowType(); List<String> pathPartsUsed = new ArrayList<String>(); for (int i = 0; i < indexNames.size(); i++) { String path = pPathStack.pop(); pathPartsUsed.add(path);//from w w w .j a v a2s.c om keys[i] = getKey(rowType, indexNames.get(i), path); } if (pTd.containsKey(keys)) { return pTd.get(keys); } else { throw new AttributeNotFoundException("No entry with " + pathPartsUsed + " found"); } }
From source file:com.betfair.testing.utils.cougar.helpers.CougarHelpers.java
public String getJMXSystemPropertyValue(String propertyName) { TabularData sysProps = (TabularData) getJMXMBeanAttributeValue("java.lang:type=Runtime", "SystemProperties"); return (String) sysProps.get(new String[] { "user.dir" }).get("value"); }