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


Java Message.getDest方法代码示例

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


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

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

示例2: up

import org.jgroups.Message; //导入方法依赖的package包/类
public void up(MessageBatch batch) {
    boolean copy=(copy_multicast_msgs || copy_unicast_msgs) && incoming_copies > 0;
    if(copy) {
        List<Message> copies=new ArrayList<>();
        for(Message msg: batch) {
            Address dest=msg.getDest();
            boolean multicast=dest == null;
            if((multicast && copy_multicast_msgs) ||  (!multicast && copy_unicast_msgs)) {
                for(int i=0; i < incoming_copies; i++)
                    copies.add(msg.copy(true));
            }
        }
        for(Message copied_msg: copies)
            batch.add(copied_msg);
    }

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

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

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

示例5: fragment

import org.jgroups.Message; //导入方法依赖的package包/类
/**
 * Send all fragments as separate messages (with same ID !).
 * Example:
 * <pre>
 * Given the generated ID is 2344, number of fragments=3, message {dst,src,buf}
 * would be fragmented into:
 * <p/>
 * [2344,3,0]{dst,src,buf1},
 * [2344,3,1]{dst,src,buf2} and
 * [2344,3,2]{dst,src,buf3}
 * </pre>
 */
private void fragment(Message msg, long size) {
    Address            dest=msg.getDest(), src=msg.getSrc();
    long               frag_id=curr_id.getAndIncrement(); // used as seqnos
    int                num_frags;

    try {
        // write message into a byte buffer and fragment it
        ByteArrayDataOutputStream dos=new ByteArrayDataOutputStream((int)(size + 50));
        msg.writeTo(dos);
        byte[] buffer=dos.buffer();
        byte[][] fragments=Util.fragmentBuffer(buffer, frag_size, dos.position());
        num_frags=fragments.length;
        num_sent_frags+=num_frags;

        if(log.isTraceEnabled()) {
            StringBuilder sb=new StringBuilder();
            sb.append("fragmenting packet to ").append(dest != null ? dest.toString() : "<all members>");
            sb.append(" (size=").append(buffer.length).append(") into ").append(num_frags);
            sb.append(" fragment(s) [frag_size=").append(frag_size).append(']');
            log.trace(sb.toString());
        }

        for(int i=0; i < num_frags; i++) {
            Message frag_msg=new Message(dest, src, fragments[i]);
            FragHeader hdr=new FragHeader(frag_id, i, num_frags);
            frag_msg.putHeader(this.id, hdr);
            Event evt=new Event(Event.MSG, frag_msg);
            down_prot.down(evt);
        }
    }
    catch(Exception e) {
        log.error("exception occurred trying to fragment message", e);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:47,代码来源:FRAG.java

示例6: fragment

import org.jgroups.Message; //导入方法依赖的package包/类
/** Send all fragments as separate messages (with same ID !).
 Example:
 <pre>
 Given the generated ID is 2344, number of fragments=3, message {dst,src,buf}
 would be fragmented into:

 [2344,3,0]{dst,src,buf1},
 [2344,3,1]{dst,src,buf2} and
 [2344,3,2]{dst,src,buf3}
 </pre>
 */
protected void fragment(Message msg) {
    try {
        byte[] buffer=msg.getRawBuffer();
        final List<Range> fragments=Util.computeFragOffsets(msg.getOffset(), msg.getLength(), frag_size);
        int num_frags=fragments.size();
        num_frags_sent.addAndGet(num_frags);

        if(log.isTraceEnabled()) {
            Address dest=msg.getDest();
            log.trace("%s: fragmenting message to %s (size=%d) into %d fragment(s) [frag_size=%d]",
                      local_addr, dest != null ? dest : "<all>", msg.getLength(), num_frags, frag_size);
        }

        long frag_id=getNextId(); // used as a seqno
        for(int i=0; i < num_frags; i++) {
            Range r=fragments.get(i);
            // don't copy the buffer, only src, dest and headers. Only copy the headers one time !
            Message frag_msg=msg.copy(false, i == 0);
            frag_msg.setBuffer(buffer, (int)r.low, (int)r.high);
            FragHeader hdr=new FragHeader(frag_id, i, num_frags);
            frag_msg.putHeader(this.id, hdr);
            down_prot.down(new Event(Event.MSG, frag_msg));
        }
    }
    catch(Exception e) {
        log.error("%s: fragmentation failure: %s", local_addr, e);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:40,代码来源:FRAG2.java

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

示例8: writeMessage

import org.jgroups.Message; //导入方法依赖的package包/类
protected static final void writeMessage(final Message msg, DataOutputStream out) throws Exception {
    byte flags=0;
    if(msg.getDest() == null)
        flags+=(byte)2;
    out.writeShort(Version.version); // write the version
    out.writeByte(flags);
    msg.writeTo(out);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:UnicastTestTcp.java

示例9: writeMessage

import org.jgroups.Message; //导入方法依赖的package包/类
protected Buffer writeMessage(final Message msg) throws Exception {
    dos.position(0);
    byte flags=0;
    dos.writeShort(Version.version); // write the version
    if(msg.getDest() == null)
        flags+=(byte)2;
    dos.writeByte(flags);
    msg.writeTo(dos);
    return new Buffer(dos.buffer(), 0, dos.position());
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:11,代码来源:UnicastTestTcpSlow.java

示例10: marshal

import org.jgroups.Message; //导入方法依赖的package包/类
private static Buffer marshal(Message msg) throws Exception {
    ByteArrayDataOutputStream dos=new ByteArrayDataOutputStream((int)(msg.size() + 50));
    Address dest=msg.getDest();
    boolean multicast=dest == null;
    writeMessage(msg, dos, multicast);
    return dos.getBuffer();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:8,代码来源:MessageSizeTest.java

示例11: updateStats

import org.jgroups.Message; //导入方法依赖的package包/类
private void updateStats(Message msg, short direction) {
    int     length;
    HashMap map;
    boolean mcast;
    Address dest, src;

    if(msg == null) return;
    length=msg.getLength();
    dest=msg.getDest();
    src=msg.getSrc();
    mcast=dest == null;

    if(direction == UP) { // received
        received_msgs++;
        received_bytes+=length;
        if(mcast) {
            received_mcasts++;
            received_mcast_bytes+=length;
        }
        else {
            received_ucasts++;
            received_ucast_bytes+=length;
        }
    }
    else {                // sent
        sent_msgs++;
        sent_bytes+=length;
        if(mcast) {
            sent_mcasts++;
            sent_mcast_bytes+=length;
        }
        else {
            sent_ucasts++;
            sent_ucast_bytes+=length;
        }
    }

    Address key=direction == UP? src : dest;
    map=direction == UP? received : sent;
    Entry entry=(Entry)map.get(key);
    if(entry == null) {
        entry=new Entry();
        map.put(key, entry);
    }
    entry.msgs++;
    entry.bytes+=length;
    if(mcast) {
        entry.mcasts++;
        entry.mcast_bytes+=length;
    }
    else {
        entry.ucasts++;
        entry.ucast_bytes+=length;
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:56,代码来源:STATS.java


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