Java Code Examples for javax.management.openmbean.TabularDataSupport#put()
The following examples show how to use
javax.management.openmbean.TabularDataSupport#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicMBeanWrapper.java From deltaspike with Apache License 2.0 | 6 votes |
private TabularData toTabularData(final String typeName, final String description, final Table table) { final OpenType<?>[] types = new OpenType<?>[table.getColumnNames().size()]; for (int i = 0; i < types.length; i++) { types[i] = SimpleType.STRING; } try { final String[] keys = table.getColumnNames().toArray(new String[table.getColumnNames().size()]); final CompositeType ct = new CompositeType( typeName, description, keys, keys, types); final TabularType type = new TabularType(typeName, description, ct, keys); final TabularDataSupport data = new TabularDataSupport(type); for (final Collection<String> line : table.getLines()) { data.put(new CompositeDataSupport(ct, keys, line.toArray(new Object[line.size()]))); } return data; } catch (final OpenDataException e) { throw new IllegalArgumentException(e); } }
Example 2
Source File: LocalMBeanServer.java From tomee with Apache License 2.0 | 6 votes |
public static TabularData tabularData(final String typeName, final String typeDescription, final String[] names, final Object[] values) { if (names.length == 0) { return null; } final OpenType<?>[] types = new OpenType<?>[names.length]; for (int i = 0; i < types.length; i++) { types[i] = SimpleType.STRING; } try { final CompositeType ct = new CompositeType(typeName, typeDescription, names, names, types); final TabularType type = new TabularType(typeName, typeDescription, ct, names); final TabularDataSupport data = new TabularDataSupport(type); final CompositeData line = new CompositeDataSupport(ct, names, values); data.put(line); return data; } catch (final OpenDataException e) { return null; } }
Example 3
Source File: JmxValueFunctionsTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testTabularDataToMapOfMaps() throws Exception { CompositeType rowType = new CompositeType( "MyRowType", "my row descr", new String[] {"key1", "key2"}, new String[] {"key1 descr", "key2 descr"}, new OpenType[] {SimpleType.STRING, SimpleType.STRING}); TabularType tabularType = new TabularType( "MyTabularType", "my table descr", rowType, new String[] {"key1"}); Map<String, ?> row1 = ImmutableMap.of( "key1", "row1.val1", "key2", "row1.val2"); Map<String, ?> row2 = ImmutableMap.of( "key1", "row2.val1", "key2", "row2.val2"); TabularDataSupport table = new TabularDataSupport(tabularType); table.put(new CompositeDataSupport(rowType, row1)); table.put(new CompositeDataSupport(rowType, row2)); Map<List<?>, Map<String, Object>> result = JmxValueFunctions.tabularDataToMapOfMaps(table); assertEquals(result, ImmutableMap.of(ImmutableList.of("row1.val1"), row1, ImmutableList.of("row2.val1"), row2)); Map<?,?> result2 = JmxValueFunctions.tabularDataToMapOfMaps().apply(table); assertEquals(result2, ImmutableMap.of(ImmutableList.of("row1.val1"), row1, ImmutableList.of("row2.val1"), row2)); }
Example 4
Source File: BatchEEMBeanImpl.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public TabularData getJobExecution(final long executionId) { final JobExecution execution = operator().getJobExecution(executionId); try { final TabularDataSupport data = new TabularDataSupport(JOB_EXECUTION_TABULAR_TYPE); data.put(new CompositeDataSupport(JOB_EXECUTION_COMPOSITE_TYPE, JOB_EXECUTION_ATTRIBUTES, asArray(execution))); return data; } catch (final OpenDataException e) { return null; } }
Example 5
Source File: BatchEEMBeanImpl.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public TabularData getJobExecutions(final long id, final String name) { final List<JobExecution> executions = operator().getJobExecutions(new JobInstanceImpl(id, name)); try { final TabularDataSupport data = new TabularDataSupport(JOB_EXECUTION_TABULAR_TYPE); for (final JobExecution n : executions) { data.put(new CompositeDataSupport(JOB_EXECUTION_COMPOSITE_TYPE, JOB_EXECUTION_ATTRIBUTES, asArray(n))); } return data; } catch (final OpenDataException e) { return null; } }
Example 6
Source File: BatchEEMBeanImpl.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public TabularData getJobInstance(final long executionId) { final JobInstance instance = operator().getJobInstance(executionId); try { final TabularDataSupport data = new TabularDataSupport(JOB_INSTANCES_TABULAR_TYPE); data.put(new CompositeDataSupport(JOB_INSTANCES_COMPOSITE_TYPE, JOB_INSTANCES_ATTRIBUTES, new Object[] { instance.getJobName(), instance.getInstanceId() })); return data; } catch (final OpenDataException e) { return null; } }
Example 7
Source File: BatchEEMBeanImpl.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public TabularData getParameters(final long executionId) { final Properties parameters = operator().getParameters(executionId); try { final TabularDataSupport data = new TabularDataSupport(PROPERTIES_TABULAR_TYPE); for (final Map.Entry<Object, Object> entry : parameters.entrySet()) { data.put(new CompositeDataSupport(PROPERTIES_COMPOSITE_TYPE, PROPERTIES_ATTRIBUTES, new Object[] { entry.getKey(), entry.getValue() })); } return data; } catch (final OpenDataException e) { return null; } }
Example 8
Source File: BatchEEMBeanImpl.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public TabularData getJobInstances(final String jobName, final int start, final int count) { final List<JobInstance> instances = operator().getJobInstances(jobName, start, count); try { final TabularDataSupport data = new TabularDataSupport(JOB_INSTANCES_TABULAR_TYPE); for (final JobInstance n : instances) { data.put(new CompositeDataSupport(JOB_INSTANCES_COMPOSITE_TYPE, JOB_INSTANCES_ATTRIBUTES, new Object[] { n.getJobName(), n.getInstanceId() })); } return data; } catch (final OpenDataException e) { return null; } }
Example 9
Source File: SimpleRouter.java From tomee with Apache License 2.0 | 5 votes |
@ManagedAttribute public TabularData getActiveRoutes() { if (routes.length == 0) { return null; } final OpenType<?>[] types = new OpenType<?>[routes.length]; final String[] keys = new String[types.length]; final String[] values = new String[types.length]; for (int i = 0; i < types.length; i++) { types[i] = SimpleType.STRING; keys[i] = routes[i].getOrigin().substring(prefix.length()); values[i] = routes[i].getRawDestination().substring(prefix.length()); } try { final CompositeType ct = new CompositeType("routes", "routes", keys, keys, types); final TabularType type = new TabularType("router", "routes", ct, keys); final TabularDataSupport data = new TabularDataSupport(type); final CompositeData line = new CompositeDataSupport(ct, keys, values); data.put(line); return data; } catch (final OpenDataException e) { return null; } }
Example 10
Source File: JmxValueFunctionsTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testTabularDataToMap() throws Exception { CompositeType rowType = new CompositeType( "MyRowType", "my row descr", new String[] {"key1", "key2"}, new String[] {"key1 descr", "key2 descr"}, new OpenType[] {SimpleType.STRING, SimpleType.STRING}); TabularType tabularType = new TabularType( "MyTabularType", "my table descr", rowType, new String[] {"key1"}); Map<String, ?> row1 = ImmutableMap.of( "key1", "row1.val1", "key2", "row1.val2"); Map<String, ?> row2 = ImmutableMap.of( "key1", "row2.val1", "key2", "row2.val2"); TabularDataSupport table = new TabularDataSupport(tabularType); table.put(new CompositeDataSupport(rowType, row1)); table.put(new CompositeDataSupport(rowType, row2)); Map<?,?> result = JmxValueFunctions.tabularDataToMap(table); assertEquals(result, row2); Map<?,?> result2 = JmxValueFunctions.tabularDataToMap().apply(table); assertEquals(result2, row2); }
Example 11
Source File: JmxFeedTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testJmxAttributeOfTypeTabularDataProviderConvertedToMap() throws Exception { // Create the CompositeType and TabularData CompositeType compositeType = new CompositeType( "typeName", "description", new String[] {"myint", "mystring", "mybool"}, // item names new String[] {"myint", "mystring", "mybool"}, // item descriptions, can't be null or empty string new OpenType<?>[] {SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN} ); TabularType tt = new TabularType( "typeName", "description", compositeType, new String[] {"myint"} ); TabularDataSupport tds = new TabularDataSupport(tt); tds.put(new CompositeDataSupport( compositeType, new String[] {"mybool", "myint", "mystring"}, new Object[] {true, 1234, "on"} )); // Create MBean GeneralisedDynamicMBean mbean = jmxService.registerMBean(ImmutableMap.of(attributeName, tds), objectName); feed = JmxFeed.builder() .entity(entity) .pollAttribute(new JmxAttributePollConfig<Map>(mapAttribute) .objectName(objectName) .attributeName(attributeName) .onSuccess((Function)JmxValueFunctions.tabularDataToMap())) .build(); // Starts with value defined when registering... assertSensorEventually( mapAttribute, ImmutableMap.of("myint", 1234, "mystring", "on", "mybool", Boolean.TRUE), TIMEOUT_MS); }
Example 12
Source File: SystemViewMBean.java From ignite with Apache License 2.0 | 5 votes |
/** * Gets tabular data with system view content. */ private TabularDataSupport viewContent(Map<String, Object> filter) { TabularDataSupport rows = new TabularDataSupport(sysViewType); AttributeToMapVisitor visitor = new AttributeToMapVisitor(); try { int idx = 0; Iterable<R> iter = filter != null && sysView instanceof FiltrableSystemView ? () -> ((FiltrableSystemView<R>)sysView).iterator(filter) : sysView; for (R row : iter) { Map<String, Object> data = new HashMap<>(); visitor.data(data); sysView.walker().visitAll(row, visitor); data.put(ID, idx++); rows.put(new CompositeDataSupport(rowType, data)); } } catch (OpenDataException e) { throw new IgniteException(e); } return rows; }
Example 13
Source File: DeltaSpikeConfigInfo.java From deltaspike with Apache License 2.0 | 5 votes |
@Override public TabularData getConfigSources() { ClassLoader originalCl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(appConfigClassLoader); String typeName = "ConfigSources"; OpenType<?>[] types = new OpenType<?>[]{SimpleType.INTEGER, SimpleType.STRING}; String[] keys = new String[]{"Ordinal", "ConfigSource"}; CompositeType ct = new CompositeType(typeName, typeName, keys, keys, types); TabularType type = new TabularType(typeName, typeName, ct, keys); TabularDataSupport configSourceInfo = new TabularDataSupport(type); ConfigSource[] configSources = ConfigResolver.getConfigSources(); for (ConfigSource configSource : configSources) { configSourceInfo.put( new CompositeDataSupport(ct, keys, new Object[]{configSource.getOrdinal(), configSource.getConfigName()})); } return configSourceInfo; } catch (OpenDataException e) { throw new RuntimeException(e); } finally { // set back the original TCCL Thread.currentThread().setContextClassLoader(originalCl); } }
Example 14
Source File: MXBeanWeirdParamTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 15
Source File: MXBeanWeirdParamTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 16
Source File: MXBeanWeirdParamTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 17
Source File: MXBeanWeirdParamTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 18
Source File: MXBeanWeirdParamTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 19
Source File: MXBeanWeirdParamTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 20
Source File: MXBeanWeirdParamTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }