Search in sources :

Example 1 with JGroupsMessenger

use of org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger in project geode by apache.

the class StatRecorderJUnitTest method messengerStackHoldsStatRecorder.

/**
   * Ensure that the messenger JGroups configuration XML strings contain the statistics recorder
   * protocol
   */
@Test
public void messengerStackHoldsStatRecorder() throws Exception {
    Services mockServices = mock(Services.class);
    ServiceConfig mockConfig = mock(ServiceConfig.class);
    when(mockServices.getConfig()).thenReturn(mockConfig);
    // first test to see if the non-multicast stack has the recorder installed
    Properties nonDefault = new Properties();
    nonDefault.put(MCAST_PORT, "0");
    nonDefault.put(LOCATORS, "localhost[12345]");
    DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
    when(mockConfig.getDistributionConfig()).thenReturn(config);
    RemoteTransportConfig transport = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
    when(mockConfig.getTransport()).thenReturn(transport);
    JGroupsMessenger messenger = new JGroupsMessenger();
    messenger.init(mockServices);
    String jgroupsConfig = messenger.getJGroupsStackConfig();
    System.out.println(jgroupsConfig);
    assertTrue(jgroupsConfig.contains("gms.messenger.StatRecorder"));
    // now test to see if the multicast stack has the recorder installed
    nonDefault.put(MCAST_PORT, "12345");
    config = new DistributionConfigImpl(nonDefault);
    transport = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
    when(mockConfig.getDistributionConfig()).thenReturn(config);
    when(mockConfig.getTransport()).thenReturn(transport);
    messenger = new JGroupsMessenger();
    messenger.init(mockServices);
    assertTrue(jgroupsConfig.contains("gms.messenger.StatRecorder"));
}
Also used : Services(org.apache.geode.distributed.internal.membership.gms.Services) ServiceConfig(org.apache.geode.distributed.internal.membership.gms.ServiceConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) JGroupsMessenger(org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger) RemoteTransportConfig(org.apache.geode.internal.admin.remote.RemoteTransportConfig) Properties(java.util.Properties) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Example 2 with JGroupsMessenger

use of org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger in project geode by apache.

the class DistributedSystemDUnitTest method testMembershipPortRangeWithExactThreeValues.

@Test
public void testMembershipPortRangeWithExactThreeValues() throws Exception {
    Properties config = new Properties();
    config.setProperty(LOCATORS, "localhost[" + getDUnitLocatorPort() + "]");
    config.setProperty(MEMBERSHIP_PORT_RANGE, this.lowerBoundOfPortRange + "-" + this.upperBoundOfPortRange);
    InternalDistributedSystem system = getSystem(config);
    Cache cache = CacheFactory.create(system);
    cache.addCacheServer();
    DistributionManager dm = (DistributionManager) system.getDistributionManager();
    InternalDistributedMember member = dm.getDistributionManagerId();
    GMSMembershipManager gms = (GMSMembershipManager) MembershipManagerHelper.getMembershipManager(system);
    JGroupsMessenger messenger = (JGroupsMessenger) gms.getServices().getMessenger();
    String jgConfig = messenger.getJGroupsStackConfig();
    assertThat(jgConfig).as("expected to find port_range=\"2\" in " + jgConfig).contains("port_range=\"2\"");
    verifyMembershipPortsInRange(member, this.lowerBoundOfPortRange, this.upperBoundOfPortRange);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) GMSMembershipManager(org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager) JGroupsMessenger(org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

Properties (java.util.Properties)2 JGroupsMessenger (org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger)2 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)2 Test (org.junit.Test)2 Cache (org.apache.geode.cache.Cache)1 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)1 DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)1 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)1 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 ServiceConfig (org.apache.geode.distributed.internal.membership.gms.ServiceConfig)1 Services (org.apache.geode.distributed.internal.membership.gms.Services)1 GMSMembershipManager (org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager)1 RemoteTransportConfig (org.apache.geode.internal.admin.remote.RemoteTransportConfig)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 UnitTest (org.apache.geode.test.junit.categories.UnitTest)1