com.faunos.skwish
Class SegmentStore

java.lang.Object
  extended by com.faunos.skwish.SegmentStore
All Implemented Interfaces:
Closeable, Channel
Direct Known Subclasses:
Store

public abstract class SegmentStore
extends Object
implements Channel

A managed union of segments on the file system exposed as a logical whole. This class provides transaction semantics and supports concurrent access to the logical whole segment.

Author:
Babak Farhang

Field Summary
protected static Validator<SegmentStoreException> validator
           
 
Constructor Summary
SegmentStore()
           
 
Method Summary
abstract  void close()
          Closes the instance.
static Provider getProvider()
          Returns the current service provider.
abstract  Segment getReadOnlySegment()
          Returns the live read-only view of the committed segments.
abstract  long getTxnCommitIdGap(long txnId)
          Returns the transaction commit id gap recorded on commit for the specified transaction, or -1, if the transaction is pending or discarded.
abstract  String getUri()
          Returns the URI used to load this instance.
static SegmentStore loadInstance(String uri)
          Loads and returns an existing segment store from the specified URI.
abstract  TxnSegment newTransaction()
          Returns a new transaction [segment].
static void setProvider(Provider provider)
          Sets the service provider.
static SegmentStore writeNewInstance(String uri)
          Writes a new segment store to the specified URI and returns the instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.nio.channels.Channel
isOpen
 

Field Detail

validator

protected static final Validator<SegmentStoreException> validator
Constructor Detail

SegmentStore

public SegmentStore()
Method Detail

setProvider

public static void setProvider(Provider provider)
Sets the service provider. Invoked to change the backing implementation.


getProvider

public static Provider getProvider()
Returns the current service provider.


loadInstance

public static SegmentStore loadInstance(String uri)
                                 throws IOException
Loads and returns an existing segment store from the specified URI. Presently, this just takes the form of a file path.

Throws:
IOException

writeNewInstance

public static SegmentStore writeNewInstance(String uri)
                                     throws IOException
Writes a new segment store to the specified URI and returns the instance.

Throws:
IOException

getUri

public abstract String getUri()
Returns the URI used to load this instance.


getReadOnlySegment

public abstract Segment getReadOnlySegment()
                                    throws IOException
Returns the live read-only view of the committed segments. Transactions are immediately visible on commit.

Throws:
IOException

newTransaction

public abstract TxnSegment newTransaction()
                                   throws IOException
Returns a new transaction [segment]. Transactions allow changes to be committed in all-or-nothing fashion. There is no architectural limit on the number of transactions that can be concurrently open (pending). Also, while transactions (TxnSegments) are not individually thread-safe, each transaction may be run concurrently in its own thread.

Throws:
IOException

getTxnCommitIdGap

public abstract long getTxnCommitIdGap(long txnId)
                                throws IOException,
                                       NotFoundException
Returns the transaction commit id gap recorded on commit for the specified transaction, or -1, if the transaction is pending or discarded.

Parameters:
txnId - the transaction id (from TxnSegment.getTxnId())
Throws:
NotFoundException - If txnId does not specify a known transaction
IOException

close

public abstract void close()
                    throws IOException
Closes the instance. All Segments opened by this instance are implicitly closed, and any uncommitted TxnSegments are discarded.

Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Throws:
IOException


SourceForge.net Logo