use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class DiskStoreCommands method backupDiskStore.
@CliCommand(value = CliStrings.BACKUP_DISK_STORE, help = CliStrings.BACKUP_DISK_STORE__HELP)
@CliMetaData(relatedTopic = { CliStrings.TOPIC_GEODE_DISKSTORE })
@ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
public Result backupDiskStore(@CliOption(key = CliStrings.BACKUP_DISK_STORE__DISKDIRS, unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.BACKUP_DISK_STORE__DISKDIRS__HELP, mandatory = true) String targetDir, @CliOption(key = CliStrings.BACKUP_DISK_STORE__BASELINEDIR, help = CliStrings.BACKUP_DISK_STORE__BASELINEDIR__HELP) String baselineDir) {
Result result = null;
try {
InternalCache cache = getCache();
DM dm = cache.getDistributionManager();
BackupStatus backupStatus = null;
if (baselineDir != null && !baselineDir.isEmpty()) {
backupStatus = AdminDistributedSystemImpl.backupAllMembers(dm, new File(targetDir), new File(baselineDir));
} else {
backupStatus = AdminDistributedSystemImpl.backupAllMembers(dm, new File(targetDir), null);
}
Map<DistributedMember, Set<PersistentID>> backedupMemberDiskstoreMap = backupStatus.getBackedUpDiskStores();
Set<DistributedMember> backedupMembers = backedupMemberDiskstoreMap.keySet();
CompositeResultData crd = ResultBuilder.createCompositeResultData();
if (!backedupMembers.isEmpty()) {
SectionResultData backedupDiskStoresSection = crd.addSection();
backedupDiskStoresSection.setHeader(CliStrings.BACKUP_DISK_STORE_MSG_BACKED_UP_DISK_STORES);
TabularResultData backedupDiskStoresTable = backedupDiskStoresSection.addTable();
for (DistributedMember member : backedupMembers) {
Set<PersistentID> backedupDiskStores = backedupMemberDiskstoreMap.get(member);
boolean printMember = true;
String memberName = member.getName();
if (memberName == null || memberName.isEmpty()) {
memberName = member.getId();
}
for (PersistentID persistentId : backedupDiskStores) {
if (persistentId != null) {
String UUID = persistentId.getUUID().toString();
String hostName = persistentId.getHost().getHostName();
String directory = persistentId.getDirectory();
if (printMember) {
writeToBackupDisktoreTable(backedupDiskStoresTable, memberName, UUID, hostName, directory);
printMember = false;
} else {
writeToBackupDisktoreTable(backedupDiskStoresTable, "", UUID, hostName, directory);
}
}
}
}
} else {
SectionResultData noMembersBackedUp = crd.addSection();
noMembersBackedUp.setHeader(CliStrings.BACKUP_DISK_STORE_MSG_NO_DISKSTORES_BACKED_UP);
}
Set<PersistentID> offlineDiskStores = backupStatus.getOfflineDiskStores();
if (!offlineDiskStores.isEmpty()) {
SectionResultData offlineDiskStoresSection = crd.addSection();
TabularResultData offlineDiskStoresTable = offlineDiskStoresSection.addTable();
offlineDiskStoresSection.setHeader(CliStrings.BACKUP_DISK_STORE_MSG_OFFLINE_DISK_STORES);
for (PersistentID offlineDiskStore : offlineDiskStores) {
offlineDiskStoresTable.accumulate(CliStrings.BACKUP_DISK_STORE_MSG_UUID, offlineDiskStore.getUUID().toString());
offlineDiskStoresTable.accumulate(CliStrings.BACKUP_DISK_STORE_MSG_HOST, offlineDiskStore.getHost().getHostName());
offlineDiskStoresTable.accumulate(CliStrings.BACKUP_DISK_STORE_MSG_DIRECTORY, offlineDiskStore.getDirectory());
}
}
result = ResultBuilder.buildResult(crd);
} catch (Exception e) {
result = ResultBuilder.createGemFireErrorResult(e.getMessage());
}
return result;
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class DataCommands method toCompositeResultData.
protected CompositeResultData toCompositeResultData(CompositeResultData rebalanceResulteData, ArrayList<String> rstlist, int index, boolean simulate, InternalCache cache) {
// add only if there are any valid regions in results
if (rstlist.size() > resultItemCount && StringUtils.isNotEmpty(rstlist.get(resultItemCount))) {
TabularResultData table1 = rebalanceResulteData.addSection().addTable("Table" + index);
String newLine = System.getProperty("line.separator");
StringBuilder resultStr = new StringBuilder();
resultStr.append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATEBYTES);
table1.accumulate("Value", rstlist.get(0));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATEBYTES).append(" = ").append(rstlist.get(0)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATETIM);
table1.accumulate("Value", rstlist.get(1));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATETIM).append(" = ").append(rstlist.get(1)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETCREATESCOMPLETED);
table1.accumulate("Value", rstlist.get(2));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETCREATESCOMPLETED).append(" = ").append(rstlist.get(2)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERBYTES);
table1.accumulate("Value", rstlist.get(3));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERBYTES).append(" = ").append(rstlist.get(3)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERTIME);
table1.accumulate("Value", rstlist.get(4));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERTIME).append(" = ").append(rstlist.get(4)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERSCOMPLETED);
table1.accumulate("Value", rstlist.get(5));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALBUCKETTRANSFERSCOMPLETED).append(" = ").append(rstlist.get(5)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERTIME);
table1.accumulate("Value", rstlist.get(6));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERTIME).append(" = ").append(rstlist.get(6)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERSCOMPLETED);
table1.accumulate("Value", rstlist.get(7));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALPRIMARYTRANSFERSCOMPLETED).append(" = ").append(rstlist.get(7)).append(newLine);
table1.accumulate("Rebalanced Stats", CliStrings.REBALANCE__MSG__TOTALTIME);
table1.accumulate("Value", rstlist.get(8));
resultStr.append(CliStrings.REBALANCE__MSG__TOTALTIME).append(" = ").append(rstlist.get(8)).append(newLine);
String headerText;
if (simulate) {
headerText = "Simulated partition regions ";
} else {
headerText = "Rebalanced partition regions ";
}
for (int i = resultItemCount; i < rstlist.size(); i++) {
headerText = headerText + " " + rstlist.get(i);
}
table1.setHeader(headerText);
cache.getLogger().info(headerText + resultStr);
}
return rebalanceResulteData;
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class DiskStoreCommands method createDiskStore.
@CliCommand(value = CliStrings.CREATE_DISK_STORE, help = CliStrings.CREATE_DISK_STORE__HELP)
@CliMetaData(shellOnly = false, relatedTopic = { CliStrings.TOPIC_GEODE_DISKSTORE })
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result createDiskStore(@CliOption(key = CliStrings.CREATE_DISK_STORE__NAME, mandatory = true, optionContext = ConverterHint.DISKSTORE, help = CliStrings.CREATE_DISK_STORE__NAME__HELP) String name, @CliOption(key = CliStrings.CREATE_DISK_STORE__ALLOW_FORCE_COMPACTION, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false", help = CliStrings.CREATE_DISK_STORE__ALLOW_FORCE_COMPACTION__HELP) boolean allowForceCompaction, @CliOption(key = CliStrings.CREATE_DISK_STORE__AUTO_COMPACT, specifiedDefaultValue = "true", unspecifiedDefaultValue = "true", help = CliStrings.CREATE_DISK_STORE__AUTO_COMPACT__HELP) boolean autoCompact, @CliOption(key = CliStrings.CREATE_DISK_STORE__COMPACTION_THRESHOLD, unspecifiedDefaultValue = "50", help = CliStrings.CREATE_DISK_STORE__COMPACTION_THRESHOLD__HELP) int compactionThreshold, @CliOption(key = CliStrings.CREATE_DISK_STORE__MAX_OPLOG_SIZE, unspecifiedDefaultValue = "1024", help = CliStrings.CREATE_DISK_STORE__MAX_OPLOG_SIZE__HELP) int maxOplogSize, @CliOption(key = CliStrings.CREATE_DISK_STORE__QUEUE_SIZE, unspecifiedDefaultValue = "0", help = CliStrings.CREATE_DISK_STORE__QUEUE_SIZE__HELP) int queueSize, @CliOption(key = CliStrings.CREATE_DISK_STORE__TIME_INTERVAL, unspecifiedDefaultValue = "1000", help = CliStrings.CREATE_DISK_STORE__TIME_INTERVAL__HELP) long timeInterval, @CliOption(key = CliStrings.CREATE_DISK_STORE__WRITE_BUFFER_SIZE, unspecifiedDefaultValue = "32768", help = CliStrings.CREATE_DISK_STORE__WRITE_BUFFER_SIZE__HELP) int writeBufferSize, @CliOption(key = CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, mandatory = true, help = CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE__HELP) String[] directoriesAndSizes, @CliOption(key = CliStrings.CREATE_DISK_STORE__GROUP, help = CliStrings.CREATE_DISK_STORE__GROUP__HELP, optionContext = ConverterHint.MEMBERGROUP) String[] groups, @CliOption(key = CliStrings.CREATE_DISK_STORE__DISK_USAGE_WARNING_PCT, unspecifiedDefaultValue = "90", help = CliStrings.CREATE_DISK_STORE__DISK_USAGE_WARNING_PCT__HELP) float diskUsageWarningPercentage, @CliOption(key = CliStrings.CREATE_DISK_STORE__DISK_USAGE_CRITICAL_PCT, unspecifiedDefaultValue = "99", help = CliStrings.CREATE_DISK_STORE__DISK_USAGE_CRITICAL_PCT__HELP) float diskUsageCriticalPercentage) {
try {
DiskStoreAttributes diskStoreAttributes = new DiskStoreAttributes();
diskStoreAttributes.allowForceCompaction = allowForceCompaction;
diskStoreAttributes.autoCompact = autoCompact;
diskStoreAttributes.compactionThreshold = compactionThreshold;
diskStoreAttributes.maxOplogSizeInBytes = maxOplogSize * (1024 * 1024);
diskStoreAttributes.queueSize = queueSize;
diskStoreAttributes.timeInterval = timeInterval;
diskStoreAttributes.writeBufferSize = writeBufferSize;
File[] directories = new File[directoriesAndSizes.length];
int[] sizes = new int[directoriesAndSizes.length];
for (int i = 0; i < directoriesAndSizes.length; i++) {
final int hashPosition = directoriesAndSizes[i].indexOf('#');
if (hashPosition == -1) {
directories[i] = new File(directoriesAndSizes[i]);
sizes[i] = Integer.MAX_VALUE;
} else {
directories[i] = new File(directoriesAndSizes[i].substring(0, hashPosition));
sizes[i] = Integer.parseInt(directoriesAndSizes[i].substring(hashPosition + 1));
}
}
diskStoreAttributes.diskDirs = directories;
diskStoreAttributes.diskDirSizes = sizes;
diskStoreAttributes.setDiskUsageWarningPercentage(diskUsageWarningPercentage);
diskStoreAttributes.setDiskUsageCriticalPercentage(diskUsageCriticalPercentage);
TabularResultData tabularData = ResultBuilder.createTabularResultData();
boolean accumulatedData = false;
Set<DistributedMember> targetMembers = CliUtil.findMembers(groups, null);
if (targetMembers.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
ResultCollector<?, ?> rc = CliUtil.executeFunction(new CreateDiskStoreFunction(), new Object[] { name, diskStoreAttributes }, targetMembers);
List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult());
AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
for (CliFunctionResult result : results) {
if (result.getThrowable() != null) {
tabularData.accumulate("Member", result.getMemberIdOrName());
tabularData.accumulate("Result", "ERROR: " + result.getThrowable().getClass().getName() + ": " + result.getThrowable().getMessage());
accumulatedData = true;
tabularData.setStatus(Status.ERROR);
} else if (result.isSuccessful()) {
tabularData.accumulate("Member", result.getMemberIdOrName());
tabularData.accumulate("Result", result.getMessage());
accumulatedData = true;
if (xmlEntity.get() == null) {
xmlEntity.set(result.getXmlEntity());
}
}
}
if (!accumulatedData) {
return ResultBuilder.createInfoResult("Unable to create disk store(s).");
}
Result result = ResultBuilder.buildResult(tabularData);
if (xmlEntity.get() != null) {
persistClusterConfiguration(result, () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), groups));
}
return ResultBuilder.buildResult(tabularData);
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
} catch (Throwable th) {
SystemFailure.checkFailure();
return ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.CREATE_DISK_STORE__ERROR_WHILE_CREATING_REASON_0, new Object[] { th.getMessage() }));
}
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class MemberCommands method listMember.
@CliCommand(value = { CliStrings.LIST_MEMBER }, help = CliStrings.LIST_MEMBER__HELP)
@CliMetaData(shellOnly = false, relatedTopic = CliStrings.TOPIC_GEODE_SERVER)
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result listMember(@CliOption(key = { CliStrings.LIST_MEMBER__GROUP }, unspecifiedDefaultValue = "", optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.LIST_MEMBER__GROUP__HELP) String group) {
Result result = null;
// TODO: Add the code for identifying the system services
try {
Set<DistributedMember> memberSet = new TreeSet<DistributedMember>();
InternalCache cache = getCache();
// default get all the members in the DS
if (group.isEmpty()) {
memberSet.addAll(CliUtil.getAllMembers(cache));
} else {
memberSet.addAll(cache.getDistributedSystem().getGroupMembers(group));
}
if (memberSet.isEmpty()) {
result = ResultBuilder.createInfoResult(CliStrings.LIST_MEMBER__MSG__NO_MEMBER_FOUND);
} else {
TabularResultData resultData = ResultBuilder.createTabularResultData();
Iterator<DistributedMember> memberIters = memberSet.iterator();
while (memberIters.hasNext()) {
DistributedMember member = memberIters.next();
resultData.accumulate("Name", member.getName());
resultData.accumulate("Id", member.getId());
}
result = ResultBuilder.buildResult(resultData);
}
} catch (Exception e) {
result = ResultBuilder.createGemFireErrorResult("Could not fetch the list of members. " + e.getMessage());
LogWrapper.getInstance().warning(e.getMessage(), e);
}
return result;
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class MiscellaneousCommands method getMemberMetrics.
/**
* Gets the Cluster wide metrics for a given member
*
* @return ResultData with required Member statistics or ErrorResultData if MemberMbean is not
* found to gather metrics
* @throws ResultDataException if building result fails
*/
private ResultData getMemberMetrics(DistributedMember distributedMember, String export_to_report_to, String[] categoriesArr, int cacheServerPort) throws ResultDataException {
final InternalCache cache = getCache();
final SystemManagementService managementService = (SystemManagementService) ManagementService.getManagementService(cache);
ObjectName memberMBeanName = managementService.getMemberMBeanName(distributedMember);
MemberMXBean memberMxBean = managementService.getMBeanInstance(memberMBeanName, MemberMXBean.class);
ObjectName csMxBeanName = null;
CacheServerMXBean csMxBean = null;
if (memberMxBean != null) {
if (cacheServerPort != -1) {
csMxBeanName = managementService.getCacheServerMBeanName(cacheServerPort, distributedMember);
csMxBean = managementService.getMBeanInstance(csMxBeanName, CacheServerMXBean.class);
if (csMxBean == null) {
ErrorResultData erd = ResultBuilder.createErrorResultData();
erd.addLine(CliStrings.format(CliStrings.SHOW_METRICS__CACHE__SERVER__NOT__FOUND, cacheServerPort, MBeanJMXAdapter.getMemberNameOrId(distributedMember)));
return erd;
}
}
JVMMetrics jvmMetrics = memberMxBean.showJVMMetrics();
CompositeResultData crd = ResultBuilder.createCompositeResultData();
SectionResultData section = crd.addSection();
TabularResultData metricsTable = section.addTable();
metricsTable.setHeader("Member Metrics");
StringBuilder csvBuilder = null;
if (export_to_report_to != null && !export_to_report_to.isEmpty()) {
csvBuilder = new StringBuilder();
csvBuilder.append("Category");
csvBuilder.append(',');
csvBuilder.append(CliStrings.SHOW_METRICS__METRIC__HEADER);
csvBuilder.append(',');
csvBuilder.append(CliStrings.SHOW_METRICS__VALUE__HEADER);
csvBuilder.append('\n');
}
Map<String, Boolean> categoriesMap = getMemberMetricsCategories();
if (categoriesArr != null && categoriesArr.length != 0) {
Set<String> categories = createSet(categoriesArr);
Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
Set<String> userCategories = getSetDifference(categories, checkSet);
// Checking if the categories specified by the user are valid or not
if (userCategories.isEmpty()) {
for (String category : checkSet) {
categoriesMap.put(category, false);
}
for (String category : categories) {
categoriesMap.put(category.toLowerCase(), true);
}
} else {
StringBuilder sb = new StringBuilder();
sb.append("Invalid Categories\n");
for (String category : userCategories) {
sb.append(category);
sb.append('\n');
}
return ResultBuilder.createErrorResultData().addLine(sb.toString());
}
}
// eviction, distribution
if (categoriesMap.get("member").booleanValue()) {
writeToTableAndCsv(metricsTable, "member", "upTime", memberMxBean.getMemberUpTime(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "cpuUsage", memberMxBean.getCpuUsage(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "currentHeapSize", memberMxBean.getCurrentHeapSize(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "maximumHeapSize", memberMxBean.getMaximumHeapSize(), csvBuilder);
}
/*
* JVM Metrics
*/
if (categoriesMap.get("jvm").booleanValue()) {
writeToTableAndCsv(metricsTable, "jvm ", "jvmThreads ", jvmMetrics.getTotalThreads(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "fileDescriptorLimit", memberMxBean.getFileDescriptorLimit(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalFileDescriptorOpen", memberMxBean.getTotalFileDescriptorOpen(), csvBuilder);
}
/*
* Member wide region metrics
*/
if (categoriesMap.get("region").booleanValue()) {
writeToTableAndCsv(metricsTable, "region ", "totalRegionCount ", memberMxBean.getTotalRegionCount(), csvBuilder);
String[] regionNames = memberMxBean.listRegions();
if (regionNames != null) {
for (int i = 0; i < regionNames.length; i++) {
if (i == 0) {
writeToTableAndCsv(metricsTable, "", "listOfRegions", regionNames[i].substring(1), csvBuilder);
} else {
writeToTableAndCsv(metricsTable, "", "", regionNames[i].substring(1), csvBuilder);
}
}
}
String[] rootRegionNames = memberMxBean.getRootRegionNames();
if (rootRegionNames != null) {
for (int i = 0; i < rootRegionNames.length; i++) {
if (i == 0) {
writeToTableAndCsv(metricsTable, "", "rootRegions", rootRegionNames[i], csvBuilder);
} else {
writeToTableAndCsv(metricsTable, "", "", rootRegionNames[i], csvBuilder);
}
}
}
writeToTableAndCsv(metricsTable, "", "totalRegionEntryCount", memberMxBean.getTotalRegionEntryCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalBucketCount", memberMxBean.getTotalBucketCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalPrimaryBucketCount", memberMxBean.getTotalPrimaryBucketCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "getsAvgLatency", memberMxBean.getGetsAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "putsAvgLatency", memberMxBean.getPutsAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "createsRate", memberMxBean.getCreatesRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "destroyRate", memberMxBean.getDestroysRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "putAllAvgLatency", memberMxBean.getPutAllAvgLatency(), csvBuilder);
// Not available from stats. After Stats re-org it will be avaialble
// writeToTableAndCsv(metricsTable, "", "getAllAvgLatency",
// memberMxBean.getGetAllAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalMissCount", memberMxBean.getTotalMissCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalHitCount", memberMxBean.getTotalHitCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "getsRate", memberMxBean.getGetsRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "putsRate", memberMxBean.getPutsRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "cacheWriterCallsAvgLatency", memberMxBean.getCacheWriterCallsAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "cacheListenerCallsAvgLatency", memberMxBean.getCacheListenerCallsAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalLoadsCompleted", memberMxBean.getTotalLoadsCompleted(), csvBuilder);
}
/*
* SERIALIZATION
*/
if (categoriesMap.get("serialization").booleanValue()) {
writeToTableAndCsv(metricsTable, "serialization", "serializationRate", memberMxBean.getSerializationRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "serializationLatency", memberMxBean.getSerializationRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "deserializationRate", memberMxBean.getDeserializationRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "deserializationLatency", memberMxBean.getDeserializationLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "deserializationAvgLatency", memberMxBean.getDeserializationAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "PDXDeserializationAvgLatency", memberMxBean.getPDXDeserializationAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "PDXDeserializationRate", memberMxBean.getPDXDeserializationRate(), csvBuilder);
}
/*
* Communication Metrics
*/
if (categoriesMap.get("communication").booleanValue()) {
writeToTableAndCsv(metricsTable, "communication", "bytesSentRate", memberMxBean.getBytesSentRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "bytesReceivedRate", memberMxBean.getBytesReceivedRate(), csvBuilder);
String[] connectedGatewayReceivers = memberMxBean.listConnectedGatewayReceivers();
writeToTableAndCsv(metricsTable, "", "connectedGatewayReceivers", connectedGatewayReceivers, csvBuilder);
String[] connectedGatewaySenders = memberMxBean.listConnectedGatewaySenders();
writeToTableAndCsv(metricsTable, "", "connectedGatewaySenders", connectedGatewaySenders, csvBuilder);
}
/*
* Member wide function metrics
*/
if (categoriesMap.get("function").booleanValue()) {
writeToTableAndCsv(metricsTable, "function", "numRunningFunctions", memberMxBean.getNumRunningFunctions(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "functionExecutionRate", memberMxBean.getFunctionExecutionRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "numRunningFunctionsHavingResults", memberMxBean.getNumRunningFunctionsHavingResults(), csvBuilder);
// Not Avaialble from Stats
// writeToTableAndCsv(metricsTable, "", "funcExecutionQueueSize",
// memberMxBean.getFuncExecutionQueueSize(), csvBuilder);
}
/*
* totalTransactionsCount currentTransactionalThreadIds transactionCommitsAvgLatency
* transactionCommittedTotalCount transactionRolledBackTotalCount transactionCommitsRate
*/
if (categoriesMap.get("transaction").booleanValue()) {
writeToTableAndCsv(metricsTable, "transaction", "totalTransactionsCount", memberMxBean.getTotalTransactionsCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "transactionCommitsAvgLatency", memberMxBean.getTransactionCommitsAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "transactionCommittedTotalCount", memberMxBean.getTransactionCommittedTotalCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "transactionRolledBackTotalCount", memberMxBean.getTransactionRolledBackTotalCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "transactionCommitsRate", memberMxBean.getTransactionCommitsRate(), csvBuilder);
}
/*
* Member wide disk metrics
*/
if (categoriesMap.get("diskstore").booleanValue()) {
writeToTableAndCsv(metricsTable, "diskstore", "totalDiskUsage", memberMxBean.getTotalDiskUsage(), // deadcoded to workaround bug 46397
csvBuilder);
writeToTableAndCsv(metricsTable, "", /* 46608 */
"diskReadsRate", memberMxBean.getDiskReadsRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "diskWritesRate", memberMxBean.getDiskWritesRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "flushTimeAvgLatency", memberMxBean.getDiskFlushAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalQueueSize", memberMxBean.getTotalDiskTasksWaiting(), // deadcoded to workaround bug
csvBuilder);
// 46397
writeToTableAndCsv(metricsTable, "", "totalBackupInProgress", memberMxBean.getTotalBackupInProgress(), csvBuilder);
}
/*
* Member wide Lock
*/
if (categoriesMap.get("lock").booleanValue()) {
writeToTableAndCsv(metricsTable, "lock", "lockWaitsInProgress", memberMxBean.getLockWaitsInProgress(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalLockWaitTime", memberMxBean.getTotalLockWaitTime(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalNumberOfLockService", memberMxBean.getTotalNumberOfLockService(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "requestQueues", memberMxBean.getLockRequestQueues(), csvBuilder);
}
/*
* Eviction
*/
if (categoriesMap.get("eviction").booleanValue()) {
writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate", memberMxBean.getLruEvictionRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "lruDestroyRate", memberMxBean.getLruDestroyRate(), csvBuilder);
}
/*
* Distribution
*/
if (categoriesMap.get("distribution").booleanValue()) {
writeToTableAndCsv(metricsTable, "distribution", "getInitialImagesInProgress", memberMxBean.getInitialImagesInProgres(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "getInitialImageTime", memberMxBean.getInitialImageTime(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "getInitialImageKeysReceived", memberMxBean.getInitialImageKeysReceived(), csvBuilder);
}
/*
* OffHeap
*/
if (categoriesMap.get("offheap").booleanValue()) {
writeToTableAndCsv(metricsTable, "offheap", "maxMemory", memberMxBean.getOffHeapMaxMemory(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "freeMemory", memberMxBean.getOffHeapFreeMemory(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "usedMemory", memberMxBean.getOffHeapUsedMemory(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "objects", memberMxBean.getOffHeapObjects(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "fragmentation", memberMxBean.getOffHeapFragmentation(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "compactionTime", memberMxBean.getOffHeapCompactionTime(), csvBuilder);
}
/*
* CacheServer stats
*/
if (csMxBean != null) {
writeToTableAndCsv(metricsTable, "cache-server", "clientConnectionCount", csMxBean.getClientConnectionCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "hostnameForClients", csMxBean.getHostNameForClients(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "getRequestAvgLatency", csMxBean.getGetRequestAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "putRequestAvgLatency", csMxBean.getPutRequestAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalConnectionsTimedOut", csMxBean.getTotalConnectionsTimedOut(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "threadQueueSize", csMxBean.getPutRequestAvgLatency(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "connectionThreads", csMxBean.getConnectionThreads(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "connectionLoad", csMxBean.getConnectionLoad(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "loadPerConnection", csMxBean.getLoadPerConnection(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "queueLoad", csMxBean.getQueueLoad(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "loadPerQueue", csMxBean.getLoadPerQueue(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "getRequestRate", csMxBean.getGetRequestRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "putRequestRate", csMxBean.getPutRequestRate(), csvBuilder);
/*
* Notification
*/
writeToTableAndCsv(metricsTable, "notification", "numClientNotificationRequests", csMxBean.getNumClientNotificationRequests(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "clientNotificationRate", csMxBean.getClientNotificationRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "clientNotificationAvgLatency", csMxBean.getClientNotificationAvgLatency(), csvBuilder);
/*
* Query
*/
writeToTableAndCsv(metricsTable, "query", "activeCQCount", csMxBean.getActiveCQCount(), csvBuilder);
writeToTableAndCsv(metricsTable, "query", "queryRequestRate", csMxBean.getQueryRequestRate(), csvBuilder);
writeToTableAndCsv(metricsTable, "", "indexCount", csMxBean.getIndexCount(), csvBuilder);
String[] indexList = csMxBean.getIndexList();
writeToTableAndCsv(metricsTable, "", "index list", indexList, csvBuilder);
writeToTableAndCsv(metricsTable, "", "totalIndexMaintenanceTime", csMxBean.getTotalIndexMaintenanceTime(), csvBuilder);
}
if (export_to_report_to != null && !export_to_report_to.isEmpty()) {
crd.addAsFile(export_to_report_to, csvBuilder.toString(), "Member metrics exported to {0}.", false);
}
return crd;
} else {
ErrorResultData erd = ResultBuilder.createErrorResultData();
String errorMessage = CliStrings.format(CliStrings.SHOW_METRICS__ERROR, "Member MBean for " + MBeanJMXAdapter.getMemberNameOrId(distributedMember) + " not found");
return ResultBuilder.createErrorResultData().addLine(errorMessage);
}
}
Aggregations