Search in sources :

Example 1 with Services

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

the class StatRecorderJUnitTest method recorderHandlesRejectedExecution.

@Test
public void recorderHandlesRejectedExecution() throws Exception {
    Message msg = mock(Message.class);
    when(msg.getHeader(any(Short.class))).thenReturn(Header.createDataHeader(1L, (short) 1, true));
    when(msg.size()).thenReturn(150L);
    // GEODE-1178, the TP protocol may throw a RejectedExecutionException & StatRecorder should
    // retry
    when(mockDownProtocol.down(any(Event.class))).thenThrow(new RejectedExecutionException());
    // after the first down() throws an exception we want StatRecorder to retry, so
    // we set the Manager to say no shutdown is in progress the first time and then say
    // one IS in progress so we can break out of the StatRecorder exception handling loop
    when(services.getCancelCriterion()).thenReturn(new Services().getCancelCriterion());
    Manager manager = mock(Manager.class);
    when(services.getManager()).thenReturn(manager);
    when(manager.shutdownInProgress()).thenReturn(Boolean.FALSE, Boolean.TRUE);
    verify(mockDownProtocol, never()).down(isA(Event.class));
    Event evt = new Event(Event.MSG, msg);
    recorder.down(evt);
    verify(mockDownProtocol, times(2)).down(isA(Event.class));
}
Also used : Services(org.apache.geode.distributed.internal.membership.gms.Services) Message(org.jgroups.Message) Event(org.jgroups.Event) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Manager(org.apache.geode.distributed.internal.membership.gms.interfaces.Manager) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Example 2 with Services

use of org.apache.geode.distributed.internal.membership.gms.Services 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 3 with Services

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

the class GMSEncryptJUnitTest method initMocks.

private void initMocks(String algo) throws Exception {
    Properties nonDefault = new Properties();
    nonDefault.put(ConfigurationProperties.SECURITY_UDP_DHALGO, algo);
    DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
    RemoteTransportConfig tconfig = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
    ServiceConfig serviceConfig = new ServiceConfig(tconfig, config);
    services = mock(Services.class);
    when(services.getConfig()).thenReturn(serviceConfig);
    mockMembers = new InternalDistributedMember[4];
    for (int i = 0; i < mockMembers.length; i++) {
        mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
    }
    int viewId = 1;
    List<InternalDistributedMember> mbrs = new LinkedList<>();
    mbrs.add(mockMembers[0]);
    mbrs.add(mockMembers[1]);
    mbrs.add(mockMembers[2]);
    // prepare the view
    netView = new NetView(mockMembers[0], viewId, mbrs);
}
Also used : Services(org.apache.geode.distributed.internal.membership.gms.Services) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ServiceConfig(org.apache.geode.distributed.internal.membership.gms.ServiceConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) NetView(org.apache.geode.distributed.internal.membership.NetView) RemoteTransportConfig(org.apache.geode.internal.admin.remote.RemoteTransportConfig) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) LinkedList(java.util.LinkedList)

Example 4 with Services

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

the class GMSJoinLeaveJUnitTest method initMocks.

public void initMocks(boolean enableNetworkPartition, boolean useTestGMSJoinLeave) throws UnknownHostException {
    mockDistConfig = mock(DistributionConfig.class);
    when(mockDistConfig.getEnableNetworkPartitionDetection()).thenReturn(enableNetworkPartition);
    when(mockDistConfig.getLocators()).thenReturn("localhost[8888]");
    when(mockDistConfig.getSecurityUDPDHAlgo()).thenReturn("");
    mockConfig = mock(ServiceConfig.class);
    when(mockDistConfig.getStartLocator()).thenReturn("localhost[12345]");
    when(mockConfig.getDistributionConfig()).thenReturn(mockDistConfig);
    when(mockDistConfig.getLocators()).thenReturn("localhost[12345]");
    when(mockDistConfig.getMcastPort()).thenReturn(0);
    when(mockDistConfig.getMemberTimeout()).thenReturn(2000);
    authenticator = mock(Authenticator.class);
    gmsJoinLeaveMemberId = new InternalDistributedMember("localhost", 8887);
    messenger = mock(Messenger.class);
    when(messenger.getMemberID()).thenReturn(gmsJoinLeaveMemberId);
    stopper = mock(Stopper.class);
    when(stopper.isCancelInProgress()).thenReturn(false);
    manager = mock(Manager.class);
    healthMonitor = mock(HealthMonitor.class);
    when(healthMonitor.getFailureDetectionPort()).thenReturn(Integer.valueOf(-1));
    services = mock(Services.class);
    when(services.getAuthenticator()).thenReturn(authenticator);
    when(services.getConfig()).thenReturn(mockConfig);
    when(services.getMessenger()).thenReturn(messenger);
    when(services.getCancelCriterion()).thenReturn(stopper);
    when(services.getManager()).thenReturn(manager);
    when(services.getHealthMonitor()).thenReturn(healthMonitor);
    Timer t = new Timer(true);
    when(services.getTimer()).thenReturn(t);
    mockMembers = new InternalDistributedMember[4];
    for (int i = 0; i < mockMembers.length; i++) {
        mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
    }
    mockOldMember = new InternalDistributedMember("localhost", 8700, Version.GFE_56);
    if (useTestGMSJoinLeave) {
        gmsJoinLeave = new GMSJoinLeaveTest();
    } else {
        gmsJoinLeave = new GMSJoinLeave();
    }
    gmsJoinLeave.init(services);
    gmsJoinLeave.start();
    gmsJoinLeave.started();
}
Also used : HealthMonitor(org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor) Messenger(org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger) Manager(org.apache.geode.distributed.internal.membership.gms.interfaces.Manager) Services(org.apache.geode.distributed.internal.membership.gms.Services) DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) Stopper(org.apache.geode.distributed.internal.membership.gms.Services.Stopper) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) Timer(java.util.Timer) ServiceConfig(org.apache.geode.distributed.internal.membership.gms.ServiceConfig) Authenticator(org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator)

Example 5 with Services

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

the class GMSJoinLeaveTestHelper method getGmsJoinLeave.

private static GMSJoinLeave getGmsJoinLeave() {
    InternalDistributedSystem distributedSystem = getInternalDistributedSystem();
    DM dm = distributedSystem.getDM();
    GMSMembershipManager membershipManager = (GMSMembershipManager) dm.getMembershipManager();
    Services services = membershipManager.getServices();
    return (GMSJoinLeave) services.getJoinLeave();
}
Also used : Services(org.apache.geode.distributed.internal.membership.gms.Services) GMSMembershipManager(org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager) DM(org.apache.geode.distributed.internal.DM) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Aggregations

Services (org.apache.geode.distributed.internal.membership.gms.Services)10 ServiceConfig (org.apache.geode.distributed.internal.membership.gms.ServiceConfig)7 Properties (java.util.Properties)6 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)5 RemoteTransportConfig (org.apache.geode.internal.admin.remote.RemoteTransportConfig)5 DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)4 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 Stopper (org.apache.geode.distributed.internal.membership.gms.Services.Stopper)4 Manager (org.apache.geode.distributed.internal.membership.gms.interfaces.Manager)4 HealthMonitor (org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor)3 JoinLeave (org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave)3 Messenger (org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger)3 Before (org.junit.Before)3 Test (org.junit.Test)3 Timer (java.util.Timer)2 DM (org.apache.geode.distributed.internal.DM)2 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)2 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)2 Authenticator (org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator)2 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)2