org.jgroups.Message.setFlag()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(262)

本文整理了Java中org.jgroups.Message.setFlag()方法的一些代码示例,展示了Message.setFlag()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setFlag()方法的具体详情如下:
包路径:org.jgroups.Message
类名称:Message
方法名:setFlag

Message.setFlag介绍

[英]Sets the flags from a short. Not recommended (use #setFlag(org.jgroups.Message.Flag...) instead), as the internal representation of flags might change anytime.
[中]

代码示例

代码示例来源:origin: wildfly/wildfly

public void sendClose(Address dest, short conn_id) {
  Message msg=new Message(dest).setFlag(Message.Flag.INTERNAL).putHeader(id, UnicastHeader3.createCloseHeader(conn_id));
  log.trace("%s --> CLOSE(%s, conn-id=%d)", local_addr, dest, conn_id);
  down_prot.down(msg);
}

代码示例来源:origin: wildfly/wildfly

protected void send(Address target, Object payload, byte header, Message.Flag ... flags) throws Exception {
  Message msg=new Message(target, payload);
  if(flags != null)
    for(Message.Flag flag: flags)
      msg.setFlag(flag);
  if(header > 0)
    msg.putHeader(ID, new MPerfHeader(header));
  channel.send(msg);
}

代码示例来源:origin: wildfly/wildfly

public void run() {
  Message heartbeat=new Message().setFlag(Message.Flag.INTERNAL).putHeader(id, new HeartbeatHeader());
  down_prot.down(heartbeat);
  num_heartbeats_sent++;
  log.trace("Sent heartbeat");
}

代码示例来源:origin: wildfly/wildfly

public void run() {
  Message heartbeat=new Message().setFlag(Message.Flag.INTERNAL).putHeader(id, new HeartbeatHeader());
  down_prot.down(heartbeat);
  num_heartbeats_sent++;
  log.trace("Sent heartbeat");
}

代码示例来源:origin: wildfly/wildfly

protected void sendHeartbeatResponse(Address dest) {
  Message hb_ack=new Message(dest).setFlag(Message.Flag.INTERNAL);
  FdHeader tmp_hdr=new FdHeader(FdHeader.HEARTBEAT_ACK);
  tmp_hdr.from=local_addr;
  hb_ack.putHeader(this.id, tmp_hdr);
  down_prot.down(hb_ack);
}

代码示例来源:origin: wildfly/wildfly

protected void sendViewAck(Address dest) {
  Message view_ack=new Message(dest).setFlag(OOB, INTERNAL)
   .putHeader(this.id, new GmsHeader(GmsHeader.VIEW_ACK));
  down_prot.down(view_ack);
}

代码示例来源:origin: wildfly/wildfly

protected void sendRequestForFirstSeqno(Address dest) {
  if(last_sync_sent.addIfAbsentOrExpired(dest)) {
    Message msg=new Message(dest).setFlag(Message.Flag.OOB)
     .putHeader(this.id, UnicastHeader3.createSendFirstSeqnoHeader(timestamper.incrementAndGet()));
    log.trace("%s --> SEND_FIRST_SEQNO(%s)", local_addr, dest);
    down_prot.down(msg);
  }
}

代码示例来源:origin: wildfly/wildfly

protected void sendLockInfoRequestTo(Buffer buf, Address[] mbrs, Address exclude) {
  Stream.of(mbrs).filter(m -> m != null && !Objects.equals(m, exclude)).forEach(dest -> {
    Message msg=new Message(dest, buf).putHeader(id, new LockingHeader());
    if(bypass_bundling)
      msg.setFlag(Message.Flag.DONT_BUNDLE);
    try {
      down_prot.down(msg);
    }
    catch(Throwable t) {
      log.error("%s: failed sending LOCK_INFO_REQ to %s: %s", local_addr, dest, t);
    }
  });
}

代码示例来源:origin: wildfly/wildfly

public void run() {
  FD.FdHeader hdr;
  synchronized(suspected_members) {
    if(suspected_members.isEmpty()) {
      stop();
      return;
    }
    hdr=new FdHeader(FdHeader.SUSPECT);
    hdr.mbrs=new ArrayList<>(suspected_members);
    hdr.from=local_addr;
  }
  Message suspect_msg=new Message().setFlag(Message.Flag.INTERNAL).putHeader(id, hdr);
  log.trace("%s: broadcasting SUSPECT message (suspects=%s)", local_addr, suspected_members);
  down_prot.down(suspect_msg);
}

代码示例来源:origin: wildfly/wildfly

/**
 Sends or broadcasts a I_HAVE_SOCK response. If 'dst' is null, the reponse will be broadcast, otherwise
 it will be unicast back to the requester
 */
protected void sendIHaveSockMessage(Address dst, Address mbr, IpAddress addr) {
  Message msg=new Message(dst).setFlag(Message.Flag.INTERNAL).setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
  FdHeader hdr=new FdHeader(FdHeader.I_HAVE_SOCK, mbr);
  hdr.sock_addr=addr;
  msg.putHeader(this.id, hdr);
  down_prot.down(msg);
}

代码示例来源:origin: wildfly/wildfly

protected void sendJoinResponse(Buffer marshalled_rsp, Address dest) {
  Message m=new Message(dest, marshalled_rsp).putHeader(this.id, new GmsHeader(GmsHeader.JOIN_RSP))
   .setFlag(OOB, INTERNAL);
  getDownProtocol().down(m);
}

代码示例来源:origin: wildfly/wildfly

public void run() {
  log.trace("%s: broadcasting SUSPECT message (suspected_mbrs=%s)", local_addr, suspects);
  FdHeader hdr;
  synchronized(suspects) {
    if(suspects.isEmpty()) {
      stopTask();
      return;
    }
    hdr=new FdHeader(FdHeader.SUSPECT).mbrs(new HashSet<>(suspects));
  }
  Message suspect_msg=new Message().setFlag(Message.Flag.INTERNAL).putHeader(id, hdr); // mcast SUSPECT to all members
  down_prot.down(suspect_msg);
}

代码示例来源:origin: wildfly/wildfly

protected void sendCredit(Address dest, long credits) {
  if(log.isTraceEnabled())
    log.trace("sending %d credits to %s", credits, dest);
  Message msg=new Message(dest, longToBuffer(credits))
   .setFlag(Message.Flag.OOB, Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE)
   .putHeader(this.id,getReplenishHeader());
  down_prot.down(msg);
  num_credit_responses_sent++;
}

代码示例来源:origin: wildfly/wildfly

private void sendLeaveResponses(Collection<Address> leaving_members) {
  for(Address address: leaving_members){
    Message msg=new Message(address).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL, Message.Flag.NO_RELIABILITY)
     .putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.LEAVE_RSP));
    log.trace("%s: sending LEAVE response to %s", gms.local_addr, address);
    gms.getDownProtocol().down(msg);
  }
}

代码示例来源:origin: wildfly/wildfly

protected void send(Address dest, Request req) {
  Message msg=new Message(dest, Util.streamableToBuffer(req)).putHeader(id, new LockingHeader());
  if(bypass_bundling)
    msg.setFlag(Message.Flag.DONT_BUNDLE);
  log.trace("%s --> %s: %s", local_addr, dest == null? "ALL" : dest, req);
  try {
    down_prot.down(msg);
  }
  catch(Exception ex) {
    log.error("%s: failed sending %s request: %s", local_addr, req.type, ex);
  }
}

代码示例来源:origin: wildfly/wildfly

protected void sendAck(Address dst, long seqno, short conn_id) {
  if(!running) // if we are disconnected, then don't send any acks which throw exceptions on shutdown
    return;
  Message ack=new Message(dst).setFlag(Message.Flag.INTERNAL).
   putHeader(this.id, UnicastHeader3.createAckHeader(seqno, conn_id, timestamper.incrementAndGet()));
  if(is_trace)
    log.trace("%s --> ACK(%s: #%d)", local_addr, dst, seqno);
  try {
    down_prot.down(ack);
    num_acks_sent++;
  }
  catch(Throwable t) {
    log.error(Util.getMessage("FailedSendingAck"), local_addr, seqno, dst, t);
  }
}

代码示例来源:origin: wildfly/wildfly

protected void broadcastUnuspectMessage(Address mbr) {
  if(mbr == null) return;
  log.debug("%s: broadcasting unsuspect(%s)", local_addr, mbr);
  // 1. Send a SUSPECT message right away; the broadcast task will take some time to send it (sleeps first)
  FdHeader hdr=new FdHeader(FdHeader.UNSUSPECT).mbrs(Collections.singleton(mbr));
  Message suspect_msg=new Message().setFlag(Message.Flag.INTERNAL).putHeader(this.id, hdr);
  down_prot.down(suspect_msg);
}

代码示例来源:origin: wildfly/wildfly

protected void multicastOwnMapping() {
  String logical_name=NameCache.get(local_addr);
  if(logical_name != null) {
    Message msg=new Message(null).setFlag(Message.Flag.OOB).setTransientFlag(Message.TransientFlag.DONT_LOOPBACK)
     .putHeader(id, new Header(Type.CACHE_RSP, local_addr, logical_name));
    down_prot.down(msg);
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * We cannot send this request as OOB message, as the credit request needs to queue up behind the regular messages;
 * if a receiver cannot process the regular messages, that is a sign that the sender should be throttled !
 * @param dest The member to which we send the credit request
 * @param credits_needed The number of bytes (of credits) left for dest
 */
protected void sendCreditRequest(final Address dest, long credits_needed) {
  if(log.isTraceEnabled())
    log.trace("sending request for %d credits to %s", credits_needed, dest);
  Message msg=new Message(dest, longToBuffer(credits_needed))
   .setFlag(Message.Flag.OOB, Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE)
   .putHeader(this.id, getCreditRequestHeader());
  down_prot.down(msg);
  num_credit_requests_sent++;
}

代码示例来源:origin: wildfly/wildfly

protected void send(Address dest, Buffer buffer) {
  try {
    Message rsp_msg=new Message(dest, buffer).putHeader(id, new CounterHeader());
    if(bypass_bundling)
      rsp_msg.setFlag(Message.Flag.DONT_BUNDLE);
    down_prot.down(rsp_msg);
  }
  catch(Exception ex) {
    log.error(Util.getMessage("FailedSendingMessageTo") + dest + ": " + ex);
  }
}

相关文章