当前位置: 首页>>代码示例>>Java>>正文


Java Message.isFlagSet方法代码示例

本文整理汇总了Java中org.jgroups.Message.isFlagSet方法的典型用法代码示例。如果您正苦于以下问题:Java Message.isFlagSet方法的具体用法?Java Message.isFlagSet怎么用?Java Message.isFlagSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jgroups.Message的用法示例。


在下文中一共展示了Message.isFlagSet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: up

import org.jgroups.Message; //导入方法依赖的package包/类
/**
   * An event was received from the layer below. Usually the current layer will want to examine
   * the event type and - depending on its type - perform some computation
   * (e.g. removing headers from a MSG event type, or updating the internal membership list
   * when receiving a VIEW_CHANGE event).
   * Finally the event is either a) discarded, or b) an event is sent down
   * the stack using <code>down_prot.down()</code> or c) the event (or another event) is sent up
   * the stack using <code>up_prot.up()</code>.
   */
  public Object up(Event evt) {
switch(evt.getType()) {
          case Event.MSG:
		Message message = (Message)evt.getArg();
		if ( message.isFlagSet( Message.Flag.OOB ) ) {
			return up_prot.up(evt);
		}
		else {
			PrioHeader hdr=(PrioHeader)message.getHeader(id);
			if(hdr != null) {
				log.trace("%s: adding priority message %d to UP queue", local_addr, hdr.getPriority());
				upMessageQueue.add( new PriorityMessage( evt, hdr.getPriority() ) );
				// send with hdr.prio
				return null;
			}
      			return up_prot.up(evt);
              }
          default:
      		return up_prot.up(evt);
      }
  }
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:31,代码来源:PRIO.java

示例2: flushBecomeServerQueue

import org.jgroups.Message; //导入方法依赖的package包/类
/**
 * Flushes the queue. Done in a separate thread as we don't want to block the
 * {@link ClientGmsImpl#installView(org.jgroups.View,org.jgroups.util.Digest)} method (called when a view is installed).
 */
protected void flushBecomeServerQueue() {
    if(become_server_queue != null && !become_server_queue.isEmpty()) {
        if(log.isTraceEnabled())
            log.trace(local_addr + ": flushing become_server_queue (" + become_server_queue.size() + " elements)");

        TP transport=getTransport();
        Executor thread_pool=transport.getDefaultThreadPool(), oob_thread_pool=transport.getOOBThreadPool();

        for(final Message msg: become_server_queue) {
            Executor pool=msg.isFlagSet(Message.Flag.OOB)? oob_thread_pool : thread_pool;
            pool.execute(new Runnable() {
                public void run() {
                    try {
                        up(new Event(Event.MSG, msg));
                    }
                    finally {
                        become_server_queue.remove(msg);
                    }
                }
            });
        }
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:28,代码来源:NAKACK.java

示例3: down

import org.jgroups.Message; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Object down(Event evt) {
    switch(evt.getType()) {
        case Event.MSG:
            Message msg=(Message)evt.getArg();
            if(msg.isFlagSet(Message.Flag.NO_FC))
                break;
            int length=msg.getLength();
            if(length == 0)
                break;
            return handleDownMessage(evt, msg, length);
        case Event.CONFIG:
            handleConfigEvent((Map<String,Object>)evt.getArg()); 
            break;
        case Event.VIEW_CHANGE:
            handleViewChange(((View)evt.getArg()).getMembers());
            break;
    }
    return down_prot.down(evt); // this could potentially use the lower protocol's thread which may block
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:21,代码来源:FC.java

示例4: queue

import org.jgroups.Message; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:17,代码来源:MAKE_BATCH.java

示例5: up

import org.jgroups.Message; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Object up(Event evt) {
    switch(evt.getType()) {

        case Event.MSG:
            Message msg=(Message)evt.getArg();
            if(msg.isFlagSet(Message.Flag.NO_FC))
                break;

            Address dest=msg.getDest();
            boolean multicast=dest == null;
            boolean handle_multicasts=handleMulticastMessage();
            FcHeader hdr=(FcHeader)msg.getHeader(this.id);
            boolean process=(handle_multicasts && multicast) || (!handle_multicasts && !multicast) || hdr != null;
            if(!process)
                break;
            
            if(hdr != null) {
                handleUpEvent(msg, hdr);
                return null; // don't pass message up
            }

            Address sender=msg.getSrc();
            long new_credits=adjustCredit(received, sender, msg.getLength());
            
            try {
                return up_prot.up(evt);
            }
            finally {
                if(new_credits > 0)
                    sendCredit(sender, new_credits);
            }

        case Event.VIEW_CHANGE:
            handleViewChange(((View)evt.getArg()).getMembers());
            break;
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:40,代码来源:FlowControl.java

示例6: up

import org.jgroups.Message; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Object up(Event evt) {
    switch(evt.getType()) {

        case Event.MSG:

            // JGRP-465. We only deal with msgs to avoid having to use a concurrent collection; ignore views,
            // suspicions, etc which can come up on unusual threads.
            Message msg=(Message)evt.getArg();
            if(msg.isFlagSet(Message.Flag.NO_FC))
                break;
            FcHeader hdr=(FcHeader)msg.getHeader(this.id);
            if(hdr != null) {
                handleUpEvent(hdr, msg);
                return null; // don't pass message up
            }

            Address sender=msg.getSrc();
            long new_credits=adjustCredit(received, sender, msg.getLength());
            
            try {
                return up_prot.up(evt);
            }
            finally {
                if(new_credits > 0) {
                    if(log.isTraceEnabled()) log.trace("sending " + new_credits + " credits to " + sender);
                    sendCredit(sender, new_credits);
                }
            }

        case Event.VIEW_CHANGE:
            handleViewChange(((View)evt.getArg()).getMembers());
            break;
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:37,代码来源:FC.java

示例7: up

import org.jgroups.Message; //导入方法依赖的package包/类
public Object up(Event evt) {
    switch(evt.getType()) {
        case Event.MSG:
            Message msg=(Message)evt.getArg();
            // 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(evt);

            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(evt);
            }
            finally {
                unblock(current_thread);
            }
        case Event.CLOSE_BARRIER:
            closeBarrier();
            return null;

        case Event.OPEN_BARRIER:
            openBarrier();
            return null;
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:33,代码来源:BARRIER.java

示例8: up

import org.jgroups.Message; //导入方法依赖的package包/类
public Object up(Event evt) {
    if(evt.getType() == Event.MSG) {
        Message msg=(Message)evt.getArg();
        if(msg.isFlagSet(Message.Flag.OOB) && msg.isFlagSet(Message.Flag.INTERNAL))
            return up_prot.up(evt);

        if((msg.dest() == null && multicasts) || (msg.dest() != null && unicasts)) {
            queue(msg);
            return null;
        }
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:14,代码来源:MAKE_BATCH.java

示例9: up

import org.jgroups.Message; //导入方法依赖的package包/类
/**
 * <b>Callback</b>. Called by superclass when event may be handled.<p> <b>Do not use <code>PassUp</code> in this
 * method as the event is passed up by default by the superclass after this method returns !</b>
 */
public Object up(Event evt) {
    switch(evt.getType()) {

    case Event.MSG:
        Message msg=(Message)evt.getArg();
        if(msg.isFlagSet(Message.Flag.NO_RELIABILITY))
            break;
        NakAckHeader hdr=(NakAckHeader)msg.getHeader(this.id);
        if(hdr == null)
            break;  // pass up (e.g. unicast msg)

        if(!is_server) { // discard messages while not yet server (i.e., until JOIN has returned)
            if(become_server_queue != null) {
                become_server_queue.add(msg);
                if(log.isTraceEnabled())
                    log.trace(local_addr + ": message " + msg.getSrc() + "::" + hdr.seqno + " was added to queue (not yet server)");
            }
            else {
                if(log.isTraceEnabled())
                    log.trace(local_addr + ": message " + msg.getSrc() + "::" + hdr.seqno + " was discarded (not yet server)");
            }
            return null;
        }

        // Changed by bela Jan 29 2003: we must not remove the header, otherwise further xmit requests will fail !
        //hdr=(NakAckHeader)msg.removeHeader(getName());

        switch(hdr.type) {

        case NakAckHeader.MSG:
            handleMessage(msg, hdr);
            return null;        // transmitter passes message up for us !

        case NakAckHeader.XMIT_REQ:
            if(hdr.range == null) {
                if(log.isErrorEnabled()) {
                    log.error("XMIT_REQ: range of xmit msg is null; discarding request from " + msg.getSrc());
                }
                return null;
            }
            handleXmitReq(msg.getSrc(), hdr.range.low, hdr.range.high, hdr.sender);
            return null;

        case NakAckHeader.XMIT_RSP:
            handleXmitRsp(msg, hdr);
            return null;

        default:
            if(log.isErrorEnabled()) {
                log.error("NakAck header type " + hdr.type + " not known !");
            }
            return null;
        }

    case Event.STABLE:  // generated by STABLE layer. Delete stable messages passed in arg
        stable((Digest)evt.getArg());
        return null;  // do not pass up further (Bela Aug 7 2001)

    case Event.SUSPECT:
        // release the promise if rebroadcasting is in progress... otherwise we wait forever. there will be a new
        // flush round anyway
        if(rebroadcasting) {
            cancelRebroadcasting();
        }
        break;
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:73,代码来源:NAKACK.java

示例10: down

import org.jgroups.Message; //导入方法依赖的package包/类
public Object down(Event evt) {
    if(evt.getType() == Event.MSG) {
        Message msg=(Message)evt.getArg();
        int len=msg.getLength();
        if(len == 0 || msg.isFlagSet(Message.Flag.NO_FC))
            return down_prot.down(evt);

        lock.lock();
        try {
            if(len > max_bytes) {
                log.error("message length (" + len + " bytes) exceeded max_bytes (" + max_bytes + "); " +
                        "adjusting max_bytes to " + len);
                max_bytes=len;
            }

            if(num_bytes_sent_in_period + len > max_bytes) { // size exceeded
                long current_time=System.nanoTime();
                long block_time=time_period_ns - (current_time - current_period_start);
                if(block_time > 0) {
                    LockSupport.parkNanos(block_time);
                    num_blockings++;
                    total_block_time+=block_time;
                }
                current_period_start=block_time > 0? current_time + block_time : System.nanoTime();
                num_bytes_sent_in_period=0;
            }
        }
        finally {
            num_bytes_sent_in_period+=len;
            lock.unlock();
        }

        return down_prot.down(evt);
    }

    if(evt.getType() == Event.CONFIG) {
        Map<String,Object> map=(Map<String, Object>)evt.getArg();
        Integer tmp=map != null? (Integer)map.get("frag_size") : null;
        if(tmp != null)
            frag_size=tmp;
        if(frag_size > 0) {
            if(max_bytes % frag_size != 0) {
                if(log.isWarnEnabled())
                    log.warn("For optimal performance, max_bytes (" + max_bytes +
                               ") should be a multiple of frag_size (" + frag_size + ")");
            }
        }
    }

    return down_prot.down(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:52,代码来源:RATE_LIMITER.java


注:本文中的org.jgroups.Message.isFlagSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。