Search in sources :

Example 66 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class RegionManagementDUnitTest method awaitDistributedRegionMXBean.

private DistributedRegionMXBean awaitDistributedRegionMXBean(final String name) {
    SystemManagementService service = getSystemManagementService_tmp();
    await().until(() -> assertThat(service.getDistributedRegionMXBean(name)).isNotNull());
    return service.getDistributedRegionMXBean(name);
}
Also used : SystemManagementService(org.apache.geode.management.internal.SystemManagementService)

Example 67 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class RegionManagementDUnitTest method createPartitionRegion_tmp.

private void createPartitionRegion_tmp(final VM vm, final String partitionRegionName) {
    vm.invoke("Create Partitioned region", () -> {
        SystemManagementService service = getSystemManagementService_tmp();
        RegionFactory regionFactory = getCache_tmp().createRegionFactory(RegionShortcut.PARTITION_REDUNDANT);
        regionFactory.create(partitionRegionName);
    });
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) SystemManagementService(org.apache.geode.management.internal.SystemManagementService)

Example 68 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class RegionManagementDUnitTest method verifyPartitionRegionAfterCreate.

private void verifyPartitionRegionAfterCreate(final VM memberVM) {
    memberVM.invoke("verifyPartitionRegionAfterCreate", () -> {
        Region region = getCache_tmp().getRegion(PARTITIONED_REGION_PATH);
        SystemManagementService service = getSystemManagementService_tmp();
        RegionMXBean regionMXBean = service.getLocalRegionMBean(PARTITIONED_REGION_PATH);
        verifyPartitionData(region.getAttributes(), regionMXBean.listPartitionAttributes());
    });
}
Also used : AbstractRegion(org.apache.geode.internal.cache.AbstractRegion) Region(org.apache.geode.cache.Region) SystemManagementService(org.apache.geode.management.internal.SystemManagementService)

Example 69 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class AbstractCommandsController method getManagingMemberMXBean.

/**
   * Lookup operation for the MemberMXBean representing the Manager in the GemFire cluster. This
   * method gets an instance fo the Platform MBeanServer for this JVM process and uses it to lookup
   * the MemberMXBean for the GemFire Manager based on the ObjectName declared in the
   * DistributedSystemMXBean.getManagerObjectName() operation.
   * 
   * @return a proxy instance to the MemberMXBean of the GemFire Manager.
   * @see #getMBeanServer()
   * @see #createMemberMXBeanForManagerUsingProxy(javax.management.MBeanServer,
   *      javax.management.ObjectName)
   * @see org.apache.geode.management.DistributedSystemMXBean
   * @see org.apache.geode.management.MemberMXBean
   */
protected synchronized MemberMXBean getManagingMemberMXBean() {
    if (managingMemberMXBeanProxy == null) {
        SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(getCache());
        MBeanServer mbs = getMBeanServer();
        final DistributedSystemMXBean distributedSystemMXBean = JMX.newMXBeanProxy(mbs, MBeanJMXAdapter.getDistributedSystemName(), DistributedSystemMXBean.class);
        managingMemberMXBeanProxy = createMemberMXBeanForManagerUsingProxy(mbs, distributedSystemMXBean.getMemberObjectName());
    }
    return managingMemberMXBeanProxy;
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) MBeanServer(javax.management.MBeanServer)

Example 70 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class WanCommands method resumeGatewaySender.

@CliCommand(value = CliStrings.RESUME_GATEWAYSENDER, help = CliStrings.RESUME_GATEWAYSENDER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result resumeGatewaySender(@CliOption(key = CliStrings.RESUME_GATEWAYSENDER__ID, mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID, help = CliStrings.RESUME_GATEWAYSENDER__ID__HELP) String senderId, @CliOption(key = CliStrings.RESUME_GATEWAYSENDER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.RESUME_GATEWAYSENDER__GROUP__HELP) String[] onGroup, @CliOption(key = CliStrings.RESUME_GATEWAYSENDER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, help = CliStrings.RESUME_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;
        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) {
            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) {
                if (bean.isRunning()) {
                    if (bean.isPaused()) {
                        bean.resume();
                        accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_OK, CliStrings.format(CliStrings.GATEWAY_SENDER_0_IS_RESUMED_ON_MEMBER_1, new Object[] { senderId, member.getId() }));
                    } else {
                        accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR, CliStrings.format(CliStrings.GATEWAY_SENDER_0_IS_NOT_PAUSED_ON_MEMBER_1, new Object[] { senderId, member.getId() }));
                    }
                } else {
                    accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR, CliStrings.format(CliStrings.GATEWAY_SENDER_0_IS_NOT_RUNNING_ON_MEMBER_1, new Object[] { senderId, member.getId() }));
                }
            } else {
                accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR, CliStrings.format(CliStrings.GATEWAY_SENDER_0_IS_NOT_AVAILABLE_ON_MEMBER_1, new Object[] { senderId, member.getId() }));
            }
        }
        result = ResultBuilder.buildResult(resultData);
    } catch (Exception e) {
        LogWrapper.getInstance().warning(CliStrings.GATEWAY_ERROR + CliUtil.stackTraceAsString(e));
        result = ResultBuilder.createGemFireErrorResult(CliStrings.GATEWAY_ERROR + e.getMessage());
    }
    return result;
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) GatewaySenderMXBean(org.apache.geode.management.GatewaySenderMXBean) 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)

Aggregations

SystemManagementService (org.apache.geode.management.internal.SystemManagementService)83 ObjectName (javax.management.ObjectName)56 DistributedMember (org.apache.geode.distributed.DistributedMember)31 CacheServerMXBean (org.apache.geode.management.CacheServerMXBean)15 InternalCache (org.apache.geode.internal.cache.InternalCache)14 VM (org.apache.geode.test.dunit.VM)14 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)13 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)12 ExecutionException (java.util.concurrent.ExecutionException)11 CliMetaData (org.apache.geode.management.cli.CliMetaData)11 Result (org.apache.geode.management.cli.Result)11 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)11 ResourceOperation (org.apache.geode.management.internal.security.ResourceOperation)11 CliCommand (org.springframework.shell.core.annotation.CliCommand)11 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)10 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)8 Test (org.junit.Test)8 GatewaySenderMXBean (org.apache.geode.management.GatewaySenderMXBean)7 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)7 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)7