Search in sources :

Example 81 with DistributedMember

use of org.apache.geode.distributed.DistributedMember in project geode by apache.

the class LocatorManagementDUnitTest method testPeerLocation.

/**
   * When plan is to start Distributed System later so that the system can use this locator
   */
@Test
public void testPeerLocation() throws Exception {
    int locPort = AvailablePortHelper.getRandomAvailableTCPPort();
    startLocator(locator, locPort);
    locatorMBeanExist(locator, locPort);
    Host host = Host.getHost(0);
    String host0 = getServerHostName(host);
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, host0 + "[" + locPort + "]");
    props.setProperty(JMX_MANAGER, "true");
    props.setProperty(JMX_MANAGER_START, "false");
    props.setProperty(JMX_MANAGER_PORT, "0");
    props.setProperty(JMX_MANAGER_HTTP_PORT, "0");
    createCache(managingNode, props);
    startManagingNode(managingNode);
    DistributedMember locatorMember = getMember(locator);
    remoteLocatorMBeanExist(managingNode, locatorMember);
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember) Host(org.apache.geode.test.dunit.Host) Properties(java.util.Properties) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 82 with DistributedMember

use of org.apache.geode.distributed.DistributedMember in project geode by apache.

the class DistributedSystemDUnitTest method verifyDistributedSystemMXBean.

/**
   * Check aggregate related functions and attributes
   */
private void verifyDistributedSystemMXBean(final VM managerVM) {
    managerVM.invoke("verifyDistributedSystemMXBean", () -> {
        ManagementService service = this.managementTestRule.getManagementService();
        DistributedSystemMXBean distributedSystemMXBean = service.getDistributedSystemMXBean();
        await().until(() -> assertThat(distributedSystemMXBean.getMemberCount()).isEqualTo(5));
        Set<DistributedMember> otherMemberSet = this.managementTestRule.getOtherNormalMembers();
        for (DistributedMember member : otherMemberSet) {
        // TODO: create some assertions (this used to just print JVMMetrics and OSMetrics)
        }
    });
}
Also used : SystemManagementService(org.apache.geode.management.internal.SystemManagementService) DistributedMember(org.apache.geode.distributed.DistributedMember)

Example 83 with DistributedMember

use of org.apache.geode.distributed.DistributedMember in project geode by apache.

the class RegionManagementDUnitTest method verifyRemoteFixedPartitionRegion.

private void verifyRemoteFixedPartitionRegion(final VM managerVM) {
    managerVM.invoke("Verify Partition region", () -> {
        Set<DistributedMember> otherMemberSet = getOtherNormalMembers_tmp();
        for (DistributedMember member : otherMemberSet) {
            RegionMXBean bean = awaitRegionMXBeanProxy(member, FIXED_PR_PATH);
            PartitionAttributesData data = bean.listPartitionAttributes();
            assertThat(data).isNotNull();
            FixedPartitionAttributesData[] fixedPrData = bean.listFixedPartitionAttributes();
            assertThat(fixedPrData).isNotNull();
            assertThat(fixedPrData).hasSize(3);
            for (int i = 0; i < fixedPrData.length; i++) {
            // TODO: add real assertions
            // LogWriterUtils.getLogWriter().info("<ExpectedString> Remote PR Data is " +
            // fixedPrData[i] + "</ExpectedString> ");
            }
        }
    });
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember)

Example 84 with DistributedMember

use of org.apache.geode.distributed.DistributedMember in project geode by apache.

the class GfshCommandJUnitTest method testGetMemberWithMatchingMemberId.

@Test
public void testGetMemberWithMatchingMemberId() {
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
    final DistributedMember mockMemberOne = createMockMember("1", "One");
    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getMembers();
            will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
            oneOf(mockCache).getDistributedSystem();
            will(returnValue(mockDistributedSystem));
            oneOf(mockDistributedSystem).getDistributedMember();
            will(returnValue(mockMemberSelf));
        }
    });
    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
    assertSame(mockMemberTwo, commands.getMember(mockCache, "2"));
}
Also used : Expectations(org.jmock.Expectations) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 85 with DistributedMember

use of org.apache.geode.distributed.DistributedMember in project geode by apache.

the class GfshCommandJUnitTest method createMockMember.

private DistributedMember createMockMember(final String memberId, final String memberName) {
    final DistributedMember mockMember = mockContext.mock(DistributedMember.class, "DistributedMember " + memberId);
    mockContext.checking(new Expectations() {

        {
            allowing(mockMember).getName();
            will(returnValue(memberName));
            allowing(mockMember).getId();
            will(returnValue(memberId));
        }
    });
    return mockMember;
}
Also used : Expectations(org.jmock.Expectations) DistributedMember(org.apache.geode.distributed.DistributedMember)

Aggregations

DistributedMember (org.apache.geode.distributed.DistributedMember)360 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)120 Test (org.junit.Test)109 HashSet (java.util.HashSet)83 InternalCache (org.apache.geode.internal.cache.InternalCache)83 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)82 ArrayList (java.util.ArrayList)64 VM (org.apache.geode.test.dunit.VM)60 CliCommand (org.springframework.shell.core.annotation.CliCommand)59 CliMetaData (org.apache.geode.management.cli.CliMetaData)57 Result (org.apache.geode.management.cli.Result)56 Set (java.util.Set)49 ResourceOperation (org.apache.geode.management.internal.security.ResourceOperation)49 List (java.util.List)48 Cache (org.apache.geode.cache.Cache)47 Region (org.apache.geode.cache.Region)42 HashMap (java.util.HashMap)39 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)39 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)39 FunctionException (org.apache.geode.cache.execute.FunctionException)37