本文整理汇总了Java中org.jgroups.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于org.jgroups包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import org.jgroups.Message; //导入依赖的package包/类
@Override
public void onMessage(@NotNull final Message msg, @NotNull final AgentLifecycleMessage agentMsg) {
switch (agentMsg.getState()) {
case CREATED:
onAgentRegistration(agentMsg);
break;
case CLOSED:
onAgentSignOff(agentMsg);
break;
case FAILED:
onAgentFailure(agentMsg);
break;
default:
break;
}
}
示例2: setMessageFlags
import org.jgroups.Message; //导入依赖的package包/类
void setMessageFlags(DistributionMessage gfmsg, Message msg) {
// GemFire uses its own reply processors so there is no need
// to maintain message order
msg.setFlag(Flag.OOB);
// Bundling is mostly only useful if we're doing no-ack work,
// which is fairly rare
msg.setFlag(Flag.DONT_BUNDLE);
if (gfmsg.getProcessorType() == DistributionManager.HIGH_PRIORITY_EXECUTOR
|| gfmsg instanceof HighPriorityDistributionMessage || AlertAppender.isThreadAlerting()) {
msg.setFlag(Flag.NO_FC);
msg.setFlag(Flag.SKIP_BARRIER);
}
if (gfmsg instanceof DistributedCacheOperation.CacheOperationMessage) {
// we don't want to see our own cache operation messages
msg.setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
}
}
示例3: processForMulticast
import org.jgroups.Message; //导入依赖的package包/类
private void processForMulticast(Message msg, int direction) {
Object o = msg.getHeader(nakackHeaderId);
// logger.debug("sending message with NakAck header {}: {}", o, msg);
if (o instanceof NakAckHeader2 && stats != null) {
NakAckHeader2 hdr = (NakAckHeader2) o;
switch (direction) {
case INCOMING:
stats.incMcastReadBytes((int) msg.size());
break;
case OUTGOING:
stats.incMcastWriteBytes((int) msg.size());
switch (hdr.getType()) {
case NakAckHeader2.XMIT_RSP:
stats.incMcastRetransmits();
break;
case NakAckHeader2.XMIT_REQ:
stats.incMcastRetransmitRequests();
break;
}
break;
}
}
}
示例4: processForUnicast
import org.jgroups.Message; //导入依赖的package包/类
private void processForUnicast(Message msg, int direction) {
Object o = msg.getHeader(unicastHeaderId);
if (o instanceof UNICAST3.Header && stats != null) {
UNICAST3.Header hdr = (UNICAST3.Header) o;
switch (direction) {
case INCOMING:
stats.incUcastReadBytes((int) msg.size());
break;
case OUTGOING:
stats.incUcastWriteBytes((int) msg.size());
switch (hdr.type()) {
case UNICAST3.Header.XMIT_REQ:
stats.incUcastRetransmits();
break;
}
break;
}
}
}
示例5: handleMessage
import org.jgroups.Message; //导入依赖的package包/类
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;
}
}
}
}
示例6: alertMessagesBypassFlowControl
import org.jgroups.Message; //导入依赖的package包/类
@Test
public void alertMessagesBypassFlowControl() throws Exception {
initMocks(false);
Message jgmsg = new Message();
DistributionMessage dmsg = mock(DistributionMessage.class);
when(dmsg.getProcessorType()).thenReturn(DistributionManager.SERIAL_EXECUTOR);
messenger.setMessageFlags(dmsg, jgmsg);
assertFalse("expected no_fc to not be set in " + jgmsg.getFlags(),
jgmsg.isFlagSet(Message.Flag.NO_FC));
AlertAppender.setIsAlerting(true);
try {
messenger.setMessageFlags(dmsg, jgmsg);
assertTrue("expected no_fc to be set in " + jgmsg.getFlags(),
jgmsg.isFlagSet(Message.Flag.NO_FC));
} finally {
AlertAppender.setIsAlerting(false);
}
}
示例7: testQuorumCheckerAllRespond
import org.jgroups.Message; //导入依赖的package包/类
@Test
public void testQuorumCheckerAllRespond() throws Exception {
NetView view = prepareView();
Set<Integer> pongResponders = new HashSet<Integer>();
for (int i = 0; i < mockMembers.length; i++) {
pongResponders.add(mockMembers[i].getPort());
}
PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
qc.initialize();
boolean quorum = qc.checkForQuorum(500);
assertTrue(quorum);
assertSame(view.getMembers().size(), answerer.getPingCount());
assertTrue(qc.checkForQuorum(500));
assertSame(qc.getMembershipInfo(), channel);
}
示例8: testQuorumCheckerMajorityRespond
import org.jgroups.Message; //导入依赖的package包/类
@Test
public void testQuorumCheckerMajorityRespond() throws Exception {
NetView view = prepareView();
Set<Integer> pongResponders = new HashSet<Integer>();
for (int i = 0; i < mockMembers.length - 1; i++) {
pongResponders.add(mockMembers[i].getPort());
}
PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
qc.initialize();
boolean quorum = qc.checkForQuorum(500);
assertTrue(quorum);
assertSame(view.getMembers().size(), answerer.getPingCount());
}
示例9: testQuorumChecker10Servers2Locators4ServersLost
import org.jgroups.Message; //导入依赖的package包/类
@Test
public void testQuorumChecker10Servers2Locators4ServersLost() throws Exception {
NetView view = prepareView();
mockMembers[0].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
mockMembers[1].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
Set<Integer> pongResponders = new HashSet<Integer>();
for (int i = 0; i < mockMembers.length; i++) {
pongResponders.add(mockMembers[i].getPort());
}
// remove 4 servers
pongResponders.remove(mockMembers[8].getPort());
pongResponders.remove(mockMembers[9].getPort());
pongResponders.remove(mockMembers[10].getPort());
pongResponders.remove(mockMembers[11].getPort());
PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
qc.initialize();
boolean quorum = qc.checkForQuorum(500);
assertTrue(quorum);
assertSame(view.getMembers().size(), answerer.getPingCount());
}
示例10: testQuorumChecker2Servers2LocatorsLeadMemberLost
import org.jgroups.Message; //导入依赖的package包/类
@Test
public void testQuorumChecker2Servers2LocatorsLeadMemberLost() throws Exception {
int numMembers = 4;
NetView view = prepareView(numMembers);
mockMembers[0].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
mockMembers[1].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
Set<Integer> pongResponders = new HashSet<Integer>();
for (int i = 0; i < numMembers; i++) {
pongResponders.add(mockMembers[i].getPort());
}
// remove lead member
pongResponders.remove(mockMembers[2].getPort()); // lead member
PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
qc.initialize();
boolean quorum = qc.checkForQuorum(500);
assertTrue(quorum);
assertSame(view.getMembers().size(), answerer.getPingCount());
}
示例11: testQuorumChecker2Servers2LocatorsLeadMemberAnd1LocatorLost
import org.jgroups.Message; //导入依赖的package包/类
@Test
public void testQuorumChecker2Servers2LocatorsLeadMemberAnd1LocatorLost() throws Exception {
int numMembers = 4;
NetView view = prepareView(numMembers);
mockMembers[0].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
mockMembers[1].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
Set<Integer> pongResponders = new HashSet<Integer>();
for (int i = 0; i < numMembers; i++) {
pongResponders.add(mockMembers[i].getPort());
}
// remove members
pongResponders.remove(mockMembers[2].getPort()); // lead member
pongResponders.remove(mockMembers[0].getPort()); // locator
PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
qc.initialize();
boolean quorum = qc.checkForQuorum(500);
assertFalse(quorum);
assertSame(view.getMembers().size(), answerer.getPingCount());
}
示例12: answer
import org.jgroups.Message; //导入依赖的package包/类
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof Message) {
Message msg = (Message) args[i];
Object content = null;
content = msg.getBuffer();
if (content instanceof byte[]) {
if (pingPonger.isPingMessage((byte[]) content)) {
pingCount++;
if (simulatedPongRespondersByPort.contains(((JGAddress) msg.getDest()).getPort())) {
channel.getReceiver()
.receive(pingPonger.createPongMessage(msg.getDest(), msg.getSrc()));
}
}
}
}
}
return null;
}
示例13: recorderHandlesRejectedExecution
import org.jgroups.Message; //导入依赖的package包/类
@Test
public void recorderHandlesRejectedExecution() 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);
// GEODE-1178, the TP protocol may throw a RejectedExecutionException & StatRecorder should
// retry
when(mockDownProtocol.down(any(Event.class))).thenThrow(new RejectedExecutionException());
// after the first down() throws an exception we want StatRecorder to retry, so
// we set the Manager to say no shutdown is in progress the first time and then say
// one IS in progress so we can break out of the StatRecorder exception handling loop
when(services.getCancelCriterion()).thenReturn(new Services().getCancelCriterion());
Manager manager = mock(Manager.class);
when(services.getManager()).thenReturn(manager);
when(manager.shutdownInProgress()).thenReturn(Boolean.FALSE, Boolean.TRUE);
verify(mockDownProtocol, never()).down(isA(Event.class));
Event evt = new Event(Event.MSG, msg);
recorder.down(evt);
verify(mockDownProtocol, times(2)).down(isA(Event.class));
}
示例14: testReceive
import org.jgroups.Message; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testReceive() throws Exception {
final Identifier<Jvm> jvmId = new Identifier<>("1");
Jvm jvm = new Jvm(jvmId, "jvm-name");
final Map<Object, Object> serverInfoMap = new HashMap();
serverInfoMap.put(JvmStateReceiverAdapter.NAME_KEY, jvm.getJvmName());
serverInfoMap.put(JvmStateReceiverAdapter.STATE_KEY, LifecycleState.STOPPING);
msg = new Message();
msg.setObject(serverInfoMap);
when (mockJvmPersistenceService.findJvmByExactName(jvm.getJvmName())).thenReturn(jvm);
jvmStateReceiverAdapter.receive(msg);
verify(mockJvmStateService).updateState(eq(jvm), eq(JvmState.JVM_STOPPING), eq(StringUtils.EMPTY));
}
示例15: testReceiveReportingJmsMessageKey
import org.jgroups.Message; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testReceiveReportingJmsMessageKey() throws Exception {
final Identifier<Jvm> jvmId = new Identifier<>("1");
Jvm jvm = new Jvm(jvmId, "jvm-name");
final Map<Object, Object> serverInfoMap = new HashMap();
serverInfoMap.put(ReportingJmsMessageTestKey.ID, "1");
serverInfoMap.put(ReportingJmsMessageTestKey.STATE, "JVM_STOPPING");
msg = new Message();
msg.setObject(serverInfoMap);
when (mockJvmPersistenceService.getJvm(jvmId)).thenReturn(jvm);
jvmStateReceiverAdapter.receive(msg);
verify(mockJvmStateService).updateState(eq(jvm), eq(JvmState.JVM_STOPPING), eq(StringUtils.EMPTY));
}