Refine search
/** Called by the sender to resend messages for which no ACK has been received yet */ protected void retransmit(Message msg) { if(is_trace) { UnicastHeader3 hdr=msg.getHeader(id); long seqno=hdr != null? hdr.seqno : -1; log.trace("%s --> XMIT(%s: #%d)", local_addr, msg.getDest(), seqno); } down_prot.down(msg); num_xmits++; }
public Object down(Message msg) { if(!bypass) { Address dest = msg.getDest(); if (dest == null) { // mcasts FlushHeader fh =msg.getHeader(this.id); if (fh != null && fh.type == FlushHeader.FLUSH_BYPASS) { return down_prot.down(msg); } else { blockMessageDuringFlush(); } } else { // unicasts are irrelevant in virtual synchrony, let them through return down_prot.down(msg); } } return down_prot.down(msg); }
private void copy(Message msg, int num_copies, Direction direction) { Address dest=msg.getDest(); boolean multicast=dest == null; if((multicast && copy_multicast_msgs) || (!multicast && copy_unicast_msgs)) { for(int i=0; i < num_copies; i++) { Message copy=msg.copy(true); switch(direction) { case UP: up_prot.up(copy); break; case DOWN: down_prot.down(copy); break; } } } } }
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 }
protected void sendResponse(Message rsp, long req_id, boolean is_exception) { Header rsp_hdr=new Header(is_exception? Header.EXC_RSP : Header.RSP, req_id, corr_id); rsp.putHeader(corr_id, rsp_hdr); if(log.isTraceEnabled()) log.trace("sending rsp for %d to %s", req_id, rsp.getDest()); transport.down(rsp); }
public Object down(Message msg) { GmsHeader hdr =msg.getHeader(GMS_ID); Address remoteAddress = msg.getDest(); if (needsAuthentication(hdr, remoteAddress)) { // We are a client who needs to authenticate SaslClientContext ctx = null; 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); } } return down_prot.down(msg); }
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; }
public Object down(Message msg) { if(msg.getDest() != null) return down_prot.down(msg); // only process multicast messages if(next == null) // view hasn'<></> been received yet, use the normal transport return down_prot.down(msg); // we need to copy the message, as we cannot do a msg.setSrc(next): the next retransmission // would use 'next' as destination ! Message copy=msg.copy(true); short hdr_ttl=(short)(loopback? view_size -1 : view_size); DaisyHeader hdr=new DaisyHeader(hdr_ttl); copy.setDest(next); copy.putHeader(getId(), hdr); msgs_sent++; if(loopback) { if(log.isTraceEnabled()) log.trace(new StringBuilder("looping back message ").append(msg)); if(msg.getSrc() == null) msg.setSrc(local_addr); default_pool.execute(() -> up_prot.up(msg)); } return down_prot.down(copy); }
@Override public void members(List<PingData> mbrs) { PhysicalAddress own_physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); PingData data=new PingData(local_addr, false, org.jgroups.util.NameCache.get(local_addr), own_physical_addr); PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name); Set<PhysicalAddress> physical_addrs=mbrs.stream().filter(ping_data -> ping_data != null && ping_data.getPhysicalAddr() != null) .map(PingData::getPhysicalAddr).collect(Collectors.toSet()); for(PhysicalAddress physical_addr: physical_addrs) { if(physical_addr != null && own_physical_addr.equals(physical_addr)) // no need to send the request to myself continue; // the message needs to be DONT_BUNDLE, see explanation above final Message msg=new Message(physical_addr).setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB) .putHeader(this.id, hdr).setBuffer(marshal(data)); log.trace("%s: sending discovery request to %s", local_addr, msg.getDest()); down_prot.down(msg); } }
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; }
protected void forward(final Message msg, long seqno, boolean flush) { Address target=coord; if(target == null) return; byte type=flush? SequencerHeader.FLUSH : SequencerHeader.FORWARD; try { SequencerHeader hdr=new SequencerHeader(type, seqno); Message forward_msg=new Message(target, Util.streamableToBuffer(msg)).putHeader(this.id,hdr); down_prot.down(forward_msg); forwarded_msgs++; } catch(Exception ex) { log.error(Util.getMessage("FailedForwardingMessageTo") + msg.getDest(), ex); } }
protected void getStateFromApplication(Address requester, Digest digest) { StateTransferInfo rsp=(StateTransferInfo)up_prot.up(new Event(Event.GET_APPLSTATE)); byte[] state=rsp.state; if(stats) { num_state_reqs.increment(); if(state != null) num_bytes_sent.add(state.length); avg_state_size=num_bytes_sent.doubleValue() / num_state_reqs.doubleValue(); } Message state_rsp=new Message(requester, state).putHeader(this.id, new StateHeader(StateHeader.STATE_RSP, digest)); log.trace("%s: sending state to %s (size=%s)", local_addr, state_rsp.getDest(), Util.printBytes(state != null? state.length : 0)); down_prot.down(state_rsp); }