com.bigdata.journal
Class TemporaryStore

java.lang.Object
  extended by com.bigdata.rawstore.AbstractRawStore
      extended by com.bigdata.rawstore.AbstractRawWormStore
          extended by com.bigdata.journal.TemporaryRawStore
              extended by com.bigdata.journal.TemporaryStore
All Implemented Interfaces:
IBTreeManager, IIndexManager, IIndexStore, IAddressManager, IMRMW, IMROW, IRawStore, IStoreSerializer, IUpdateStore, IWORM

public class TemporaryStore
extends TemporaryRawStore
implements IBTreeManager

A temporary store that supports named indices but no concurrency controls. checkpoint() may be used to checkpoint the indices and restoreLastCheckpoint() may be used to revert to the last checkpoint. If you note the checkpoint addresses from checkpoint() then you can restore any checkpoint with restoreCheckpoint(long)

If you want a temporary store that supports named indices and concurrency controls then choose a Journal with BufferMode.Temporary. This has the advantage of full concurrency support, group commit, and low-latency startup (since the file is not created until the store attempts to write through to the disk). However, TemporaryStore is lighter weight precisely because it does not provide concurrency control.

Version:
$Id: TemporaryStore.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
 
Fields inherited from class com.bigdata.journal.TemporaryRawStore
log
 
Fields inherited from class com.bigdata.rawstore.AbstractRawWormStore
am
 
Fields inherited from class com.bigdata.rawstore.AbstractRawStore
serializer
 
Fields inherited from interface com.bigdata.rawstore.IAddressManager
NULL
 
Constructor Summary
TemporaryStore()
          A TemporaryStore that can scale-up.
TemporaryStore(int offsetBits)
          A TemporaryStore provisioned with the specified offsetBits.
TemporaryStore(int offsetBits, File file)
          A TemporaryStore provisioned with the specified offsetBits and backed by the specified file.
 
Method Summary
 long checkpoint()
          Checkpoints the dirty indices and notes the new restoreLastCheckpoint() point.
 void close()
          Close the store and delete the associated file, if any.
 void dropIndex(String name)
          Drops the named index.
 ExecutorService getExecutorService()
          A ExecutorService that may be used to parallelize operations.
 BigdataFileSystem getGlobalFileSystem()
          Return the global file system used to store block-structured files and their metadata and as a source and sink for map/reduce processing.
 SparseRowStore getGlobalRowStore()
          Return the global SparseRowStore used to store named property sets.
 BTree getIndex(String name)
          Return an ITx.UNISOLATED view of the named index -or- null if there is no registered index by that name.
 BTree getIndex(String name, long timestamp)
          Historical reads and transactions are not supported.
 long getLastCommitTime()
          Always returns ZERO (0L) since you can not perform a commit on a TemporaryRawStore (it supports checkpoints but not commits).
 DefaultResourceLocator getResourceLocator()
          Return the default locator for resources that are logical index containers (relations and relation containers).
 IResourceLockService getResourceLockService()
          The service that may be used to acquire synchronous distributed locks without deadlock detection.
 TemporaryStore getTempStore()
          Always returns this TemporaryStore.
 void registerIndex(IndexMetadata metadata)
          Register a named index.
 BTree registerIndex(String name, BTree btree)
          Register a named index.
 BTree registerIndex(String name, IndexMetadata metadata)
          Register a named index.
 void restoreCheckpoint(long checkpointAddr)
          Reverts to the checkpoint associated with the given checkpointAddr.
 void restoreLastCheckpoint()
          Reverts to the last checkpoint, if any.
 
Methods inherited from class com.bigdata.journal.TemporaryRawStore
allocate, assertOpen, deleteResources, destroy, finalize, force, getBufferStrategy, getCounters, getFile, getMaxRecordSize, getResourceMetadata, getTempFile, getTempFile, getUUID, isFullyBuffered, isOpen, isReadOnly, isStable, read, size, toString, update, write
 
Methods inherited from class com.bigdata.rawstore.AbstractRawWormStore
getAddressManager, getByteCount, getOffset, getOffsetBits, packAddr, toAddr, toString, unpackAddr
 
Methods inherited from class com.bigdata.rawstore.AbstractRawStore
deserialize, deserialize, deserialize, serialize
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.bigdata.journal.IIndexStore
destroy
 
Methods inherited from interface com.bigdata.rawstore.IAddressManager
getByteCount, getOffset, packAddr, toAddr, toString, unpackAddr
 
Methods inherited from interface com.bigdata.rawstore.IStoreSerializer
deserialize, deserialize, deserialize, serialize
 

Constructor Detail

TemporaryStore

public TemporaryStore()
A TemporaryStore that can scale-up. The backing file will be created using the Java temporary file mechanism.

See Also:
WormAddressManager.SCALE_UP_OFFSET_BITS, TemporaryRawStore.getTempFile()

TemporaryStore

public TemporaryStore(int offsetBits)
A TemporaryStore provisioned with the specified offsetBits. The backing file will be created using the Java temporary file mechanism.

Parameters:
offsetBits - This determines the capacity of the store file and the maximum length of a record. The value is passed through to WormAddressManager.WormAddressManager(int).

TemporaryStore

public TemporaryStore(int offsetBits,
                      File file)
A TemporaryStore provisioned with the specified offsetBits and backed by the specified file.

Parameters:
offsetBits - This determines the capacity of the store file and the maximum length of a record. The value is passed through to WormAddressManager.WormAddressManager(int).
file - The backing file (may exist, but must be empty if it exists).
Method Detail

restoreLastCheckpoint

public void restoreLastCheckpoint()
Reverts to the last checkpoint, if any. If there is no last checkpoint, then the post-condition is as if the store had never been written on (except that the storage on the backing file is not reclaimed).


restoreCheckpoint

public void restoreCheckpoint(long checkpointAddr)
Reverts to the checkpoint associated with the given checkpointAddr. When ZERO(0L), the post-condition is as if the store had never been written on (except that the storage on the backing file is not reclaimed). The checkpointAddr is noted as the current restoreLastCheckpoint() point.


checkpoint

public long checkpoint()
Checkpoints the dirty indices and notes the new restoreLastCheckpoint() point. You can revert to the last written checkpoint using restoreLastCheckpoint() or to an arbitrary checkpoint using restoreCheckpoint(long).

Note: ITx.READ_COMMITTED views of indices become available after a checkpoint(). If the store has not been checkpointed, then the read committed views are unavailable for an index. After a checkpoint in which a given index was dirty, a new read-committed view is available for that index and checkpoint.

Note: This is NOT an atomic commit protocol, but the restore point will be updated iff the checkpoint succeeds.

Returns:
The checkpoint address.

registerIndex

public void registerIndex(IndexMetadata metadata)
Description copied from interface: IIndexManager
Register a named index.

Note: The name property MUST be set on the IndexMetadata and the index will be registered under that name.

Specified by:
registerIndex in interface IIndexManager
Parameters:
metadata - The metadata describing the index.

registerIndex

public BTree registerIndex(String name,
                           IndexMetadata metadata)
Description copied from interface: IBTreeManager
Register a named index.

This variant allows you to register an index under a name other than the value returned by IndexMetadata.getName().

Note: This variant is generally by the IMetadataService when it needs to register a index partition of some scale-out index on a IDataService. In this case the name is the name of the index partition while the value reported by IndexMetadata.getName() is the name of the scale-out index. In nearly all other cases you can use IIndexManager.registerIndex(IndexMetadata) instead. The same method signature is also declared by IDataService.registerIndex(String, IndexMetadata) in order to support registration of index partitions.

Specified by:
registerIndex in interface IBTreeManager
Parameters:
name - The name that can be used to recover the index.
metadata - The metadata describing the index.
Returns:
The object that would be returned by IBTreeManager.getIndex(String).

registerIndex

public BTree registerIndex(String name,
                           BTree btree)
Description copied from interface: IBTreeManager
Register a named index.

Specified by:
registerIndex in interface IBTreeManager
Parameters:
name - The name that can be used to recover the index.
btree - The btree.
Returns:
The object that would be returned by IBTreeManager.getIndex(String).

dropIndex

public void dropIndex(String name)
Description copied from interface: IIndexManager
Drops the named index.

Note: Whether or not and when index resources are reclaimed is dependent on the store. For example, an immortal store will retain all historical states for all indices. Likewise, a store that uses index partitions may be able to delete index segments immediately.

Specified by:
dropIndex in interface IIndexManager
Parameters:
name - The name of the index to be dropped.

getIndex

public BTree getIndex(String name)
Return an ITx.UNISOLATED view of the named index -or- null if there is no registered index by that name.

Specified by:
getIndex in interface IBTreeManager
Parameters:
name - The name of the index.
Returns:
The unisolated view named index or null iff there is no index registered with that name.

getIndex

public BTree getIndex(String name,
                      long timestamp)
Historical reads and transactions are not supported.

Note: If ITx.READ_COMMITTED is requested, then the returned BTree will reflect the state of the named index as of the last checkpoint(). This view will be read-only and is NOT updated by checkpoint(). You must actually checkpoint() before an ITx.READ_COMMITTED view will be available.

Specified by:
getIndex in interface IIndexStore
Parameters:
name -
timestamp -
Returns:
The index or null iff there is no index registered with that name for that timestamp.
Throws:
UnsupportedOperationException - unless the timestamp is either ITx.READ_COMMITTED or ITx.UNISOLATED.

getGlobalRowStore

public SparseRowStore getGlobalRowStore()
Description copied from interface: IIndexStore
Return the global SparseRowStore used to store named property sets.

Specified by:
getGlobalRowStore in interface IIndexStore
See Also:
GlobalRowStoreSchema

getGlobalFileSystem

public BigdataFileSystem getGlobalFileSystem()
Description copied from interface: IIndexStore
Return the global file system used to store block-structured files and their metadata and as a source and sink for map/reduce processing.

Specified by:
getGlobalFileSystem in interface IIndexStore
See Also:
BigdataFileSystem

getResourceLocator

public DefaultResourceLocator getResourceLocator()
Description copied from interface: IIndexStore
Return the default locator for resources that are logical index containers (relations and relation containers).

Specified by:
getResourceLocator in interface IIndexStore

getExecutorService

public ExecutorService getExecutorService()
Description copied from interface: IIndexStore
A ExecutorService that may be used to parallelize operations. This service is automatically used when materializing located resources. While the service does not impose concurrency controls, tasks run on this service may submit operations to a ConcurrencyManager.

Specified by:
getExecutorService in interface IIndexStore

getResourceLockService

public final IResourceLockService getResourceLockService()
Description copied from interface: IIndexStore
The service that may be used to acquire synchronous distributed locks without deadlock detection.

Specified by:
getResourceLockService in interface IIndexStore

close

public void close()
Description copied from class: TemporaryRawStore
Close the store and delete the associated file, if any.

Specified by:
close in interface IRawStore
Overrides:
close in class TemporaryRawStore

getLastCommitTime

public long getLastCommitTime()
Always returns ZERO (0L) since you can not perform a commit on a TemporaryRawStore (it supports checkpoints but not commits).

Specified by:
getLastCommitTime in interface IIndexStore
Returns:
The timestamp of the most recent commit on the store or 0L iff there have been no commits.
See Also:
IRootBlockView.getLastCommitTime()

getTempStore

public TemporaryStore getTempStore()
Always returns this TemporaryStore.

Specified by:
getTempStore in interface IIndexStore
Returns:
A TemporaryStore.


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