Search in sources :

Example 1 with MembershipManager

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

the class DistributionManager method getViewMembers.

public List<InternalDistributedMember> getViewMembers() {
    NetView result = null;
    DistributionChannel ch = this.channel;
    if (ch != null) {
        MembershipManager mgr = ch.getMembershipManager();
        if (mgr != null) {
            result = mgr.getView();
        }
    }
    if (result == null) {
        result = new NetView();
    }
    return result.getMembers();
}
Also used : NetView(org.apache.geode.distributed.internal.membership.NetView) MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager)

Example 2 with MembershipManager

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

the class DistributionChannel method getId.

/**
   * Returns the id of this distribution channel. If this channel uses JavaGroups and the conduit to
   * communicate with others, then the port of the JavaGroups channel's
   * {@link InternalDistributedMember address} is returned.
   *
   * @since GemFire 3.0
   */
public long getId() {
    MembershipManager mgr = this.membershipManager;
    if (mgr == null) {
        throw new DistributedSystemDisconnectedException(LocalizedStrings.DistributionChannel_I_NO_LONGER_HAVE_A_MEMBERSHIP_ID.toLocalizedString());
    }
    InternalDistributedMember moi = mgr.getLocalMember();
    if (moi == null) {
        throw new DistributedSystemDisconnectedException(LocalizedStrings.DistributionChannel_I_NO_LONGER_HAVE_A_MEMBERSHIP_ID.toLocalizedString(), membershipManager.getShutdownCause());
    }
    return moi.getPort();
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager)

Example 3 with MembershipManager

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

the class Connection method setRemoteAddr.

private void setRemoteAddr(DistributedMember m) {
    this.remoteAddr = this.owner.getDM().getCanonicalId(m);
    MembershipManager mgr = this.conduit.getMembershipManager();
    mgr.addSurpriseMember(m);
}
Also used : MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager)

Example 4 with MembershipManager

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

the class ConnectionJUnitTest method testSuspicionRaised.

/**
   * Test whether suspicion is raised about a member that closes its shared/unordered TCPConduit
   * connection
   */
@Test
public void testSuspicionRaised() throws Exception {
    // this test has to create a lot of mocks because Connection
    // uses a lot of objects
    // mock the socket
    ConnectionTable table = mock(ConnectionTable.class);
    DM distMgr = mock(DM.class);
    MembershipManager membership = mock(MembershipManager.class);
    TCPConduit conduit = mock(TCPConduit.class);
    // mock the connection table and conduit
    when(table.getConduit()).thenReturn(conduit);
    CancelCriterion stopper = mock(CancelCriterion.class);
    when(stopper.cancelInProgress()).thenReturn(null);
    when(conduit.getCancelCriterion()).thenReturn(stopper);
    when(conduit.getSocketId()).thenReturn(new InetSocketAddress(SocketCreator.getLocalHost(), 10337));
    // NIO can't be mocked because SocketChannel has a final method that
    // is used by Connection - configureBlocking
    when(conduit.useNIO()).thenReturn(false);
    // mock the distribution manager and membership manager
    when(distMgr.getMembershipManager()).thenReturn(membership);
    when(conduit.getDM()).thenReturn(distMgr);
    when(table.getDM()).thenReturn(distMgr);
    SocketCloser closer = mock(SocketCloser.class);
    when(table.getSocketCloser()).thenReturn(closer);
    InputStream instream = mock(InputStream.class);
    when(instream.read()).thenReturn(-1);
    Socket socket = mock(Socket.class);
    when(socket.getInputStream()).thenReturn(instream);
    Connection conn = new Connection(table, socket);
    conn.setSharedUnorderedForTest();
    conn.run();
    verify(membership).suspectMember(any(InternalDistributedMember.class), any(String.class));
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InetSocketAddress(java.net.InetSocketAddress) InputStream(java.io.InputStream) CancelCriterion(org.apache.geode.CancelCriterion) DM(org.apache.geode.distributed.internal.DM) MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager) SocketCloser(org.apache.geode.internal.net.SocketCloser) Socket(java.net.Socket) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Example 5 with MembershipManager

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

the class DistributionManagerDUnitTest method testWaitForViewInstallation.

/**
   * install a new view and show that waitForViewInstallation works as expected
   */
@Test
public void testWaitForViewInstallation() {
    getSystem(new Properties());
    MembershipManager mgr = basicGetSystem().getDM().getMembershipManager();
    final NetView v = mgr.getView();
    final boolean[] passed = new boolean[1];
    Thread t = new Thread("wait for view installation") {

        public void run() {
            try {
                ((DistributionManager) basicGetSystem().getDM()).waitForViewInstallation(v.getViewId() + 1);
                synchronized (passed) {
                    passed[0] = true;
                }
            } catch (InterruptedException e) {
            // failed
            }
        }
    };
    t.setDaemon(true);
    t.start();
    Wait.pause(2000);
    NetView newView = new NetView(v, v.getViewId() + 1);
    ((Manager) mgr).installView(newView);
    Wait.pause(2000);
    synchronized (passed) {
        Assert.assertTrue(passed[0]);
    }
}
Also used : NetView(org.apache.geode.distributed.internal.membership.NetView) GMSMembershipManager(org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager) MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedRestoreSystemProperties(org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties) GMSMembershipManager(org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager) MembershipManager(org.apache.geode.distributed.internal.membership.MembershipManager) Manager(org.apache.geode.distributed.internal.membership.gms.interfaces.Manager) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

MembershipManager (org.apache.geode.distributed.internal.membership.MembershipManager)16 GMSMembershipManager (org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager)6 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)6 Test (org.junit.Test)6 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)5 Properties (java.util.Properties)4 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 IOException (java.io.IOException)3 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)3 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)3 File (java.io.File)2 ForcedDisconnectException (org.apache.geode.ForcedDisconnectException)2 GemFireConfigException (org.apache.geode.GemFireConfigException)2 SystemConnectException (org.apache.geode.SystemConnectException)2 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)2 NetView (org.apache.geode.distributed.internal.membership.NetView)2 GemFireSecurityException (org.apache.geode.security.GemFireSecurityException)2 Host (org.apache.geode.test.dunit.Host)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2 VM (org.apache.geode.test.dunit.VM)2