/** * Obtains a snapshot of the store metadata for the recovery target. * * @param recoveryTarget the target of the recovery * @return a snapshot of the store metadata */ private Store.MetadataSnapshot getStoreMetadataSnapshot(final RecoveryTarget recoveryTarget) { try { return recoveryTarget.indexShard().snapshotStoreMetadata(); } catch (final org.apache.lucene.index.IndexNotFoundException e) { // happens on an empty folder. no need to log logger.trace("{} shard folder empty, recovering all files", recoveryTarget); return Store.MetadataSnapshot.EMPTY; } catch (final IOException e) { logger.warn("error while listing local files, recovering as if there are none", e); return Store.MetadataSnapshot.EMPTY; } }
MetadataSnapshot metadata = snapshotStoreMetadata(); for (Map.Entry<String, StoreFileMetaData> entry : metadata.asMap().entrySet()) { try {
if (indexShard != null) { exists = true; return new StoreFilesMetaData(shardId, indexShard.snapshotStoreMetadata());
recoveryTargetMetadata = targetShard.snapshotStoreMetadata(); } catch (IndexNotFoundException e) {
private Store.MetadataSnapshot getMetadataSnapshotOrEmpty(IndexShard replica) throws IOException { Store.MetadataSnapshot result; try { result = replica.snapshotStoreMetadata(); } catch (IndexNotFoundException e) { // OK! result = Store.MetadataSnapshot.EMPTY; } catch (IOException e) { logger.warn("failed read store, treating as empty", e); result = Store.MetadataSnapshot.EMPTY; } return result; }
/** * Obtains a snapshot of the store metadata for the recovery target. * * @param recoveryTarget the target of the recovery * @return a snapshot of the store metadata */ private Store.MetadataSnapshot getStoreMetadataSnapshot(final RecoveryTarget recoveryTarget) { try { return recoveryTarget.indexShard().snapshotStoreMetadata(); } catch (final org.apache.lucene.index.IndexNotFoundException e) { // happens on an empty folder. no need to log logger.trace("{} shard folder empty, recovering all files", recoveryTarget); return Store.MetadataSnapshot.EMPTY; } catch (final IOException e) { logger.warn("error while listing local files, recovering as if there are none", e); return Store.MetadataSnapshot.EMPTY; } }
/** * Obtains a snapshot of the store metadata for the recovery target. * * @param recoveryTarget the target of the recovery * @return a snapshot of the store metadata */ private Store.MetadataSnapshot getStoreMetadataSnapshot(final RecoveryTarget recoveryTarget) { try { return recoveryTarget.indexShard().snapshotStoreMetadata(); } catch (final org.apache.lucene.index.IndexNotFoundException e) { // happens on an empty folder. no need to log logger.trace("{} shard folder empty, recovering all files", recoveryTarget); return Store.MetadataSnapshot.EMPTY; } catch (final IOException e) { logger.warn("error while listing local files, recovering as if there are none", e); return Store.MetadataSnapshot.EMPTY; } }
MetadataSnapshot metadata = snapshotStoreMetadata(); for (Map.Entry<String, StoreFileMetaData> entry : metadata.asMap().entrySet()) { try {
MetadataSnapshot metadata = snapshotStoreMetadata(); for (Map.Entry<String, StoreFileMetaData> entry : metadata.asMap().entrySet()) { try {
MetadataSnapshot metadata = snapshotStoreMetadata(); for (Map.Entry<String, StoreFileMetaData> entry : metadata.asMap().entrySet()) { try {
metadataSnapshot = recoveryTarget.indexShard().snapshotStoreMetadata();
if (indexShard != null) { exists = true; return new StoreFilesMetaData(shardId, indexShard.snapshotStoreMetadata());
if (indexShard != null) { exists = true; return new StoreFilesMetaData(shardId, indexShard.snapshotStoreMetadata());
if (indexShard != null) { exists = true; return new StoreFilesMetaData(shardId, indexShard.snapshotStoreMetadata());
recoveryTargetMetadata = targetShard.snapshotStoreMetadata(); } catch (IndexNotFoundException e) {
recoveryTargetMetadata = targetShard.snapshotStoreMetadata(); } catch (IndexNotFoundException e) {
Store.MetadataSnapshot recoveryTargetMetadata; try { recoveryTargetMetadata = targetShard.snapshotStoreMetadata(); } catch (IndexNotFoundException e) {
/** Snapshot a shard using a given repository **/ protected void snapshotShard(final IndexShard shard, final Snapshot snapshot, final Repository repository) throws IOException { final IndexShardSnapshotStatus snapshotStatus = IndexShardSnapshotStatus.newInitializing(); try (Engine.IndexCommitRef indexCommitRef = shard.acquireIndexCommit(false, true)) { Index index = shard.shardId().getIndex(); IndexId indexId = new IndexId(index.getName(), index.getUUID()); repository.snapshotShard(shard, snapshot.getSnapshotId(), indexId, indexCommitRef.getIndexCommit(), snapshotStatus); } final IndexShardSnapshotStatus.Copy lastSnapshotStatus = snapshotStatus.asCopy(); assertEquals(IndexShardSnapshotStatus.Stage.DONE, lastSnapshotStatus.getStage()); assertEquals(shard.snapshotStoreMetadata().size(), lastSnapshotStatus.getNumberOfFiles()); assertNull(lastSnapshotStatus.getFailure()); }