Package com.github.ambry.store
Interface Store
-
public interface Store
The object store's underlying store
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
completeBootstrap()
Take actions (if any) to complete the bootstrap (i.e, delete bootstrap file in store directory)void
delete(java.util.List<MessageInfo> infosToDelete)
Deletes all the messages in the list.FindInfo
findEntriesSince(FindToken token, long maxTotalSizeOfEntries)
Finds all the entries from the store given a find tokenMessageInfo
findKey(StoreKey key)
ReturnMessageInfo
of given key.java.util.Set<StoreKey>
findMissingKeys(java.util.List<StoreKey> keys)
Finds all the keys that are not present in the store from the input keysStoreInfo
get(java.util.List<? extends StoreKey> ids, java.util.EnumSet<StoreGetOptions> storeGetOptions)
Returns the store info for the given idsReplicaState
getCurrentState()
long
getEndPositionOfLastPut()
long
getSizeInBytes()
Returns the size of the store in bytesStoreStats
getStoreStats()
Get the correspondingStoreStats
instance for this store.boolean
isBootstrapInProgress()
boolean
isDecommissionInProgress()
boolean
isDisabled()
boolean
isEmpty()
boolean
isKeyDeleted(StoreKey key)
Checks if the key is deleted.boolean
isStarted()
void
put(MessageWriteSet messageSetToWrite)
Puts a set of messages into the store.boolean
recoverFromDecommission()
void
setCurrentState(ReplicaState state)
Set current state of the store.void
shutdown()
Shuts down the storevoid
start()
Starts the storeshort
undelete(MessageInfo info)
Undelete the blob identified byid
.void
updateTtl(java.util.List<MessageInfo> infosToUpdate)
Updates the TTL of all the messages in the list.
-
-
-
Method Detail
-
start
void start() throws StoreException
Starts the store- Throws:
StoreException
-
get
StoreInfo get(java.util.List<? extends StoreKey> ids, java.util.EnumSet<StoreGetOptions> storeGetOptions) throws StoreException
Returns the store info for the given ids- Parameters:
ids
- The list of ids whose messages need to be retrievedstoreGetOptions
- A set of additional options that the store needs to use while getting the message- Returns:
- The store info for the given ids
- Throws:
StoreException
-
put
void put(MessageWriteSet messageSetToWrite) throws StoreException
Puts a set of messages into the store. When the lifeVersion isMessageInfo.LIFE_VERSION_FROM_FRONTEND
, this method is invoked by the responding to the frontend request. Otherwise, it's invoked in the replication thread.- Parameters:
messageSetToWrite
- The message set to write to the store Only the StoreKey, OperationTime, ExpirationTime, LifeVersion should be used in this method.- Throws:
StoreException
-
delete
void delete(java.util.List<MessageInfo> infosToDelete) throws StoreException
Deletes all the messages in the list. When the lifeVersion isMessageInfo.LIFE_VERSION_FROM_FRONTEND
, this method is invoked by the responding to the frontend request. Otherwise, it's invoked in the replication thread.- Parameters:
infosToDelete
- The list of messages that need to be deleted. Only the StoreKey, OperationTime, LifeVersion should be used in this method.- Throws:
StoreException
-
undelete
short undelete(MessageInfo info) throws StoreException
Undelete the blob identified byid
. When the lifeVersion isMessageInfo.LIFE_VERSION_FROM_FRONTEND
, this method is invoked by the responding to the frontend request. Otherwise, it's invoked in the replication thread.- Parameters:
info
- TheMessageInfo
that carries some basic information about this operation. Only the StoreKey, OperationTime, LifeVersion should be used in this method.- Returns:
- the lifeVersion of the undeleted blob.
- Throws:
StoreException
-
updateTtl
void updateTtl(java.util.List<MessageInfo> infosToUpdate) throws StoreException
Updates the TTL of all the messages in the list. When the lifeVersion isMessageInfo.LIFE_VERSION_FROM_FRONTEND
, this method is invoked by the responding to the frontend request. Otherwise, it's invoked in the replication thread.- Parameters:
infosToUpdate
- The list of messages that need to be updated Only the StoreKey, OperationTime, ExpirationTime, LifeVersion should be used in this method.- Throws:
StoreException
-
findEntriesSince
FindInfo findEntriesSince(FindToken token, long maxTotalSizeOfEntries) throws StoreException
Finds all the entries from the store given a find token- Parameters:
token
- The token that acts as a bookmark to make subsequent searchesmaxTotalSizeOfEntries
- The maximum total size of entries that needs to be returned. The api will try to return a list of entries whose total size is close to this value.- Returns:
- The FindInfo instance that contains the entries found and the new token for future searches
- Throws:
StoreException
-
findMissingKeys
java.util.Set<StoreKey> findMissingKeys(java.util.List<StoreKey> keys) throws StoreException
Finds all the keys that are not present in the store from the input keys- Parameters:
keys
- The list of keys that need to be checked for existence- Returns:
- The list of keys that are not present in the store
- Throws:
StoreException
-
findKey
MessageInfo findKey(StoreKey key) throws StoreException
ReturnMessageInfo
of given key. This method will only be used in replication thread.- Parameters:
key
- The key of which blob to returnMessageInfo
.- Returns:
- The
MessageInfo
. - Throws:
StoreException
-
getStoreStats
StoreStats getStoreStats()
Get the correspondingStoreStats
instance for this store.- Returns:
- a
StoreStats
instance which can be used to fetch store related stats
-
isKeyDeleted
boolean isKeyDeleted(StoreKey key) throws StoreException
Checks if the key is deleted. Returns true is the key is deleted. Returns false if the key is present, not available, ttl expired.- Parameters:
key
- The key that needs to be checked for deletion state- Returns:
- True, if the key is deleted, false otherwise
- Throws:
StoreException
-
getSizeInBytes
long getSizeInBytes()
Returns the size of the store in bytes- Returns:
- The size of the store in bytes
-
getEndPositionOfLastPut
long getEndPositionOfLastPut() throws StoreException
- Returns:
- absolute end position of last PUT in bytes.
- Throws:
StoreException
-
isEmpty
boolean isEmpty()
- Returns:
- true if the store contains no data
-
isStarted
boolean isStarted()
- Returns:
- true if the store is started
-
isBootstrapInProgress
boolean isBootstrapInProgress()
- Returns:
true
if store has initiated bootstrap process and bootstrap is still in progress.
-
isDecommissionInProgress
boolean isDecommissionInProgress()
- Returns:
true
if store has initiated decommission process (STANDBY -> INACTIVE -> OFFLINE) and decommission is still in progress.
-
completeBootstrap
void completeBootstrap()
Take actions (if any) to complete the bootstrap (i.e, delete bootstrap file in store directory)
-
setCurrentState
void setCurrentState(ReplicaState state)
Set current state of the store.- Parameters:
state
-ReplicaState
associated with local store
-
getCurrentState
ReplicaState getCurrentState()
- Returns:
- current
ReplicaState
of the store
-
recoverFromDecommission
boolean recoverFromDecommission()
- Returns:
true
if the store is recovering from previous decommission failure.false
otherwise.
-
isDisabled
boolean isDisabled()
- Returns:
true
if the store is disabled due to disk I/O error or by admin operation(i.e. stop replica).
-
shutdown
void shutdown() throws StoreException
Shuts down the store- Throws:
StoreException
-
-