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