/** * Returns the cluster name of the group of which the channel is a member. This is the object * that was the argument to <code>connect()</code>. Calling this method on a closed channel * returns <code>null</code>. * * @return The cluster name */ public String getClusterName() {return ch.getClusterName();}
public String clusterName() {return getClusterName();} public View getView() {return state == State.CONNECTED ? view : null;}
/** * Constructs a new ReplicatedHashMap using provided map instance. */ public ReplicatedHashMap(ConcurrentMap<K,V> map, JChannel channel) { if(channel == null) throw new IllegalArgumentException("Cannot create ReplicatedHashMap with null channel"); if(map == null) throw new IllegalArgumentException("Cannot create ReplicatedHashMap with null map"); this.map=map; this.cluster_name=channel.getClusterName(); this.channel=channel; init(); }
@Override public String getName() { return this.dispatcher.getChannel().getClusterName(); }
@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; Protocol[] protocols = new Protocol[this.protocols.size()]; for (int i = 0; i < protocols.length; ++i) { protocols[i] = this.protocols.get(i).createProtocol(this.parentFactory.getProtocolStackConfiguration()); } return new ForkChannel(this.channel, stackName, id, protocols); }
@Override public ProtocolStackConfiguration getProtocolStackConfiguration() { ProtocolStackConfiguration parentStack = this.parentFactory.getProtocolStackConfiguration(); return new ForkProtocolStackConfiguration(this.channel.getClusterName(), parentStack, Stream.concat(parentStack.getProtocols().stream(), this.protocols.stream()).collect(Collectors.toList())); }
public static void registerChannel(JChannel channel,String name) { MBeanServer server=Util.getMBeanServer(); if(server != null) { try { JmxConfigurator.registerChannel(channel, server, (name != null? name : "jgroups"), channel.getClusterName(), true); } catch(Exception e) { e.printStackTrace(); } } }
protected void _init(JChannel ch, long sleep_time, String name) throws Exception { this.sleep_time=sleep_time; channel=ch; if(name != null) channel.setName(name); channel.connect(getClass().getSimpleName()); channel.setReceiver(receiver); try { MBeanServer server=Util.getMBeanServer(); JmxConfigurator.registerChannel(channel, server, "jgroups-" + name, channel.getClusterName(), true); } catch(Throwable ex) { System.err.println("registering the channel with JMX failed: " + ex); } }
protected void stop() { log.info("%s: leaving bridge cluster '%s'", channel.getAddress(), channel.getClusterName()); Util.close(channel); }
public void exit() { // 8 ProtocolStack stack=channel.getProtocolStack(); String cluster_name=channel.getClusterName(); try { JmxConfigurator.unregisterChannel(channel, Util.getMBeanServer(), "jgroups", "mperf"); } catch(Exception e) { } stack.stopStack(cluster_name); stack.destroy(); }
public void start() throws Exception { ch=new JChannel(props); if(name != null) ch.setName(name); execution_service=new ExecutionService(ch); runner=new ExecutionRunner(ch); ch.connect("executing-cluster"); JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "execution-service", ch.getClusterName(), true); // Start a consumer queue.add(executor.submit(runner)); random = new Random(); printValues = false; try { loop(); } catch(Exception e) { e.printStackTrace(); } finally { Util.close(ch); } }
throw new NullPointerException("channel cannot be null"); if (cluster_name == null) cluster_name=channel.getClusterName(); if (cluster_name == null) cluster_name = "null";
public ReplicatedTree(String groupname, String props, long state_fetch_timeout, boolean jmx) throws Exception { if(groupname != null) this.groupname=groupname; if(props != null) this.props=props; this.jmx=jmx; this.state_fetch_timeout=state_fetch_timeout; channel=new JChannel(this.props); channel.setReceiver(this); channel.connect(this.groupname); if(jmx) { MBeanServer server=Util.getMBeanServer(); if(server == null) throw new Exception("No MBeanServers found; need to run with an MBeanServer present, or inside JDK 5"); JmxConfigurator.registerChannel(channel, server, "jgroups", channel.getClusterName() , true); } start(); }
public void start(JChannel ch) throws Exception { this.ch=ch; lock_service=new LockService(ch); lock_service.addLockListener(this); ch.connect("lock-cluster"); JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "lock-service", ch.getClusterName(), true); try { loop(); } catch(Exception e) { e.printStackTrace(); } finally { Util.close(ch); } }
throw new Exception("No MBeanServers found;" + "\nLargeState needs to be run with an MBeanServer present, or inside JDK 5"); JmxConfigurator.registerChannel((JChannel)channel, server, "jgroups", channel.getClusterName(), true); System.out.println("-- connected to channel");
public void start() throws Exception { try { ch=new JChannel(props); if(name != null) ch.setName(name); lock_service=new LockService(ch); lock_service.addLockListener(this); ch.connect("lock-cluster"); JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "lock-service", ch.getClusterName(), true); loop(); } catch(Exception e) { e.printStackTrace(); } finally { Util.close(ch); } }
public void start(String props, boolean jmx, String name) throws Exception { channel=new JChannel(props).name(name); disp=new RpcDispatcher(channel, this) // no concurrent processing on incoming method calls .setMembershipListener(this).setMethodLookup(id -> METHODS[0]); if(jmx) { MBeanServer srv=Util.getMBeanServer(); if(srv == null) throw new Exception("No MBeanServers found"); JmxConfigurator.registerChannel(channel, srv, "jgroups", channel.getClusterName(), true); } channel.connect("rpc-speed-test"); View view=channel.getView(); if(view.size() > 2) System.err.printf("More than 2 members in cluster: %s; terminating\n", view); else loop(); Util.close(disp, channel); }
public void init(String props, final String name, String cluster_name) throws Exception { if(cluster_name != null) groupname=cluster_name; channel=new JChannel(props); if(name != null) channel.setName(name); disp=new RpcDispatcher(channel, this).setMethodLookup(id -> METHODS[id]).setMarshaller(new CustomMarshaller()) .setMembershipListener(this); 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); } }
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); }
String cluster_name=channel.getClusterName(); try { JmxConfigurator.unregisterChannel(channel, Util.getMBeanServer(), "jgroups", "mperf");