Refine search
protected void start(String props, String name) throws Exception { channel=new JChannel(props).name(name); // TP transport=channel.getProtocolStack().getTransport(); // transport.setThreadPool(new DirectExecutor()); disp=new RpcDispatcher(channel, this).setMembershipListener(this); disp.setMethodLookup(ignored -> requestMethod); channel.connect("rt"); View view=channel.getView(); if(view.size() > 2) System.err.printf("More than 2 members found (%s); terminating\n", view); else loop(); Util.close(channel, disp); }
private void start(String props, String name, boolean nohup) throws Exception { channel=new JChannel(props); if(name != null) channel.name(name); channel.setReceiver(this); channel.connect("ChatCluster"); if(!nohup) { eventLoop(); channel.close(); } }
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); } }
public Draw(JChannel channel) throws Exception { this.channel=channel; channel.setReceiver(this); channel.addChannelListener(this); }
public void start(String props) throws Exception { channel=new JChannel(props); channel.setReceiver(this); channel.connect("ViewDemo"); while(true) { Util.sleep(10000); } }
public Object down(Message msg) { if(channel != null) { if(!(channel.isConnected() || channel.isConnecting())) { // return null; throw new IllegalStateException("channel is not connected"); } return channel.down(msg); } return null; }
private void createJChannel() throws Exception { System.out.println("Creating Channel"); receiver = new MyReceiver(numberOfNodes, this); jChannel = new JChannel(config); jChannel.setReceiver(receiver); jChannel.connect(CLUSTER); receiver.waitUntilClusterIsFormed(); Util.registerChannel(jChannel, JMX_DOMAIN); members.addAll(jChannel.getView().getMembers()); }
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); }
protected void createBridge() { try { if(log.isTraceEnabled()) log.trace("I'm the coordinator, creating a channel (props=" + bridge_props + ", cluster_name=" + bridge_name + ")"); bridge=new JChannel(bridge_props); bridge.setDiscardOwnMessages(true); // don't receive my own messages bridge.setReceiver(new Receiver()); bridge.connect(bridge_name); } catch(Exception e) { log.error(Util.getMessage("FailedCreatingBridgeChannelProps") + bridge_props + ")", e); } }
final JChannel ch=new JChannel(props); if(name != null) ch.setName(name); ch.setReceiver(new ReceiverAdapter() { public void receive(Message msg) { Address sender=msg.getSrc(); RELAY2 relay=ch.getProtocolStack().findProtocol(RELAY2.class); relay.setRouteStatusListener(new RouteStatusListener() { public void sitesUp(String... sites) { ch.connect("RelayDemo"); String line=Util.readStringFromStdin(": "); ch.send(null, line);
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 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 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); }
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"); local_addr=ch.getAddress().toString(); String line=Util.readStringFromStdin(": "); if(line.startsWith("help")) { System.out.println("unicast <text> // unicasts to all members of local view\n" + for(Address dest: view.getMembers()) { System.out.println("invoking method in " + dest + ": "); try { Object rsp=disp.callRemoteMethod(dest, call, new RequestOptions(ResponseMode.GET_ALL, RPC_TIMEOUT)); System.out.println("rsp from " + dest + ": " + rsp); dests.addAll(view.getMembers()); System.out.println("invoking method in " + dests + ": "); RspList<Object> rsps=disp.callRemoteMethods(dests, call,
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 void start() { try { channel=new JChannel(props); disp=(RpcDispatcher)new RpcDispatcher(channel, this) .setMembershipListener(this).setStateListener(this); channel.connect(channel_name); System.out.println("\nQuote Server started at " + new Date()); System.out.println("Joined channel '" + channel_name + "' (" + channel.getView().size() + " members)"); channel.getState(null, 0); System.out.println("Ready to serve requests"); } catch(Exception e) { log.error("QuoteServer.start() : " + e); System.exit(-1); } }
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 receive(Message msg) { Address sender=msg.getSrc(); if(bridge.getAddress().equals(sender)) // discard my own messages return; RelayHeader hdr=msg.getHeader(id); switch(hdr.type) { case DISSEMINATE: // should not occur here, but we'll ignore it anyway break; case FORWARD: sendOnLocalCluster(msg.getRawBuffer(), msg.getOffset(), msg.getLength()); break; case VIEW: try { ViewData data=Util.streamableFromByteBuffer(ViewData::new, msg.getRawBuffer(), msg.getOffset(), msg.getLength()); List<Address> mbrs=new LinkedList<>(data.remote_view.getMembers()); data.remote_view=new View(data.remote_view.getViewId(), mbrs); log.error(Util.getMessage("FailedUnmarshallingViewFromRemoteCluster"), e);
@ManagedOperation public void start() throws Exception { hash_function=new ConsistentHashFunction<>(); addMembershipListener((MembershipListener)hash_function); ch=new JChannel(props); Marshaller m=new CustomMarshaller(); disp=new RpcDispatcher(ch, this).setMarshaller(m).setMethodLookup(methods::get).setMembershipListener(this); ch.connect(cluster_name); local_addr=ch.getAddress(); view=ch.getView(); }
/** * Removes the node from the tree. * @param fqn The fully qualified name of the node. */ public void remove(String fqn) { if(!remote_calls) { _remove(fqn); return; } //Changes done by <aos> //if true, propagate action to the group if(send_message) { if(channel == null) { if(log.isErrorEnabled()) log.error("channel is null, cannot broadcast REMOVE request"); return; } try { channel.send(new Message(null, new Request(Request.REMOVE, fqn))); } catch(Exception ex) { if(log.isErrorEnabled()) log.error("failure bcasting REMOVE request: " + ex); } } else { _remove(fqn); } }