List of usage examples for javax.management.openmbean CompositeData get
public Object get(String key);
From source file:org.apache.cassandra.tools.nodetool.TopPartitions.java
@Override public void execute(NodeProbe probe) { checkArgument(args.size() == 3, "toppartitions requires keyspace, column family name, and duration"); checkArgument(topCount < size, "TopK count (-k) option must be smaller then the summary capacity (-s)"); String keyspace = args.get(0); String cfname = args.get(1);// ww w . j av a 2 s .co m Integer duration = Integer.parseInt(args.get(2)); // generate the list of samplers List<Sampler> targets = Lists.newArrayList(); for (String s : samplers.split(",")) { try { targets.add(Sampler.valueOf(s.toUpperCase())); } catch (Exception e) { throw new IllegalArgumentException( s + " is not a valid sampler, choose one of: " + join(Sampler.values(), ", ")); } } Map<Sampler, CompositeData> results; try { results = probe.getPartitionSample(keyspace, cfname, size, duration, topCount, targets); } catch (OpenDataException e) { throw new RuntimeException(e); } boolean first = true; for (Entry<Sampler, CompositeData> result : results.entrySet()) { CompositeData sampling = result.getValue(); // weird casting for http://bugs.sun.com/view_bug.do?bug_id=6548436 List<CompositeData> topk = (List<CompositeData>) (Object) Lists .newArrayList(((TabularDataSupport) sampling.get("partitions")).values()); Collections.sort(topk, new Ordering<CompositeData>() { public int compare(CompositeData left, CompositeData right) { return Long.compare((long) right.get("count"), (long) left.get("count")); } }); if (!first) System.out.println(); System.out.println(result.getKey().toString() + " Sampler:"); System.out.printf(" Cardinality: ~%d (%d capacity)%n", (long) sampling.get("cardinality"), size); System.out.printf(" Top %d partitions:%n", topCount); if (topk.size() == 0) { System.out.println("\tNothing recorded during sampling period..."); } else { int offset = 0; for (CompositeData entry : topk) offset = Math.max(offset, entry.get("string").toString().length()); System.out.printf("\t%-" + offset + "s%10s%10s%n", "Partition", "Count", "+/-"); for (CompositeData entry : topk) System.out.printf("\t%-" + offset + "s%10d%10d%n", entry.get("string").toString(), entry.get("count"), entry.get("error")); } first = false; } }
From source file:org.eclipse.virgo.server.svt.watchrepo.WatchedRepositoryTests.java
@Test public void testParDeployThatDependsUponArtifactsInWatchRepo() throws Exception { signature = new String[] { String.class.getName() }; params = new Object[] { new File(APP_URI_PAR).toURI().toString() }; CompositeData compositeData = deploy(signature, params); artifactName2 = compositeData.get("symbolicName").toString(); artifactType2 = compositeData.get("type").toString(); artifactVersion2 = compositeData.get("version").toString(); waitForMBeanRegister(artifactType2, artifactName2, artifactVersion2, HALF_SECOND, TWO_MINUTES); assertArtifactExists(artifactType2, artifactName2, artifactVersion2); UrlWaitLatch.waitFor("http://localhost:8080/greenpages/app/home.htm"); assertArtifactState(artifactType2, artifactName2, artifactVersion2, "ACTIVE"); }
From source file:org.eclipse.virgo.server.svt.watchrepo.WatchedRepositoryTests.java
@Test public void testSharedServicesWarDeployThatDependsUponArtifactsInWatchRepo() throws Exception { signature = new String[] { String.class.getName() }; params = new Object[] { new File(APP_URI_SHAREDSERVICES_WAR).toURI().toString() }; CompositeData compositeData = deploy(signature, params); artifactName1 = compositeData.get("symbolicName").toString(); artifactType1 = compositeData.get("type").toString(); artifactVersion1 = compositeData.get("version").toString(); waitForMBeanRegister(artifactType1, artifactName1, artifactVersion1, HALF_SECOND, TWO_MINUTES); UrlWaitLatch.waitFor("http://localhost:8080/formtags-shared-services-war-2.0.1.BUILD-20100413113234"); UrlWaitLatch//w ww. jav a2 s .c o m .waitFor("http://localhost:8080/formtags-shared-services-war-2.0.1.BUILD-20100413113234/list.htm"); UrlWaitLatch.waitFor( "http://localhost:8080/formtags-shared-services-war-2.0.1.BUILD-20100413113234/form.htm?id=1"); assertArtifactExists(artifactType1, artifactName1, artifactVersion1); assertArtifactState(artifactType1, artifactName1, artifactVersion1, "ACTIVE"); }
From source file:org.hyperic.hq.product.jmx.MxLiveDataPlugin.java
private Map convertCompositeData(CompositeData data) { Map retval = new HashMap(); for (Iterator i = data.getCompositeType().keySet().iterator(); i.hasNext();) { String key = (String) i.next(); Object val = data.get(key); retval.put(key, val); }/*from w w w. j a v a 2 s . com*/ return retval; }
From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java
private CompositeData checkCompositeKey(List pKeys) { for (Object o : pKeys) { if (o instanceof CompositeData) { CompositeData cd = (CompositeData) o; assertEquals(cd.get("name"), "roland"); assertEquals(cd.get("age"), 44); return cd; }/*from w ww . j ava 2 s . c o m*/ } fail("No CD Key found"); return null; }
From source file:org.jolokia.converter.json.CompositeDataExtractor.java
private Object extractCompleteCdAsJson(ObjectToJsonConverter pConverter, CompositeData pData, Stack<String> pPath) throws AttributeNotFoundException { JSONObject ret = new JSONObject(); for (String key : (Set<String>) pData.getCompositeType().keySet()) { Stack<String> path = (Stack<String>) pPath.clone(); try {//from w w w .ja va 2 s.c o m ret.put(key, pConverter.extractObject(pData.get(key), path, true)); } catch (ValueFaultHandler.AttributeFilteredException exp) { // Ignore this key; } } if (ret.isEmpty()) { // If every key was filtered, this composite data should be skipped completely throw new ValueFaultHandler.AttributeFilteredException(); } return ret; }
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 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 ww .ja v a2 s . co 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.apache.qpid.systest.management.jmx.ConnectionManagementTest.java
private void assertChannelRowData(final CompositeData row, int unacknowledgedMessages, boolean isTransactional, boolean flowBlocked) { assertNotNull(row);//from w w w . j av a 2s. c om assertEquals("Unexpected transactional flag", isTransactional, row.get(ManagedConnection.TRANSACTIONAL)); assertEquals("Unexpected unacknowledged message count", unacknowledgedMessages, row.get(ManagedConnection.UNACKED_COUNT)); assertEquals("Unexpected flow blocked", flowBlocked, row.get(ManagedConnection.FLOW_BLOCKED)); }