/** * Sets the logical name for the channel. The name will stay associated with this channel for the * channel's lifetime (until close() is called). This method should be called <em>before</em> * calling connect(). * * @param name */ public void setName(String name) {ch.setName(name);}
public JChannel name(String name) {return setName(name);} public String clusterName() {return getClusterName();}
protected Bridge(final JChannel ch, final String cluster_name, String channel_name, AddressGenerator addr_generator) throws Exception { this.channel=ch; channel.setName(channel_name); channel.setReceiver(this); channel.addAddressGenerator(addr_generator); this.cluster_name=cluster_name; }
public void start(String props, String name) throws Exception { this.props=props; this.name=name; StringBuilder sb=new StringBuilder(); sb.append("\n\n----------------------- MPerf -----------------------\n"); sb.append("Date: ").append(new Date()).append('\n'); sb.append("Run by: ").append(System.getProperty("user.name")).append("\n"); sb.append("JGroups version: ").append(Version.description).append('\n'); System.out.println(sb); channel=new JChannel(props); channel.setName(name); channel.setReceiver(this); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); // send a CONFIG_REQ to the current coordinator, so we can get the current config Address coord=channel.getView().getCoord(); if(coord != null && !local_addr.equals(coord)) send(coord,null,MPerfHeader.CONFIG_REQ, Message.Flag.RSVP); }
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); } }
void start(String props, String channel_name) throws Exception { ch=new JChannel(props); ch.setName(channel_name); ch.setReceiver(new ReceiverAdapter() { public void viewAccepted(View view) { System.out.println("-- view: " + view); } }); loop(); }
public void start(String props, String name) throws Exception { this.props=props; this.name=name; StringBuilder sb=new StringBuilder(); sb.append("\n\n----------------------- MPerf -----------------------\n"); sb.append("Date: ").append(new Date()).append('\n'); sb.append("Run by: ").append(System.getProperty("user.name")).append("\n"); sb.append("JGroups version: ").append(Version.description).append('\n'); System.out.println(sb); channel=new JChannel(props); channel.setName(name); disp=new RpcDispatcher(channel, this).setMembershipListener(this).setMethodLookup(id -> METHODS[id]) .setMarshaller(new MperfMarshaller()); send_options.mode(sync? ResponseMode.GET_ALL : ResponseMode.GET_NONE); if(oob) send_options.flags(Message.Flag.OOB); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); // send a CONFIG_REQ to the current coordinator, so we can get the current config Address coord=channel.getView().getCoord(); if(coord != null && !local_addr.equals(coord)) invokeRpc(configReq, coord, RequestOptions.ASYNC().flags(Message.Flag.RSVP), local_addr); }
public Draw(String props, boolean no_channel, boolean jmx, boolean use_state, long state_timeout, boolean use_unicasts, String name, boolean send_own_state_on_merge, AddressGenerator gen) throws Exception { this.no_channel=no_channel; this.jmx=jmx; this.use_state=use_state; this.state_timeout=state_timeout; this.use_unicasts=use_unicasts; if(no_channel) return; channel=new JChannel(props).addAddressGenerator(gen).setName(name); channel.setReceiver(this).addChannelListener(this); this.send_own_state_on_merge=send_own_state_on_merge; }
public void start(String props, String name) throws Exception { ch=new JChannel(props); ch.setName(name); ch.setReceiver(this); ch.connect("FlowControlTest"); loop(); Util.close(ch); }
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); } }
channel.setReceiver(this); if(name != null) channel.setName(name); channel.connect("TestChannel"); MBeanServer server=Util.getMBeanServer();
public void start(String props, String name) throws Exception { ch=new JChannel(props); if(name != null) ch.setName(name); disp=new RpcDispatcher(ch, this).setMembershipListener(this); ch.connect("RelayDemo");
ch.setName(name); ch.setReceiver(new ReceiverAdapter() { public void receive(Message msg) {
protected void applyNewConfig(byte[] buffer) { final InputStream in=new ByteArrayInputStream(buffer); Thread thread=new Thread(() -> { try { JChannel ch=new JChannel(in); Util.sleepRandom(1000, 5000); channel.disconnect(); JChannel tmp=channel; channel=ch; channel.setName(name); channel.setReceiver(MPerf.this); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.unregisterChannel(tmp, Util.getMBeanServer(), "jgroups", "mperf"); Util.close(tmp); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); } catch(Exception e) { System.err.println("failed creating new channel"); } }); System.out.println("<< restarting channel"); thread.start(); }
public void start(String props, String name, boolean unicast) throws Exception { ch=new JChannel(props); if(name != null) ch.setName(name); ch.setReceiver(this); ch.connect("ping"); while(true) { Util.keyPress("enter to ping"); Address dest=null; if(unicast) dest=Util.pickRandomElement(members); Message msg=new Message(dest, PING_REQ); msg.setFlag(Message.Flag.DONT_BUNDLE, Message.Flag.NO_FC); start=System.nanoTime(); ch.send(msg); } }
channel.setName(this.configuration.getNodeName());
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 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); }
private JChannel createChannel(String name, int portRange) throws Exception { String configString = JGroupsConfigBuilder .getJGroupsConfig(ConcurrentStartChanelLookupTest.class.getName(), new TransportFlags().withPortRange(portRange)); JChannel channel = new JChannel(new ByteArrayInputStream(configString.getBytes())); channel.setName(name); channel.connect(ConcurrentStartChanelLookupTest.class.getSimpleName()); log.tracef("Channel %s connected: %s", channel, channel.getViewAsString()); return channel; } }