Search in sources :

Example 6 with Manager

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

Manager (org.apache.geode.distributed.internal.membership.gms.interfaces.Manager)6 Services (org.apache.geode.distributed.internal.membership.gms.Services)4 Properties (java.util.Properties)3 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)3 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)3 ServiceConfig (org.apache.geode.distributed.internal.membership.gms.ServiceConfig)3 Stopper (org.apache.geode.distributed.internal.membership.gms.Services.Stopper)3 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)3 Test (org.junit.Test)3 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)2 NetView (org.apache.geode.distributed.internal.membership.NetView)2 HealthMonitor (org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor)2 JoinLeave (org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave)2 Messenger (org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger)2 LinkedList (java.util.LinkedList)1 Timer (java.util.Timer)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 DM (org.apache.geode.distributed.internal.DM)1 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)1 DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)1