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


Java Message.getHeader方法代码示例

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


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

示例1: 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;
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:StatRecorder.java

示例2: 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;
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:StatRecorder.java

示例3: 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;
      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:InterceptUDP.java

示例4: down

import org.jgroups.Message; //导入方法依赖的package包/类
public Object down(Event evt) {
    switch(evt.getType()) {
        case Event.MSG:
            Message msg=(Message)evt.getArg();
            FORK.ForkHeader hdr=(FORK.ForkHeader)msg.getHeader(FORK.ID);
            if(hdr == null)
                msg.putHeader(FORK.ID, hdr=new FORK.ForkHeader(fork_stack_id, null));
            else
                hdr.setForkStackId(fork_stack_id);
            break;
        case Event.SET_LOCAL_ADDRESS:
        case Event.VIEW_CHANGE:
        case Event.CONNECT:
        case Event.CONNECT_USE_FLUSH:
        case Event.CONNECT_WITH_STATE_TRANSFER:
        case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH:
        case Event.DISCONNECT:
            return null; // don't propagate further down, this is only important for the main stack
    }
    return down_prot.down(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:22,代码来源:ForkProtocol.java

示例5: 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

示例6: sendXmitRsp

import org.jgroups.Message; //导入方法依赖的package包/类
/**
 * Sends a message msg to the requester. We have to wrap the original message into a retransmit message, as we need
 * to preserve the original message's properties, such as src, headers etc.
 * @param dest
 * @param msg
 */
private void sendXmitRsp(Address dest, Message msg) {
    if(msg == null) {
        if(log.isErrorEnabled())
            log.error("message is null, cannot send retransmission");
        return;
    }

    if(stats)
        xmit_rsps_sent.incrementAndGet();

    if(msg.getSrc() == null)
        msg.setSrc(local_addr);

    if(use_mcast_xmit) { // we simply send the original multicast message
        down_prot.down(new Event(Event.MSG, msg));
        return;
    }

    Message xmit_msg=msg.copy(true, true).dest(dest).setFlag(Message.Flag.INTERNAL); // copy payload and headers
    NakAckHeader hdr=(NakAckHeader)xmit_msg.getHeader(id);
    NakAckHeader newhdr=hdr.copy();    // create a copy of the header: https://issues.jboss.org/browse/JGRP-1502
    newhdr.type=NakAckHeader.XMIT_RSP; // change the type in the copy from MSG --> XMIT_RSP
    xmit_msg.putHeader(id, newhdr);
    down_prot.down(new Event(Event.MSG, xmit_msg));
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:32,代码来源:NAKACK.java

示例7: up

import org.jgroups.Message; //导入方法依赖的package包/类
/**
 * If there is no header, we pass the message up. Otherwise we uncompress the payload to its original size.
 * @param evt
 */
public Object up(Event evt) {
    if(evt.getType() == Event.MSG) {
        Message msg=(Message)evt.getArg();
        CompressHeader hdr=(CompressHeader)msg.getHeader(this.id);
        if(hdr != null) {
            Message uncompressed_msg=uncompress(msg, hdr.original_size);
            if(uncompressed_msg != null) {
                if(log.isTraceEnabled())
                    log.trace("up(): uncompressed " + msg.getLength() + " bytes to " + uncompressed_msg.getLength() + " bytes");
                return up_prot.up(new Event(Event.MSG, uncompressed_msg));
            }
        }
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:COMPRESS.java

示例8: up

import org.jgroups.Message; //导入方法依赖的package包/类
/**
 * If event is a message, if it is fragmented, re-assemble fragments into big message and pass up the stack.
 */
public Object up(Event evt) {
    switch(evt.getType()) {
        case Event.MSG:
            Message msg=(Message)evt.getArg();
            FragHeader hdr=(FragHeader)msg.getHeader(this.id);
            if(hdr != null) { // needs to be defragmented
                Message assembled_msg=unfragment(msg, hdr);
                if(assembled_msg != null)
                    up_prot.up(new Event(Event.MSG, assembled_msg));
                return null;
            }
            else {
                num_received_msgs++;
            }
            break;

        case Event.VIEW_CHANGE:
            handleViewChange((View)evt.getArg());
            break;
    }

    return up_prot.up(evt); // Pass up to the layer above us by default
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:FRAG.java

示例9: up

import org.jgroups.Message; //导入方法依赖的package包/类
/**
 * If event is a message, if it is fragmented, re-assemble fragments into big message and pass up the stack.
 */
public Object up(Event evt) {
    switch(evt.getType()) {

        case Event.MSG:
            Message msg=(Message)evt.getArg();
            FragHeader hdr=(FragHeader)msg.getHeader(this.id);
            if(hdr != null) { // needs to be defragmented
                Message assembled_msg=unfragment(msg, hdr);
                if(assembled_msg != null) {
                    if(log.isTraceEnabled()) log.trace("%s: assembled_msg is %s", local_addr, assembled_msg);
                    assembled_msg.setSrc(msg.getSrc()); // needed ? YES, because fragments have a null src !!
                    up_prot.up(new Event(Event.MSG, assembled_msg));
                }
                return null;
            }
            break;

        case Event.VIEW_CHANGE:
            handleViewChange((View)evt.getArg());
            break;
    }

    return up_prot.up(evt); // Pass up to the layer above us by default
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:28,代码来源:FRAG2.java

示例10: up

import org.jgroups.Message; //导入方法依赖的package包/类
public Object up(Event evt) {
    switch(evt.getType()) {
        case Event.MSG:
            Message msg=(Message)evt.getArg();
            ForkHeader hdr=(ForkHeader)msg.getHeader(id);
            if(hdr == null)
                break;
            if(hdr.fork_stack_id == null)
                throw new IllegalArgumentException("header has a null fork_stack_id");
            Protocol bottom_prot=get(hdr.fork_stack_id);
            return bottom_prot != null? bottom_prot.up(evt) : this.unknownForkHandler.handleUnknownForkStack(msg, hdr.fork_stack_id);

        case Event.VIEW_CHANGE:
            for(Protocol bottom: fork_stacks.values())
                bottom.up(evt);
            break;
    }
    return up_prot.up(evt);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:FORK.java

示例11: up

import org.jgroups.Message; //导入方法依赖的package包/类
@Override
public void up(MessageBatch batch) {
    for (Message msg : batch) {
        // If we have a join or merge request --> authenticate, else pass up
        GmsHeader gmsHeader = (GmsHeader) msg.getHeader(GMS_ID);
        if (needsAuthentication(gmsHeader)) {
            SaslHeader saslHeader = (SaslHeader) msg.getHeader(id);
            if (saslHeader == null) {
                log.warn("Found GMS join or merge request but no SASL header");
                sendRejectionMessage(gmsHeader.getType(), batch.sender(), "join or merge without an SASL header");
                batch.remove(msg);
            } else if (!serverChallenge(gmsHeader, saslHeader, msg)) // authentication failed
                batch.remove(msg); // don't pass up
        }
    }

    if (!batch.isEmpty())
        up_prot.up(batch);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:SASL.java

示例12: filter

import org.jgroups.Message; //导入方法依赖的package包/类
private void filter(Message msg, int direction) {
  if (direction == INCOMING) {
    Header h = msg.getHeader(frag2HeaderId);
    boolean copyBuffer = false;
    if (h != null && h instanceof FragHeader) {
      copyBuffer = true;
      // String str = direction == OUTGOING? "sending" : "receiving";
      // logger.debug("{} fragment {} msg buffer hash {} offset {} msg size {} first bytes=\n{}",
      // str, hdr,
      // msg.getRawBuffer().hashCode(), msg.getOffset(), msg.getLength(),
      // GMSUtil.formatBytes(msg.getRawBuffer(), msg.getOffset(),
      // Math.min(200, msg.getLength())));
    } else {
      h = msg.getHeader(unicastHeaderId);
      if (h instanceof UNICAST3.Header) {
        copyBuffer = true;
      } else {
        h = msg.getHeader(nakackHeaderId);
        if (h instanceof NakAckHeader2) {
          copyBuffer = true;
        }
      }
    }
    if (copyBuffer) {
      // JGroups doesn't copy its message buffer when thread pools are
      // disabled. This causes Frag2 fragments to become corrupted
      msg.setBuffer(msg.getBuffer(), 0, msg.getLength());
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:31,代码来源:StatRecorder.java

示例13: 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

示例14: 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

示例15: down

import org.jgroups.Message; //导入方法依赖的package包/类
@Override
public Object down(Event evt) {
    switch (evt.getType()) {
    case Event.SET_LOCAL_ADDRESS:
        local_addr = (Address) evt.getArg();
        break;
    case Event.MSG:
        Message msg = (Message) evt.getArg();
        GmsHeader hdr = (GmsHeader) msg.getHeader(GMS_ID);
        if (needsAuthentication(hdr)) {
            // We are a client who needs to authenticate
            SaslClientContext ctx = null;
            Address remoteAddress = msg.getDest();
            try {
                ctx = new SaslClientContext(saslClientFactory, mech, server_name != null ? server_name : remoteAddress.toString(), client_callback_handler, sasl_props, client_subject);
                sasl_context.put(remoteAddress, ctx);
                ctx.addHeader(msg, null);
            } catch (Exception e) {
                if (ctx != null) {
                    disposeContext(remoteAddress);
                }
                throw new SecurityException(e);
            }
        }
        break;
    }

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


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