Search in sources :

Example 1 with Messenger

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

the class GMSMembershipManagerJUnitTest method initMocks.

@Before
public void initMocks() throws Exception {
    Properties nonDefault = new Properties();
    nonDefault.put(ACK_WAIT_THRESHOLD, "1");
    nonDefault.put(ACK_SEVERE_ALERT_THRESHOLD, "10");
    nonDefault.put(DISABLE_TCP, "true");
    nonDefault.put(MCAST_PORT, "0");
    nonDefault.put(MCAST_TTL, "0");
    nonDefault.put(LOG_FILE, "");
    nonDefault.put(LOG_LEVEL, "fine");
    nonDefault.put(MEMBER_TIMEOUT, "2000");
    nonDefault.put(LOCATORS, "localhost[10344]");
    distConfig = new DistributionConfigImpl(nonDefault);
    distProperties = nonDefault;
    RemoteTransportConfig tconfig = new RemoteTransportConfig(distConfig, DistributionManager.NORMAL_DM_TYPE);
    mockConfig = mock(ServiceConfig.class);
    when(mockConfig.getDistributionConfig()).thenReturn(distConfig);
    when(mockConfig.getTransport()).thenReturn(tconfig);
    authenticator = mock(Authenticator.class);
    myMemberId = new InternalDistributedMember("localhost", 8887);
    messenger = mock(Messenger.class);
    when(messenger.getMemberID()).thenReturn(myMemberId);
    stopper = mock(Stopper.class);
    when(stopper.isCancelInProgress()).thenReturn(false);
    healthMonitor = mock(HealthMonitor.class);
    when(healthMonitor.getFailureDetectionPort()).thenReturn(Integer.valueOf(-1));
    joinLeave = mock(JoinLeave.class);
    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.getHealthMonitor()).thenReturn(healthMonitor);
    when(services.getJoinLeave()).thenReturn(joinLeave);
    Timer t = new Timer(true);
    when(services.getTimer()).thenReturn(t);
    Random r = new Random();
    mockMembers = new InternalDistributedMember[5];
    for (int i = 0; i < mockMembers.length; i++) {
        mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
        GMSMember m = (GMSMember) mockMembers[i].getNetMember();
        UUID uuid = new UUID(r.nextLong(), r.nextLong());
        m.setUUID(uuid);
    }
    members = new ArrayList<>(Arrays.asList(mockMembers));
    listener = mock(DistributedMembershipListener.class);
    manager = new GMSMembershipManager(listener);
    manager.init(services);
    when(services.getManager()).thenReturn(manager);
}
Also used : JoinLeave(org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave) GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) HealthMonitor(org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor) RemoteTransportConfig(org.apache.geode.internal.admin.remote.RemoteTransportConfig) Messenger(org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger) DistributedMembershipListener(org.apache.geode.distributed.internal.membership.DistributedMembershipListener) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) Services(org.apache.geode.distributed.internal.membership.gms.Services) Stopper(org.apache.geode.distributed.internal.membership.gms.Services.Stopper) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) Timer(java.util.Timer) Random(java.util.Random) ServiceConfig(org.apache.geode.distributed.internal.membership.gms.ServiceConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) UUID(org.jgroups.util.UUID) Authenticator(org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator) Before(org.junit.Before)

Example 2 with Messenger

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

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

the class GMSHealthMonitorJUnitTest method initMocks.

@Before
public void initMocks() throws UnknownHostException {
    // System.setProperty("gemfire.bind-address", "localhost");
    mockDistConfig = mock(DistributionConfig.class);
    mockConfig = mock(ServiceConfig.class);
    messenger = mock(Messenger.class);
    joinLeave = mock(JoinLeave.class);
    manager = mock(Manager.class);
    services = mock(Services.class);
    Stopper stopper = mock(Stopper.class);
    Properties nonDefault = new Properties();
    nonDefault.put(ACK_WAIT_THRESHOLD, "1");
    nonDefault.put(ACK_SEVERE_ALERT_THRESHOLD, "10");
    nonDefault.put(DISABLE_TCP, "true");
    nonDefault.put(MCAST_PORT, "0");
    nonDefault.put(MCAST_TTL, "0");
    nonDefault.put(LOG_FILE, "");
    nonDefault.put(LOG_LEVEL, "fine");
    nonDefault.put(MEMBER_TIMEOUT, "2000");
    nonDefault.put(LOCATORS, "localhost[10344]");
    DM dm = mock(DM.class);
    SocketCreatorFactory.setDistributionConfig(new DistributionConfigImpl(new Properties()));
    InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
    when(mockConfig.getDistributionConfig()).thenReturn(mockDistConfig);
    when(mockConfig.getMemberTimeout()).thenReturn(memberTimeout);
    when(mockConfig.getMembershipPortRange()).thenReturn(portRange);
    when(services.getConfig()).thenReturn(mockConfig);
    when(services.getMessenger()).thenReturn(messenger);
    when(services.getJoinLeave()).thenReturn(joinLeave);
    when(services.getCancelCriterion()).thenReturn(stopper);
    when(services.getManager()).thenReturn(manager);
    when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));
    when(stopper.isCancelInProgress()).thenReturn(false);
    if (mockMembers == null) {
        mockMembers = new ArrayList<InternalDistributedMember>();
        for (int i = 0; i < 7; i++) {
            InternalDistributedMember mbr = new InternalDistributedMember("localhost", 8888 + i);
            if (i == 0 || i == 1) {
                mbr.setVmKind(DistributionManager.LOCATOR_DM_TYPE);
                mbr.getNetMember().setPreferredForCoordinator(true);
            }
            mockMembers.add(mbr);
        }
    }
    when(joinLeave.getMemberID()).thenReturn(mockMembers.get(myAddressIndex));
    when(messenger.getMemberID()).thenReturn(mockMembers.get(myAddressIndex));
    gmsHealthMonitor = new GMSHealthMonitorTest();
    gmsHealthMonitor.init(services);
    gmsHealthMonitor.start();
}
Also used : JoinLeave(org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave) Messenger(org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger) Manager(org.apache.geode.distributed.internal.membership.gms.interfaces.Manager) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) Services(org.apache.geode.distributed.internal.membership.gms.Services) Stopper(org.apache.geode.distributed.internal.membership.gms.Services.Stopper) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ServiceConfig(org.apache.geode.distributed.internal.membership.gms.ServiceConfig) Before(org.junit.Before)

Aggregations

InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)3 ServiceConfig (org.apache.geode.distributed.internal.membership.gms.ServiceConfig)3 Services (org.apache.geode.distributed.internal.membership.gms.Services)3 Stopper (org.apache.geode.distributed.internal.membership.gms.Services.Stopper)3 Messenger (org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger)3 Properties (java.util.Properties)2 Timer (java.util.Timer)2 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)2 Authenticator (org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator)2 HealthMonitor (org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor)2 JoinLeave (org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave)2 Manager (org.apache.geode.distributed.internal.membership.gms.interfaces.Manager)2 Before (org.junit.Before)2 Random (java.util.Random)1 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)1 DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)1 DistributedMembershipListener (org.apache.geode.distributed.internal.membership.DistributedMembershipListener)1 GMSMember (org.apache.geode.distributed.internal.membership.gms.GMSMember)1 RemoteTransportConfig (org.apache.geode.internal.admin.remote.RemoteTransportConfig)1 UUID (org.jgroups.util.UUID)1