use of org.jgroups.util.Digest in project geode by apache.
the class JGroupsMessenger method filterIncomingMessage.
void filterIncomingMessage(DistributionMessage m) {
switch(m.getDSFID()) {
case JOIN_RESPONSE:
JoinResponseMessage jrsp = (JoinResponseMessage) m;
if (jrsp.getRejectionMessage() == null && services.getConfig().getTransport().isMcastEnabled()) {
byte[] serializedDigest = jrsp.getMessengerData();
ByteArrayInputStream bis = new ByteArrayInputStream(serializedDigest);
DataInputStream dis = new DataInputStream(bis);
try {
Digest digest = new Digest();
digest.readFrom(dis);
logger.trace("installing JGroups message digest {}", digest);
this.myChannel.getProtocolStack().getTopProtocol().down(new Event(Event.MERGE_DIGEST, digest));
jrsp.setMessengerData(null);
} catch (Exception e) {
logger.fatal("Unable to read JGroups messaging digest", e);
}
}
break;
default:
break;
}
}
use of org.jgroups.util.Digest in project geode by apache.
the class JGroupsMessenger method filterOutgoingMessage.
/** look for certain messages that may need to be altered before being sent */
void filterOutgoingMessage(DistributionMessage m) {
switch(m.getDSFID()) {
case JOIN_RESPONSE:
JoinResponseMessage jrsp = (JoinResponseMessage) m;
if (jrsp.getRejectionMessage() == null && services.getConfig().getTransport().isMcastEnabled()) {
// get the multicast message digest and pass it with the join response
Digest digest = (Digest) this.myChannel.getProtocolStack().getTopProtocol().down(Event.GET_DIGEST_EVT);
HeapDataOutputStream hdos = new HeapDataOutputStream(500, Version.CURRENT);
try {
digest.writeTo(hdos);
} catch (Exception e) {
logger.fatal("Unable to serialize JGroups messaging digest", e);
}
jrsp.setMessengerData(hdos.toByteArray());
}
break;
default:
break;
}
}
use of org.jgroups.util.Digest in project geode by apache.
the class JGroupsMessengerJUnitTest method testWaitForMessageStateThrowsExceptionIfMessagesMissing.
@Test
public void testWaitForMessageStateThrowsExceptionIfMessagesMissing() throws Exception {
initMocks(true);
NAKACK2 nakack = mock(NAKACK2.class);
Digest digest = mock(Digest.class);
when(nakack.getDigest(any(Address.class))).thenReturn(digest);
when(digest.get(any(Address.class))).thenReturn(new long[] { 0, 0 }, new long[] { 2, 50 }, new long[] { 49, 50 });
try {
// message 50 will never arrive
Map state = new HashMap();
state.put("JGroups.mcastState", Long.valueOf(50));
InternalDistributedMember mbr = createAddress(1234);
messenger.scheduledMcastSeqnos.put(mbr, new JGroupsMessenger.MessageTracker(30));
messenger.waitForMessageState(mbr, state);
fail("expected a GemFireIOException to be thrown");
} catch (GemFireIOException e) {
// pass
}
}
Aggregations