Search in sources :

Example 11 with Event

use of org.jgroups.Event in project geode by apache.

the class GMSQuorumChecker method initialize.

public void initialize() {
    receivedAcks = new ConcurrentHashSet<>();
    pingPonger = new GMSPingPonger();
    // UUID logicalAddress = (UUID) channel.getAddress();
    // IpAddress ipaddr = (IpAddress) channel.down(new Event(Event.GET_PHYSICAL_ADDRESS));
    //
    // myAddress = new JGAddress(logicalAddress, ipaddr);
    myAddress = (JGAddress) channel.down(new Event(Event.GET_LOCAL_ADDRESS));
    addressConversionMap = new ConcurrentHashMap<>(this.lastView.size());
    List<InternalDistributedMember> members = this.lastView.getMembers();
    for (InternalDistributedMember addr : members) {
        SocketAddress sockaddr = new InetSocketAddress(addr.getNetMember().getInetAddress(), addr.getPort());
        addressConversionMap.put(sockaddr, addr);
    }
    isDebugEnabled = logger.isDebugEnabled();
    resume();
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InetSocketAddress(java.net.InetSocketAddress) Event(org.jgroups.Event) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress)

Example 12 with Event

use of org.jgroups.Event in project geode by apache.

the class InterceptUDP method handleMessage.

private void handleMessage(Message msg) {
    if (collectMessages) {
        collectedMessages.add(msg);
    }
    Object o = msg.getHeader(nakackHeaderId);
    if (o != null) {
        mcastSentDataMessages++;
    } else {
        o = msg.getHeader(unicastHeaderId);
        if (o != null) {
            UNICAST3.Header hdr = (UNICAST3.Header) o;
            switch(hdr.type()) {
                case UNICAST3.Header.DATA:
                    unicastSentDataMessages++;
                    Message response = new Message(uuid, msg.getDest(), null);
                    response.putHeader(unicastHeaderId, UNICAST3.Header.createAckHeader(hdr.seqno(), hdr.connId(), System.currentTimeMillis()));
                    up_prot.up(new Event(Event.MSG, response));
                    break;
            }
        }
    }
}
Also used : Message(org.jgroups.Message) Event(org.jgroups.Event) UNICAST3(org.jgroups.protocols.UNICAST3)

Example 13 with Event

use of org.jgroups.Event in project geode by apache.

the class JGroupsMessengerJUnitTest method doTestMessageDeliveredToHandler.

private void doTestMessageDeliveredToHandler(boolean mcast) throws Exception {
    initMocks(mcast);
    MessageHandler mh = mock(MessageHandler.class);
    messenger.addHandler(JoinRequestMessage.class, mh);
    InternalDistributedMember addr = messenger.getMemberID();
    NetView v = new NetView(addr);
    when(joinLeave.getView()).thenReturn(v);
    InternalDistributedMember sender = createAddress(8888);
    JoinRequestMessage msg = new JoinRequestMessage(messenger.localAddress, sender, null, -1, 0);
    Message jmsg = messenger.createJGMessage(msg, messenger.jgAddress, Version.CURRENT_ORDINAL);
    interceptor.up(new Event(Event.MSG, jmsg));
    verify(mh, times(1)).processMessage(any(JoinRequestMessage.class));
    LeaveRequestMessage lmsg = new LeaveRequestMessage(messenger.localAddress, sender, "testing");
    when(joinLeave.getMemberID(any())).thenReturn(sender);
    jmsg = messenger.createJGMessage(lmsg, messenger.jgAddress, Version.CURRENT_ORDINAL);
    interceptor.up(new Event(Event.MSG, jmsg));
    verify(manager).processMessage(any(LeaveRequestMessage.class));
}
Also used : LeaveRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage) MessageHandler(org.apache.geode.distributed.internal.membership.gms.interfaces.MessageHandler) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) JoinRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage) LeaveRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage) InstallViewMessage(org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage) JoinResponseMessage(org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage) SerialAckedMessage(org.apache.geode.distributed.internal.SerialAckedMessage) Message(org.jgroups.Message) NetView(org.apache.geode.distributed.internal.membership.NetView) Event(org.jgroups.Event) JoinRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)

Example 14 with Event

use of org.jgroups.Event in project geode by apache.

the class StatRecorderJUnitTest method testUnicastStats.

/**
   * Ensure that unicast events are recorded in DMStats
   */
@Test
public void testUnicastStats() throws Exception {
    Message msg = mock(Message.class);
    when(msg.getHeader(any(Short.class))).thenReturn(Header.createDataHeader(1L, (short) 1, true));
    when(msg.size()).thenReturn(150L);
    Event evt = new Event(Event.MSG, msg);
    recorder.up(evt);
    assertTrue("stats.ucastMessagesReceived =" + stats.ucastMessagesReceived, stats.ucastMessagesReceived == 1);
    assertEquals(stats.ucastMessageBytesReceived, 150);
    recorder.down(evt);
    assertTrue("stats.ucastMessagesSent =" + stats.ucastMessagesSent, stats.ucastMessagesSent == 1);
    assertEquals(stats.ucastMessageBytesSent, 150);
    msg = mock(Message.class);
    when(msg.getHeader(any(Short.class))).thenReturn(Header.createXmitReqHeader());
    when(msg.size()).thenReturn(150L);
    evt = new Event(Event.MSG, msg);
    recorder.down(evt);
    assertTrue("stats.ucastRetransmits =" + stats.ucastRetransmits, stats.ucastRetransmits == 1);
}
Also used : Message(org.jgroups.Message) Event(org.jgroups.Event) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Aggregations

Event (org.jgroups.Event)14 Message (org.jgroups.Message)7 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)5 NetView (org.apache.geode.distributed.internal.membership.NetView)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)3 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)3 UnitTest (org.apache.geode.test.junit.categories.UnitTest)3 UUID (org.jgroups.util.UUID)3 Test (org.junit.Test)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DataInputStream (java.io.DataInputStream)2 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 ForcedDisconnectException (org.apache.geode.ForcedDisconnectException)2 GemFireConfigException (org.apache.geode.GemFireConfigException)2 GemFireIOException (org.apache.geode.GemFireIOException)2 SystemConnectException (org.apache.geode.SystemConnectException)2