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(); JChannel mock_channel = new JChannel() {}; ProtocolStack stack = new ProtocolStack(mock_channel); stack.setup(Configurator.parseConfigurations(props)); stack.insertProtocol(harness, ProtocolStack.ABOVE, stack.getTopProtocol().getClass()); bottom = stack.getBottomProtocol(); // 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); }
protected void startStack(String cluster_name) throws Exception { /*make sure the channel is not closed*/ checkClosed(); /*make sure we have a valid channel name*/ if (cluster_name == null) log.debug("cluster_name is null, assuming unicast channel"); else this.cluster_name = cluster_name; if (socket_factory != null) prot_stack.getTopProtocol().setSocketFactory(socket_factory); prot_stack.startStack( cluster_name, local_addr); // calls start() in all protocols, from top to bottom /*create a temporary view, assume this channel is the only member and is the coordinator*/ List<Address> t = new ArrayList<>(1); t.add(local_addr); my_view = new View(local_addr, 0, t); // create a dummy view TP transport = prot_stack.getTransport(); transport.registerProbeHandler(probe_handler); }