public void destroy() { if(top_prot != null) getProtocols().forEach(Protocol::destroy); }
private String printProtocolSpecAsPlainString(boolean print_props) { StringBuilder sb=new StringBuilder(); List<Protocol> protocols=getProtocols(); if(protocols == null) return null; Collections.reverse(protocols); for(Protocol prot: protocols) { sb.append(prot.getClass().getName()).append("\n"); if(print_props) { Map<String,String> tmp=getProps(prot); for(Map.Entry<String,String> entry: tmp.entrySet()) { sb.append(" ").append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); } } } return sb.toString(); }
protected JChannel resetAllStats() { List<Protocol> prots=ch.getProtocolStack().getProtocols(); prots.forEach(Protocol::resetStatistics); return ch.resetStats(); }
/** * Iterates through all the protocols <em>from top to bottom</em> and does the following: * <ol> * <li>Waits until all messages in the down queue have been flushed (ie., size is 0) * <li>Calls stop() on the protocol * </ol> */ public void stopStack(String cluster) { if(stopped) return; getProtocols().forEach(Protocol::stop); TP transport=getTransport(); transport.unregisterProbeHandler(props_handler); stopped=true; }
List<Protocol> protocols=getProtocols();
@Override public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, ChannelFactory factory) throws OperationFailedException { // Create a temporary channel, but don't connect it try (JChannel channel = factory.createChannel(UUID.randomUUID().toString())) { // ProtocolStack.printProtocolSpecAsXML() is very hacky and only works on an uninitialized stack List<Protocol> protocols = channel.getProtocolStack().getProtocols(); Collections.reverse(protocols); ProtocolStack stack = new ProtocolStack(); stack.addProtocols(protocols); return new ModelNode(stack.printProtocolSpecAsXML()); } catch (Exception e) { throw new OperationFailedException(e); } } },
/** * Start all layers. The {@link Protocol#start()} method is called in each protocol, * <em>from top to bottom</em>. * Each layer can perform some initialization, e.g. create a multicast socket */ public void startStack() throws Exception { if(!stopped) return; for(Protocol prot: getProtocols()) prot.start(); TP transport=getTransport(); transport.registerProbeHandler(props_handler); stopped=false; }
public List<Protocol> copyProtocols(ProtocolStack targetStack) throws IllegalAccessException, InstantiationException { List<Protocol> list=getProtocols(); List<Protocol> retval=new ArrayList<>(list.size()); for(Protocol prot: list) {
public void initProtocolStack() throws Exception { List<Protocol> protocols = getProtocols(); Collections.reverse(protocols); for(Protocol prot: protocols) { if(prot.getProtocolStack() == null) prot.setProtocolStack(this); callAfterCreationHook(prot, prot.afterCreationHook()); prot.init(); } }
public void init() throws Exception { List<Protocol> protocols=getProtocols(); Collections.reverse(protocols); top_prot=Configurator.connectProtocols(protocols); top_prot.setUpProtocol(this); this.setDownProtocol(top_prot); bottom_prot=getBottomProtocol(); Configurator.setDefaultValues(protocols); initProtocolStack(); }
/** * Creates a channel from a list of protocols. Note that after a {@link org.jgroups.JChannel#close()}, the protocol * list <em>should not</em> be reused, ie. new JChannel(protocols) would reuse the same protocol list, and this * might lead to problems ! * @param protocols The list of protocols, from bottom to top, ie. the first protocol in the list is the transport, * the last the top protocol * @deprecated Use {@link JChannel#JChannel(List)} instead */ @Deprecated public JChannel(Collection<Protocol> protocols) throws Exception { prot_stack=new ProtocolStack().setChannel(this); for(Protocol prot: protocols) { prot_stack.addProtocol(prot); prot.setProtocolStack(prot_stack); } prot_stack.init(); // Substitute vars with defined system props (if any) List<Protocol> prots=prot_stack.getProtocols(); Map<String,String> map=new HashMap<>(); for(Protocol prot: prots) Configurator.resolveAndAssignFields(prot, map); }
/** * Creates a channel from a list of protocols. Note that after a {@link org.jgroups.JChannel#close()}, the protocol * list <em>should not</em> be reused, ie. new JChannel(protocols) would reuse the same protocol list, and this * might lead to problems ! * @param protocols The list of protocols, from bottom to top, ie. the first protocol in the list is the transport, * the last the top protocol */ public JChannel(List<Protocol> protocols) throws Exception { prot_stack=new ProtocolStack().setChannel(this); for(Protocol prot: protocols) { prot_stack.addProtocol(prot); prot.setProtocolStack(prot_stack); } prot_stack.init(); // Substitute vars with defined system props (if any) List<Protocol> prots=prot_stack.getProtocols(); Map<String,String> map=new HashMap<>(); for(Protocol prot: prots) Configurator.resolveAndAssignFields(prot, map); }
List<Protocol> prots=getProtocols(); Collections.reverse(prots); StringBuilder sb=new StringBuilder();
public static void unregisterChannel(JChannel c, MBeanServer server, String domain, String clusterName) throws Exception { if(clusterName != null) clusterName=ObjectName.quote(clusterName); ProtocolStack stack = c.getProtocolStack(); List<Protocol> protocols = stack.getProtocols(); for (Protocol p : protocols) { if (p.getClass().isAnnotationPresent(MBean.class)) { try { String obj_name=getProtocolRegistrationName(clusterName, domain, p); unregister(p, server, obj_name); } catch (MBeanRegistrationException e) { log.warn("MBean unregistration failed: " + e.getCause()); } } } unregister(c, server, getChannelRegistrationName(c, domain, clusterName)); }
List<Protocol> protocols = stack.getProtocols(); for (Protocol p : protocols) { if (p.getClass().isAnnotationPresent(MBean.class)) {
protected JChannel resetAllStats() { List<Protocol> prots=ch.getProtocolStack().getProtocols(); prots.forEach(Protocol::resetStatistics); return ch.resetStats(); }
public void init() throws Exception { List<Protocol> protocols=getProtocols(); Collections.reverse(protocols); top_prot=Configurator.connectProtocols(protocols); top_prot.setUpProtocol(this); this.setDownProtocol(top_prot); bottom_prot=getBottomProtocol(); Configurator.setDefaultValues(protocols); initProtocolStack(); }
private boolean isDiscardEnabled(TEST_PING discovery) { // Not pretty but since this protocol does not rely on the transport, the // only possible way to discard messages is by hacking the protocol itself. List<Protocol> protocols = discovery.getProtocolStack().getProtocols(); for (Protocol protocol : protocols) { if (protocol instanceof DISCARD) { discovery.discard = (DISCARD) protocol; } } return discovery.discard != null && discovery.discard.isDiscardAll(); }
protected void initializeChannel(Channel channel) { // turn off local message reception channel.setDiscardOwnMessages(true); TP transport = channel.getProtocolStack().getTransport(); // Replace the default thread pool transport.setDefaultThreadPool(executor); for (Protocol protocol : channel.getProtocolStack().getProtocols()) { if (protocol instanceof GMS) { ((GMS) protocol).setPrintLocalAddr(printLocalAddress); } } }
private void observeMembers(Partition partition) { for (JChannel c : channels) { List<Protocol> protocols = c.getProtocolStack().getProtocols(); for (Protocol p : protocols) { if (p instanceof DISCARD) { for (JChannel oc : partition.channels) { ((DISCARD) p).removeIgnoredMember(oc.getAddress()); } } } } }