org.jgroups.protocols.pbcast
Class STATE
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.pbcast.StreamingStateTransfer
org.jgroups.protocols.pbcast.STATE
public class STATE
- extends StreamingStateTransfer
STATE streams the state (written to an OutputStream) to the state requester in chunks (defined by
chunk_size). Every chunk is sent via a unicast message. The state requester writes the chunks into a blocking
input stream (BlockingInputStream
) from which the MessageListener.setState(java.io.InputStream)
reads it. The size of the BlockingInputStream is buffer_size bytes.
When implementing MessageListener.getState(java.io.OutputStream)
, the state should be written in sizeable
chunks, because the underlying output stream generates 1 message / write. So if there are 1000 writes of 1 byte
each, this would generate 1000 messages ! We suggest using a BufferedOutputStream
over the output
stream handed to the application as argument of the callback.
When implementing the MessageListener.setState(java.io.InputStream)
callback, there is no need to use a
BufferedOutputStream
, as the input stream handed to the application already buffers incoming data
internally.
- Since:
- 2.4
- Author:
- Bela Ban, Vladimir Blagojevic
Fields inherited from class org.jgroups.protocols.pbcast.StreamingStateTransfer |
avg_state_size, barrier_closed, buffer_size, flushProtocolInStack, local_addr, max_pool, members, num_bytes_sent, num_state_reqs, pending_state_transfers, pool_thread_keep_alive, state_lock, state_provider, thread_pool |
Constructor Summary |
STATE()
|
Methods inherited from class org.jgroups.protocols.pbcast.StreamingStateTransfer |
closeBarrierAndSuspendStable, createThreadPool, destroy, determineCoordinator, down, getAverageStateSize, getNumberOfStateBytesSent, getNumberOfStateRequests, getStateFromApplication, getThreadPoolCompletedTasks, getThreadPoolSize, handleConfig, handleStateReq, init, isDigestNeeded, modifyStateResponseHeader, openBarrierAndResumeStable, removeRequester, requiredDownServices, resetStats, sendEof, sendException, setStateInApplication, start, stop, up |
Methods inherited from class org.jgroups.stack.Protocol |
dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
input_stream
protected volatile BlockingInputStream input_stream
- If use_default_transport is true, we consume bytes off of this blocking queue. Used on the state
requester side only
STATE
public STATE()
handleViewChange
protected void handleViewChange(View v)
- Overrides:
handleViewChange
in class StreamingStateTransfer
handleEOF
protected void handleEOF(Address sender)
- Overrides:
handleEOF
in class StreamingStateTransfer
handleException
protected void handleException(java.lang.Throwable exception)
- Overrides:
handleException
in class StreamingStateTransfer
handleStateChunk
protected void handleStateChunk(Address sender,
byte[] buffer,
int offset,
int length)
- Overrides:
handleStateChunk
in class StreamingStateTransfer
createStreamToRequester
protected void createStreamToRequester(Address requester)
- Description copied from class:
StreamingStateTransfer
- Creates an OutputStream to the state requester to write the state
- Specified by:
createStreamToRequester
in class StreamingStateTransfer
createStreamToProvider
protected void createStreamToProvider(Address provider,
StreamingStateTransfer.StateHeader hdr)
- Description copied from class:
StreamingStateTransfer
- Creates an InputStream to the state provider to read the state
- Specified by:
createStreamToProvider
in class StreamingStateTransfer
Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.