protected TimeScheduler getTimer() { if(prot_stack != null) { TP transport=prot_stack.getTransport(); if(transport != null) return transport.getTimer(); } return null; }
/** * 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; }
/** * find and initialize the method used to update UDP's address cache */ private void findPingDataMethod() { transport = (TP) getProtocolStack().getTransport(); try { setPingData = TP.class.getDeclaredMethod("setPingData", new Class<?>[] {PingData.class}); setPingData.setAccessible(true); } catch (NoSuchMethodException e) { if (!warningLogged) { log.warn("Unable to update JGroups address cache - this may affect performance", e); warningLogged = true; } } }
public <X extends MessageDispatcher> X stop() { if(corr != null) { corr.stop(); if(channel instanceof JChannel) { TP transport=channel.getProtocolStack().getTransport(); corr.unregisterProbeHandler(transport); } } return (X)this; }
protected JChannel startStack(String cluster_name) throws Exception { checkClosed(); this.cluster_name=cluster_name; prot_stack.startStack(); // calls start() in all protocols, from top to bottom /*create a temporary view, assume this channel is the only member and is the coordinator*/ view=new View(local_addr, 0, Collections.singletonList(local_addr)); // create a dummy view TP transport=prot_stack.getTransport(); transport.registerProbeHandler(probe_handler); return this; }
/** * 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 void start(String ... options) throws Exception { String props="udp.xml", name=null; options(options); if(options !=null) { for(int i=0; i < options.length; i++) { if(options[i].startsWith("-props")) { props=options[++i]; continue; } if(options[i].startsWith("-name")) { name=options[++i]; } } } ch=new JChannel(props).name(name).receiver(this); TP transport=ch.getProtocolStack().getTransport(); // uncomment below to disable the regular and OOB thread pools // transport.setOOBThreadPool(new DirectExecutor()); // transport.setDefaultThreadPool(new DirectExecutor()); //ThreadPoolExecutor thread_pool=new ThreadPoolExecutor(4, 4, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(5000)); //transport.setDefaultThreadPool(thread_pool); //transport.setOOBThreadPool(thread_pool); //transport.setInternalThreadPool(thread_pool); ch.connect("rt"); View v=ch.getView(); if(v.size() > 2) throw new IllegalStateException(String.format("More than 2 members found (%s); terminating\n", v)); }
protected JChannel stopStack(boolean stop, boolean destroy) { if(prot_stack != null) { try { if(stop) prot_stack.stopStack(cluster_name); if(destroy) prot_stack.destroy(); } catch(Exception e) { log.error(Util.getMessage("StackDestroyFailure"), e); } TP transport=prot_stack.getTransport(); if(transport != null) transport.unregisterProbeHandler(probe_handler); } return this; }
public void init(String props, String name, AddressGenerator generator, int bind_port) throws Throwable { channel=new JChannel(props).addAddressGenerator(generator).setName(name); if(bind_port > 0) { TP transport=channel.getProtocolStack().getTransport(); transport.setBindPort(bind_port); } disp=new RpcDispatcher(channel, this).setMembershipListener(this).setMethodLookup(id -> METHODS[id]) .setMarshaller(new UPerfMarshaller()); channel.connect(groupname); local_addr=channel.getAddress(); try { MBeanServer server=Util.getMBeanServer(); JmxConfigurator.registerChannel(channel, server, "jgroups", channel.getClusterName(), true); } catch(Throwable ex) { System.err.println("registering the channel in JMX failed: " + ex); } if(members.size() < 2) return; Address coord=members.get(0); Config config=disp.callRemoteMethod(coord, new MethodCall(GET_CONFIG), new RequestOptions(ResponseMode.GET_ALL, 5000)); if(config != null) { applyConfig(config); System.out.println("Fetched config from " + coord + ": " + config + "\n"); } else System.err.println("failed to fetch config from " + coord); }
Transport transport = (Transport) myChannel.getProtocolStack().getTransport(); transport.setMessenger(this);
public <X extends MessageDispatcher> X start() { if(corr == null) corr=createRequestCorrelator(prot_adapter, this, local_addr) .asyncDispatching(async_dispatching).wrapExceptions(this.wrap_exceptions); correlatorStarted(); corr.start(); if(channel != null) { List<Address> tmp_mbrs=channel.getView() != null ? channel.getView().getMembers() : null; setMembers(tmp_mbrs); if(channel instanceof JChannel) { TP transport=channel.getProtocolStack().getTransport(); corr.registerProbeHandler(transport); } } return (X)this; }
/** * Drops messages to/from other members and then closes the channel. Note that this member won't get excluded from * the view until failure detection has kicked in and the new coord installed the new view */ public static void shutdown(JChannel ch) throws Exception { DISCARD discard=new DISCARD(); discard.setLocalAddress(ch.getAddress()); discard.setDiscardAll(true); ProtocolStack stack=ch.getProtocolStack(); TP transport=stack.getTransport(); stack.insertProtocol(discard,ProtocolStack.Position.ABOVE,transport.getClass()); //abruptly shutdown FD_SOCK just as in real life when member gets killed non gracefully FD_SOCK fd=ch.getProtocolStack().findProtocol(FD_SOCK.class); if(fd != null) fd.stopServerSocket(false); View view=ch.getView(); if(view != null) { ViewId vid=view.getViewId(); List<Address> members=Collections.singletonList(ch.getAddress()); ViewId new_vid=new ViewId(ch.getAddress(),vid.getId() + 1); View new_view=new View(new_vid,members); // inject view in which the shut down member is the only element GMS gms=stack.findProtocol(GMS.class); gms.installView(new_view); } Util.close(ch); }
@ManagedOperation public void start() throws Exception { if(hash_function_factory != null) { hash_function=hash_function_factory.create(); } if(hash_function == null) hash_function=new ConsistentHashFunction<>(); ch=new JChannel(props); disp=new RpcDispatcher(ch, this).setMethodLookup(methods::get).setMembershipListener(this); Marshaller marshaller=new CustomMarshaller(); disp.setMarshaller(marshaller); ch.connect(cluster_name); local_addr=ch.getAddress(); view=ch.getView(); timer=ch.getProtocolStack().getTransport().getTimer(); l2_cache.addChangeListener(this); }
this.jgAddress = new JGAddress(logicalAddress, ipaddr); } else { UDP udp = (UDP) myChannel.getProtocolStack().getTransport();
protected TimeScheduler getTimer() { if(prot_stack != null) { TP transport=prot_stack.getTransport(); if(transport != null) return transport.getTimer(); } return null; }
@Override public ModelNode execute(JChannel channel) { return new ModelNode((channel.getProtocolStack().getTransport()).getTimerThreads()); } },
@Override public ModelNode execute(JChannel channel) { return new ModelNode((channel.getProtocolStack().getTransport()).getNumTimerTasks()); } },
public <X extends MessageDispatcher> X stop() { if(corr != null) { corr.stop(); if(channel instanceof JChannel) { TP transport=channel.getProtocolStack().getTransport(); corr.unregisterProbeHandler(transport); } } return (X)this; }
protected JChannel startStack(String cluster_name) throws Exception { checkClosed(); this.cluster_name=cluster_name; prot_stack.startStack(); // calls start() in all protocols, from top to bottom /*create a temporary view, assume this channel is the only member and is the coordinator*/ view=new View(local_addr, 0, Collections.singletonList(local_addr)); // create a dummy view TP transport=prot_stack.getTransport(); transport.registerProbeHandler(probe_handler); return this; }
@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()])); }