public static RequestOptions SYNC() {return new RequestOptions(ResponseMode.GET_ALL, 10000);} public static RequestOptions ASYNC() {return new RequestOptions(ResponseMode.GET_NONE, 10000);}
public static RequestOptions ASYNC() {return new RequestOptions(ResponseMode.GET_NONE, 10000);}
RspList sendGroupRpc() throws Exception { return disp.callRemoteMethods(null, "print", new Object[]{new Integer(i++)}, new Class[] {int.class}, new RequestOptions(ResponseMode.GET_ALL, 0)); }
public ChannelCommandDispatcher(MessageDispatcher dispatcher, CommandMarshaller<C> marshaller, Group<Address> group, Duration timeout, CommandDispatcher<C> localDispatcher, Runnable closeTask) { this.dispatcher = dispatcher; this.marshaller = marshaller; this.group = group; this.timeout = timeout; this.localDispatcher = localDispatcher; this.closeTask = closeTask; this.localAddress = dispatcher.getChannel().getAddress(); this.options = new RequestOptions(ResponseMode.GET_ALL, this.timeout.toMillis(), false, FILTER, Message.Flag.DONT_BUNDLE, Message.Flag.OOB); }
public void start(String name) { myname=name; int xloc=(int)(10 + 250 * Math.random()); int yloc=(int)(10 + 250 * Math.random()); try { MethodCall call=new MethodCall("addNode", new Object[]{name,my_addr,Integer.valueOf(xloc),Integer.valueOf(yloc)}, new Class[]{String.class,Address.class,int.class,int.class}); wb.disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0)); } catch(Exception e) { log.error(e.toString()); } repaint(); }
public void mouseReleased(MouseEvent e) { Point p=e.getPoint(); if(pick == null) return; pick.x=p.x; pick.y=p.y; pick.fixed=pickfixed; try { MethodCall call=new MethodCall("moveNode", new Object[]{pick}, new Class[]{Node.class}); wb.disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0)); } catch(Exception ex) { log.error(ex.toString()); } pick=null; }
void sendMessages(int num) throws Exception { long start, stop; int show=num/10; if(show <=0) show=1; start=System.currentTimeMillis(); RequestOptions opts=new RequestOptions(ResponseMode.GET_ALL, TIMEOUT).flags(Message.Flag.DONT_BUNDLE, Message.Flag.NO_FC); byte[] data="bla".getBytes(); Buffer buf=new Buffer(data, 0, data.length); System.out.println("-- sending " + num + " messages"); for(int i=1; i <= num; i++) { disp.castMessage(null, buf, opts); if(i % show == 0) System.out.println("-- sent " + i); } stop=System.currentTimeMillis(); printStats(stop-start, num); }
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(); }
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(); } } } }
private void mcastPut(K key, V val, short repl_count, long caching_time, boolean synchronous) { try { ResponseMode mode=synchronous? ResponseMode.GET_ALL : ResponseMode.GET_NONE; disp.callRemoteMethods(null, new MethodCall(PUT, key, val, repl_count, caching_time), new RequestOptions(mode, call_timeout)); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("put() failed", t); } }
private void mcastClear(Set<K> keys, boolean synchronous) { try { ResponseMode mode=synchronous? ResponseMode.GET_ALL : ResponseMode.GET_NONE; disp.callRemoteMethods(null, new MethodCall(REMOVE_MANY, keys), new RequestOptions(mode, call_timeout)); } catch(Throwable t) { if(log.isWarnEnabled()) log.warn("clear() 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); } }
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); } }
protected void invokeRpcs() throws Exception { Average avg=new Average(); long min=Long.MAX_VALUE, max=0; RequestOptions opts=new RequestOptions(ResponseMode.GET_FIRST, 0).transientFlags(Message.TransientFlag.DONT_LOOPBACK); MethodCall call=new MethodCall((short)0); int print=num/10;
public void destroy() { if (disp != null) { try { MethodCall call = new MethodCall("removeNode", new Object[] {panel.my_addr}, new Class[] {Object.class}); disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 5000)); } catch (Exception e) { log.error(e.toString()); } channel.close(); disp = null; if (panel != null) { panel.stop(); panel = null; } } }
RequestOptions options=new RequestOptions(ResponseMode.GET_ALL, 15000, anycasting, null); if(sync) options.flags(Message.Flag.DONT_BUNDLE); if(oob) options.flags(Message.Flag.OOB);
@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); } }
/** * Removes key in all nodes in the cluster, both from their local hashmaps and L1 caches * @param key The key, needs to be serializable */ @ManagedOperation public void remove(K key, boolean synchronous) { try { disp.callRemoteMethods(null, new MethodCall(REMOVE, key), new RequestOptions(synchronous? ResponseMode.GET_ALL : 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); }
new RequestOptions(ResponseMode.GET_FIRST, call_timeout));