/** * Finds the first protocol of a list and returns it. Returns null if no protocol can be found * @param classes A list of protocol classes to find * @return Protocol The protocol found */ @SafeVarargs public final <T extends Protocol> T findProtocol(Class<? extends Protocol>... classes) { for(Class<? extends Protocol> clazz: classes) { T prot=findProtocol(clazz); if(prot != null) return prot; } return null; }
/** * Removes a protocol from the stack. Stops the protocol and readjusts the linked lists of protocols. * @param prot_name The name of the protocol. Since all protocol names in a stack have to be unique * (otherwise the stack won't be created), the name refers to just 1 protocol. * @exception Exception Thrown if the protocol cannot be stopped correctly. */ public <T extends Protocol> T removeProtocol(String prot_name) { if(prot_name == null) return null; return removeProtocol((T)findProtocol(prot_name)); }
public void setChannel(JChannel ch) { this.ch=ch; _execProt=ch.getProtocolStack().findProtocol(Executing.class); if(_execProt == null) throw new IllegalStateException("Channel configuration must include a executing protocol " + "(subclass of " + Executing.class.getName() + ")"); }
public <T extends Protocol> T removeProtocol(Class<? extends Protocol> prot) { if(prot == null) return null; return removeProtocol((T)findProtocol(prot)); }
public void setChannel(JChannel ch) { this.ch=ch; counter_prot=ch.getProtocolStack().findProtocol(COUNTER.class); if(counter_prot == null) throw new IllegalStateException("channel configuration must include the COUNTER protocol"); }
public void setChannel(JChannel ch) { this.ch=ch; lock_prot=ch.getProtocolStack().findProtocol(Locking.class); if(lock_prot == null) throw new IllegalStateException("Channel configuration must include a locking protocol " + "(subclass of " + Locking.class.getName() + ")"); }
public void setChannel(JChannel ch) { this.ch=ch; _execProt=ch.getProtocolStack().findProtocol(Executing.class); if(_execProt == null) throw new IllegalStateException("Channel configuration must include a executing protocol " + "(subclass of " + Executing.class.getName() + ")"); }
public void insertProtocolAtTop(Protocol prot) { if(prot == null) throw new IllegalArgumentException("prot needs to be non-null"); // check if prot already exists (we cannot have more than 1 protocol of a given class) Class<? extends Protocol> clazz=prot.getClass(); Protocol existing_instance=findProtocol(clazz); if(existing_instance != null) return; top_prot.up_prot=prot; prot.down_prot=top_prot; prot.up_prot=this; top_prot=prot; log.debug("inserted " + prot + " at the top of the stack"); }
public void insertProtocol(Protocol prot, Position position, Class<? extends Protocol> neighbor_prot) throws Exception { if(neighbor_prot == null) throw new IllegalArgumentException("neighbor_prot is null"); Protocol neighbor=findProtocol(neighbor_prot); if(neighbor == null) throw new IllegalArgumentException("protocol \"" + neighbor_prot + "\" not found in " + stack.printProtocolSpec(false)); if(position == Position.BELOW && neighbor instanceof TP) throw new IllegalArgumentException("\"" + prot + "\" cannot be inserted below the transport (" + neighbor + ")"); insertProtocolInStack(prot, neighbor, position); }
@SafeVarargs public final void insertProtocol(Protocol prot, Position position, Class<? extends Protocol>... neighbor_prots) throws Exception { if(neighbor_prots == null) throw new IllegalArgumentException("neighbor_prots is null"); Protocol neighbor=findProtocol(neighbor_prots); if(neighbor == null) throw new IllegalArgumentException("protocol \"" + Arrays.toString(neighbor_prots) + "\" not found in " + stack.printProtocolSpec(false)); insertProtocolInStack(prot, neighbor, position); }
protected static List<String> getSites(JChannel channel) { RELAY2 relay=channel.getProtocolStack().findProtocol(RELAY2.class); return relay != null? relay.siteNames() : Collections.<String>emptyList(); }
protected static List<String> getSites(JChannel channel) { RELAY2 relay=channel.getProtocolStack().findProtocol(RELAY2.class); return relay != null? relay.siteNames() : new ArrayList<>(0); }
@Override public void getMessageState(InternalDistributedMember target, Map<String, Long> state, boolean includeMulticast) { if (includeMulticast) { NAKACK2 nakack = (NAKACK2) myChannel.getProtocolStack().findProtocol("NAKACK2"); if (nakack != null) { long seqno = nakack.getCurrentSeqno(); state.put("JGroups.mcastState", seqno); } } }
protected static void registerBypasser(AUTH auth) { ASYM_ENCRYPT asym_encr=auth.getProtocolStack().findProtocol(ASYM_ENCRYPT.class); if(asym_encr != null) asym_encr.registerBypasser(BYPASSER_FUNCTION); }
protected static void unregisterBypasser(AUTH auth) { ASYM_ENCRYPT asym_encr=auth.getProtocolStack().findProtocol(ASYM_ENCRYPT.class); if(asym_encr != null) asym_encr.unregisterBypasser(BYPASSER_FUNCTION); }
public void init() { super.init(); fd=(FD)sv.getProtocolStack().findProtocol(FD.class); if(fd == null) { log.info("FD was not found, uninstalling myself (" + getClass().getSimpleName() + ")"); sv.uninstallRule(getClass().getSimpleName()); } }
protected void printConnections() { Protocol prot=channel.getProtocolStack().findProtocol(Util.getUnicastProtocols()); if(prot instanceof UNICAST3) System.out.println(((UNICAST3)prot).printConnections()); }
protected void removeAllConnections() { Protocol prot=channel.getProtocolStack().findProtocol(Util.getUnicastProtocols()); if(prot instanceof UNICAST3) ((UNICAST3)prot).removeAllConnections(); }
@Override public void accept(ChannelFactory factory) { ProtocolStack stack = this.parentChannel.get().getProtocolStack(); FORK fork = (FORK) stack.findProtocol(FORK.class); fork.remove(this.address.getLastElement().getValue()); }
public void init() throws Exception { super.init(); timer=getTransport().getTimer(); if(timeout > 0 && resend_interval > 0 && resend_interval >= timeout) { log.warn(Util.getMessage("RSVP_Misconfig"), resend_interval, timeout); resend_interval=timeout / 3; } handle_unicasts=stack.findProtocol(UNICAST3.class) == null; }