Rename repository api methods for clarity and tweak documentation.
This commit is contained in:
parent
dd7be74bcf
commit
593f8bdf0c
|
@ -397,7 +397,7 @@ final class StoreRecovery {
|
||||||
if (!shardId.getIndexName().equals(restoreSource.index())) {
|
if (!shardId.getIndexName().equals(restoreSource.index())) {
|
||||||
snapshotShardId = new ShardId(restoreSource.index(), IndexMetaData.INDEX_UUID_NA_VALUE, shardId.id());
|
snapshotShardId = new ShardId(restoreSource.index(), IndexMetaData.INDEX_UUID_NA_VALUE, shardId.id());
|
||||||
}
|
}
|
||||||
repository.restore(indexShard, restoreSource.snapshot().getSnapshotId(), restoreSource.version(), snapshotShardId, indexShard.recoveryState());
|
repository.restoreShard(indexShard, restoreSource.snapshot().getSnapshotId(), restoreSource.version(), snapshotShardId, indexShard.recoveryState());
|
||||||
indexShard.skipTranslogRecovery();
|
indexShard.skipTranslogRecovery();
|
||||||
indexShard.finalizeRecovery();
|
indexShard.finalizeRecovery();
|
||||||
indexShard.postRecovery("restore done");
|
indexShard.postRecovery("restore done");
|
||||||
|
|
|
@ -35,15 +35,16 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Snapshot repository interface.
|
* An interface for interacting with a repository in snapshot and restore.
|
||||||
* <p>
|
* <p>
|
||||||
* Responsible for index and cluster and shard level operations.
|
* Implementations are responsible for reading and writing both metadata and actual shard data to and from
|
||||||
|
* a repository backend.
|
||||||
* <p>
|
* <p>
|
||||||
* Typical snapshot usage pattern:
|
* To perform a snapshot:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Master calls {@link #initializeSnapshot(SnapshotId, List, org.elasticsearch.cluster.metadata.MetaData)}
|
* <li>Master calls {@link #initializeSnapshot(SnapshotId, List, org.elasticsearch.cluster.metadata.MetaData)}
|
||||||
* with list of indices that will be included into the snapshot</li>
|
* with list of indices that will be included into the snapshot</li>
|
||||||
* <li>Data nodes call {@link Repository#snapshot(IndexShard, SnapshotId, IndexCommit, IndexShardSnapshotStatus)}
|
* <li>Data nodes call {@link Repository#snapshotShard(IndexShard, SnapshotId, IndexCommit, IndexShardSnapshotStatus)}
|
||||||
* for each shard</li>
|
* for each shard</li>
|
||||||
* <li>When all shard calls return master calls {@link #finalizeSnapshot} with possible list of failures</li>
|
* <li>When all shard calls return master calls {@link #finalizeSnapshot} with possible list of failures</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
@ -56,7 +57,7 @@ public interface Repository extends LifecycleComponent {
|
||||||
* @param snapshotId snapshot id
|
* @param snapshotId snapshot id
|
||||||
* @return information about snapshot
|
* @return information about snapshot
|
||||||
*/
|
*/
|
||||||
SnapshotInfo readSnapshot(SnapshotId snapshotId);
|
SnapshotInfo getSnapshotInfo(SnapshotId snapshotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns global metadata associate with the snapshot.
|
* Returns global metadata associate with the snapshot.
|
||||||
|
@ -67,7 +68,7 @@ public interface Repository extends LifecycleComponent {
|
||||||
* @param indices list of indices
|
* @param indices list of indices
|
||||||
* @return information about snapshot
|
* @return information about snapshot
|
||||||
*/
|
*/
|
||||||
MetaData readSnapshotMetaData(SnapshotInfo snapshot, List<String> indices) throws IOException;
|
MetaData getSnapshotMetaData(SnapshotInfo snapshot, List<String> indices) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of snapshots currently stored in the repository that match the given predicate on the snapshot name.
|
* Returns the list of snapshots currently stored in the repository that match the given predicate on the snapshot name.
|
||||||
|
@ -75,7 +76,7 @@ public interface Repository extends LifecycleComponent {
|
||||||
*
|
*
|
||||||
* @return snapshot list
|
* @return snapshot list
|
||||||
*/
|
*/
|
||||||
List<SnapshotId> snapshots();
|
List<SnapshotId> getSnapshots();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts snapshotting process
|
* Starts snapshotting process
|
||||||
|
@ -109,12 +110,12 @@ public interface Repository extends LifecycleComponent {
|
||||||
/**
|
/**
|
||||||
* Returns snapshot throttle time in nanoseconds
|
* Returns snapshot throttle time in nanoseconds
|
||||||
*/
|
*/
|
||||||
long snapshotThrottleTimeInNanos();
|
long getSnapshotThrottleTimeInNanos();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns restore throttle time in nanoseconds
|
* Returns restore throttle time in nanoseconds
|
||||||
*/
|
*/
|
||||||
long restoreThrottleTimeInNanos();
|
long getRestoreThrottleTimeInNanos();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,11 +137,18 @@ public interface Repository extends LifecycleComponent {
|
||||||
*/
|
*/
|
||||||
void endVerification(String verificationToken);
|
void endVerification(String verificationToken);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies repository settings on data node.
|
||||||
|
* @param verificationToken value returned by {@link org.elasticsearch.repositories.Repository#startVerification()}
|
||||||
|
* @param localNode the local node information, for inclusion in verification errors
|
||||||
|
*/
|
||||||
|
void verify(String verificationToken, DiscoveryNode localNode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the repository supports only read operations
|
* Returns true if the repository supports only read operations
|
||||||
* @return true if the repository is read/only
|
* @return true if the repository is read/only
|
||||||
*/
|
*/
|
||||||
boolean readOnly();
|
boolean isReadOnly();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a snapshot of the shard based on the index commit point.
|
* Creates a snapshot of the shard based on the index commit point.
|
||||||
|
@ -156,7 +164,7 @@ public interface Repository extends LifecycleComponent {
|
||||||
* @param snapshotIndexCommit commit point
|
* @param snapshotIndexCommit commit point
|
||||||
* @param snapshotStatus snapshot status
|
* @param snapshotStatus snapshot status
|
||||||
*/
|
*/
|
||||||
void snapshot(IndexShard shard, SnapshotId snapshotId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus);
|
void snapshotShard(IndexShard shard, SnapshotId snapshotId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores snapshot of the shard.
|
* Restores snapshot of the shard.
|
||||||
|
@ -169,22 +177,17 @@ public interface Repository extends LifecycleComponent {
|
||||||
* @param snapshotShardId shard id (in the snapshot)
|
* @param snapshotShardId shard id (in the snapshot)
|
||||||
* @param recoveryState recovery state
|
* @param recoveryState recovery state
|
||||||
*/
|
*/
|
||||||
void restore(IndexShard shard, SnapshotId snapshotId, Version version, ShardId snapshotShardId, RecoveryState recoveryState);
|
void restoreShard(IndexShard shard, SnapshotId snapshotId, Version version, ShardId snapshotShardId, RecoveryState recoveryState);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve shard snapshot status for the stored snapshot
|
* Retrieve shard snapshot status for the stored snapshot
|
||||||
*
|
*
|
||||||
* @param snapshotId snapshot id
|
* @param snapshotId snapshot id
|
||||||
* @param version version of elasticsearch that created this snapshot
|
* @param version version of elasticsearch that created this snapshot
|
||||||
* @param shardId shard id
|
* @param shardId shard id
|
||||||
* @return snapshot status
|
* @return snapshot status
|
||||||
*/
|
*/
|
||||||
IndexShardSnapshotStatus snapshotStatus(SnapshotId snapshotId, Version version, ShardId shardId);
|
IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, Version version, ShardId shardId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifies repository settings on data node.
|
|
||||||
* @param verificationToken value returned by {@link org.elasticsearch.repositories.Repository#startVerification()}
|
|
||||||
* @param localNode the local node information, for inclusion in verification errors
|
|
||||||
*/
|
|
||||||
void verify(String verificationToken, DiscoveryNode localNode);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,13 +300,13 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeSnapshot(SnapshotId snapshotId, List<String> indices, MetaData metaData) {
|
public void initializeSnapshot(SnapshotId snapshotId, List<String> indices, MetaData metaData) {
|
||||||
if (readOnly()) {
|
if (isReadOnly()) {
|
||||||
throw new RepositoryException(this.repositoryName, "cannot create snapshot in a readonly repository");
|
throw new RepositoryException(this.repositoryName, "cannot create snapshot in a readonly repository");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final String snapshotName = snapshotId.getName();
|
final String snapshotName = snapshotId.getName();
|
||||||
// check if the snapshot name already exists in the repository
|
// check if the snapshot name already exists in the repository
|
||||||
if (snapshots().stream().anyMatch(s -> s.getName().equals(snapshotName))) {
|
if (getSnapshots().stream().anyMatch(s -> s.getName().equals(snapshotName))) {
|
||||||
throw new SnapshotCreationException(repositoryName, snapshotId, "snapshot with the same name already exists");
|
throw new SnapshotCreationException(repositoryName, snapshotId, "snapshot with the same name already exists");
|
||||||
}
|
}
|
||||||
if (snapshotFormat.exists(snapshotsBlobContainer, blobId(snapshotId)) ||
|
if (snapshotFormat.exists(snapshotsBlobContainer, blobId(snapshotId)) ||
|
||||||
|
@ -328,13 +328,13 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteSnapshot(SnapshotId snapshotId) {
|
public void deleteSnapshot(SnapshotId snapshotId) {
|
||||||
if (readOnly()) {
|
if (isReadOnly()) {
|
||||||
throw new RepositoryException(this.repositoryName, "cannot delete snapshot from a readonly repository");
|
throw new RepositoryException(this.repositoryName, "cannot delete snapshot from a readonly repository");
|
||||||
}
|
}
|
||||||
List<String> indices = Collections.emptyList();
|
List<String> indices = Collections.emptyList();
|
||||||
SnapshotInfo snapshot = null;
|
SnapshotInfo snapshot = null;
|
||||||
try {
|
try {
|
||||||
snapshot = readSnapshot(snapshotId);
|
snapshot = getSnapshotInfo(snapshotId);
|
||||||
indices = snapshot.indices();
|
indices = snapshot.indices();
|
||||||
} catch (SnapshotMissingException ex) {
|
} catch (SnapshotMissingException ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
|
@ -365,7 +365,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
globalMetaDataFormat.delete(snapshotsBlobContainer, snapshotName);
|
globalMetaDataFormat.delete(snapshotsBlobContainer, snapshotName);
|
||||||
}
|
}
|
||||||
// Delete snapshot from the snapshot list
|
// Delete snapshot from the snapshot list
|
||||||
List<SnapshotId> snapshotIds = snapshots().stream().filter(id -> snapshotId.equals(id) == false).collect(Collectors.toList());
|
List<SnapshotId> snapshotIds = getSnapshots().stream().filter(id -> snapshotId.equals(id) == false).collect(Collectors.toList());
|
||||||
writeSnapshotsToIndexGen(snapshotIds);
|
writeSnapshotsToIndexGen(snapshotIds);
|
||||||
|
|
||||||
// Now delete all indices
|
// Now delete all indices
|
||||||
|
@ -411,7 +411,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
totalShards,
|
totalShards,
|
||||||
shardFailures);
|
shardFailures);
|
||||||
snapshotFormat.write(blobStoreSnapshot, snapshotsBlobContainer, blobId(snapshotId));
|
snapshotFormat.write(blobStoreSnapshot, snapshotsBlobContainer, blobId(snapshotId));
|
||||||
List<SnapshotId> snapshotIds = snapshots();
|
List<SnapshotId> snapshotIds = getSnapshots();
|
||||||
if (!snapshotIds.contains(snapshotId)) {
|
if (!snapshotIds.contains(snapshotId)) {
|
||||||
snapshotIds = new ArrayList<>(snapshotIds);
|
snapshotIds = new ArrayList<>(snapshotIds);
|
||||||
snapshotIds.add(snapshotId);
|
snapshotIds.add(snapshotId);
|
||||||
|
@ -425,7 +425,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SnapshotId> snapshots() {
|
public List<SnapshotId> getSnapshots() {
|
||||||
try {
|
try {
|
||||||
return Collections.unmodifiableList(readSnapshotsFromIndex());
|
return Collections.unmodifiableList(readSnapshotsFromIndex());
|
||||||
} catch (NoSuchFileException | FileNotFoundException e) {
|
} catch (NoSuchFileException | FileNotFoundException e) {
|
||||||
|
@ -437,12 +437,12 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MetaData readSnapshotMetaData(SnapshotInfo snapshot, List<String> indices) throws IOException {
|
public MetaData getSnapshotMetaData(SnapshotInfo snapshot, List<String> indices) throws IOException {
|
||||||
return readSnapshotMetaData(snapshot.snapshotId(), snapshot.version(), indices, false);
|
return readSnapshotMetaData(snapshot.snapshotId(), snapshot.version(), indices, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SnapshotInfo readSnapshot(final SnapshotId snapshotId) {
|
public SnapshotInfo getSnapshotInfo(final SnapshotId snapshotId) {
|
||||||
try {
|
try {
|
||||||
return snapshotFormat.read(snapshotsBlobContainer, blobId(snapshotId));
|
return snapshotFormat.read(snapshotsBlobContainer, blobId(snapshotId));
|
||||||
} catch (FileNotFoundException | NoSuchFileException ex) {
|
} catch (FileNotFoundException | NoSuchFileException ex) {
|
||||||
|
@ -561,19 +561,19 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
private static final String UUID = "uuid";
|
private static final String UUID = "uuid";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long snapshotThrottleTimeInNanos() {
|
public long getSnapshotThrottleTimeInNanos() {
|
||||||
return snapshotRateLimitingTimeInNanos.count();
|
return snapshotRateLimitingTimeInNanos.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long restoreThrottleTimeInNanos() {
|
public long getRestoreThrottleTimeInNanos() {
|
||||||
return restoreRateLimitingTimeInNanos.count();
|
return restoreRateLimitingTimeInNanos.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String startVerification() {
|
public String startVerification() {
|
||||||
try {
|
try {
|
||||||
if (readOnly()) {
|
if (isReadOnly()) {
|
||||||
// It's readonly - so there is not much we can do here to verify it
|
// It's readonly - so there is not much we can do here to verify it
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -593,7 +593,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endVerification(String seed) {
|
public void endVerification(String seed) {
|
||||||
if (readOnly()) {
|
if (isReadOnly()) {
|
||||||
throw new UnsupportedOperationException("shouldn't be called");
|
throw new UnsupportedOperationException("shouldn't be called");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -608,7 +608,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean readOnly() {
|
public boolean isReadOnly() {
|
||||||
return readOnly;
|
return readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeSnapshotsToIndexGen(final List<SnapshotId> snapshots) throws IOException {
|
protected void writeSnapshotsToIndexGen(final List<SnapshotId> snapshots) throws IOException {
|
||||||
assert readOnly() == false; // can not write to a read only repository
|
assert isReadOnly() == false; // can not write to a read only repository
|
||||||
final BytesReference snapshotsBytes;
|
final BytesReference snapshotsBytes;
|
||||||
try (BytesStreamOutput bStream = new BytesStreamOutput()) {
|
try (BytesStreamOutput bStream = new BytesStreamOutput()) {
|
||||||
try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
|
try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
|
||||||
|
@ -641,7 +641,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
// write the index file
|
// write the index file
|
||||||
writeAtomic(SNAPSHOTS_FILE_PREFIX + Long.toString(gen), snapshotsBytes);
|
writeAtomic(SNAPSHOTS_FILE_PREFIX + Long.toString(gen), snapshotsBytes);
|
||||||
// delete the N-2 index file if it exists, keep the previous one around as a backup
|
// delete the N-2 index file if it exists, keep the previous one around as a backup
|
||||||
if (readOnly() == false && gen - 2 >= 0) {
|
if (isReadOnly() == false && gen - 2 >= 0) {
|
||||||
final String oldSnapshotIndexFile = SNAPSHOTS_FILE_PREFIX + Long.toString(gen - 2);
|
final String oldSnapshotIndexFile = SNAPSHOTS_FILE_PREFIX + Long.toString(gen - 2);
|
||||||
if (snapshotsBlobContainer.blobExists(oldSnapshotIndexFile)) {
|
if (snapshotsBlobContainer.blobExists(oldSnapshotIndexFile)) {
|
||||||
snapshotsBlobContainer.deleteBlob(oldSnapshotIndexFile);
|
snapshotsBlobContainer.deleteBlob(oldSnapshotIndexFile);
|
||||||
|
@ -797,7 +797,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void snapshot(IndexShard shard, SnapshotId snapshotId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus) {
|
public void snapshotShard(IndexShard shard, SnapshotId snapshotId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus) {
|
||||||
SnapshotContext snapshotContext = new SnapshotContext(shard, snapshotId, snapshotStatus);
|
SnapshotContext snapshotContext = new SnapshotContext(shard, snapshotId, snapshotStatus);
|
||||||
snapshotStatus.startTime(System.currentTimeMillis());
|
snapshotStatus.startTime(System.currentTimeMillis());
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restore(IndexShard shard, SnapshotId snapshotId, Version version, ShardId snapshotShardId, RecoveryState recoveryState) {
|
public void restoreShard(IndexShard shard, SnapshotId snapshotId, Version version, ShardId snapshotShardId, RecoveryState recoveryState) {
|
||||||
final RestoreContext snapshotContext = new RestoreContext(shard, snapshotId, version, snapshotShardId, recoveryState);
|
final RestoreContext snapshotContext = new RestoreContext(shard, snapshotId, version, snapshotShardId, recoveryState);
|
||||||
try {
|
try {
|
||||||
snapshotContext.restore();
|
snapshotContext.restore();
|
||||||
|
@ -828,7 +828,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexShardSnapshotStatus snapshotStatus(SnapshotId snapshotId, Version version, ShardId shardId) {
|
public IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, Version version, ShardId shardId) {
|
||||||
Context context = new Context(snapshotId, version, shardId);
|
Context context = new Context(snapshotId, version, shardId);
|
||||||
BlobStoreIndexShardSnapshot snapshot = context.loadSnapshot();
|
BlobStoreIndexShardSnapshot snapshot = context.loadSnapshot();
|
||||||
IndexShardSnapshotStatus status = new IndexShardSnapshotStatus();
|
IndexShardSnapshotStatus status = new IndexShardSnapshotStatus();
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class URLRepository extends BlobStoreRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean readOnly() {
|
public boolean isReadOnly() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,16 +185,16 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
||||||
try {
|
try {
|
||||||
// Read snapshot info and metadata from the repository
|
// Read snapshot info and metadata from the repository
|
||||||
Repository repository = repositoriesService.repository(request.repositoryName);
|
Repository repository = repositoriesService.repository(request.repositoryName);
|
||||||
final Optional<SnapshotId> matchingSnapshotId = repository.snapshots().stream()
|
final Optional<SnapshotId> matchingSnapshotId = repository.getSnapshots().stream()
|
||||||
.filter(s -> request.snapshotName.equals(s.getName())).findFirst();
|
.filter(s -> request.snapshotName.equals(s.getName())).findFirst();
|
||||||
if (matchingSnapshotId.isPresent() == false) {
|
if (matchingSnapshotId.isPresent() == false) {
|
||||||
throw new SnapshotRestoreException(request.repositoryName, request.snapshotName, "snapshot does not exist");
|
throw new SnapshotRestoreException(request.repositoryName, request.snapshotName, "snapshot does not exist");
|
||||||
}
|
}
|
||||||
final SnapshotId snapshotId = matchingSnapshotId.get();
|
final SnapshotId snapshotId = matchingSnapshotId.get();
|
||||||
final SnapshotInfo snapshotInfo = repository.readSnapshot(snapshotId);
|
final SnapshotInfo snapshotInfo = repository.getSnapshotInfo(snapshotId);
|
||||||
final Snapshot snapshot = new Snapshot(request.repositoryName, snapshotId);
|
final Snapshot snapshot = new Snapshot(request.repositoryName, snapshotId);
|
||||||
List<String> filteredIndices = SnapshotUtils.filterIndices(snapshotInfo.indices(), request.indices(), request.indicesOptions());
|
List<String> filteredIndices = SnapshotUtils.filterIndices(snapshotInfo.indices(), request.indices(), request.indicesOptions());
|
||||||
MetaData metaDataIn = repository.readSnapshotMetaData(snapshotInfo, filteredIndices);
|
MetaData metaDataIn = repository.getSnapshotMetaData(snapshotInfo, filteredIndices);
|
||||||
|
|
||||||
final MetaData metaData;
|
final MetaData metaData;
|
||||||
if (snapshotInfo.version().before(Version.V_2_0_0_beta1)) {
|
if (snapshotInfo.version().before(Version.V_2_0_0_beta1)) {
|
||||||
|
|
|
@ -340,7 +340,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent implements
|
||||||
// we flush first to make sure we get the latest writes snapshotted
|
// we flush first to make sure we get the latest writes snapshotted
|
||||||
IndexCommit snapshotIndexCommit = indexShard.snapshotIndex(true);
|
IndexCommit snapshotIndexCommit = indexShard.snapshotIndex(true);
|
||||||
try {
|
try {
|
||||||
repository.snapshot(indexShard, snapshot.getSnapshotId(), snapshotIndexCommit, snapshotStatus);
|
repository.snapshotShard(indexShard, snapshot.getSnapshotId(), snapshotIndexCommit, snapshotStatus);
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(" index : version [").append(snapshotStatus.indexVersion()).append("], number_of_files [").append(snapshotStatus.numberOfFiles()).append("] with total_size [").append(new ByteSizeValue(snapshotStatus.totalSize())).append("]\n");
|
sb.append(" index : version [").append(snapshotStatus.indexVersion()).append("], number_of_files [").append(snapshotStatus.numberOfFiles()).append("] with total_size [").append(new ByteSizeValue(snapshotStatus.totalSize())).append("]\n");
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||||
public List<SnapshotId> snapshotIds(final String repositoryName) {
|
public List<SnapshotId> snapshotIds(final String repositoryName) {
|
||||||
Repository repository = repositoriesService.repository(repositoryName);
|
Repository repository = repositoriesService.repository(repositoryName);
|
||||||
assert repository != null; // should only be called once we've validated the repository exists
|
assert repository != null; // should only be called once we've validated the repository exists
|
||||||
return repository.snapshots();
|
return repository.getSnapshots();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +148,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||||
if (!entries.isEmpty()) {
|
if (!entries.isEmpty()) {
|
||||||
return inProgressSnapshot(entries.iterator().next());
|
return inProgressSnapshot(entries.iterator().next());
|
||||||
}
|
}
|
||||||
return repositoriesService.repository(repositoryName).readSnapshot(snapshotId);
|
return repositoriesService.repository(repositoryName).getSnapshotInfo(snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,7 +174,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||||
final Repository repository = repositoriesService.repository(repositoryName);
|
final Repository repository = repositoriesService.repository(repositoryName);
|
||||||
for (SnapshotId snapshotId : snapshotIdsToIterate) {
|
for (SnapshotId snapshotId : snapshotIdsToIterate) {
|
||||||
try {
|
try {
|
||||||
snapshotSet.add(repository.readSnapshot(snapshotId));
|
snapshotSet.add(repository.getSnapshotInfo(snapshotId));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (ignoreUnavailable) {
|
if (ignoreUnavailable) {
|
||||||
logger.warn("failed to get snapshot [{}]", ex, snapshotId);
|
logger.warn("failed to get snapshot [{}]", ex, snapshotId);
|
||||||
|
@ -546,7 +546,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||||
final SnapshotInfo snapshotInfo) throws IOException {
|
final SnapshotInfo snapshotInfo) throws IOException {
|
||||||
Map<ShardId, IndexShardSnapshotStatus> shardStatus = new HashMap<>();
|
Map<ShardId, IndexShardSnapshotStatus> shardStatus = new HashMap<>();
|
||||||
Repository repository = repositoriesService.repository(repositoryName);
|
Repository repository = repositoriesService.repository(repositoryName);
|
||||||
MetaData metaData = repository.readSnapshotMetaData(snapshotInfo, snapshotInfo.indices());
|
MetaData metaData = repository.getSnapshotMetaData(snapshotInfo, snapshotInfo.indices());
|
||||||
for (String index : snapshotInfo.indices()) {
|
for (String index : snapshotInfo.indices()) {
|
||||||
IndexMetaData indexMetaData = metaData.indices().get(index);
|
IndexMetaData indexMetaData = metaData.indices().get(index);
|
||||||
if (indexMetaData != null) {
|
if (indexMetaData != null) {
|
||||||
|
@ -561,7 +561,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||||
shardStatus.put(shardId, shardSnapshotStatus);
|
shardStatus.put(shardId, shardSnapshotStatus);
|
||||||
} else {
|
} else {
|
||||||
IndexShardSnapshotStatus shardSnapshotStatus =
|
IndexShardSnapshotStatus shardSnapshotStatus =
|
||||||
repository.snapshotStatus(snapshotInfo.snapshotId(), snapshotInfo.version(), shardId);
|
repository.getShardSnapshotStatus(snapshotInfo.snapshotId(), snapshotInfo.version(), shardId);
|
||||||
shardStatus.put(shardId, shardSnapshotStatus);
|
shardStatus.put(shardId, shardSnapshotStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -953,7 +953,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||||
public void deleteSnapshot(final String repositoryName, final String snapshotName, final DeleteSnapshotListener listener) {
|
public void deleteSnapshot(final String repositoryName, final String snapshotName, final DeleteSnapshotListener listener) {
|
||||||
// First, look for the snapshot in the repository
|
// First, look for the snapshot in the repository
|
||||||
final Repository repository = repositoriesService.repository(repositoryName);
|
final Repository repository = repositoriesService.repository(repositoryName);
|
||||||
Optional<SnapshotId> matchedEntry = repository.snapshots().stream().filter(s -> s.getName().equals(snapshotName)).findFirst();
|
Optional<SnapshotId> matchedEntry = repository.getSnapshots().stream().filter(s -> s.getName().equals(snapshotName)).findFirst();
|
||||||
// if nothing found by the same name, then look in the cluster state for current in progress snapshots
|
// if nothing found by the same name, then look in the cluster state for current in progress snapshots
|
||||||
if (matchedEntry.isPresent() == false) {
|
if (matchedEntry.isPresent() == false) {
|
||||||
matchedEntry = currentSnapshots(repositoryName, Collections.emptyList()).stream()
|
matchedEntry = currentSnapshots(repositoryName, Collections.emptyList()).stream()
|
||||||
|
|
|
@ -1184,7 +1184,7 @@ public class IndexShardTests extends ESSingleNodeTestCase {
|
||||||
test_target_shard.markAsRecovering("store", new RecoveryState(routing.shardId(), routing.primary(), RecoveryState.Type.SNAPSHOT, routing.restoreSource(), localNode));
|
test_target_shard.markAsRecovering("store", new RecoveryState(routing.shardId(), routing.primary(), RecoveryState.Type.SNAPSHOT, routing.restoreSource(), localNode));
|
||||||
assertTrue(test_target_shard.restoreFromRepository(new RestoreOnlyRepository() {
|
assertTrue(test_target_shard.restoreFromRepository(new RestoreOnlyRepository() {
|
||||||
@Override
|
@Override
|
||||||
public void restore(IndexShard shard, SnapshotId snapshotId, Version version, ShardId snapshotShardId, RecoveryState recoveryState) {
|
public void restoreShard(IndexShard shard, SnapshotId snapshotId, Version version, ShardId snapshotShardId, RecoveryState recoveryState) {
|
||||||
try {
|
try {
|
||||||
cleanLuceneIndex(targetStore.directory());
|
cleanLuceneIndex(targetStore.directory());
|
||||||
for (String file : sourceStore.directory().listAll()) {
|
for (String file : sourceStore.directory().listAll()) {
|
||||||
|
@ -1653,15 +1653,15 @@ public class IndexShardTests extends ESSingleNodeTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void doClose() {}
|
protected void doClose() {}
|
||||||
@Override
|
@Override
|
||||||
public SnapshotInfo readSnapshot(SnapshotId snapshotId) {
|
public SnapshotInfo getSnapshotInfo(SnapshotId snapshotId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public MetaData readSnapshotMetaData(SnapshotInfo snapshot, List<String> indices) throws IOException {
|
public MetaData getSnapshotMetaData(SnapshotInfo snapshot, List<String> indices) throws IOException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<SnapshotId> snapshots() {
|
public List<SnapshotId> getSnapshots() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -1673,11 +1673,11 @@ public class IndexShardTests extends ESSingleNodeTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void deleteSnapshot(SnapshotId snapshotId) {}
|
public void deleteSnapshot(SnapshotId snapshotId) {}
|
||||||
@Override
|
@Override
|
||||||
public long snapshotThrottleTimeInNanos() {
|
public long getSnapshotThrottleTimeInNanos() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public long restoreThrottleTimeInNanos() {
|
public long getRestoreThrottleTimeInNanos() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -1687,13 +1687,13 @@ public class IndexShardTests extends ESSingleNodeTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void endVerification(String verificationToken) {}
|
public void endVerification(String verificationToken) {}
|
||||||
@Override
|
@Override
|
||||||
public boolean readOnly() {
|
public boolean isReadOnly() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void snapshot(IndexShard shard, SnapshotId snapshotId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus) {}
|
public void snapshotShard(IndexShard shard, SnapshotId snapshotId, IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus) {}
|
||||||
@Override
|
@Override
|
||||||
public IndexShardSnapshotStatus snapshotStatus(SnapshotId snapshotId, Version version, ShardId shardId) {
|
public IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, Version version, ShardId shardId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class BlobStoreRepositoryTests extends ESSingleNodeTestCase {
|
||||||
(BlobStoreRepository) repositoriesService.repository(repositoryName);
|
(BlobStoreRepository) repositoriesService.repository(repositoryName);
|
||||||
final List<SnapshotId> originalSnapshots = Arrays.asList(snapshotId1, snapshotId2);
|
final List<SnapshotId> originalSnapshots = Arrays.asList(snapshotId1, snapshotId2);
|
||||||
|
|
||||||
List<SnapshotId> snapshotIds = repository.snapshots().stream()
|
List<SnapshotId> snapshotIds = repository.getSnapshots().stream()
|
||||||
.sorted((s1, s2) -> s1.getName().compareTo(s2.getName()))
|
.sorted((s1, s2) -> s1.getName().compareTo(s2.getName()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
assertThat(snapshotIds, equalTo(originalSnapshots));
|
assertThat(snapshotIds, equalTo(originalSnapshots));
|
||||||
|
@ -110,9 +110,9 @@ public class BlobStoreRepositoryTests extends ESSingleNodeTestCase {
|
||||||
final BlobStoreRepository repository = setupRepo();
|
final BlobStoreRepository repository = setupRepo();
|
||||||
|
|
||||||
// write to and read from a snapshot file with no entries
|
// write to and read from a snapshot file with no entries
|
||||||
assertThat(repository.snapshots().size(), equalTo(0));
|
assertThat(repository.getSnapshots().size(), equalTo(0));
|
||||||
repository.writeSnapshotsToIndexGen(Collections.emptyList());
|
repository.writeSnapshotsToIndexGen(Collections.emptyList());
|
||||||
assertThat(repository.snapshots().size(), equalTo(0));
|
assertThat(repository.getSnapshots().size(), equalTo(0));
|
||||||
|
|
||||||
// write to and read from a snapshot file with a random number of entries
|
// write to and read from a snapshot file with a random number of entries
|
||||||
final int numSnapshots = randomIntBetween(1, 1000);
|
final int numSnapshots = randomIntBetween(1, 1000);
|
||||||
|
@ -121,7 +121,7 @@ public class BlobStoreRepositoryTests extends ESSingleNodeTestCase {
|
||||||
snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()));
|
snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()));
|
||||||
}
|
}
|
||||||
repository.writeSnapshotsToIndexGen(snapshotIds);
|
repository.writeSnapshotsToIndexGen(snapshotIds);
|
||||||
assertThat(repository.snapshots(), equalTo(snapshotIds));
|
assertThat(repository.getSnapshots(), equalTo(snapshotIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIndexGenerationalFiles() throws Exception {
|
public void testIndexGenerationalFiles() throws Exception {
|
||||||
|
@ -165,7 +165,7 @@ public class BlobStoreRepositoryTests extends ESSingleNodeTestCase {
|
||||||
snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), SnapshotId.UNASSIGNED_UUID));
|
snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), SnapshotId.UNASSIGNED_UUID));
|
||||||
}
|
}
|
||||||
writeOldFormat(repository, snapshotIds.stream().map(SnapshotId::getName).collect(Collectors.toList()));
|
writeOldFormat(repository, snapshotIds.stream().map(SnapshotId::getName).collect(Collectors.toList()));
|
||||||
assertThat(Sets.newHashSet(repository.snapshots()), equalTo(Sets.newHashSet(snapshotIds)));
|
assertThat(Sets.newHashSet(repository.getSnapshots()), equalTo(Sets.newHashSet(snapshotIds)));
|
||||||
|
|
||||||
// write to and read from a snapshot file with a random number of new entries added
|
// write to and read from a snapshot file with a random number of new entries added
|
||||||
final int numSnapshots = randomIntBetween(1, 1000);
|
final int numSnapshots = randomIntBetween(1, 1000);
|
||||||
|
@ -173,7 +173,7 @@ public class BlobStoreRepositoryTests extends ESSingleNodeTestCase {
|
||||||
snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()));
|
snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()));
|
||||||
}
|
}
|
||||||
repository.writeSnapshotsToIndexGen(snapshotIds);
|
repository.writeSnapshotsToIndexGen(snapshotIds);
|
||||||
assertThat(Sets.newHashSet(repository.snapshots()), equalTo(Sets.newHashSet(snapshotIds)));
|
assertThat(Sets.newHashSet(repository.getSnapshots()), equalTo(Sets.newHashSet(snapshotIds)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBlobId() {
|
public void testBlobId() {
|
||||||
|
|
|
@ -1397,8 +1397,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
long snapshotPause = 0L;
|
long snapshotPause = 0L;
|
||||||
long restorePause = 0L;
|
long restorePause = 0L;
|
||||||
for (RepositoriesService repositoriesService : internalCluster().getDataNodeInstances(RepositoriesService.class)) {
|
for (RepositoriesService repositoriesService : internalCluster().getDataNodeInstances(RepositoriesService.class)) {
|
||||||
snapshotPause += repositoriesService.repository("test-repo").snapshotThrottleTimeInNanos();
|
snapshotPause += repositoriesService.repository("test-repo").getSnapshotThrottleTimeInNanos();
|
||||||
restorePause += repositoriesService.repository("test-repo").restoreThrottleTimeInNanos();
|
restorePause += repositoriesService.repository("test-repo").getRestoreThrottleTimeInNanos();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (throttleSnapshot) {
|
if (throttleSnapshot) {
|
||||||
|
|
|
@ -185,7 +185,7 @@ public class AzureRepository extends BlobStoreRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean readOnly() {
|
public boolean isReadOnly() {
|
||||||
return readonly;
|
return readonly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue