![JAR search and dependency download from the Maven repository](/logo.png)
bboss.org.jgroups.StreamingGetStateEvent Maven / Gradle / Ivy
The newest version!
package bboss.org.jgroups;
import java.io.OutputStream;
/**
*
* Represents an event returned by channel.receive()
, as a result
* of another channel instance requesting a state from this channel. Other channel
* has to invoke channel.getState()
indicating intent of state
* retrieval.
*
*
*
* Allows applications using a channel in a pull mode to receive
* StreamingGetStateEvent
event and thus provide state to requsting
* channel instance. Channels have to be configured with
* STREAMING_STATE_TRANSFER
protocol rather than the default
* STATE_TRANSFER
protocol in order to receive this event
*
*
*
* The following code demonstrates how to pull events from a channel, processing
* StreamingGetStateEvent
and sending hypothetical state through
* OutputStream
reference.
*
*
* Object obj=channel.receive(0);
* if(obj instanceof StreamingGetStateEvent) {
* StreamingGetStateEvent evt=(StreamingGetStateEvent)obj;
* OutputStream oos = null;
* try {
* oos = new ObjectOutputStream(evt.getArg());
* oos.writeObject(state);
* oos.flush();
* } catch (Exception e) {}
* finally
* {
* try {
* oos.close();
* } catch (IOException e) {
* System.err.println(e);
* }
* }
* }
*
*
*
* @author Vladimir Blagojevic
* @see bboss.org.jgroups.JChannel#getState(Address, long)
* @see bboss.org.jgroups.StreamingMessageListener#getState(OutputStream)
* @since 2.4
*
*/
public class StreamingGetStateEvent {
OutputStream os;
String state_id;
public StreamingGetStateEvent(OutputStream os,String state_id) {
super();
this.os=os;
this.state_id=state_id;
}
/**
* Returns OutputStream used for writing of a state.
*
* @return the OutputStream
*/
public OutputStream getArg()
{
return os;
}
/**
* Returns id of the partial state if partial state was requested.
* If full state transfer was requested this method will return null.
*
* @see JChannel#getState(Address, long)
* @see JChannel#getState(Address, String, long)
* @return partial state id
*/
public String getStateId()
{
return state_id;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy