Search in sources :

Example 1 with GatewayReceiverMXBean

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);
}
Also used : GatewayReceiverMXBean(org.apache.geode.management.GatewayReceiverMXBean) ManagementService(org.apache.geode.management.ManagementService) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Cache(org.apache.geode.cache.Cache)

Example 2 with GatewayReceiverMXBean

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;
}
Also used : GatewayReceiverMXBean(org.apache.geode.management.GatewayReceiverMXBean) TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) CommandResultException(org.apache.geode.management.internal.cli.result.CommandResultException) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) CommandResultException(org.apache.geode.management.internal.cli.result.CommandResultException) ExecutionException(java.util.concurrent.ExecutionException) Result(org.apache.geode.management.cli.Result) CliFunctionResult(org.apache.geode.management.internal.cli.functions.CliFunctionResult) ObjectName(javax.management.ObjectName) CliCommand(org.springframework.shell.core.annotation.CliCommand) CliMetaData(org.apache.geode.management.cli.CliMetaData) ResourceOperation(org.apache.geode.management.internal.security.ResourceOperation)

Example 3 with GatewayReceiverMXBean

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;
}
Also used : GatewayReceiverMXBean(org.apache.geode.management.GatewayReceiverMXBean) CompositeResultData(org.apache.geode.management.internal.cli.result.CompositeResultData) TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) CommandResultException(org.apache.geode.management.internal.cli.result.CommandResultException) ExecutionException(java.util.concurrent.ExecutionException) Result(org.apache.geode.management.cli.Result) CliFunctionResult(org.apache.geode.management.internal.cli.functions.CliFunctionResult) ObjectName(javax.management.ObjectName) CliCommand(org.springframework.shell.core.annotation.CliCommand) CliMetaData(org.apache.geode.management.cli.CliMetaData) ResourceOperation(org.apache.geode.management.internal.security.ResourceOperation)

Example 4 with GatewayReceiverMXBean

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);
}
Also used : GatewayReceiverMXBean(org.apache.geode.management.GatewayReceiverMXBean) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName)

Example 5 with GatewayReceiverMXBean

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());
        }
    }
}
Also used : GatewayReceiverMXBean(org.apache.geode.management.GatewayReceiverMXBean) ManagementException(org.apache.geode.management.ManagementException) ListenerNotFoundException(javax.management.ListenerNotFoundException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectName(javax.management.ObjectName)

Aggregations

GatewayReceiverMXBean (org.apache.geode.management.GatewayReceiverMXBean)8 ObjectName (javax.management.ObjectName)6 ExecutionException (java.util.concurrent.ExecutionException)4 DistributedMember (org.apache.geode.distributed.DistributedMember)4 InternalCache (org.apache.geode.internal.cache.InternalCache)4 CliMetaData (org.apache.geode.management.cli.CliMetaData)4 Result (org.apache.geode.management.cli.Result)4 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)4 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)4 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)4 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)4 ResourceOperation (org.apache.geode.management.internal.security.ResourceOperation)4 CliCommand (org.springframework.shell.core.annotation.CliCommand)4 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 GatewaySenderMXBean (org.apache.geode.management.GatewaySenderMXBean)2 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 ListenerNotFoundException (javax.management.ListenerNotFoundException)1 Notification (javax.management.Notification)1