protected final void init() { disp=new RpcDispatcher(channel, this).setMethodLookup(id -> methods.get(id)); disp.setMembershipListener(this).setStateListener(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); }
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); }
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); }
/** * Creates an rpc dispatcher used by this transport * @return an rpc dispatcher */ protected RpcDispatcher createRpcDispatcher() { RpcDispatcher dispatcher = new RpcDispatcher(channel, null, this, this); dispatcher.setMethodLookup(new MethodLookup() { @Override public Method findMethod(short key) { return methods.get(key); } }); return dispatcher; }
protected final void init() { disp=new RpcDispatcher(channel, this).setMethodLookup(id -> methods.get(id)); disp.setMembershipListener(this).setStateListener(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); }
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 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); }
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); }
/** * Creates a ReplicatedHashMap * @param clustername The name of the group to join * @param factory The ChannelFactory which will be used to create a channel * @param properties The property string to be used to define the channel. This will override the properties of * the factory. If null, then the factory properties will be used * @param state_timeout The time to wait until state is retrieved in milliseconds. A value of 0 means wait forever. */ public ReplicatedHashMap(String clustername, ChannelFactory factory, String properties, long state_timeout) throws ChannelException { this.cluster_name=clustername; if(factory != null) { channel=properties != null? factory.createChannel(properties) : factory.createChannel(); } else { channel=new JChannel(properties); } disp=new RpcDispatcher(channel, this, this, this); disp.setMethodLookup(new MethodLookup() { public Method findMethod(short id) { return methods.get(id); } }); channel.connect(clustername); start(state_timeout); }
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); }