@Override public ForkChannel getState(Address target, long timeout) throws Exception { main_channel.getState(target, timeout); return this; }
/** * Fetch the group state from the current coordinator. If successful, this will trigger setState(). */ public void fetchState(long timeout) throws Exception { channel.getState(null, timeout); }
/** * Fetches the state * @param state_timeout */ public final void start(long state_timeout) throws Exception { channel.getState(null, state_timeout); }
public final void start() throws Exception { channel.getState(null, state_fetch_timeout); }
/** * Retrieves the full state from the target member. * <p> * The state transfer is initiated by invoking getState() on this channel. The state provider in turn invokes the * {@link MessageListener#getState(java.io.OutputStream)} callback and sends the state to this node, the state receiver. * After the state arrives at the state receiver, the {@link MessageListener#setState(java.io.InputStream)} callback * is invoked to install the state. * @param target the state provider. If null the coordinator is used by default * @param timeout the number of milliseconds to wait for the operation to complete successfully. 0 * waits forever until the state has been received * @see MessageListener#getState(java.io.OutputStream) * @see MessageListener#setState(java.io.InputStream) * @exception IllegalStateException the channel was closed or disconnected, or the flush (if present) failed * @exception StateTransferException raised if there was a problem during the state transfer */ public JChannel getState(Address target, long timeout) throws Exception { return getState(target, timeout, true); }
@Override public ModelNode execute(JChannel channel) { return new ModelNode(channel.getState()); } },
/** * Retrieves the full state from the target member. * <p> * State transfer is initiated by invoking getState on this channel. The state provider in turn * invokes {@link MessageListener#getState(java.io.OutputStream)} callback and sends a state to * this node, the state receiver. After the state arrives to the state receiver * {@link MessageListener#setState(java.io.InputStream)} callback is invoked to install the * state. * * @param target * The state provider. If null the coordinator is used by default * @param timeout * The number of milliseconds to wait for the operation to complete successfully. 0 * waits until the state has been received * * @see MessageListener#getState(java.io.OutputStream) * @see MessageListener#setState(java.io.InputStream) * * @exception IllegalStateException * The channel was closed or disconnected, or the flush (if present) failed * @exception StateTransferException * raised if there was a problem during the state transfer */ public void getState(Address target, long timeout) throws Exception { ch.getState(target, timeout); }
@Override public ForkChannel connect(String cluster_name, Address target, long timeout) throws Exception { connect(cluster_name); main_channel.getState(target, timeout); return this; }
/** Retrieves state from the target member. See {@link #getState(Address,long)} for details */ public JChannel getState(Address target, long timeout, boolean useFlushIfPresent) throws Exception { Callable<Boolean> flusher =() -> Util.startFlush(JChannel.this); return getState(target, timeout, useFlushIfPresent?flusher:null); }
@ManagedAttribute(description="The current state") public String getState() {return ch.getState();}
channel.getState(coord, 5000); if(copy != null)
public void start() { try { channel=new JChannel(props); disp=(RpcDispatcher)new RpcDispatcher(channel, this) .setMembershipListener(this).setStateListener(this); channel.connect(channel_name); System.out.println("\nQuote Server started at " + new Date()); System.out.println("Joined channel '" + channel_name + "' (" + channel.getView().size() + " members)"); channel.getState(null, 0); System.out.println("Ready to serve requests"); } catch(Exception e) { log.error("QuoteServer.start() : " + e); System.exit(-1); } }
channel.getState(null, 0);
canFetchState=view != null && view.size() > 1; if(canFetchState) // if I am not the only member in cluster then ... getState(target, timeout, false); // fetch state from target
disp =(RpcDispatcher)new RpcDispatcher(channel, this).setMembershipListener(this); channel.connect(groupname); channel.getState(null, 0); } catch (Exception e) { log.error("Whiteboard.init(): " + e);
/** * Retrieves the current group state. Sends GET_STATE event down to STATE_TRANSFER layer. * Blocks until STATE_TRANSFER sends up a GET_STATE_OK event or until <code>timeout</code> * milliseconds have elapsed. The argument of GET_STATE_OK should be a single object. * @param target the target member to receive the state from. if null, state is retrieved from coordinator * @param timeout the number of milliseconds to wait for the operation to complete successfully. 0 waits until * the state has been received * @return true of the state was received, false if the operation timed out */ public boolean getState(Address target, long timeout) throws ChannelNotConnectedException, ChannelClosedException { return getState(target,null,timeout); }
@Override public ModelNode execute(JChannel channel) { return new ModelNode(channel.getState()); } },
@Override public ForkChannel connect(String cluster_name, Address target, long timeout) throws Exception { connect(cluster_name); main_channel.getState(target, timeout); return this; }
private boolean getState(String stateId, Address target) throws ChannelNotConnectedException, ChannelClosedException { lastStateTransferSource = target; return ((JChannel) channel).getState(target, stateId, configuration.getStateRetrievalTimeout(), !configuration.isNonBlockingStateTransfer()); }