Package org.jgroups
Class StreamingSetStateEvent
- java.lang.Object
-
- org.jgroups.StreamingSetStateEvent
-
public class StreamingSetStateEvent extends java.lang.Object
Represents an event returned bychannel.receive()
, as requested bychannel.getState()
previously.Allows applications using a channel in a pull mode to receive a state from another channel instance providing state. Channels have to be configured with
STREAMING_STATE_TRANSFER
protocol rather than the defaultSTATE_TRANSFER
protocol in order to receive this event.The following code demonstrate how to pull events from a channel, processing
StreamingSetStateEvent
and retrieving hypothetical state in the form of LinkedList from event'sInputStream
reference.Object obj=channel.receive(0); if(obj instanceof StreamingSetStateEvent) { StreamingSetStateEvent evt=(StreamingSetStateEvent)obj; ObjectInputStream ois = null; try { ois = new ObjectInputStream(evt.getArg()); state = (LinkedList)ois.readObject(); } catch (Exception e) {} finally { try { ois.close(); } catch (IOException e) { System.err.println(e); } } }
- Since:
- 2.4
- Author:
- Vladimir Blagojevic
- See Also:
JChannel.getState(Address, long)
,org.jgroups.StreamingMessageListener#setState(InputStream)
-
-
Constructor Summary
Constructors Constructor Description StreamingSetStateEvent(java.io.InputStream is, java.lang.String state_id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStream
getArg()
Returns InputStream used for reading of a state.java.lang.String
getStateId()
Returns id of the partial state if partial state was requested.
-
-
-
Method Detail
-
getArg
public java.io.InputStream getArg()
Returns InputStream used for reading of a state.- Returns:
- the InputStream
-
getStateId
public java.lang.String getStateId()
Returns id of the partial state if partial state was requested. If full state transfer was requested this method will return null.- Returns:
- partial state id
- See Also:
JChannel.getState(Address, long)
,JChannel.getState(Address, String, long)
-
-