/** Removes and returns all messages which have a header with ID == id */ public Collection<Message> getMatchingMessages(final short id, boolean remove) { return map((msg, batch) -> { if(msg != null && msg.getHeader(id) != null) { if(remove) batch.remove(msg); return msg; } return null; }); }
public void up(MessageBatch batch) { for(Message msg: batch) { for(Predicate<Message> pred: up_filters) { if(pred.test(msg)) { dropped(msg, false); batch.remove(msg); break; } } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { if(bypass) { up_prot.up(batch); return; } for(Message msg: batch) { if(msg.getHeader(id) != null) { batch.remove(msg); up(msg); // let the existing code handle this } else { if(msg.getDest() != null) { // skip unicast messages, process them right away batch.remove(msg); up_prot.up(msg); } } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { Header hdr=msg.getHeader(id); if(hdr != null) handleMessage(msg, hdr); } batch.remove(msg -> msg.getHeader(id) != null); // remove all messages with NAMING headers if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { DhHeader hdr=msg.getHeader(id); if(hdr != null) { batch.remove(msg); handle(hdr, msg.src()); } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { try { Message deserialized_msg=deserialize(msg); batch.replace(msg, deserialized_msg); } catch(Exception e) { log.error("failed deserializing message", e); batch.remove(msg); } } if(!batch.isEmpty()) up_prot.up(batch); }
public void receiveMessageBatch(MessageBatch batch) { for(Message msg : batch) { Header hdr=msg.getHeader(this.corr_id); if(hdr == null || hdr.corrId != this.corr_id) // msg was sent by a different request corr in the same stack continue; if(hdr instanceof MultiDestinationHeader) { // if we are part of the exclusion list, then we discard the request (addressed to different members) Address[] exclusion_list=((MultiDestinationHeader)hdr).exclusion_list; if(exclusion_list != null && local_addr != null && Util.contains(local_addr, exclusion_list)) { log.trace("%s: dropped req from %s as we are in the exclusion list, hdr=%s", local_addr, msg.src(), hdr); batch.remove(msg); continue; // don't pass this message further up } } dispatch(msg, hdr); } }
public void up(MessageBatch batch) { for(Message msg: batch) { FragHeader hdr=msg.getHeader(this.id); if(hdr != null) { // needs to be defragmented Message assembled_msg=unfragment(msg,hdr); if(assembled_msg != null) // the reassembled msg has to be add in the right place (https://issues.jboss.org/browse/JGRP-1648), // and canot be added to the tail of the batch ! batch.replace(msg, assembled_msg); else batch.remove(msg); } } if(!batch.isEmpty()) up_prot.up(batch); }
ForkHeader hdr=msg.getHeader(id); if(hdr != null) { batch.remove(msg); List<Message> list=map.computeIfAbsent(hdr.fork_stack_id, k -> new ArrayList<>()); list.add(msg);
FORK.ForkHeader hdr=msg.getHeader(FORK.ID); if(hdr != null) { batch.remove(msg); List<Message> list=map.computeIfAbsent(hdr.getForkChannelId(), k -> new ArrayList<>()); list.add(msg);
public void up(MessageBatch batch) { for(Message msg: batch) { // If we have a join or merge request --> authenticate, else pass up GMS.GmsHeader gms_hdr=getGMSHeader(msg); if(gms_hdr != null && needsAuthentication(gms_hdr)) { AuthHeader auth_hdr=msg.getHeader(id); if(auth_hdr == null) { log.warn("%s: found GMS join or merge request from %s but no AUTH header", local_addr, batch.sender()); sendRejectionMessage(gms_hdr.getType(), batch.sender(), "join or merge without an AUTH header"); batch.remove(msg); } else if(!handleAuthHeader(gms_hdr, auth_hdr, msg)) // authentication failed batch.remove(msg); // don't pass up } } if(!batch.isEmpty()) up_prot.up(batch); }
@Override public void up(MessageBatch batch) { for (Message msg : batch) { // If we have a join or merge request --> authenticate, else pass up GmsHeader gmsHeader =msg.getHeader(GMS_ID); Address remoteAddress = msg.getSrc(); if (needsAuthentication(gmsHeader, remoteAddress)) { 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); }
public void up(MessageBatch batch) { for(Message msg: batch) { StompHeader hdr=msg.getHeader(id); if(hdr != null || forward_non_client_generated_msgs) { try { batch.remove(msg); up(msg); } catch(Throwable t) { log.error(Util.getMessage("FailedPassingUpMessage"), t); } } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { if(msg.isFlagSet(Message.Flag.NO_TOTAL_ORDER) || msg.isFlagSet(Message.Flag.OOB) || msg.getHeader(id) == null) continue; batch.remove(msg); // simplistic implementation try { up(msg); } catch(Throwable t) { log.error(Util.getMessage("FailedPassingUpMessage"), t); } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { if(msg.isFlagSet(Message.Flag.NO_TOTAL_ORDER) || msg.isFlagSet(Message.Flag.OOB) || msg.getHeader(id) == null) continue; batch.remove(msg); // simplistic implementation try { up(msg); } catch(Throwable t) { log.error(Util.getMessage("FailedPassingUpMessage"), t); } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { Frag3Header hdr=msg.getHeader(this.id); if(hdr != null) { // needs to be defragmented Message assembled_msg=unfragment(msg,hdr); if(assembled_msg != null) { // the reassembled msg has to be add in the right place (https://issues.jboss.org/browse/JGRP-1648), // and canot be added to the tail of the batch ! assembled_msg.setSrc(batch.sender()); batch.replace(msg, assembled_msg); avg_size_up.add(assembled_msg.length()); } else batch.remove(msg); } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { StableHeader hdr; for(Message msg: batch) { // remove and handle messages with flow control headers (STABLE_GOSSIP, STABILITY) if((hdr=msg.getHeader(id)) != null) { batch.remove(msg); handleUpEvent(hdr, batch.sender(), readDigest(msg.getRawBuffer(), msg.getOffset(), msg.getLength())); } } // only if message counting is on, and only for multicast messages (http://jira.jboss.com/jira/browse/JGRP-233) if(max_bytes > 0 && batch.dest() == null && !batch.isEmpty()) { boolean send_stable_msg=false; received.lock(); try { num_bytes_received+=batch.length(); if(num_bytes_received >= max_bytes) { log.trace("max_bytes has been reached (%s, bytes received=%s): triggers stable msg", max_bytes, num_bytes_received); num_bytes_received=0; send_stable_msg=true; } } finally { received.unlock(); } if(send_stable_msg) sendStableMessage(true); } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { FragHeader hdr=msg.getHeader(this.id); if(hdr != null) { // needs to be defragmented Message assembled_msg=unfragment(msg,hdr); if(assembled_msg != null) { // the reassembled msg has to be add in the right place (https://issues.jboss.org/browse/JGRP-1648), // and canot be added to the tail of the batch ! assembled_msg.setSrc(batch.sender()); batch.replace(msg, assembled_msg); avg_size_up.add(assembled_msg.length()); } else batch.remove(msg); } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { RelayHeader hdr=msg.getHeader(getId()); if(hdr != null) { batch.remove(msg); try { handleUpEvent(msg, hdr); continue; // fix for https://issues.jboss.org/browse/JGRP-2073 } catch(Throwable t) { log.error(Util.getMessage("FailedProcessingMessage"), t); } } // Leave the messages in the batch: they're going to be forwarded, but we also need to deliver them locally if(is_coord && relay && msg.dest() == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) { Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks try { byte[] buf=Util.streamableToByteBuffer(tmp); forward(buf, 0, buf.length); } catch(Exception e) { log.warn("failed relaying message", e); } } } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { for(Message msg: batch) { Relay2Header hdr=msg.getHeader(id); Address dest=msg.getDest(); if(hdr == null) { // forward a multicast message to all bridges except myself, then pass up if(dest == null && is_site_master && relay_multicasts && !msg.isFlagSet(Message.Flag.NO_RELAY)) { Address src=msg.getSrc(); Address sender=new SiteUUID((UUID)msg.getSrc(), NameCache.get(msg.getSrc()), site); if(src instanceof ExtendedUUID) ((SiteUUID)sender).addContents((ExtendedUUID)src); sendToBridges(sender, msg, site); } } else { // header is not null batch.remove(msg); // message is consumed if(dest != null) handleMessage(hdr, msg); else deliver(null, hdr.original_sender, msg); } } if(!batch.isEmpty()) up_prot.up(batch); }