List of usage examples for javax.management.openmbean TabularData put
public void put(CompositeData value);
From source file:com.alibaba.dragoon.stat.WebStatisticManager.java
public TabularData getURIList() throws JMException { CompositeType rowType = WebURIStatistic.getCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("URIStatisticList", "URIStatisticList", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); for (Map.Entry<String, WebURIStatistic> entry : this.statsMap.entrySet()) { if (entry.getValue().getCountDirect() == 0) { continue; }//from www . j a v a2 s.c o m data.put(entry.getValue().getCompositeData()); } return data; }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*Boolean.*") void extractTabularDataWithPathButWrongIndexType() throws OpenDataException, AttributeNotFoundException { TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "verein", "absteiger" }, new CompositeTypeAndJson(STRING, "verein", null, INTEGER, "platz", null, BOOLEAN, "absteiger", null));/*from w w w.j a v a 2 s. c o m*/ TabularData data = new TabularDataSupport(taj.getType()); data.put(new CompositeDataSupport(taj.getType().getRowType(), new String[] { "verein", "platz", "absteiger" }, new Object[] { "fcn", 6, false })); extract(true, data, "fcn", "true"); }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
@Test(expectedExceptions = ValueFaultHandler.AttributeFilteredException.class) public void noMatchWithWildcardPattern() throws OpenDataException, MalformedObjectNameException, AttributeNotFoundException { TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "oName" }, new CompositeTypeAndJson(OBJECTNAME, "oName", null)); TabularData data = new TabularDataSupport(taj.getType()); data.put(new CompositeDataSupport(taj.getType().getRowType(), new String[] { "oName" }, new Object[] { new ObjectName("test:type=bundle") })); extract(true, data, null, "oName2"); }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
private TabularData getComplexTabularData() throws OpenDataException { 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()); data.put(new CompositeDataSupport(ctj.getType(), new String[] { "name", "firstname", "age", "male" }, new Object[] { "meyer", "xaver", 12, true })); data.put(new CompositeDataSupport(ctj.getType(), new String[] { "name", "firstname", "age", "male" }, new Object[] { "meyer", "zensi", 28, false })); data.put(new CompositeDataSupport(ctj.getType(), new String[] { "name", "firstname", "age", "male" }, new Object[] { "huber", "erna", 18, false })); return data;/*from ww w . j a v a2 s .com*/ }
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));//from w w w . ja v a2 s . c om 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);// ww w. j a va 2s . c o 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.jolokia.converter.json.TabularDataExtractorTest.java
private TabularData getMapTabularData(OpenType keyType, Object... keyAndValues) throws OpenDataException { CompositeTypeAndJson ctj = new CompositeTypeAndJson(keyType, "key", null, STRING, "value", null); TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "key" }, ctj); TabularData data = new TabularDataSupport(taj.getType()); for (int i = 0; i < keyAndValues.length; i += 2) { CompositeData cd = new CompositeDataSupport(ctj.getType(), new String[] { "key", "value" }, new Object[] { keyAndValues[i], keyAndValues[i + 1] }); data.put(cd); }/*from w w w.jav a 2 s . c o m*/ return data; }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
private TabularData prepareMxMBeanMapData(String... keyAndValues) throws OpenDataException, MalformedObjectNameException { CompositeTypeAndJson ctj = new CompositeTypeAndJson(STRING, "key", null, OBJECTNAME, "value", null); TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "key" }, ctj); TabularData data = new TabularDataSupport(taj.getType()); for (int i = 0; i < keyAndValues.length; i += 2) { CompositeData cd = new CompositeDataSupport(ctj.getType(), new String[] { "key", "value" }, new Object[] { keyAndValues[i], new ObjectName(keyAndValues[i + 1]) }); data.put(cd); }/*from www. jav a 2 s . c om*/ return data; }
From source file:org.alfresco.repo.security.authentication.ldap.Monitor.java
/** * test authenticate/*from w ww . j av a 2 s . c o m*/ * * @param userName String * @param credentials String * @throws AuthenticationException */ public CompositeData testAuthenticate(String userName, String credentials) { String stepKeys[] = { "id", "stepMessage", "success" }; String stepDescriptions[] = { "id", "stepMessage", "success" }; OpenType<?> stepTypes[] = { SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN }; try { String[] key = { "id" }; CompositeType sType = new CompositeType("Authentication Step", "Step", stepKeys, stepDescriptions, stepTypes); TabularType tType = new TabularType("Diagnostic", "Authentication Steps", sType, key); TabularData table = new TabularDataSupport(tType); String attributeKeys[] = { "authenticationMessage", "success", "diagnostic" }; String attributeDescriptions[] = { "authenticationMessage", "success", "diagnostic" }; OpenType<?> attributeTypes[] = { SimpleType.STRING, SimpleType.BOOLEAN, tType }; try { component.authenticate(userName, credentials.toCharArray()); CompositeType cType = new CompositeType("Authentication Result", "Result Success", attributeKeys, attributeDescriptions, attributeTypes); Map<String, Object> value = new HashMap<String, Object>(); value.put("authenticationMessage", "Test Passed"); value.put("success", true); value.put("diagnostic", table); CompositeDataSupport row = new CompositeDataSupport(cType, value); return row; } catch (AuthenticationException ae) { CompositeType cType = new CompositeType("Authentication Result", "Result Failed", attributeKeys, attributeDescriptions, attributeTypes); Map<String, Object> value = new HashMap<String, Object>(); value.put("authenticationMessage", ae.getMessage()); value.put("success", false); if (ae.getDiagnostic() != null) { int i = 0; for (AuthenticationStep step : ae.getDiagnostic().getSteps()) { Map<String, Object> x = new HashMap<String, Object>(); x.put("id", i++); x.put("stepMessage", step.getMessage()); x.put("success", step.isSuccess()); CompositeDataSupport row = new CompositeDataSupport(sType, x); table.put(row); } } value.put("diagnostic", table); CompositeDataSupport row = new CompositeDataSupport(cType, value); return row; } } catch (OpenDataException oe) { logger.error("", oe); return null; } }
From source file:com.cyberway.issue.crawler.Heritrix.java
protected TabularData makeJobsTabularData(List jobs) throws OpenDataException { if (jobs == null || jobs.size() == 0) { return null; }//from w w w . j av a 2 s . c o m TabularData td = new TabularDataSupport(this.jobsTabularType); for (Iterator i = jobs.iterator(); i.hasNext();) { CrawlJob job = (CrawlJob) i.next(); CompositeData cd = new CompositeDataSupport(this.jobCompositeType, JOB_KEYS, new String[] { job.getUID(), job.getJobName(), job.getStatus() }); td.put(cd); } return td; }