protected final JChannel init(ProtocolStackConfigurator configurator) throws Exception { List<ProtocolConfiguration> configs=configurator.getProtocolStack(); // replace vars with system props configs.forEach(ProtocolConfiguration::substituteVariables); prot_stack=new ProtocolStack(this); prot_stack.setup(configs); // Setup protocol stack (creates protocol, calls init() on them) return this; }
protected final JChannel init(JChannel ch) throws Exception { if(ch == null) throw new IllegalArgumentException("channel is null"); prot_stack=new ProtocolStack(this); prot_stack.setup(ch.getProtocolStack()); // Setup protocol stack (creates protocol, calls init() on them) return this; }
@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); } } },
/** * 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); }
protected final JChannel init(JChannel ch) throws Exception { if(ch == null) throw new IllegalArgumentException("channel is null"); prot_stack=new ProtocolStack(this); prot_stack.setup(ch.getProtocolStack()); // Setup protocol stack (creates protocol, calls init() on them) return this; }
protected final JChannel init(ProtocolStackConfigurator configurator) throws Exception { List<ProtocolConfiguration> configs=configurator.getProtocolStack(); // replace vars with system props configs.forEach(ProtocolConfiguration::substituteVariables); prot_stack=new ProtocolStack(this); prot_stack.setup(configs); // Setup protocol stack (creates protocol, calls init() on them) return this; }
protected final void init(ProtocolStackConfigurator configurator) throws ChannelException { if(log.isInfoEnabled()) log.info("JGroups version: " + Version.description); ConfiguratorFactory.substituteVariables(configurator); // replace vars with system props props=configurator.getProtocolStackString(); prot_stack=new ProtocolStack(this, props); try { prot_stack.setup(); // Setup protocol stack (create layers, queues between them } catch(Throwable e) { throw new ChannelException("unable to setup the protocol stack", e); } }
@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); } } },
public ProtocolTester(String prot_spec, Protocol harness) throws Exception { if(prot_spec == null || harness == null) throw new Exception("ProtocolTester(): prot_spec or harness is null"); props=prot_spec; this.harness=harness; props="LOOPBACK:" + props; // add a loopback layer at the bottom of the stack config=new Configurator(); ProtocolStack stack=new ProtocolStack(); top=config.setupProtocolStack(props, stack); harness.setDownProtocol(top); top.setUpProtocol(harness); // +++ bottom=getBottomProtocol(top); // has to be set after StartProtocolStack, otherwise the up and down handler threads in the harness // will be started as well (we don't want that) ! // top.setUpProtocol(harness); }
/** * 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); }
@Override public JChannel createChannel(String id) throws Exception { JGroupsLogger.ROOT_LOGGER.debugf("Creating fork channel %s from channel %s", id, this.channel.getClusterName()); String stackName = this.protocols.isEmpty() ? this.channel.getClusterName() : id; ProtocolStackConfiguration forkStack = new ForkProtocolStackConfiguration(stackName, this.parentFactory.getProtocolStackConfiguration(), this.protocols); List<Protocol> protocols = Configurator.createProtocols(JChannelFactory.createProtocols(forkStack, this.channel.getProtocolStack().getTransport().isMulticastCapable()), new ProtocolStack()); return new ForkChannel(this.channel, stackName, id, protocols.toArray(new Protocol[protocols.size()])); }
/** * Opens the channel. * This does the following actions: * <ol> * <li> Resets the receiver queue by calling Queue.reset * <li> Sets up the protocol stack by calling ProtocolStack.setup * <li> Sets the closed flag to false * </ol> */ public synchronized void open() throws ChannelException { if(!closed) throw new ChannelException("channel is already open"); try { mq.reset(); // new stack is created on open() - bela June 12 2003 prot_stack=new ProtocolStack(this, props); prot_stack.setup(); closed=false; } catch(Exception e) { throw new ChannelException("failed to open channel" , e); } }
/** * 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); }
public void setProtocolStack(Protocol[] stack) { this.protStack=stack; this.protStack[0].setUpProtocol(ad); this.protStack[this.protStack.length-1].setDownProtocol(ad); top=protStack[0]; bottom=this.protStack[this.protStack.length-1]; prot_stack=new ProtocolStack(); if(protStack.length > 1) { for(int i=0; i < protStack.length; i++) { Protocol p1=protStack[i]; p1.setProtocolStack(prot_stack); Protocol p2=i+1 >= protStack.length? null : protStack[i+1]; if(p2 != null) { p1.setDownProtocol(p2); p2.setUpProtocol(p1); } } } }
ProtocolStack stack = new ProtocolStack(); stack.addProtocols(protocols); context.getResult().set(stack.printProtocolSpecAsXML());
ProtocolStack stack = new ProtocolStack(); stack.addProtocols(protocols); context.getResult().set(stack.printProtocolSpecAsXML());