com.bigdata.ha
Class QuorumReadImpl<S extends HAReadGlue>

java.lang.Object
  extended by com.bigdata.quorum.QuorumStateChangeListenerBase
      extended by com.bigdata.ha.QuorumReadImpl<S>
Type Parameters:
S -
All Implemented Interfaces:
QuorumRead<S>, QuorumStateChangeListener

public class QuorumReadImpl<S extends HAReadGlue>
extends QuorumStateChangeListenerBase
implements QuorumRead<S>

QuorumRead implementation.

Version:
$Id: QuorumReadImpl.java 4069 2011-01-09 20:58:02Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static org.apache.log4j.Logger log
           
protected  QuorumMember<S> member
           
 
Constructor Summary
QuorumReadImpl(QuorumMember<S> member)
           
 
Method Summary
protected  UUID getNextBadReadServiceId(UUID[] joinedServiceIds)
          Return the UUID of the joined service to which this service will direct a failover read.
 byte[] readFromQuorum(UUID storeId, long addr)
          Used by any service joined with the quorum to read a record from another service joined with the quorum in order to work around a "bad read" as identified by a checksum error on the local service.
 
Methods inherited from class com.bigdata.quorum.QuorumStateChangeListenerBase
consensus, lostConsensus, memberAdd, memberRemove, pipelineAdd, pipelineChange, pipelineElectedLeader, pipelineRemove, quorumBreak, quorumMeet, serviceJoin, serviceLeave
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final transient org.apache.log4j.Logger log

member

protected final QuorumMember<S extends HAReadGlue> member
Constructor Detail

QuorumReadImpl

public QuorumReadImpl(QuorumMember<S> member)
Method Detail

getNextBadReadServiceId

protected UUID getNextBadReadServiceId(UUID[] joinedServiceIds)
Return the UUID of the joined service to which this service will direct a failover read. The default implementation uses a round-robin policy.

Parameters:
joinedServiceIds - The UUIDs of the services currently joined with the quorum.
Returns:
The UUID of the service to which the failover read will be directed.

readFromQuorum

public byte[] readFromQuorum(UUID storeId,
                             long addr)
                      throws InterruptedException,
                             IOException
Used by any service joined with the quorum to read a record from another service joined with the quorum in order to work around a "bad read" as identified by a checksum error on the local service.

Note: This is NOT the normal path for reading on a record from a service. This is used to handle bad reads (when a checksum or IO error is reported by the local disk) by reading the record from another member of the quorum.

Specified by:
readFromQuorum in interface QuorumRead<S extends HAReadGlue>
Parameters:
storeId - The UUID of the IRawStore from which the record should be read.
addr - The address of a record on that store.
Returns:
The record.
Throws:
InterruptedException
IOException
See Also:
HAGlue#readFromDisk(UUID, long)
TODO:
If this blocks awaiting a quorum, then make sure that it is not invoked in a context where it is holding a lock on the local low-level store!


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.