Search in sources :

Example 1 with Digest

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;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Digest(org.jgroups.util.Digest) Event(org.jgroups.Event) JoinResponseMessage(org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage) VersionedDataInputStream(org.apache.geode.internal.VersionedDataInputStream) DataInputStream(java.io.DataInputStream) MemberShunnedException(org.apache.geode.internal.tcp.MemberShunnedException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ForcedDisconnectException(org.apache.geode.ForcedDisconnectException) GemFireIOException(org.apache.geode.GemFireIOException) SystemConnectException(org.apache.geode.SystemConnectException) GemFireConfigException(org.apache.geode.GemFireConfigException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 2 with Digest

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;
    }
}
Also used : Digest(org.jgroups.util.Digest) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) JoinResponseMessage(org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage) MemberShunnedException(org.apache.geode.internal.tcp.MemberShunnedException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ForcedDisconnectException(org.apache.geode.ForcedDisconnectException) GemFireIOException(org.apache.geode.GemFireIOException) SystemConnectException(org.apache.geode.SystemConnectException) GemFireConfigException(org.apache.geode.GemFireConfigException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 3 with Digest

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
    }
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) Address(org.jgroups.Address) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) Digest(org.jgroups.util.Digest) HashMap(java.util.HashMap) GemFireIOException(org.apache.geode.GemFireIOException) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

GemFireIOException (org.apache.geode.GemFireIOException)3 Digest (org.jgroups.util.Digest)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 UnknownHostException (java.net.UnknownHostException)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 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)2 MemberShunnedException (org.apache.geode.internal.tcp.MemberShunnedException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)1 VersionedDataInputStream (org.apache.geode.internal.VersionedDataInputStream)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)1