use of org.apache.geode.management.GatewayReceiverMXBean in project geode by apache.
the class TestRemoteClusterDUnitTest method checkReceiverMBean.
/**
* Checks whether a GatewayReceiverMBean is created or not
*
* @param vm reference to VM
*/
@SuppressWarnings("serial")
protected void checkReceiverMBean(final VM vm) {
SerializableRunnable checkMBean = new SerializableRunnable("Check Receiver MBean") {
public void run() {
Cache cache = GemFireCacheImpl.getInstance();
ManagementService service = ManagementService.getManagementService(cache);
GatewayReceiverMXBean bean = service.getLocalGatewayReceiverMXBean();
assertNotNull(bean);
}
};
vm.invoke(checkMBean);
}
use of org.apache.geode.management.GatewayReceiverMXBean 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.GatewayReceiverMXBean in project geode by apache.
the class WanCommands method statusGatewayReceiver.
@CliCommand(value = CliStrings.STATUS_GATEWAYRECEIVER, help = CliStrings.STATUS_GATEWAYRECEIVER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result statusGatewayReceiver(@CliOption(key = CliStrings.STATUS_GATEWAYRECEIVER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.STATUS_GATEWAYRECEIVER__GROUP__HELP) String[] onGroup, @CliOption(key = CliStrings.STATUS_GATEWAYRECEIVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, help = CliStrings.STATUS_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember) {
Result result = null;
try {
InternalCache cache = getCache();
SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
CompositeResultData crd = ResultBuilder.createCompositeResultData();
TabularResultData availableReceiverData = crd.addSection(CliStrings.SECTION_GATEWAY_RECEIVER_AVAILABLE).addTable(CliStrings.TABLE_GATEWAY_RECEIVER);
TabularResultData notAvailableReceiverData = crd.addSection(CliStrings.SECTION_GATEWAY_RECEIVER_NOT_AVAILABLE).addTable(CliStrings.TABLE_GATEWAY_RECEIVER);
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) {
GatewayReceiverMXBean receieverBean = service.getMBeanProxy(gatewayReceiverObjectName, GatewayReceiverMXBean.class);
if (receieverBean != null) {
buildReceiverStatus(member.getId(), receieverBean, availableReceiverData);
continue;
}
}
buildReceiverStatus(member.getId(), null, notAvailableReceiverData);
}
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.GatewayReceiverMXBean in project geode by apache.
the class ManagementAdapter method createGatewayReceiverMBean.
private void createGatewayReceiverMBean(GatewayReceiver recv) {
GatewayReceiverMBeanBridge bridge = new GatewayReceiverMBeanBridge(recv);
GatewayReceiverMXBean receiverMBean = new GatewayReceiverMBean(bridge);
ObjectName recvObjectName = MBeanJMXAdapter.getGatewayReceiverMBeanName(internalCache.getDistributedSystem().getDistributedMember());
ObjectName changedMBeanName = service.registerInternalMBean(receiverMBean, recvObjectName);
service.federate(changedMBeanName, GatewayReceiverMXBean.class, true);
Notification notification = new Notification(JMXNotificationType.GATEWAY_RECEIVER_CREATED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.GATEWAY_RECEIVER_CREATED_PREFIX);
memberLevelNotifEmitter.sendNotification(notification);
}
use of org.apache.geode.management.GatewayReceiverMXBean in project geode by apache.
the class DistributedSystemBridge method fetchGatewayReceiverObjectName.
public ObjectName fetchGatewayReceiverObjectName(String member) throws Exception {
validateMember(member);
ObjectName receiverName = MBeanJMXAdapter.getGatewayReceiverMBeanName(member);
GatewayReceiverMXBean bean = service.getMBeanInstance(receiverName, GatewayReceiverMXBean.class);
if (bean != null) {
return receiverName;
} else {
// check for local MBean
bean = service.getLocalGatewayReceiverMXBean();
if (bean != null) {
return receiverName;
} else {
throw new Exception(ManagementStrings.GATEWAY_RECEIVER_MBEAN_NOT_FOUND_IN_SYSTEM.toString());
}
}
}
Aggregations