Refine search
protected RspList invokeRpc(short method_id, RequestOptions options, Object ... args) throws Exception { MethodCall call=new MethodCall(method_id, args); return disp.callRemoteMethods(null, call, options); }
/** * Removes all of the mappings from this map. */ public void clear() { try { MethodCall call=new MethodCall(CLEAR); disp.callRemoteMethods(null, call, call_options); } catch(Exception e) { throw new RuntimeException("clear() failed", e); } }
/** * Invokes a method in all members and expects responses from members contained in dests (or all members if dests is null). * @param dests A list of addresses. If null, we'll wait for responses from all cluster members * @param method_name The name of the target method * @param args The arguments to be passed * @param types The types of the arguments * @param options A collection of call options, e.g. sync versus async, timeout etc * @return RspList<T> A response list with results, one for each member in dests, or null if the RPC is asynchronous * @throws Exception If the sending of the message threw an exception. Note that <em>no</em> exception will be * thrown if any of the target members threw an exception, but this exception will be in the Rsp * object for the particular member in the RspList */ public <T> RspList<T> callRemoteMethods(Collection<Address> dests, String method_name, Object[] args, Class[] types, RequestOptions options) throws Exception { MethodCall method_call=new MethodCall(method_name, args, types); return callRemoteMethods(dests, method_call, options); }
/** * Copies all of the mappings from the specified map to this one. These * mappings replace any mappings that this map had for any of the keys * currently in the specified map. * * @param m * mappings to be stored in this map */ public void putAll(Map<? extends K,? extends V> m) { try { MethodCall call=new MethodCall(PUT_ALL, m); disp.callRemoteMethods(null, call, call_options); } catch(Throwable t) { throw new RuntimeException("putAll() failed", t); } }
/** @throws NullPointerException if the specified key is null */ public boolean remove(Object key, Object value) { Object val=get(key); boolean removed=val != null && value != null && val.equals(value); try { MethodCall call=new MethodCall(REMOVE_IF_EQUALS, key, value); disp.callRemoteMethods(null, call, call_options); } catch(Exception e) { throw new RuntimeException("remove(" + key + ", " + value + ") failed", e); } return removed; }
protected void changeFieldAcrossCluster(Field field, Object value) throws Exception { disp.callRemoteMethods(null, new MethodCall(SET, field.getName(), value), RequestOptions.SYNC()); }
/** * @return the previous value associated with the specified key, or <tt>null</tt> if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ public V putIfAbsent(K key, V value) { V prev_val=get(key); try { MethodCall call=new MethodCall(PUT_IF_ABSENT, key, value); disp.callRemoteMethods(null, call, call_options); } catch(Exception e) { throw new RuntimeException("putIfAbsent(" + key + ", " + value + ") failed", e); } return prev_val; }
/** @throws NullPointerException if any of the arguments are null */ public boolean replace(K key, V oldValue, V newValue) { Object val=get(key); boolean replaced=val != null && oldValue != null && val.equals(oldValue); try { MethodCall call=new MethodCall(REPLACE_IF_EQUALS, key, oldValue, newValue); disp.callRemoteMethods(null, call, call_options); } catch(Exception e) { throw new RuntimeException("replace(" + key + ", " + oldValue + ", " + newValue + ") failed", e); } return replaced; }
/** * * * @return the previous value associated with the specified key, or * <tt>null</tt> if there was no mapping for the key * @throws NullPointerException * if the specified key or value is null */ public V replace(K key, V value) { V retval=get(key); try { MethodCall call=new MethodCall(REPLACE_IF_EXISTS, key, value); disp.callRemoteMethods(null, call, call_options); } catch(Exception e) { throw new RuntimeException("replace(" + key + ", " + value + ") failed", e); } return retval; }
/** * Removes the key (and its corresponding value) from this map. This method * does nothing if the key is not in the map. * * @param key * the key that needs to be removed * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt> * @throws NullPointerException * if the specified key is null */ public V remove(Object key) { V retval=get(key); try { MethodCall call=new MethodCall(REMOVE, key); disp.callRemoteMethods(null, call, call_options); } catch(Exception e) { throw new RuntimeException("remove(" + key + ") failed", e); } return retval; }
/** * Maps the specified key to the specified value in this table. Neither the key nor the value can be null. <p/> * <p> * The value can be retrieved by calling the <tt>get</tt> method with a key that is equal to the original key. * * @param key * key with which the specified value is to be associated * @param value * value to be associated with the specified key * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt> * @throws NullPointerException * if the specified key or value is null */ public V put(K key, V value) { V prev_val=get(key); try { MethodCall call=new MethodCall(PUT, key, value); disp.callRemoteMethods(null, call, call_options); } catch(Exception e) { throw new RuntimeException("put(" + key + ", " + value + ") failed", e); } return prev_val; }
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; }
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 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(); } } } }
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 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); } }
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; } } }
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(); }
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; for(int i=0; i < num; i++) { long start=System.nanoTime(); RspList<Void> rsps=disp.callRemoteMethods(null, call, opts); long time_ns=System.nanoTime() - start; if(i > 0 && i % print == 0)
/** * 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); } }