use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class JGroupsMessengerJUnitTest method testSendToMultipleMembers.
@Test
public void testSendToMultipleMembers() throws Exception {
initMocks(false);
InternalDistributedMember sender = messenger.getMemberID();
InternalDistributedMember other = createAddress(8888);
NetView v = new NetView(sender);
v.add(other);
when(joinLeave.getView()).thenReturn(v);
messenger.installView(v);
List<InternalDistributedMember> recipients = v.getMembers();
SerialAckedMessage msg = new SerialAckedMessage();
msg.setRecipients(recipients);
messenger.send(msg);
int sentMessages = interceptor.unicastSentDataMessages;
assertTrue("expected 2 message to be sent but found " + sentMessages, sentMessages == 2);
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class JGroupsMessengerJUnitTest method testJGroupsIOExceptionHandler.
@Test
public void testJGroupsIOExceptionHandler() throws Exception {
initMocks(false);
InternalDistributedMember mbr = createAddress(8888);
NetView v = new NetView(mbr);
v.add(messenger.getMemberID());
messenger.installView(v);
IOException ioe = new IOException("test exception");
messenger.handleJGroupsIOException(ioe, new JGAddress(mbr));
// should be ignored
messenger.handleJGroupsIOException(ioe, new JGAddress(mbr));
verify(healthMonitor).suspect(mbr, "Unable to send messages to this member via JGroups");
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class JGroupsMessengerJUnitTest method testMessageFiltering.
@Test
public void testMessageFiltering() throws Exception {
initMocks(true);
InternalDistributedMember mbr = createAddress(8888);
NetView view = new NetView(mbr);
// the digest should be set in an outgoing join response
JoinResponseMessage joinResponse = new JoinResponseMessage(mbr, view, 0);
messenger.filterOutgoingMessage(joinResponse);
assertNotNull(joinResponse.getMessengerData());
// save the view digest for later
byte[] data = joinResponse.getMessengerData();
// the digest should be used and the message bytes nulled out in an incoming join response
messenger.filterIncomingMessage(joinResponse);
assertNull(joinResponse.getMessengerData());
// the digest shouldn't be set in an outgoing rejection message
joinResponse = new JoinResponseMessage("you can't join my distributed system. nyah nyah nyah!", 0);
messenger.filterOutgoingMessage(joinResponse);
assertNull(joinResponse.getMessengerData());
// the digest shouldn't be installed from an incoming rejection message
joinResponse.setMessengerData(data);
messenger.filterIncomingMessage(joinResponse);
assertNotNull(joinResponse.getMessengerData());
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class ClientServerTransactionCCEDUnitTest method verifyVersionTags.
public void verifyVersionTags(VM client, VM server1, VM server2, VM server3) {
Map<Object, VersionTag> clientTags = getVersionTagsForRegion(client, D_REFERENCE);
Map<Object, VersionTag> serverTags = getVersionTagsForRegion(server1, D_REFERENCE);
InternalDistributedMember serverId = getMemberId(server1);
for (Object key : clientTags.keySet()) {
VersionTag serverTag = serverTags.get(key);
serverTag.setMemberID(serverId);
LogWriterUtils.getLogWriter().fine("SWAP:key:" + key + " clientVersion:" + clientTags.get(key) + " serverVersion:" + serverTag);
assertEquals(clientTags.get(key), serverTags.get(key));
serverTags.remove(key);
}
assertTrue(serverTags.isEmpty());
}
use of org.apache.geode.distributed.internal.membership.InternalDistributedMember in project geode by apache.
the class ClientServerTransactionDUnitTest method testCleanupAfterClientAndProxyFailure.
@Test
public void testCleanupAfterClientAndProxyFailure() {
Host host = Host.getHost(0);
VM accessor = host.getVM(0);
VM datastore = host.getVM(1);
final boolean cachingProxy = false;
// some other VMs seem to be hanging around and have the region this
disconnectAllFromDS();
// tests uses
final int port1 = createRegionsAndStartServerWithTimeout(accessor, true, 5);
createRegionOnServerWithTimeout(datastore, false, false, 5);
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "bridge.disableShufflingOfEndpoints", "true");
ClientCacheFactory ccf = new ClientCacheFactory();
setCCF(port1, ccf);
ClientCache cCache = getClientCache(ccf);
ClientRegionFactory<CustId, Customer> custrf = cCache.createClientRegionFactory(cachingProxy ? ClientRegionShortcut.CACHING_PROXY : ClientRegionShortcut.PROXY);
ClientRegionFactory<Integer, String> refrf = cCache.createClientRegionFactory(cachingProxy ? ClientRegionShortcut.CACHING_PROXY : ClientRegionShortcut.PROXY);
Region<Integer, String> r = refrf.create(D_REFERENCE);
Region<CustId, Customer> pr = custrf.create(CUSTOMER);
TXManagerImpl mgr = getGemfireCache().getTxManager();
mgr.begin();
doTxOps(r, pr);
final DistributedMember myId = cCache.getDistributedSystem().getDistributedMember();
SerializableCallable verifyExists = new SerializableCallable("verify txstate for client exists") {
public Object call() throws Exception {
TXManagerImpl txmgr = getGemfireCache().getTxManager();
Set states = txmgr.getTransactionsForClient((InternalDistributedMember) myId);
// only one in-progress transaction
assertEquals(1, states.size());
return null;
}
};
accessor.invoke(verifyExists);
datastore.invoke(verifyExists);
accessor.invoke(() -> closeCache());
accessor.invoke(() -> disconnectFromDS());
SerializableCallable verifyExpired = new SerializableCallable("verify txstate is expired") {
public Object call() throws Exception {
final TXManagerImpl txmgr = getGemfireCache().getTxManager();
return verifyTXStateExpired(myId, txmgr);
}
};
try {
datastore.invoke(verifyExpired);
} finally {
cCache.close();
}
}
Aggregations