protected Object invokeRpc(short method_id, Address dest, RequestOptions options, Object ... args) throws Exception { MethodCall call=new MethodCall(method_id, args); return disp.callRemoteMethod(dest, call, options); }
public void run() { byte[] buf=new byte[msg_size]; Object[] args={buf}; MethodCall call=new MethodCall((short)0, args); try { latch.await(); } catch(InterruptedException e) { e.printStackTrace(); return; } for(;;) { int i=num_requests.incrementAndGet(); if(i > num_msgs) break; try { if(dests != null) disp.callRemoteMethods(dests, call, options); else disp.callRemoteMethod(dest, call, options); if(print > 0 && i % print == 0) System.out.println("-- invoked " + i); } catch(Throwable throwable) { throwable.printStackTrace(); } } } }
public void actionPerformed(ActionEvent e) { String command=e.getActionCommand(); String retval=msg.getText(); if(retval == null || retval.length() < 1) { dispose(); return; } try { MethodCall call=new MethodCall("displayMessage", new Object[]{sender,retval}, new Class[]{String.class,String.class}); if(command.equals("Send")) disp.callRemoteMethod(dest.addr, call, new RequestOptions(ResponseMode.GET_FIRST, 0)); else if(command.equals("Send to all")) disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0)); } catch(Throwable ex) { System.err.println(ex); } dispose(); }
/** * Invokes a method in a cluster member and - if blocking - returns the result * @param dest The target member on which to invoke the method * @param meth The name of the method * @param args The arguments * @param types The types of the arguments * @param opts The options (e.g. blocking, timeout etc) * @return The result. Null if the call is asynchronous (non-blocking) or if the method returns void * @throws Exception Thrown if the method invocation threw an exception, either at the caller or the callee */ public <T> T callRemoteMethod(Address dest, String meth, Object[] args, Class[] types, RequestOptions opts) throws Exception { MethodCall method_call=new MethodCall(meth, args, types); return (T)callRemoteMethod(dest, method_call, opts); }
get(1); else { disp.callRemoteMethod(target, get_call, get_options);
public void run() { try { latch.await(); } catch(InterruptedException e) { e.printStackTrace(); } RequestOptions opts=new RequestOptions(ResponseMode.GET_ALL, 0); if(oob) opts.flags(Message.Flag.OOB); if(dont_bundle) opts.flags(Message.Flag.DONT_BUNDLE); MethodCall call=new MethodCall((short)1, id); for(;;) { int num=sent_msgs.getAndIncrement(); if(num > num_msgs) break; if(num > 0 && num % print == 0) System.out.printf("."); try { long start=System.nanoTime(); disp.callRemoteMethod(target, call, opts); long time=System.nanoTime()-start; avg.add(time); } catch(Exception e) { e.printStackTrace(); } } } }
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); SiteMaster dest=new SiteMaster(site_master); System.out.println("invoking method in " + dest + ": "); Object rsp=disp.callRemoteMethod(dest, call, new RequestOptions(ResponseMode.GET_ALL, RPC_TIMEOUT)); System.out.println("rsp from " + dest + ": " + rsp);
private void sendPut(Address dest, K key, V val, long caching_time, boolean synchronous) { try { ResponseMode mode=synchronous? ResponseMode.GET_ALL : ResponseMode.GET_NONE; disp.callRemoteMethod(dest, new MethodCall(PUT, key, val, caching_time), new RequestOptions(mode, call_timeout)); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("_put() failed", t); } }
private void move(Address dest, K key, V val, short repl_count, long caching_time, boolean synchronous) { try { ResponseMode mode=synchronous? ResponseMode.GET_ALL : ResponseMode.GET_NONE; disp.callRemoteMethod(dest, new MethodCall(PUT_FORCE, key, val, repl_count, caching_time, true), new RequestOptions(mode, call_timeout)); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("move() failed", t); } }
@ManagedOperation public void remove(K key) { Address dest_node=getNode(key); try { if(dest_node.equals(local_addr)) { l2_cache.remove(key); } else { disp.callRemoteMethod(dest_node, new MethodCall(REMOVE, key), new RequestOptions(ResponseMode.GET_NONE, call_timeout)); } if(l1_cache != null) l1_cache.remove(key); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("_remove() failed", t); } }
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); }
val=disp.callRemoteMethod(dest_node, new MethodCall(GET, key), new RequestOptions(ResponseMode.GET_FIRST, call_timeout));
public Object callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout) throws Throwable { return callRemoteMethod(dest, method_call, mode, timeout, false); }
public Object callRemoteMethod(Address dest, String method_name, Object[] args, Class[] types, int mode, long timeout) throws Throwable { MethodCall method_call=new MethodCall(method_name, args, types); return callRemoteMethod(dest, method_call, mode, timeout); }
public Object callRemoteMethod(Address dest, String method_name, Object[] args, String[] signature, int mode, long timeout) throws Throwable { MethodCall method_call=new MethodCall(method_name, args, signature); return callRemoteMethod(dest, method_call, mode, timeout); }
/** * Invokes a method in a cluster member and - if blocking - returns the result * @param dest The target member on which to invoke the method * @param meth The name of the method * @param args The arguments * @param types The types of the arguments * @param opts The options (e.g. blocking, timeout etc) * @return The result. Null if the call is asynchronous (non-blocking) or if the method returns void * @throws Exception Thrown if the method invocation threw an exception, either at the caller or the callee */ public <T> T callRemoteMethod(Address dest, String meth, Object[] args, Class[] types, RequestOptions opts) throws Exception { MethodCall method_call=new MethodCall(meth, args, types); return (T)callRemoteMethod(dest, method_call, opts); }
protected Object invokeRpc(short method_id, Address dest, RequestOptions options, Object ... args) throws Exception { MethodCall call=new MethodCall(method_id, args); return disp.callRemoteMethod(dest, call, options); }
private void move(Address dest, K key, V val, short repl_count, long caching_time, boolean synchronous) { try { ResponseMode mode=synchronous? ResponseMode.GET_ALL : ResponseMode.GET_NONE; disp.callRemoteMethod(dest, new MethodCall(PUT_FORCE, key, val, repl_count, caching_time, true), new RequestOptions(mode, call_timeout)); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("move() failed", t); } }
private void sendPut(Address dest, K key, V val, long caching_time, boolean synchronous) { try { ResponseMode mode=synchronous? ResponseMode.GET_ALL : ResponseMode.GET_NONE; disp.callRemoteMethod(dest, new MethodCall(PUT, key, val, caching_time), new RequestOptions(mode, call_timeout)); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("_put() failed", t); } }
@ManagedOperation public void remove(K key) { Address dest_node=getNode(key); try { if(dest_node.equals(local_addr)) { l2_cache.remove(key); } else { disp.callRemoteMethod(dest_node, new MethodCall(REMOVE, key), new RequestOptions(ResponseMode.GET_NONE, call_timeout)); } if(l1_cache != null) l1_cache.remove(key); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("_remove() failed", t); } }