public abstract class BlobStoreRepository extends AbstractLifecycleComponent implements Repository
This repository works with any BlobStore
implementation. The blobStore should be initialized in the derived
class before doStart()
is called.
BlobStoreRepository maintains the following structure in the blob store
STORE_ROOT
|- index-N - list of all snapshot ids and the indices belonging to each snapshot, N is the generation of the file
|- index.latest - contains the numeric value of the latest generation of the index file (i.e. N from above)
|- incompatible-snapshots - list of all snapshot ids that are no longer compatible with the current version of the cluster
|- snap-20131010 - JSON serialized Snapshot for snapshot "20131010"
|- meta-20131010.dat - JSON serialized MetaData for snapshot "20131010" (includes only global metadata)
|- snap-20131011 - JSON serialized Snapshot for snapshot "20131011"
|- meta-20131011.dat - JSON serialized MetaData for snapshot "20131011"
.....
|- indices/ - data for all indices
|- Ac1342-B_x/ - data for index "foo" which was assigned the unique id of Ac1342-B_x in the repository
| |- meta-20131010.dat - JSON Serialized IndexMetaData for index "foo"
| |- 0/ - data for shard "0" of index "foo"
| | |- __1 \
| | |- __2 |
| | |- __3 |- files from different segments see snapshot-* for their mappings to real segment files
| | |- __4 |
| | |- __5 /
| | .....
| | |- snap-20131010.dat - JSON serialized BlobStoreIndexShardSnapshot for snapshot "20131010"
| | |- snap-20131011.dat - JSON serialized BlobStoreIndexShardSnapshot for snapshot "20131011"
| | |- list-123 - JSON serialized BlobStoreIndexShardSnapshot for snapshot "20131011"
| |
| |- 1/ - data for shard "1" of index "foo"
| | |- __1
| | .....
| |
| |-2/
| ......
|
|- 1xB0D8_B3y/ - data for index "bar" which was assigned the unique id of 1xB0D8_B3y in the repository
......
Repository.Factory
Modifier and Type | Field and Description |
---|---|
protected RepositoryMetaData |
metadata |
protected NamedXContentRegistry |
namedXContentRegistry |
lifecycle
deprecationLogger, logger, settings
Modifier | Constructor and Description |
---|---|
protected |
BlobStoreRepository(RepositoryMetaData metadata,
Settings globalSettings,
NamedXContentRegistry namedXContentRegistry)
Constructs new BlobStoreRepository
|
Modifier and Type | Method and Description |
---|---|
protected abstract BlobPath |
basePath()
Returns base path of the repository
|
protected abstract BlobStore |
blobStore()
Returns the BlobStore to read and write data.
|
protected ByteSizeValue |
chunkSize()
Returns data file chunk size.
|
void |
deleteSnapshot(SnapshotId snapshotId,
long repositoryStateId)
Deletes snapshot
|
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
void |
endVerification(java.lang.String seed)
Called at the end of repository verification process.
|
SnapshotInfo |
finalizeSnapshot(SnapshotId snapshotId,
java.util.List<IndexId> indices,
long startTime,
java.lang.String failure,
int totalShards,
java.util.List<SnapshotShardFailure> shardFailures,
long repositoryStateId)
Finalizes snapshotting process
|
RepositoryMetaData |
getMetadata()
Returns metadata about this repository.
|
RepositoryData |
getRepositoryData()
Returns a
RepositoryData to describe the data in the repository, including the snapshots
and the indices across all snapshots found in the repository. |
long |
getRestoreThrottleTimeInNanos()
Returns restore throttle time in nanoseconds
|
IndexShardSnapshotStatus |
getShardSnapshotStatus(SnapshotId snapshotId,
Version version,
IndexId indexId,
ShardId shardId)
Retrieve shard snapshot status for the stored snapshot
|
SnapshotInfo |
getSnapshotInfo(SnapshotId snapshotId)
Reads snapshot description from repository.
|
MetaData |
getSnapshotMetaData(SnapshotInfo snapshot,
java.util.List<IndexId> indices)
Returns global metadata associate with the snapshot.
|
long |
getSnapshotThrottleTimeInNanos()
Returns snapshot throttle time in nanoseconds
|
void |
initializeSnapshot(SnapshotId snapshotId,
java.util.List<IndexId> indices,
MetaData clusterMetaData)
Starts snapshotting process
|
protected boolean |
isCompress()
Returns true if metadata and snapshot files should be compressed
|
boolean |
isReadOnly()
Returns true if the repository supports only read operations
|
static boolean |
legacyMetaData(Version version)
In v2.0.0 we changed the metadata file format
|
void |
restoreShard(IndexShard shard,
SnapshotId snapshotId,
Version version,
IndexId indexId,
ShardId snapshotShardId,
RecoveryState recoveryState)
Restores snapshot of the shard.
|
void |
snapshotShard(IndexShard shard,
SnapshotId snapshotId,
IndexId indexId,
org.apache.lucene.index.IndexCommit snapshotIndexCommit,
IndexShardSnapshotStatus snapshotStatus)
Creates a snapshot of the shard based on the index commit point.
|
java.lang.String |
startVerification()
Verifies repository on the master node and returns the verification token.
|
static java.lang.String |
testBlobPrefix(java.lang.String seed) |
java.lang.String |
toString() |
void |
verify(java.lang.String seed,
DiscoveryNode localNode)
Verifies repository settings on data node.
|
protected void |
writeIndexGen(RepositoryData repositoryData,
long repositoryStateId) |
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addLifecycleListener, lifecycleState, removeLifecycleListener, start, stop
close
protected final RepositoryMetaData metadata
protected final NamedXContentRegistry namedXContentRegistry
protected BlobStoreRepository(RepositoryMetaData metadata, Settings globalSettings, NamedXContentRegistry namedXContentRegistry)
metadata
- The metadata for this repository including name and settingsglobalSettings
- Settings for the node this repository object is created onprotected void doStart()
doStart
in class AbstractLifecycleComponent
protected void doStop()
doStop
in class AbstractLifecycleComponent
protected void doClose()
doClose
in class AbstractLifecycleComponent
protected abstract BlobStore blobStore()
protected abstract BlobPath basePath()
protected boolean isCompress()
protected ByteSizeValue chunkSize()
This method should return null if no chunking is needed.
public RepositoryMetaData getMetadata()
Repository
getMetadata
in interface Repository
public void initializeSnapshot(SnapshotId snapshotId, java.util.List<IndexId> indices, MetaData clusterMetaData)
Repository
initializeSnapshot
in interface Repository
snapshotId
- snapshot idindices
- list of indices to be snapshottedclusterMetaData
- cluster metadatapublic void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId)
Repository
deleteSnapshot
in interface Repository
snapshotId
- snapshot idrepositoryStateId
- the unique id identifying the state of the repository when the snapshot deletion beganpublic SnapshotInfo finalizeSnapshot(SnapshotId snapshotId, java.util.List<IndexId> indices, long startTime, java.lang.String failure, int totalShards, java.util.List<SnapshotShardFailure> shardFailures, long repositoryStateId)
This method is called on master after all shards are snapshotted.
finalizeSnapshot
in interface Repository
snapshotId
- snapshot idindices
- list of indices in the snapshotstartTime
- start time of the snapshotfailure
- global failure reason or nulltotalShards
- total number of shardsshardFailures
- list of shard failuresrepositoryStateId
- the unique id identifying the state of the repository when the snapshot beganpublic MetaData getSnapshotMetaData(SnapshotInfo snapshot, java.util.List<IndexId> indices) throws java.io.IOException
Repository
The returned meta data contains global metadata as well as metadata for all indices listed in the indices parameter.
getSnapshotMetaData
in interface Repository
snapshot
- snapshotindices
- list of indicesjava.io.IOException
public SnapshotInfo getSnapshotInfo(SnapshotId snapshotId)
Repository
getSnapshotInfo
in interface Repository
snapshotId
- snapshot idpublic static boolean legacyMetaData(Version version)
public long getSnapshotThrottleTimeInNanos()
Repository
getSnapshotThrottleTimeInNanos
in interface Repository
public long getRestoreThrottleTimeInNanos()
Repository
getRestoreThrottleTimeInNanos
in interface Repository
public java.lang.String startVerification()
Repository
If the verification token is not null, it's passed to all data nodes for verification. If it's null - no additional verification is required
startVerification
in interface Repository
public void endVerification(java.lang.String seed)
Repository
This method should perform all necessary cleanup of the temporary files created in the repository
endVerification
in interface Repository
seed
- verification request generated by Repository.startVerification()
commandpublic RepositoryData getRepositoryData()
Repository
RepositoryData
to describe the data in the repository, including the snapshots
and the indices across all snapshots found in the repository. Throws a RepositoryException
if there was an error in reading the data.getRepositoryData
in interface Repository
public static java.lang.String testBlobPrefix(java.lang.String seed)
public boolean isReadOnly()
Repository
isReadOnly
in interface Repository
protected void writeIndexGen(RepositoryData repositoryData, long repositoryStateId) throws java.io.IOException
java.io.IOException
public void snapshotShard(IndexShard shard, SnapshotId snapshotId, IndexId indexId, org.apache.lucene.index.IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus)
Repository
The index commit point can be obtained by using Engine.acquireIndexCommit(boolean)
method.
Repository implementations shouldn't release the snapshot index commit point. It is done by the method caller.
As snapshot process progresses, implementation of this method should update IndexShardSnapshotStatus
object and check
IndexShardSnapshotStatus.aborted()
to see if the snapshot process should be aborted.
snapshotShard
in interface Repository
shard
- shard to be snapshottedsnapshotId
- snapshot idindexId
- id for the index being snapshottedsnapshotIndexCommit
- commit pointsnapshotStatus
- snapshot statuspublic void restoreShard(IndexShard shard, SnapshotId snapshotId, Version version, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState)
Repository
The index can be renamed on restore, hence different shardId
and snapshotShardId
are supplied.
restoreShard
in interface Repository
shard
- the shard to restore the index intosnapshotId
- snapshot idversion
- version of elasticsearch that created this snapshotindexId
- id of the index in the repository from which the restore is occurringsnapshotShardId
- shard id (in the snapshot)recoveryState
- recovery statepublic IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, Version version, IndexId indexId, ShardId shardId)
Repository
getShardSnapshotStatus
in interface Repository
snapshotId
- snapshot idversion
- version of elasticsearch that created this snapshotindexId
- the snapshotted index id for the shard to get status forshardId
- shard idpublic void verify(java.lang.String seed, DiscoveryNode localNode)
Repository
verify
in interface Repository
seed
- value returned by Repository.startVerification()
localNode
- the local node information, for inclusion in verification errorspublic java.lang.String toString()
toString
in class java.lang.Object