protected void sendToSingleMember(Address dest, byte[] buf, int offset, int length) throws Exception { Map<Address,SHARED_LOOPBACK> dests=routing_table.get(cluster_name); if(dests == null) { log.trace("no destination found for " + cluster_name); return; } SHARED_LOOPBACK target=dests.get(dest); if(target == null) { log.trace("destination address " + dest + " not found"); return; } target.receive(local_addr, buf, offset, length); }
public String getInfo() { return toString(); }
public void destroy() { super.destroy(); // We cannot clear the routing table, as it is shared between channels, and so we would clear the routing for // a different channel, too ! unregister(cluster_name, local_addr); }
public static List<PingData> getDiscoveryResponsesFor(String cluster_name) { if(cluster_name == null) return null; Map<Address,SHARED_LOOPBACK> mbrs=routing_table.get(new AsciiString(cluster_name)); List<PingData> rsps=new ArrayList<>(mbrs != null? mbrs.size() : 0); if(mbrs != null) { for(Map.Entry<Address,SHARED_LOOPBACK> entry: mbrs.entrySet()) { Address addr=entry.getKey(); SHARED_LOOPBACK slp=entry.getValue(); PingData data=new PingData(addr, slp.isServer(), NameCache.get(addr), null).coord(slp.isCoord()); rsps.add(data); } } return rsps; }
protected static Protocol[] props() { return new Protocol[]{ new SHARED_LOOPBACK().setValue("bundler_type", "sender-sends").setValue("ignore_dont_bundle", false), new SHARED_LOOPBACK_PING(), new NAKACK2(), new UNICAST3().setValue("conn_expiry_timeout", 0).setValue("conn_close_timeout", 0), new STABLE(), new GMS()}; } }
public Object down(Event evt) { Object retval=super.down(evt); switch(evt.getType()) { case Event.CONNECT: register(channel_name, local_addr, this); break; case Event.DISCONNECT: unregister(channel_name, local_addr); break; } return retval; }
public Object down(Event evt) { Object retval=super.down(evt); switch(evt.getType()) { case Event.CONNECT: case Event.CONNECT_WITH_STATE_TRANSFER: case Event.CONNECT_USE_FLUSH: case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH: register(cluster_name, local_addr, this); break; case Event.SET_LOCAL_ADDRESS: local_addr=evt.getArg(); break; case Event.BECOME_SERVER: // called after client has joined and is fully working group member is_server=true; break; case Event.VIEW_CHANGE: case Event.TMP_VIEW: curr_view=evt.getArg(); Address[] mbrs=((View)evt.getArg()).getMembersRaw(); is_coord=local_addr != null && mbrs != null && mbrs.length > 0 && local_addr.equals(mbrs[0]); break; case Event.GET_PING_DATA: return getDiscoveryResponsesFor(evt.getArg()); // don't pass further down } return retval; }
public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws Exception { sendToSingleMember(dest, data, offset, length); }
/** * Returns a default stack for testing with transport = SHARED_LOOPBACK * @param additional_protocols Any number of protocols to add to the top of the returned protocol list * @return */ public static Protocol[] getTestStack(Protocol... additional_protocols) { Protocol[] protocols={ new SHARED_LOOPBACK(), new SHARED_LOOPBACK_PING(), new NAKACK2(), new UNICAST3(), new STABLE(), new GMS().joinTimeout(1000), new FRAG2().fragSize(8000) }; if(additional_protocols == null) return protocols; Protocol[] tmp=Arrays.copyOf(protocols,protocols.length + additional_protocols.length); System.arraycopy(additional_protocols, 0, tmp, protocols.length, additional_protocols.length); return tmp; }
public Object down(Event evt) { Object retval=super.down(evt); switch(evt.getType()) { case Event.CONNECT: case Event.CONNECT_WITH_STATE_TRANSFER: case Event.CONNECT_USE_FLUSH: case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH: register(cluster_name, local_addr, this); break; case Event.SET_LOCAL_ADDRESS: local_addr=evt.getArg(); break; case Event.BECOME_SERVER: // called after client has joined and is fully working group member is_server=true; break; case Event.VIEW_CHANGE: case Event.TMP_VIEW: curr_view=evt.getArg(); Address[] mbrs=((View)evt.getArg()).getMembersRaw(); is_coord=local_addr != null && mbrs != null && mbrs.length > 0 && local_addr.equals(mbrs[0]); break; case Event.GET_PING_DATA: return getDiscoveryResponsesFor(evt.getArg()); // don't pass further down } return retval; }
protected static Protocol[] props() { return new Protocol[]{ new SHARED_LOOPBACK().setValue("bundler_type", "sender-sends").setValue("ignore_dont_bundle", false), new SHARED_LOOPBACK_PING(), new NAKACK2(), new UNICAST3().setValue("conn_expiry_timeout", 0).setValue("conn_close_timeout", 0), new STABLE(), new GMS()}; } }
public static List<PingData> getDiscoveryResponsesFor(String cluster_name) { if(cluster_name == null) return null; Map<Address,SHARED_LOOPBACK> mbrs=routing_table.get(new AsciiString(cluster_name)); List<PingData> rsps=new ArrayList<>(mbrs != null? mbrs.size() : 0); if(mbrs != null) { for(Map.Entry<Address,SHARED_LOOPBACK> entry: mbrs.entrySet()) { Address addr=entry.getKey(); SHARED_LOOPBACK slp=entry.getValue(); PingData data=new PingData(addr, slp.isServer(), NameCache.get(addr), null).coord(slp.isCoord()); rsps.add(data); } } return rsps; }
public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws Exception { sendToSingleMember(dest, data, offset, length); }
/** * Returns a default stack for testing with transport = SHARED_LOOPBACK * @param additional_protocols Any number of protocols to add to the top of the returned protocol list * @return */ public static Protocol[] getTestStack(Protocol... additional_protocols) { Protocol[] protocols={ new SHARED_LOOPBACK(), new SHARED_LOOPBACK_PING(), new NAKACK2(), new UNICAST3(), new STABLE(), new GMS().joinTimeout(1000), new FRAG2().fragSize(8000) }; if(additional_protocols == null) return protocols; Protocol[] tmp=Arrays.copyOf(protocols,protocols.length + additional_protocols.length); System.arraycopy(additional_protocols, 0, tmp, protocols.length, additional_protocols.length); return tmp; }
public void sendMulticast(byte[] data, int offset, int length) throws Exception { Map<Address,SHARED_LOOPBACK> dests=routing_table.get(this.cluster_name); if(dests == null) { log.trace("no destination found for " + this.cluster_name); return; } for(Map.Entry<Address,SHARED_LOOPBACK> entry: dests.entrySet()) { Address dest=entry.getKey(); SHARED_LOOPBACK target=entry.getValue(); if(Objects.equals(local_addr, dest)) continue; // message was already looped back try { target.receive(local_addr, data, offset, length); } catch(Throwable t) { log.error(Util.getMessage("FailedSendingMessageTo") + dest, t); } } }
public void stop() { super.stop(); is_server=is_coord=false; unregister(cluster_name, local_addr); }
public String getInfo() { return toString(); }
public void sendToSingleMember(Address dest, byte[] data, int offset, int length) throws Exception { Map<Address,SHARED_LOOPBACK> dests=routing_table.get(channel_name); if(dests == null) { if(log.isWarnEnabled()) log.warn("no destination found for " + channel_name); return; } SHARED_LOOPBACK target=dests.get(dest); if(target == null) { if(log.isWarnEnabled()) log.warn("destination address " + dest + " not found"); return; } target.receive(dest, local_addr, data, offset, length); }
public void destroy() { super.destroy(); // We cannot clear the routing table, as it is shared between channels, and so we would clear the routing for // a different channel, too ! unregister(cluster_name, local_addr); }
public String getInfo() { return toString(); }