use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class WanCommands method statusGatewaySender.
@CliCommand(value = CliStrings.STATUS_GATEWAYSENDER, help = CliStrings.STATUS_GATEWAYSENDER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result statusGatewaySender(@CliOption(key = CliStrings.STATUS_GATEWAYSENDER__ID, mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID, help = CliStrings.STATUS_GATEWAYSENDER__ID__HELP) String senderId, @CliOption(key = CliStrings.STATUS_GATEWAYSENDER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.STATUS_GATEWAYSENDER__GROUP__HELP) String[] onGroup, @CliOption(key = CliStrings.STATUS_GATEWAYSENDER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, help = CliStrings.STATUS_GATEWAYSENDER__MEMBER__HELP) String[] onMember) {
Result result = null;
if (senderId != null)
senderId = senderId.trim();
try {
InternalCache cache = getCache();
SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
GatewaySenderMXBean bean = null;
CompositeResultData crd = ResultBuilder.createCompositeResultData();
TabularResultData availableSenderData = crd.addSection(CliStrings.SECTION_GATEWAY_SENDER_AVAILABLE).addTable(CliStrings.TABLE_GATEWAY_SENDER);
TabularResultData notAvailableSenderData = crd.addSection(CliStrings.SECTION_GATEWAY_SENDER_NOT_AVAILABLE).addTable(CliStrings.TABLE_GATEWAY_SENDER);
Set<DistributedMember> dsMembers = CliUtil.findMembers(onGroup, onMember);
if (dsMembers.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
for (DistributedMember member : dsMembers) {
if (cache.getDistributedSystem().getDistributedMember().getId().equals(member.getId())) {
bean = service.getLocalGatewaySenderMXBean(senderId);
} else {
ObjectName objectName = service.getGatewaySenderMBeanName(member, senderId);
bean = service.getMBeanProxy(objectName, GatewaySenderMXBean.class);
}
if (bean != null) {
buildSenderStatus(member.getId(), bean, availableSenderData);
} else {
buildSenderStatus(member.getId(), bean, notAvailableSenderData);
}
}
result = ResultBuilder.buildResult(crd);
} catch (Exception e) {
LogWrapper.getInstance().warning(CliStrings.GATEWAY_ERROR + CliUtil.stackTraceAsString(e));
result = ResultBuilder.createGemFireErrorResult(CliStrings.GATEWAY_ERROR + e.getMessage());
}
return result;
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class WanCommands method stopGatewayReceiver.
@CliCommand(value = CliStrings.STOP_GATEWAYRECEIVER, help = CliStrings.STOP_GATEWAYRECEIVER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result stopGatewayReceiver(@CliOption(key = CliStrings.STOP_GATEWAYRECEIVER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.STOP_GATEWAYRECEIVER__GROUP__HELP) String[] onGroup, @CliOption(key = CliStrings.STOP_GATEWAYRECEIVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, help = CliStrings.STOP_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember) {
Result result = null;
try {
InternalCache cache = getCache();
SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
GatewayReceiverMXBean receieverBean = null;
TabularResultData resultData = ResultBuilder.createTabularResultData();
Set<DistributedMember> dsMembers = CliUtil.findMembers(onGroup, onMember);
if (dsMembers.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
for (DistributedMember member : dsMembers) {
ObjectName gatewayReceiverObjectName = MBeanJMXAdapter.getGatewayReceiverMBeanName(member);
if (gatewayReceiverObjectName != null) {
receieverBean = service.getMBeanProxy(gatewayReceiverObjectName, GatewayReceiverMXBean.class);
if (receieverBean != null) {
if (receieverBean.isRunning()) {
receieverBean.stop();
accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_OK, CliStrings.format(CliStrings.GATEWAY_RECEIVER_IS_STOPPED_ON_MEMBER_0, new Object[] { member.getId() }));
} else {
accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR, CliStrings.format(CliStrings.GATEWAY_RECEIVER_IS_NOT_RUNNING_ON_MEMBER_0, new Object[] { member.getId() }));
}
} else {
accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR, CliStrings.format(CliStrings.GATEWAY_RECEIVER_IS_NOT_AVAILABLE_ON_MEMBER_0, new Object[] { member.getId() }));
}
} else {
accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR, CliStrings.format(CliStrings.GATEWAY_RECEIVER_IS_NOT_AVAILABLE_ON_MEMBER_0, new Object[] { member.getId() }));
}
}
result = ResultBuilder.buildResult(resultData);
} catch (CommandResultException crex) {
result = handleCommandResultException(crex);
} catch (Exception e) {
LogWrapper.getInstance().warning(CliStrings.GATEWAY_ERROR + CliUtil.stackTraceAsString(e));
result = ResultBuilder.createGemFireErrorResult(CliStrings.GATEWAY_ERROR + e.getMessage());
}
return result;
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class WanCommands method createGatewayReceiver.
@CliCommand(value = CliStrings.CREATE_GATEWAYRECEIVER, help = CliStrings.CREATE_GATEWAYRECEIVER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result createGatewayReceiver(@CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.CREATE_GATEWAYRECEIVER__GROUP__HELP) String[] onGroups, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.CREATE_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART, help = CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART__HELP) Boolean manualStart, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT, help = CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT__HELP) Integer startPort, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT, help = CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT__HELP) Integer endPort, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS, help = CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS__HELP) String bindAddress, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS, help = CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS__HELP) Integer maximumTimeBetweenPings, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE, help = CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE__HELP) Integer socketBufferSize, @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER, help = CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER__HELP) String[] gatewayTransportFilters) {
Result result = null;
AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
try {
GatewayReceiverFunctionArgs gatewayReceiverFunctionArgs = new GatewayReceiverFunctionArgs(manualStart, startPort, endPort, bindAddress, socketBufferSize, maximumTimeBetweenPings, gatewayTransportFilters);
Set<DistributedMember> membersToCreateGatewayReceiverOn = CliUtil.findMembers(onGroups, onMember);
if (membersToCreateGatewayReceiverOn.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(GatewayReceiverCreateFunction.INSTANCE, gatewayReceiverFunctionArgs, membersToCreateGatewayReceiverOn);
@SuppressWarnings("unchecked") List<CliFunctionResult> gatewayReceiverCreateResults = (List<CliFunctionResult>) resultCollector.getResult();
TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
final String errorPrefix = "ERROR: ";
for (CliFunctionResult gatewayReceiverCreateResult : gatewayReceiverCreateResults) {
boolean success = gatewayReceiverCreateResult.isSuccessful();
tabularResultData.accumulate("Member", gatewayReceiverCreateResult.getMemberIdOrName());
tabularResultData.accumulate("Status", (success ? "" : errorPrefix) + gatewayReceiverCreateResult.getMessage());
if (success && xmlEntity.get() == null) {
xmlEntity.set(gatewayReceiverCreateResult.getXmlEntity());
}
}
result = ResultBuilder.buildResult(tabularResultData);
} catch (IllegalArgumentException e) {
LogWrapper.getInstance().info(e.getMessage());
result = ResultBuilder.createUserErrorResult(e.getMessage());
}
if (xmlEntity.get() != null) {
persistClusterConfiguration(result, () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), onGroups));
}
return result;
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class WanCommands method createGatewaySender.
@CliCommand(value = CliStrings.CREATE_GATEWAYSENDER, help = CliStrings.CREATE_GATEWAYSENDER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result createGatewaySender(@CliOption(key = CliStrings.CREATE_GATEWAYSENDER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.CREATE_GATEWAYSENDER__GROUP__HELP) String[] onGroups, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.CREATE_GATEWAYSENDER__MEMBER__HELP) String[] onMember, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ID, mandatory = true, help = CliStrings.CREATE_GATEWAYSENDER__ID__HELP) String id, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID, mandatory = true, help = CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID__HELP) Integer remoteDistributedSystemId, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__PARALLEL, help = CliStrings.CREATE_GATEWAYSENDER__PARALLEL__HELP) Boolean parallel, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__MANUALSTART, help = CliStrings.CREATE_GATEWAYSENDER__MANUALSTART__HELP) Boolean manualStart, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE, help = CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE__HELP) Integer socketBufferSize, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT, help = CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT__HELP) Integer socketReadTimeout, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION, help = CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION__HELP) Boolean enableBatchConflation, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE, help = CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE__HELP) Integer batchSize, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL, help = CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL__HELP) Integer batchTimeInterval, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE, help = CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE__HELP) Boolean enablePersistence, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__DISKSTORENAME, help = CliStrings.CREATE_GATEWAYSENDER__DISKSTORENAME__HELP) String diskStoreName, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS, help = CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS__HELP) Boolean diskSynchronous, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY, help = CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY__HELP) Integer maxQueueMemory, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD, help = CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD__HELP) Integer alertThreshold, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS, help = CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS__HELP) Integer dispatcherThreads, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY, help = CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY__HELP) String orderPolicy, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER, help = CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER__HELP) String[] gatewayEventFilters, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER, help = CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER__HELP) String[] gatewayTransportFilter) {
Result result = null;
AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
try {
GatewaySenderFunctionArgs gatewaySenderFunctionArgs = new GatewaySenderFunctionArgs(id, remoteDistributedSystemId, parallel, manualStart, socketBufferSize, socketReadTimeout, enableBatchConflation, batchSize, batchTimeInterval, enablePersistence, diskStoreName, diskSynchronous, maxQueueMemory, alertThreshold, dispatcherThreads, orderPolicy, gatewayEventFilters, gatewayTransportFilter);
Set<DistributedMember> membersToCreateGatewaySenderOn = CliUtil.findMembers(onGroups, onMember);
if (membersToCreateGatewaySenderOn.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(GatewaySenderCreateFunction.INSTANCE, gatewaySenderFunctionArgs, membersToCreateGatewaySenderOn);
@SuppressWarnings("unchecked") List<CliFunctionResult> gatewaySenderCreateResults = (List<CliFunctionResult>) resultCollector.getResult();
TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
final String errorPrefix = "ERROR: ";
for (CliFunctionResult gatewaySenderCreateResult : gatewaySenderCreateResults) {
boolean success = gatewaySenderCreateResult.isSuccessful();
tabularResultData.accumulate("Member", gatewaySenderCreateResult.getMemberIdOrName());
tabularResultData.accumulate("Status", (success ? "" : errorPrefix) + gatewaySenderCreateResult.getMessage());
if (success && xmlEntity.get() == null) {
xmlEntity.set(gatewaySenderCreateResult.getXmlEntity());
}
}
result = ResultBuilder.buildResult(tabularResultData);
} catch (IllegalArgumentException e) {
LogWrapper.getInstance().info(e.getMessage());
result = ResultBuilder.createUserErrorResult(e.getMessage());
}
if (xmlEntity.get() != null) {
persistClusterConfiguration(result, () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), onGroups));
}
return result;
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class ShellCommands method buildResultForEcho.
TabularResultData buildResultForEcho(Set<Entry<String, String>> propertyMap) {
TabularResultData resultData = ResultBuilder.createTabularResultData();
Iterator<Entry<String, String>> it = propertyMap.iterator();
while (it.hasNext()) {
Entry<String, String> setEntry = it.next();
resultData.accumulate("Property", setEntry.getKey());
resultData.accumulate("Value", String.valueOf(setEntry.getValue()));
}
return resultData;
}
Aggregations