Package org.jgroups.protocols.pbcast
Class STATE
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.pbcast.StreamingStateTransfer
org.jgroups.protocols.pbcast.STATE
- All Implemented Interfaces:
Lifecycle,ProcessingQueue.Handler<Address>
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 Receiver.setState(java.io.InputStream)
reads it. The size of the BlockingInputStream is buffer_size bytes.
When implementing Receiver.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 Receiver.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
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.jgroups.protocols.pbcast.StreamingStateTransfer
StreamingStateTransfer.StateGetter, StreamingStateTransfer.StateHeader -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BlockingInputStreamIf use_default_transport is true, we consume bytes off of this blocking queue.Fields inherited from class org.jgroups.protocols.pbcast.StreamingStateTransfer
avg_state_size, buffer_size, flushProtocolInStack, max_pool, members, num_bytes_sent, num_state_reqs, pool_thread_keep_alive, state_provider, state_requesters, thread_poolFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Tuple<InputStream, Object> createStreamToProvider(Address provider, StreamingStateTransfer.StateHeader hdr) Creates an InputStream to the state provider to read the state.protected voidcreateStreamToRequester(Address requester) Creates an OutputStream to the state requester to write the stateprotected voidprotected voidhandleException(Throwable exception) protected voidhandleStateChunk(Address sender, byte[] buffer, int offset, int length) protected voidprotected booleanMethods inherited from class org.jgroups.protocols.pbcast.StreamingStateTransfer
close, closeBarrierAndSuspendStable, closeHoleFor, createThreadPool, destroy, determineCoordinator, down, getAverageStateSize, getNumberOfStateBytesSent, getNumberOfStateRequests, getStateFromApplication, getThreadPoolCompletedTasks, getThreadPoolSize, handle, handle, handleConfig, handleStateReq, handleStateRsp, init, isDigestNeeded, modifyStateResponseHeader, openBarrier, openBarrierAndResumeStable, punchHoleFor, requiredDownServices, resetStats, resumeStable, sendEof, sendException, setStateInApplication, start, stop, up, up, upMethods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
Field Details
-
input_stream
If use_default_transport is true, we consume bytes off of this blocking queue. Used on the state requester side only. Note that we cannot use a PipedInputStream as we have multiple writer threads pushing data into the input stream
-
-
Constructor Details
-
STATE
public STATE()
-
-
Method Details
-
handleViewChange
- Overrides:
handleViewChangein classStreamingStateTransfer
-
handleEOF
- Overrides:
handleEOFin classStreamingStateTransfer
-
handleException
- Overrides:
handleExceptionin classStreamingStateTransfer
-
handleStateChunk
- Overrides:
handleStateChunkin classStreamingStateTransfer
-
createStreamToRequester
Description copied from class:StreamingStateTransferCreates an OutputStream to the state requester to write the state- Overrides:
createStreamToRequesterin classStreamingStateTransfer
-
createStreamToProvider
protected Tuple<InputStream,Object> createStreamToProvider(Address provider, StreamingStateTransfer.StateHeader hdr) Description copied from class:StreamingStateTransferCreates an InputStream to the state provider to read the state. Return the input stream and a handback object as a tuple. The handback object is handed back to the subclass when done, or in case of an error (e.g. to clean up resources)- Specified by:
createStreamToProviderin classStreamingStateTransfer
-
useAsyncStateDelivery
protected boolean useAsyncStateDelivery()- Overrides:
useAsyncStateDeliveryin classStreamingStateTransfer
-