/** * Whether updates across the cluster should be asynchronous (default) or synchronous) * * @param blocking_updates */ public void setBlockingUpdates(boolean blocking_updates) { call_options.mode(blocking_updates? ResponseMode.GET_ALL : ResponseMode.GET_NONE); }
public boolean isBlockingUpdates() { return call_options.mode() == ResponseMode.GET_ALL; }
public String toString() { return String.format("%s, mode=%s", getClass().getSimpleName(), options.mode()); }
public void sendRequest(Buffer data) throws Exception { try { corr.sendUnicastRequest(target, data, options.mode() == ResponseMode.GET_NONE? null : this, this.options); } catch(Exception ex) { corrDone(); throw ex; } }
protected void sendRequest(Buffer data, final Collection<Address> targetMembers) throws Exception { try { corr.sendRequest(targetMembers, data, options.mode() == ResponseMode.GET_NONE? null : this, options); } catch(Exception ex) { corrDone(); throw ex; } }
@GuardedBy("lock") public boolean responsesComplete() { return options.mode() == ResponseMode.GET_NONE || isDone(); }
public void configChange(ConfigChange config_change) { // 5 String attr_name=config_change.attr_name; try { Object attr_value=config_change.getValue(); Field field=Util.getField(this.getClass(), attr_name); Util.setField(field, this, attr_value); System.out.println(config_change.attr_name + "=" + attr_value); log_interval=num_msgs / 10; receive_log_interval=num_msgs * Math.max(1, members.size()) / 10; send_options.mode(sync? ResponseMode.GET_ALL : ResponseMode.GET_NONE); if(oob) send_options.flags(Message.Flag.OOB); } catch(Exception e) { System.err.println("failed applying config change for attr " + attr_name + ": " + e); } }
@GuardedBy("lock") protected boolean responsesComplete() { if(isDone()) return true; final int num_total=rsps.size(); switch(options.mode()) { case GET_FIRST: return num_valid >= 1 || num_received >= num_total; case GET_ALL: return num_valid >= num_total || num_received >= num_total; case GET_NONE: return true; } return false; }
/** * Sends a unicast message to the target defined by msg.getDest() and returns a future * @param dest the target to which to send the unicast message. Must not be null. * @param data the payload to send * @param opts the options * @return CompletableFuture<T> A future from which the result can be fetched, or null if the call was asynchronous * @throws Exception If there was problem sending the request, processing it at the receiver, or processing * it at the sender. {@link java.util.concurrent.Future#get()} will throw this exception */ public <T> CompletableFuture<T> sendMessageWithFuture(Address dest, Buffer data, RequestOptions opts) throws Exception { if(dest == null) throw new IllegalArgumentException("message destination is null, cannot send message"); if(opts == null) { log.warn("request options were null, using default of sync"); opts=RequestOptions.SYNC(); } rpc_stats.add(RpcStats.Type.UNICAST, dest, opts.mode() != ResponseMode.GET_NONE, 0); if(opts.mode() == ResponseMode.GET_NONE) { corr.sendUnicastRequest(dest, data, null, opts); return null; } // if we get here, the RPC is synchronous UnicastRequest<T> req=new UnicastRequest<>(corr, dest, opts); req.execute(data, false); return req; }
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); }
boolean sync=options.mode() != ResponseMode.GET_NONE; boolean non_blocking=!sync || !block_for_results, anycast=options.anycasting(); if(non_blocking)
public T execute(Buffer data, boolean block_for_results) throws Exception { if(corr == null) return null; sendRequest(data); if(!block_for_results || options.mode() == ResponseMode.GET_NONE) return null; long timeout=options.timeout(); return timeout > 0? waitForCompletion(options.timeout(), TimeUnit.MILLISECONDS) : waitForCompletion(); }
if(oob) options.flags(Message.Flag.OOB); options.mode(sync? ResponseMode.GET_ALL : ResponseMode.GET_NONE);
if(opts.mode() == ResponseMode.GET_NONE) { rpc_stats.add(RpcStats.Type.UNICAST, dest, false, 0); corr.sendUnicastRequest(dest, data, null, opts);
/** * Whether updates across the cluster should be asynchronous (default) or synchronous) * * @param blocking_updates */ public void setBlockingUpdates(boolean blocking_updates) { call_options.mode(blocking_updates? ResponseMode.GET_ALL : ResponseMode.GET_NONE); }
public String toString() { return String.format("%s, mode=%s", getClass().getSimpleName(), options.mode()); }
protected void sendRequest(Buffer data, final Collection<Address> targetMembers) throws Exception { try { corr.sendRequest(targetMembers, data, options.mode() == ResponseMode.GET_NONE? null : this, options); } catch(Exception ex) { corrDone(); throw ex; } }
public void sendRequest(Buffer data) throws Exception { try { corr.sendUnicastRequest(target, data, options.mode() == ResponseMode.GET_NONE? null : this, this.options); } catch(Exception ex) { corrDone(); throw ex; } }
@GuardedBy("lock") protected boolean responsesComplete() { if(isDone()) return true; final int num_total=rsps.size(); switch(options.mode()) { case GET_FIRST: return num_valid >= 1 || num_received >= num_total; case GET_ALL: return num_valid >= num_total || num_received >= num_total; case GET_NONE: return true; } return false; }
public T execute(Buffer data, boolean block_for_results) throws Exception { if(corr == null) return null; sendRequest(data); if(!block_for_results || options.mode() == ResponseMode.GET_NONE) return null; long timeout=options.timeout(); return timeout > 0? waitForCompletion(options.timeout(), TimeUnit.MILLISECONDS) : waitForCompletion(); }