protected final void init() { disp=new RpcDispatcher(channel, this).setMethodLookup(id -> methods.get(id)); disp.setMembershipListener(this).setStateListener(this); }
public void start() throws Exception { int c; RspList rsps; channel=new JChannel(); // default props disp=new RpcDispatcher(channel, this).setMembershipListener(this); channel.connect("rpc-test"); while(true) { System.out.println("[x]: exit [s]: send sync group RPC"); System.out.flush(); c=System.in.read(); switch(c) { case 'x': channel.close(); disp.stop(); return; case 's': rsps=sendGroupRpc(); System.out.println("responses:\n" + rsps); break; } System.in.skip(System.in.available()); } }
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 QuoteClient() { super(); try { channel=new JChannel(props); channel.setDiscardOwnMessages(true); disp=(RpcDispatcher)new RpcDispatcher(channel, this).setMembershipListener(this); channel.connect(channel_name); } catch(Exception e) { System.err.println("QuoteClient(): " + e); } addWindowListener(this); }
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); }
if(name != null) ch.setName(name); disp=new RpcDispatcher(ch, this).setMembershipListener(this); ch.connect("RelayDemo"); local_addr=ch.getAddress().toString();
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); }
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, 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); }
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); } }
@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(); }
@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); }
disp =(RpcDispatcher)new RpcDispatcher(channel, this).setMembershipListener(this); channel.connect(groupname); channel.getState(null, 0);
protected final void init(long state_timeout) { initSignatures(); disp = new RpcDispatcher(channel, this, this, this); // Changed by bela (jan 20 2003): start() has to be called by user (only when providing // own channel). First, Channel.connect() has to be called, then start(). // start(state_timeout); }
protected final void init(long state_timeout) { disp=new RpcDispatcher(channel, this, this, this); disp.setMethodLookup(new MethodLookup() { public Method findMethod(short id) { return methods.get(id); } }); // Changed by bela (jan 20 2003): start() has to be called by user (only when providing // own channel). First, Channel.connect() has to be called, then start(). // start(state_timeout); }
public DistributedTree(PullPushAdapter adapter, Serializable id, long state_timeout) throws ChannelException { channel = (Channel)adapter.getTransport(); disp=new RpcDispatcher(adapter, id, this, this, this); boolean flag = channel.getState(null, state_timeout); if(flag) { if(log.isInfoEnabled()) log.info("state was retrieved successfully"); } else if(log.isInfoEnabled()) log.info("state could not be retrieved (must be first member in group)"); }
protected final void init() { initSignatures(); internalQueue = new LinkedList(); disp = new RpcDispatcher(channel, this, this, this); disp.setDeadlockDetection(false); // To ensure strict FIFO MethodCall }
public RpcDispatcherAnycastServerObject(JChannel channel,EventRemoteService eventService) throws Exception { c=channel; d=new RpcDispatcher(c, eventService); d.setMembershipListener(this); d.setStateListener(this); }
public CacheManager(Vertx vertx, JChannel channel) { this.channel = channel; this.multiMapService = new DefaultRpcMultiMapService(); this.mapService = new DefaultRpcMapService(); RpcServerObjDelegate server_obj = new RpcServerObjDelegate(mapService, multiMapService); // Don't want to loose the channel receiver. this.dispatcher = new RpcDispatcher(this.channel, this, channel.getReceiver(), server_obj); this.dispatcher.setMethodLookup(server_obj.getMethodLookup()); this.executorService = new DefaultRpcExecutorService(vertx, dispatcher); }
@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(); }