voldemort.store.readonly
Class ReadOnlyStorageEngine

java.lang.Object
  extended by voldemort.store.readonly.ReadOnlyStorageEngine
All Implemented Interfaces:
StorageEngine<ByteArray,byte[],byte[]>, Store<ByteArray,byte[],byte[]>

public class ReadOnlyStorageEngine
extends java.lang.Object
implements StorageEngine<ByteArray,byte[],byte[]>

A read-only store that fronts a big file


Constructor Summary
ReadOnlyStorageEngine(java.lang.String name, SearchStrategy searchStrategy, RoutingStrategy routingStrategy, int nodeId, java.io.File storeDir, int numBackups)
          Create an instance of the store
ReadOnlyStorageEngine(java.lang.String name, SearchStrategy searchStrategy, RoutingStrategy routingStrategy, int nodeId, java.io.File storeDir, int numBackups, int deleteBackupMs)
          Create an instance of the store
 
Method Summary
 void close()
          Close the store.
 boolean delete(ByteArray key, Version version)
          Not supported, throws UnsupportedOperationException if called
 ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries()
          Get an iterator over pairs of entries in the store.
 java.util.List<Versioned<byte[]>> get(ByteArray key, byte[] transforms)
          Get the value associated with the given key
 java.util.Map<ByteArray,java.util.List<Versioned<byte[]>>> getAll(java.lang.Iterable<ByteArray> keys, java.util.Map<ByteArray,byte[]> transforms)
          Get the values associated with the given keys and returns them in a Map of keys to a list of versioned values.
 java.lang.Object getCapability(StoreCapabilityType capability)
          Get some capability of the store.
 ChunkedFileSet getChunkedFileSet()
          Returns the internal chunked file set
 java.lang.String getChunkIdToNumChunks()
          Returns a string representation of map of chunk id to number of chunks
 java.lang.String getCurrentDirPath()
          Retrieve the absolute path of the current version
 long getCurrentVersionId()
          Retrieve the version id of the current directory
 long getLastSwapped()
          Time since last time the store was swapped
 java.lang.String getName()
           
 ReadOnlyStorageFormat getReadOnlyStorageFormat()
          Retrieve the storage format of RO
 java.lang.String getStoreDirPath()
          Retrieves the path of the store
 java.util.List<Version> getVersions(ByteArray key)
           
 boolean isPartitionAware()
          Is the data persistence aware of partitions? In other words is the data internally stored on a per partition basis or together
 ClosableIterator<ByteArray> keys()
          Get an iterator over keys in the store.
 void open(java.io.File versionDir)
          Open the store with the version directory specified.
 void put(ByteArray key, Versioned<byte[]> value, byte[] transforms)
          Not supported, throws UnsupportedOperationException if called
 void rollback(java.io.File rollbackToDir)
          Rollback to the specified push version
 void rollback(java.lang.String rollbackToDir)
          Rollback to the specified push version
 void setRoutingStrategy(RoutingStrategy routingStrategy)
          Set the routing strategy required to find which partition the key belongs to
 void swapFiles(java.lang.String newStoreDirectory)
          Swap the current version folder for a new one
 void truncate()
          Truncate all entries in the store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyStorageEngine

public ReadOnlyStorageEngine(java.lang.String name,
                             SearchStrategy searchStrategy,
                             RoutingStrategy routingStrategy,
                             int nodeId,
                             java.io.File storeDir,
                             int numBackups,
                             int deleteBackupMs)
Create an instance of the store

Parameters:
name - The name of the store
searchStrategy - The algorithm to use for searching for keys
routingStrategy - The routing strategy used to route keys
nodeId - Node id
storeDir - The directory in which the .data and .index files reside
numBackups - The number of backups of these files to retain
deleteBackupMs - The time in ms for which we'll wait before we delete a backup

ReadOnlyStorageEngine

public ReadOnlyStorageEngine(java.lang.String name,
                             SearchStrategy searchStrategy,
                             RoutingStrategy routingStrategy,
                             int nodeId,
                             java.io.File storeDir,
                             int numBackups)
Create an instance of the store

Parameters:
name - The name of the store
searchStrategy - The algorithm to use for searching for keys
routingStrategy - The routing strategy used to route keys
nodeId - Node id
storeDir - The directory in which the .data and .index files reside
numBackups - The number of backups of these files to retain
Method Detail

getChunkedFileSet

public ChunkedFileSet getChunkedFileSet()
Returns the internal chunked file set

Returns:
The chunked file set

getChunkIdToNumChunks

public java.lang.String getChunkIdToNumChunks()
Returns a string representation of map of chunk id to number of chunks

Returns:
String of map of chunk id to number of chunks

open

public void open(java.io.File versionDir)
Open the store with the version directory specified. If null is specified we open the directory with the maximum version

Parameters:
versionDir - Version Directory to open. If null, we open the max versioned / latest directory

setRoutingStrategy

public void setRoutingStrategy(RoutingStrategy routingStrategy)
Set the routing strategy required to find which partition the key belongs to


getCurrentDirPath

public java.lang.String getCurrentDirPath()
Retrieve the absolute path of the current version

Returns:
Returns the absolute path of the current dir

getCurrentVersionId

public long getCurrentVersionId()
Retrieve the version id of the current directory

Returns:
Returns a long indicating the version number

getStoreDirPath

public java.lang.String getStoreDirPath()
Retrieves the path of the store

Returns:
The absolute path of the store

getReadOnlyStorageFormat

public ReadOnlyStorageFormat getReadOnlyStorageFormat()
Retrieve the storage format of RO

Returns:
The type of the storage format

getLastSwapped

public long getLastSwapped()
Time since last time the store was swapped

Returns:
Time in milliseconds since the store was swapped

close

public void close()
           throws VoldemortException
Close the store.

Specified by:
close in interface Store<ByteArray,byte[],byte[]>
Throws:
VoldemortException - If closing fails.

swapFiles

public void swapFiles(java.lang.String newStoreDirectory)
Swap the current version folder for a new one

Parameters:
newStoreDirectory - The path to the new version directory

rollback

public void rollback(java.lang.String rollbackToDir)
Rollback to the specified push version

Parameters:
rollbackToDir - The full path of the version directory to rollback to

rollback

public void rollback(java.io.File rollbackToDir)
Rollback to the specified push version

Parameters:
rollbackToDir - The version directory to rollback to

keys

public ClosableIterator<ByteArray> keys()
Description copied from interface: StorageEngine
Get an iterator over keys in the store. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
keys in interface StorageEngine<ByteArray,byte[],byte[]>
Returns:
An iterator over the keys in this StorageEngine.

entries

public ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries()
Description copied from interface: StorageEngine
Get an iterator over pairs of entries in the store. The key is the first element in the pair and the versioned value is the second element. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
entries in interface StorageEngine<ByteArray,byte[],byte[]>
Returns:
An iterator over the entries in this StorageEngine.

truncate

public void truncate()
Description copied from interface: StorageEngine
Truncate all entries in the store

Specified by:
truncate in interface StorageEngine<ByteArray,byte[],byte[]>

get

public java.util.List<Versioned<byte[]>> get(ByteArray key,
                                             byte[] transforms)
                                      throws VoldemortException
Description copied from interface: Store
Get the value associated with the given key

Specified by:
get in interface Store<ByteArray,byte[],byte[]>
Parameters:
key - The key to check for
Returns:
The value associated with the key or an empty list if no values are found.
Throws:
VoldemortException

getAll

public java.util.Map<ByteArray,java.util.List<Versioned<byte[]>>> getAll(java.lang.Iterable<ByteArray> keys,
                                                                         java.util.Map<ByteArray,byte[]> transforms)
                                                                  throws VoldemortException
Description copied from interface: Store
Get the values associated with the given keys and returns them in a Map of keys to a list of versioned values. Note that the returned map will only contain entries for the keys which have a value associated with them.

Specified by:
getAll in interface Store<ByteArray,byte[],byte[]>
Parameters:
keys - The keys to check for.
Returns:
A Map of keys to a list of versioned values.
Throws:
VoldemortException

delete

public boolean delete(ByteArray key,
                      Version version)
               throws VoldemortException
Not supported, throws UnsupportedOperationException if called

Specified by:
delete in interface Store<ByteArray,byte[],byte[]>
Parameters:
key - The key to delete
version - The current value of the key
Returns:
True if anything was deleted
Throws:
VoldemortException

put

public void put(ByteArray key,
                Versioned<byte[]> value,
                byte[] transforms)
         throws VoldemortException
Not supported, throws UnsupportedOperationException if called

Specified by:
put in interface Store<ByteArray,byte[],byte[]>
Parameters:
key - The key to use
value - The value to store and its version.
Throws:
VoldemortException

getName

public java.lang.String getName()
Specified by:
getName in interface Store<ByteArray,byte[],byte[]>
Returns:
The name of the store.

getCapability

public java.lang.Object getCapability(StoreCapabilityType capability)
Description copied from interface: Store
Get some capability of the store. Examples would be the serializer used, or the routing strategy. This provides a mechanism to verify that the store hierarchy has some set of capabilities without knowing the precise layering.

Specified by:
getCapability in interface Store<ByteArray,byte[],byte[]>
Parameters:
capability - The capability type to retrieve
Returns:
The given capaiblity

getVersions

public java.util.List<Version> getVersions(ByteArray key)
Specified by:
getVersions in interface Store<ByteArray,byte[],byte[]>

isPartitionAware

public boolean isPartitionAware()
Description copied from interface: StorageEngine
Is the data persistence aware of partitions? In other words is the data internally stored on a per partition basis or together

Specified by:
isPartitionAware in interface StorageEngine<ByteArray,byte[],byte[]>
Returns:
Boolean indicating if the data persistence is partition aware


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao