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();
}
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();
}
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);
}
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));
}
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]);
}
}
Aggregations