Package org.jgroups
Class StreamingGetStateEvent
- java.lang.Object
-
- org.jgroups.StreamingGetStateEvent
-
public class StreamingGetStateEvent extends java.lang.Object
Represents an event returned bychannel.receive()
, as a result of another channel instance requesting a state from this channel. Other channel has to invokechannel.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 withSTREAMING_STATE_TRANSFER
protocol rather than the defaultSTATE_TRANSFER
protocol in order to receive this eventThe following code demonstrates how to pull events from a channel, processing
StreamingGetStateEvent
and sending hypothetical state throughOutputStream
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); } } }
- Since:
- 2.4
- Author:
- Vladimir Blagojevic
- See Also:
JChannel.getState(Address, long)
,org.jgroups.StreamingMessageListener#getState(OutputStream)
-
-
Constructor Summary
Constructors Constructor Description StreamingGetStateEvent(java.io.OutputStream os, java.lang.String state_id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.OutputStream
getArg()
Returns OutputStream used for writing of a state.java.lang.String
getStateId()
Returns id of the partial state if partial state was requested.
-
-
-
Method Detail
-
getArg
public java.io.OutputStream getArg()
Returns OutputStream used for writing of a state.- Returns:
- the OutputStream
-
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)
-
-