本文整理汇总了Java中org.jgroups.Message.setDest方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setDest方法的具体用法?Java Message.setDest怎么用?Java Message.setDest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.Message
的用法示例。
在下文中一共展示了Message.setDest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleXmitRsp
import org.jgroups.Message; //导入方法依赖的package包/类
private void handleXmitRsp(Message msg, NakAckHeader hdr) {
if(msg == null)
return;
try {
if(stats)
xmit_rsps_received.incrementAndGet();
msg.setDest(null);
NakAckHeader newhdr=hdr.copy();
newhdr.type=NakAckHeader.MSG; // change the type back from XMIT_RSP --> MSG
msg.putHeader(id, newhdr);
up(new Event(Event.MSG, msg));
if(rebroadcasting)
checkForRebroadcasts();
}
catch(Exception ex) {
if(log.isErrorEnabled()) {
log.error("failed reading retransmitted message", ex);
}
}
}
示例2: testDontLoopback
import org.jgroups.Message; //导入方法依赖的package包/类
public void testDontLoopback() {
final Address DEST=Util.createRandomAddress("A");
Message msg=new Message(null).setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
msg.dest(null); // OK
msg.setDest(null);
msg.dest(DEST);
msg.clearTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
msg.dest(DEST); // OK
msg.setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
msg.setTransientFlagIfAbsent(Message.TransientFlag.DONT_LOOPBACK);
short flags=(short)(Message.TransientFlag.DONT_LOOPBACK.value() + Message.TransientFlag.OOB_DELIVERED.value());
msg.setTransientFlag(flags);
}
示例3: createJGMessage
import org.jgroups.Message; //导入方法依赖的package包/类
private Message createJGMessage(byte[] msgBytes, Address src, Address dest, short version) {
Message msg = new Message();
msg.setDest(dest);
msg.setSrc(src);
msg.setObject(msgBytes);
msg.setFlag(Message.Flag.NO_RELIABILITY);
msg.setFlag(Message.Flag.NO_FC);
msg.setFlag(Message.Flag.DONT_BUNDLE);
msg.setFlag(Message.Flag.OOB);
return msg;
}
示例4: flushMessagesInForwardTable
import org.jgroups.Message; //导入方法依赖的package包/类
/**
* Sends all messages currently in forward_table to the new target (changing the dest field).
* This needs to be done, so the underlying reliable unicast protocol (e.g. UNICAST) adds these messages
* to its retransmission mechanism<br/>
* Note that we need to resend the messages in order of their seqnos ! We also need to prevent other message
* from being inserted until we're done, that's why there's synchronization.<br/>
* Access to the forward_table doesn't need to be synchronized as there won't be any insertions during flushing
* (all down-threads are blocked)
*/
protected void flushMessagesInForwardTable(Address target) {
// for forwarded messages, we need to receive the forwarded message from the coordinator, to prevent this case:
// - V1={A,B,C}
// - A crashes
// - C installs V2={B,C}
// - C forwards messages 3 and 4 to B (the new coord)
// - B drops 3 because its view is still V1
// - B installs V2
// - B receives message 4 and broadcasts it
// ==> C's message 4 is delivered *before* message 3 !
// ==> By resending 3 until it is received, then resending 4 until it is received, we make sure this won't happen
// (see https://issues.jboss.org/browse/JGRP-1449)
// Forward the first entry and wait for the ack
Map.Entry<Long,Message> first=forward_table.firstEntry();
if(first == null)
return;
Long key=first.getKey();
Message val=first.getValue();
Message forward_msg;
while(flushing && running && !forward_table.isEmpty()) {
forward_msg=val.copy();
forward_msg.setDest(target);
forward_msg.setFlag(Message.Flag.DONT_BUNDLE);
if(log.isTraceEnabled())
log.trace(local_addr + ": flushing (forwarding) " + "::" + key + " to target " + target);
ack_promise.reset();
down_prot.down(new Event(Event.MSG, forward_msg));
Long ack=ack_promise.getResult(500);
if((ack != null && ack.equals(key)) || !forward_table.containsKey(key))
break;
}
for(Map.Entry<Long,Message> entry: forward_table.entrySet()) {
key=entry.getKey();
val=entry.getValue();
if(flushing && running) {
forward_msg=val.copy();
forward_msg.setDest(target);
forward_msg.setFlag(Message.Flag.DONT_BUNDLE);
if(log.isTraceEnabled())
log.trace(local_addr + ": flushing (forwarding) " + "::" + key + " to target " + target);
down_prot.down(new Event(Event.MSG, forward_msg));
}
}
}