org.jgroups.protocols.pbcast
Class STATE

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.pbcast.StreamingStateTransfer
          extended by 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

Nested Class Summary
protected  class STATE.StateOutputStream
           
 
Nested classes/interfaces inherited from class org.jgroups.protocols.pbcast.StreamingStateTransfer
StreamingStateTransfer.StateGetter, StreamingStateTransfer.StateHeader
 
Field Summary
protected  BlockingInputStream input_stream
          If 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, 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
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
STATE()
           
 
Method Summary
protected  void createStreamToProvider(Address provider, StreamingStateTransfer.StateHeader hdr)
          Creates an InputStream to the state provider to read the state
protected  void createStreamToRequester(Address requester)
          Creates an OutputStream to the state requester to write the state
protected  void handleEOF(Address sender)
           
protected  void handleException(java.lang.Throwable exception)
           
protected  void handleStateChunk(Address sender, byte[] buffer, int offset, int length)
           
protected  void handleViewChange(View v)
           
 
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
 

Field Detail

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

Constructor Detail

STATE

public STATE()
Method Detail

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.