本文整理汇总了Java中javax.management.openmbean.TabularData.get方法的典型用法代码示例。如果您正苦于以下问题:Java TabularData.get方法的具体用法?Java TabularData.get怎么用?Java TabularData.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.openmbean.TabularData
的用法示例。
在下文中一共展示了TabularData.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStatistics
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
public String getStatistics(String kind, String method) throws Exception {
ObjectName mName = new ObjectName("com.bagri.db:type=Schema,name=" + schema + ",kind=" + kind);
TabularData data = (TabularData) mbsc.getAttribute(mName, "InvocationStatistics");
if (data != null) {
CompositeData stats = data.get(new String[] {method});
if (stats != null) {
StringBuilder buff = new StringBuilder();
for (String key: stats.getCompositeType().keySet()) {
buff.append(key).append("=").append(stats.get(key));
buff.append("; ");
}
return buff.toString();
}
}
return "";
}
示例2: testViewUsers
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
public void testViewUsers()
{
TabularData userList = _amqumMBean.viewUsers();
assertNotNull(userList);
assertEquals("Unexpected number of users in user list", 1, userList.size());
assertTrue(userList.containsKey(new Object[]{TEST_USERNAME}));
// Check the deprecated read, write and admin items continue to exist but return false.
CompositeData userRec = userList.get(new Object[]{TEST_USERNAME});
assertTrue(userRec.containsKey(UserManagement.RIGHTS_READ_ONLY));
assertEquals(false, userRec.get(UserManagement.RIGHTS_READ_ONLY));
assertEquals(false, userRec.get(UserManagement.RIGHTS_READ_WRITE));
assertTrue(userRec.containsKey(UserManagement.RIGHTS_READ_WRITE));
assertTrue(userRec.containsKey(UserManagement.RIGHTS_ADMIN));
assertEquals(false, userRec.get(UserManagement.RIGHTS_ADMIN));
}
示例3: getProperty
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
private static String getProperty(TabularData td, String propName) {
CompositeData cd = td.get(new Object[] { propName});
if (cd != null) {
String key = (String) cd.get("key");
if (!propName.equals(key)) {
throw new RuntimeException("TEST FAILED: " +
key + " property found" +
" but expected to be " + propName);
}
return (String) cd.get("value");
}
return null;
}
示例4: properlyAggregateMapsByKeyAccordingToTheirValueAggregationPolicy
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
@Test
public void properlyAggregateMapsByKeyAccordingToTheirValueAggregationPolicy() throws Exception {
Map<String, Integer> map_1 = new HashMap<>();
map_1.put("a", 1);
map_1.put("b", 2);
map_1.put("c", 100);
Map<String, Integer> map_2 = new HashMap<>();
map_2.put("b", 2);
map_2.put("c", 200);
map_2.put("d", 5);
MBeanWithMap mBeanWithMap_1 = new MBeanWithMap(map_1);
MBeanWithMap mBeanWithMap_2 = new MBeanWithMap(map_2);
DynamicMBean mbean = createDynamicMBeanFor(mBeanWithMap_1, mBeanWithMap_2);
TabularData tabularData = (TabularData) mbean.getAttribute("nameToNumber");
assertEquals(4, tabularData.size());
CompositeData row_1 = tabularData.get(keyForTabularData("a"));
assertEquals(1, row_1.get("value"));
CompositeData row_2 = tabularData.get(keyForTabularData("b"));
assertEquals(2, row_2.get("value"));
CompositeData row_3 = tabularData.get(keyForTabularData("c"));
assertEquals(null, row_3.get("value"));
CompositeData row_4 = tabularData.get(keyForTabularData("d"));
assertEquals(5, row_4.get("value"));
}
示例5: execute
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
@Override
public void execute(NodeProbe probe)
{
TabularData data = probe.getFailureDetectorPhilValues();
System.out.printf("%10s,%16s%n", "Endpoint", "Phi");
for (Object o : data.keySet())
{
@SuppressWarnings({ "rawtypes", "unchecked" })
CompositeData datum = data.get(((List) o).toArray(new Object[((List) o).size()]));
System.out.printf("%10s,%16.8f%n",datum.get("Endpoint"), datum.get("PHI"));
}
}
示例6: testGetEntities
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
@Test
public void testGetEntities() throws Exception {
ObjectName name = getObjectName();
TabularData entities = (TabularData) mbsc.getAttribute(name, getEntityName());
assertNotNull(entities);
List<String> expected = Arrays.asList(getExpectedEntities());
assertEquals(expected.size(), entities.size());
Set<List> keys = (Set<List>) entities.keySet();
for (List key: keys) {
Object[] index = key.toArray();
CompositeData schema = entities.get(index);
String sn = (String) schema.get("name");
assertTrue(expected.contains(sn));
}
}
示例7: getCollections
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
@Override
public List<Collection> getCollections() throws ServiceException {
List<Collection> result = new ArrayList<>();
try {
ObjectName on = getDocMgrObjectName();
Object res = connection.getAttribute(on, "Collections");
if (res == null) {
return result;
}
TabularData clns = (TabularData) res;
Set<List> keys = (Set<List>) clns.keySet();
res = connection.getAttribute(on, "CollectionStatistics");
TabularData stats = (TabularData) res;
for (List key: keys) {
Object[] index = key.toArray();
CompositeData clnData = clns.get(index);
CompositeData stsData = null;
if (stats != null) {
stsData = stats.get(index);
}
Collection cln = readCollection(clnData, stsData);
result.add(cln);
}
return result;
} catch (Exception ex) {
LOGGER.throwing(this.getClass().getName(), "getCollections", ex);
throw new ServiceException(ex);
}
}
示例8: getTabularDataValue
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
private static MBeanDump.MBeanValue getTabularDataValue(TabularData tabularData) {
// linked hash map used to preserve row ordering
List<MBeanDump.MBeanValueMapEntry> outerEntries = Lists.newArrayList();
Set<String> attributeNames = tabularData.getTabularType().getRowType().keySet();
for (Object key : tabularData.keySet()) {
// TabularData.keySet() returns "Set<List<?>> but is declared Set<?> for
// compatibility reasons" (see javadocs) so safe to cast to List<?>
List<?> keyList = (List<?>) key;
@SuppressWarnings("argument.type.incompatible")
String keyString = Joiner.on(", ").join(keyList);
@SuppressWarnings("argument.type.incompatible")
CompositeData compositeData = tabularData.get(keyList.toArray());
// linked hash map used to preserve attribute ordering
List<MBeanDump.MBeanValueMapEntry> innerEntries = Lists.newArrayList();
for (String attributeName : attributeNames) {
innerEntries.add(MBeanDump.MBeanValueMapEntry.newBuilder()
.setKey(attributeName)
.setValue(getMBeanAttributeValue(compositeData.get(attributeName)))
.build());
}
outerEntries.add(MBeanDump.MBeanValueMapEntry.newBuilder()
.setKey(keyString)
.setValue(MBeanDump.MBeanValue.newBuilder()
.setMap(MBeanDump.MBeanValueMap.newBuilder()
.addAllEntry(innerEntries))
.build())
.build());
}
return MBeanDump.MBeanValue.newBuilder()
.setMap(MBeanDump.MBeanValueMap.newBuilder()
.addAllEntry(outerEntries))
.build();
}
示例9: processNotification
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
private static void processNotification(ObjectName name) {
CompositeData cd;
try {
cd = (CompositeData) SERVER.getAttribute(name, "LastGcInfo");
} catch (AttributeNotFoundException | InstanceNotFoundException
| MBeanException | ReflectionException e) {
e.printStackTrace();
throw new RuntimeException();
}
if (cd == null) {
//This happens every now and then...
return;
}
//System.out.println("cds: " + cd.getClass().getName() + " " + cd.getCompositeType());
//CompositeDataSupport cds = new CompositeDataSupport(cd.getCompositeType(), cd);
// String[] keys = {"GcThreadCount", "duration", "endTime", "id",
// "memoryUsageAfterGc", "memoryUsageBeforeGc", "startTime"};
String[] keys = {"GcThreadCount", "duration", "id", "startTime", "endTime"};
Object[] mix = cd.getAll(keys);
MemInfo mi = new MemInfo((int)mix[0], (long)mix[1], (long)mix[2]);//, (Long)mix[3], (Long)mix[4]);
String KEY_BEFORE = "memoryUsageBeforeGc";
String KEY_AFTER = "memoryUsageAfterGc";
TabularData tdBefore = (TabularData) cd.get(KEY_BEFORE);
TabularData tdAfter = (TabularData) cd.get(KEY_AFTER);
for (String mpName: POOL_NAMES) {
CompositeData cdBefore = tdBefore.get(new Object[]{mpName});
MemoryUsage muBefore = MemoryUsage.from((CompositeData) cdBefore.get("value"));
CompositeData cdAfter = tdAfter.get(new Object[]{mpName});
MemoryUsage muAfter = MemoryUsage.from((CompositeData) cdAfter.get("value"));
// System.out.println("MP-diff: " + mpName + " / " + name +
// " init: " + (muAfter.getInit()) + " " + (muBefore.getInit()) +
// " used: " + (muAfter.getUsed()) + " " + (muBefore.getUsed()) +
// " committed: " + (muAfter.getCommitted()) + " " + (muBefore.getCommitted()) +
// " max: " + (muAfter.getMax()) + " " + (muBefore.getMax())
// );
long diff = muAfter.getUsed()-muBefore.getUsed();
mi.addDiff(diff);
//System.out.println("MP-diff: " + mpName + " " + diff);
}
// if (mi.diff > 0) {
// System.err.println("WARNING: diff=" + mi.diff);
// }
totalDiff += mi.diff;
totalTime += mi.duration;
}
示例10: processNotification
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
private static void processNotification(ObjectName name) {
CompositeData cd;
try {
cd = (CompositeData) SERVER.getAttribute(name, "LastGcInfo");
} catch (AttributeNotFoundException | InstanceNotFoundException
| MBeanException | ReflectionException e) {
e.printStackTrace();
throw new RuntimeException();
}
//System.out.println("cds: " + cd.getClass().getName() + " " + cd.getCompositeType());
//CompositeDataSupport cds = new CompositeDataSupport(cd.getCompositeType(), cd);
// String[] keys = {"GcThreadCount", "duration", "endTime", "id",
// "memoryUsageAfterGc", "memoryUsageBeforeGc", "startTime"};
String[] keys = {"GcThreadCount", "duration", "id", "startTime", "endTime"};
Object[] mix = cd.getAll(keys);
MemInfo mi = new MemInfo((int)mix[0], (long)mix[1], (long)mix[2], (Long)mix[3], (Long)mix[4]);
String KEY_BEFORE = "memoryUsageBeforeGc";
String KEY_AFTER = "memoryUsageAfterGc";
TabularData tdBefore = (TabularData) cd.get(KEY_BEFORE);
TabularData tdAfter = (TabularData) cd.get(KEY_AFTER);
for (String mpName: POOL_NAMES) {
CompositeData cdBefore = tdBefore.get(new Object[]{mpName});
MemoryUsage muBefore = MemoryUsage.from((CompositeData) cdBefore.get("value"));
CompositeData cdAfter = tdAfter.get(new Object[]{mpName});
MemoryUsage muAfter = MemoryUsage.from((CompositeData) cdAfter.get("value"));
// System.out.println("MP-diff: " + mpName + " / " + name +
// " init: " + (muAfter.getInit()) + " " + (muBefore.getInit()) +
// " used: " + (muAfter.getUsed()) + " " + (muBefore.getUsed()) +
// " committed: " + (muAfter.getCommitted()) + " " + (muBefore.getCommitted()) +
// " max: " + (muAfter.getMax()) + " " + (muBefore.getMax())
// );
long diff = muAfter.getUsed()-muBefore.getUsed();
mi.addDiff(diff);
//System.out.println("MP-diff: " + mpName + " " + diff);
}
// if (mi.diff > 0) {
// System.err.println("WARNING: diff=" + mi.diff);
// }
totalDiff += mi.diff;
totalTime += mi.duration;
}
示例11: run
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
public void run() {
try {
Schema s = service.getSchema(schema);
if (s != null && s.isActive()) {
long totalECost = 0;
long totalCCost = 0;
long totalRCost = 0;
long totalICost = 0;
long totalDCost = 0;
TabularData data = service.getSchemaPartitionStatistics(schema);
Set<List<Integer>> keys = (Set<List<Integer>>) data.keySet();
Set<List<Integer>> sorted = new TreeSet<List<Integer>>(this);
sorted.addAll(keys);
for (List key: sorted) {
Object[] index = key.toArray();
CompositeData cd = data.get(index);
int partition = (Integer) cd.get("partition");
long eCost = (Long) cd.get("element cost");
eCost = new java.math.BigDecimal(eCost).movePointLeft(3).longValue();
totalECost += eCost;
long cCost = (Long) cd.get("content cost");
cCost = new java.math.BigDecimal(cCost).movePointLeft(3).longValue();
totalCCost += cCost;
long rCost = (Long) cd.get("result cost");
rCost = new java.math.BigDecimal(rCost).movePointLeft(3).longValue();
totalRCost += rCost;
long iCost = (Long) cd.get("index cost");
iCost = new java.math.BigDecimal(iCost).movePointLeft(3).longValue();
totalICost += iCost;
long dCost = (Long) cd.get("document cost");
dCost = new java.math.BigDecimal(dCost).movePointLeft(3).longValue();
totalDCost += dCost;
chart.addValues(partition, new long[] {eCost, cCost, rCost, iCost, dCost});
}
long overallCost = totalECost + totalCCost + totalRCost + totalICost + totalDCost;
Component[] labels = header.getComponents();
((JLabel) labels[0]).setText("Total elements cost: " + chart.formatDecimal(totalECost));
((JLabel) labels[1]).setText("Total content cost: " + chart.formatDecimal(totalCCost));
((JLabel) labels[2]).setText("Total results cost: " + chart.formatDecimal(totalRCost));
((JLabel) labels[4]).setText("Total indices cost: " + chart.formatDecimal(totalICost));
((JLabel) labels[5]).setText("Total documents cost: " + chart.formatDecimal(totalDCost));
((JLabel) labels[6]).setText("Overall cost: " + chart.formatDecimal(overallCost));
}
} catch (Exception ex) {
LOGGER.severe(ex.getMessage());
}
}
示例12: getSystemProperty
import javax.management.openmbean.TabularData; //导入方法依赖的package包/类
/**
* @param key the key
* @return RuntimeMXBean.getSystemProperties
* @throws InstanceNotFoundException the instance not found exception
* @throws MalformedObjectNameException the malformed object name
*/
public String getSystemProperty(String key)
throws MalformedObjectNameException, InstanceNotFoundException
{
TabularData td =getAttribute(new ObjectName("java.lang:type=Runtime"), "SystemProperties");
String [] keyArray = {key};
CompositeData cd = td.get(keyArray);
return toText(cd);
}