本文整理了Java中org.jgroups.Message.isFlagSet()
方法的一些代码示例,展示了Message.isFlagSet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.isFlagSet()
方法的具体详情如下:
包路径:org.jgroups.Message
类名称:Message
方法名:isFlagSet
[英]Checks if a given flag is set
[中]检查是否设置了给定的标志
代码示例来源:origin: wildfly/wildfly
/**
* Checks if a given flag is set
* @param flag The flag
* @return Whether or not the flag is currently set
*/
public boolean isFlagSet(Flag flag) {
return isFlagSet(flags, flag);
}
代码示例来源:origin: wildfly/wildfly
public Mode determineMode() {
int num_oob=0, num_reg=0, num_internal=0;
for(int i=0; i < index; i++) {
if(messages[i] == null)
continue;
if(messages[i].isFlagSet(Message.Flag.OOB))
num_oob++;
else if(messages[i].isFlagSet(Message.Flag.INTERNAL))
num_internal++;
else
num_reg++;
}
if(num_internal > 0 && num_oob == 0 && num_reg == 0)
return Mode.INTERNAL;
if(num_oob > 0 && num_internal == 0 && num_reg == 0)
return Mode.OOB;
if(num_reg > 0 && num_oob == 0 && num_internal == 0)
return Mode.REG;
return Mode.MIXED;
}
代码示例来源:origin: wildfly/wildfly
protected void flushQueue(final Map<Address,Message> queue) {
if(queue.isEmpty())
return;
for(Message msg: queue.values()) {
boolean oob=msg.isFlagSet(Message.Flag.OOB), internal=msg.isFlagSet(Message.Flag.INTERNAL);
transport.msg_processing_policy.process(msg, oob, internal);
}
queue.clear();
}
代码示例来源:origin: wildfly/wildfly
protected void queue(Message msg) {
Address dest=msg.dest();
Map<Address,List<Message>> map;
if(dest == null)
map=msg.isFlagSet(Message.Flag.OOB)? oob_map_mcast : reg_map_mcast;
else
map=msg.isFlagSet(Message.Flag.OOB)? oob_map_ucast : reg_map_ucast;
Address sender=msg.src();
synchronized(map) {
List<Message> list=map.get(sender);
if(list == null)
map.put(sender, list=new ArrayList<>());
list.add(msg);
}
}
代码示例来源:origin: wildfly/wildfly
public static String flagsToString(short flags) {
StringBuilder sb=new StringBuilder();
boolean first=true;
Flag[] all_flags=Flag.values();
for(Flag flag: all_flags) {
if(isFlagSet(flags, flag)) {
if(first)
first=false;
else
sb.append("|");
sb.append(flag);
}
}
return sb.toString();
}
代码示例来源:origin: wildfly/wildfly
public Object up(Message msg) {
// https://issues.jboss.org/browse/JGRP-1341: let unicast messages pass
if(msg.isFlagSet(Message.Flag.SKIP_BARRIER) || msg.getDest() != null
&& ((msg.isFlagSet(Message.Flag.OOB) && msg.isFlagSet(Message.Flag.INTERNAL)) || holes.contains(msg.getSrc())))
return up_prot.up(msg);
if(barrier_closed.get()) {
final Map<Address,Message> map=msg.getDest() == null? mcast_queue : ucast_queue;
map.put(msg.getSrc(), msg);
return null; // queue and drop the message
}
Thread current_thread=Thread.currentThread();
in_flight_threads.put(current_thread, NULL);
try {
return up_prot.up(msg);
}
finally {
unblock(current_thread);
}
}
代码示例来源:origin: wildfly/wildfly
public Object down(Message msg) {
if(msg.getDest() != null || msg.isFlagSet(Message.Flag.NO_TOTAL_ORDER) || msg.isFlagSet(Message.Flag.OOB))
return down_prot.down(msg);
if(msg.getSrc() == null)
msg.setSrc(local_addr);
try {
fwd_queue.put(msg);
if(seqno_reqs.getAndIncrement() == 0) {
int num_reqs=seqno_reqs.get();
sendSeqnoRequest(num_reqs);
}
}
catch(InterruptedException e) {
if(!running)
return null;
throw new RuntimeException(e);
}
return null; // don't pass down
}
代码示例来源:origin: wildfly/wildfly
public Object up(Message msg) {
if(msg.isFlagSet(Message.Flag.OOB) && msg.isFlagSet(Message.Flag.INTERNAL))
return up_prot.up(msg);
if((msg.dest() == null && multicasts) || (msg.dest() != null && unicasts)) {
queue(msg);
return null;
}
return up_prot.up(msg);
}
代码示例来源:origin: wildfly/wildfly
protected void loopback(Message msg, final boolean multicast) {
final Message copy=loopback_copy? msg.copy() : msg;
if(is_trace)
log.trace("%s: looping back message %s, headers are %s", local_addr, copy, copy.printHeaders());
if(!loopback_separate_thread) {
passMessageUp(copy, null, false, multicast, false);
return;
}
// changed to fix http://jira.jboss.com/jira/browse/JGRP-506
boolean internal=msg.isFlagSet(Message.Flag.INTERNAL);
boolean oob=msg.isFlagSet(Message.Flag.OOB);
// submitToThreadPool(() -> passMessageUp(copy, null, false, multicast, false), internal);
msg_processing_policy.loopback(msg, oob, internal);
}
代码示例来源:origin: wildfly/wildfly
/**
* Removes messages with flags DONT_BUNDLE and OOB set and executes them in the oob or internal thread pool. JGRP-1737
*/
protected void removeAndDispatchNonBundledMessages(MessageBatch oob_batch) {
if(oob_batch == null)
return;
AsciiString tmp=oob_batch.clusterName();
byte[] cname=tmp != null? tmp.chars() : null;
for(Iterator<Message> it=oob_batch.iterator(); it.hasNext();) {
Message msg=it.next();
if(msg.isFlagSet(Message.Flag.DONT_BUNDLE) && msg.isFlagSet(Message.Flag.OOB)) {
boolean internal=msg.isFlagSet(Message.Flag.INTERNAL);
it.remove();
if(tp.statsEnabled())
tp.getMessageStats().incrNumOOBMsgsReceived(1);
tp.submitToThreadPool(new SingleMessageHandlerWithClusterName(msg, cname), internal);
}
}
}
代码示例来源:origin: wildfly/wildfly
public Object down(Message msg) {
Address dest=msg.getDest();
if(dest != null || msg.isFlagSet(Message.Flag.NO_RELIABILITY))
return down_prot.down(msg); // unicast address: not null and not mcast, pass down unchanged
send(msg);
return null; // don't pass down the stack
}
代码示例来源:origin: wildfly/wildfly
protected void handleSingleMessage(DataInput in, boolean multicast) {
try {
Message msg=new Message(false); // don't create headers, readFrom() will do this
msg.readFrom(in);
if(!multicast && unicastDestMismatch(msg.getDest()))
return;
boolean oob=msg.isFlagSet(Message.Flag.OOB), internal=msg.isFlagSet(Message.Flag.INTERNAL);
msg_processing_policy.process(msg, oob, internal);
}
catch(Throwable t) {
log.error(String.format(Util.getMessage("IncomingMsgFailure"), local_addr), t);
}
}
代码示例来源:origin: wildfly/wildfly
protected void deliverMessage(final Message msg, final Address sender, final long seqno) {
if(is_trace)
log.trace("%s: delivering %s#%s", local_addr, sender, seqno);
try {
up_prot.up(msg);
}
catch(Throwable t) {
log.warn(Util.getMessage("FailedToDeliverMsg"), local_addr, msg.isFlagSet(Message.Flag.OOB) ?
"OOB message" : "message", msg, t);
}
}
代码示例来源:origin: wildfly/wildfly
public void up(MessageBatch batch) {
for(Message msg: batch) {
if(msg.isFlagSet(Message.Flag.NO_TOTAL_ORDER) || msg.isFlagSet(Message.Flag.OOB) || msg.getHeader(id) == null)
continue;
batch.remove(msg);
// simplistic implementation
try {
up(msg);
}
catch(Throwable t) {
log.error(Util.getMessage("FailedPassingUpMessage"), t);
}
}
if(!batch.isEmpty())
up_prot.up(batch);
}
代码示例来源:origin: wildfly/wildfly
public void up(MessageBatch batch) {
for(Message msg: batch) {
if(msg.isFlagSet(Message.Flag.NO_TOTAL_ORDER) || msg.isFlagSet(Message.Flag.OOB) || msg.getHeader(id) == null)
continue;
batch.remove(msg);
// simplistic implementation
try {
up(msg);
}
catch(Throwable t) {
log.error(Util.getMessage("FailedPassingUpMessage"), t);
}
}
if(!batch.isEmpty())
up_prot.up(batch);
}
代码示例来源:origin: wildfly/wildfly
public Object down(Message message) {
Address dest = message.getDest();
if (dest != null && dest instanceof AnycastAddress && !message.isFlagSet(Message.Flag.NO_TOTAL_ORDER)) {
// anycast message
sendTotalOrderAnycastMessage(extract((AnycastAddress) dest), message);
} else if (dest != null && dest instanceof AnycastAddress) {
//anycast address with NO_TOTAL_ORDER flag (should no be possible, but...)
send(extract((AnycastAddress) dest), message, true);
} else {
//normal message
down_prot.down(message);
}
return null;
}
代码示例来源:origin: wildfly/wildfly
public void run() {
Address dest=msg.getDest();
boolean multicast=dest == null;
try {
if(tp.statsEnabled()) {
MsgStats msg_stats=tp.getMessageStats();
if(msg.isFlagSet(Message.Flag.OOB))
msg_stats.incrNumOOBMsgsReceived(1);
else if(msg.isFlagSet(Message.Flag.INTERNAL))
msg_stats.incrNumInternalMsgsReceived(1);
else
msg_stats.incrNumMsgsReceived(1);
msg_stats.incrNumBytesReceived(msg.getLength());
}
byte[] cname=getClusterName();
tp.passMessageUp(msg, cname, true, multicast, true);
}
catch(Throwable t) {
log.error(Util.getMessage("PassUpFailure"), t);
}
}
代码示例来源:origin: wildfly/wildfly
public Object up(Message msg) {
if(msg.getDest() == null || msg.isFlagSet(Message.Flag.NO_RELIABILITY)) // only handle unicast messages
return up_prot.up(msg); // pass up
UnicastHeader3 hdr=msg.getHeader(this.id);
if(hdr == null)
return up_prot.up(msg);
Address sender=msg.getSrc();
switch(hdr.type) {
case UnicastHeader3.DATA: // received regular message
if(is_trace)
log.trace("%s <-- DATA(%s: #%d, conn_id=%d%s)", local_addr, sender, hdr.seqno, hdr.conn_id, hdr.first? ", first" : "");
if(Objects.equals(local_addr, sender))
handleDataReceivedFromSelf(sender, hdr.seqno, msg);
else
handleDataReceived(sender, hdr.seqno, hdr.conn_id, hdr.first, msg);
break; // we pass the deliverable message up in handleDataReceived()
default:
handleUpEvent(sender, msg, hdr);
break;
}
return null;
}
代码示例来源:origin: wildfly/wildfly
public Object up(Message msg) {
Address dest=msg.getDest();
RelayHeader hdr=msg.getHeader(getId());
if(hdr != null)
return handleUpEvent(msg, hdr);
if(is_coord && relay && dest == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks
try {
byte[] buf=Util.streamableToByteBuffer(tmp);
forward(buf, 0, buf.length);
}
catch(Exception e) {
log.warn("failed relaying message", e);
}
}
return up_prot.up(msg);
}
代码示例来源:origin: wildfly/wildfly
public Object down(Message msg) {
if(msg.isFlagSet(Message.Flag.NO_FC))
return down_prot.down(msg);
Address dest=msg.getDest();
boolean multicast=dest == null;
boolean handle_multicasts=handleMulticastMessage();
boolean process=(handle_multicasts && multicast) || (!handle_multicasts && !multicast);
if(!process)
return down_prot.down(msg);
int length=msg.getLength();
if(length == 0)
return down_prot.down(msg);
Object retval=handleDownMessage(msg);
// if the message is DONT_LOOPBACK, we will not receive it, therefore the credit
// check needs to be done now
if(msg.isTransientFlagSet(Message.TransientFlag.DONT_LOOPBACK)) {
long new_credits=adjustCredit(received, local_addr, length);
if(new_credits > 0)
sendCredit(local_addr, new_credits);
}
return retval;
}
内容来源于网络,如有侵权,请联系作者删除!