use of org.elasticsearch.repositories.IndexId in project elasticsearch by elastic.
the class SnapshotsInProgressSerializationTests method randomSnapshot.
private Entry randomSnapshot() {
Snapshot snapshot = new Snapshot(randomAsciiOfLength(10), new SnapshotId(randomAsciiOfLength(10), randomAsciiOfLength(10)));
boolean includeGlobalState = randomBoolean();
boolean partial = randomBoolean();
State state = randomFrom(State.values());
int numberOfIndices = randomIntBetween(0, 10);
List<IndexId> indices = new ArrayList<>();
for (int i = 0; i < numberOfIndices; i++) {
indices.add(new IndexId(randomAsciiOfLength(10), randomAsciiOfLength(10)));
}
long startTime = randomLong();
long repositoryStateId = randomLong();
ImmutableOpenMap.Builder<ShardId, SnapshotsInProgress.ShardSnapshotStatus> builder = ImmutableOpenMap.builder();
int shardsCount = randomIntBetween(0, 10);
for (int j = 0; j < shardsCount; j++) {
ShardId shardId = new ShardId(new Index(randomAsciiOfLength(10), randomAsciiOfLength(10)), randomIntBetween(0, 10));
String nodeId = randomAsciiOfLength(10);
State shardState = randomFrom(State.values());
builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(nodeId, shardState));
}
ImmutableOpenMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards = builder.build();
return new Entry(snapshot, includeGlobalState, partial, state, indices, startTime, repositoryStateId, shards);
}
use of org.elasticsearch.repositories.IndexId in project elasticsearch by elastic.
the class ESBlobStoreRepositoryIntegTestCase method testIndicesDeletedFromRepository.
public void testIndicesDeletedFromRepository() throws Exception {
Client client = client();
logger.info("--> creating repository");
final String repoName = "test-repo";
createTestRepository(repoName);
createIndex("test-idx-1", "test-idx-2", "test-idx-3");
ensureGreen();
logger.info("--> indexing some data");
for (int i = 0; i < 20; i++) {
index("test-idx-1", "doc", Integer.toString(i), "foo", "bar" + i);
index("test-idx-2", "doc", Integer.toString(i), "foo", "baz" + i);
index("test-idx-3", "doc", Integer.toString(i), "foo", "baz" + i);
}
refresh();
logger.info("--> take a snapshot");
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repoName, "test-snap").setWaitForCompletion(true).get();
assertEquals(createSnapshotResponse.getSnapshotInfo().successfulShards(), createSnapshotResponse.getSnapshotInfo().totalShards());
logger.info("--> indexing more data");
for (int i = 20; i < 40; i++) {
index("test-idx-1", "doc", Integer.toString(i), "foo", "bar" + i);
index("test-idx-2", "doc", Integer.toString(i), "foo", "baz" + i);
index("test-idx-3", "doc", Integer.toString(i), "foo", "baz" + i);
}
logger.info("--> take another snapshot with only 2 of the 3 indices");
createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repoName, "test-snap2").setWaitForCompletion(true).setIndices("test-idx-1", "test-idx-2").get();
assertEquals(createSnapshotResponse.getSnapshotInfo().successfulShards(), createSnapshotResponse.getSnapshotInfo().totalShards());
logger.info("--> delete a snapshot");
assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, "test-snap").get());
logger.info("--> verify index folder deleted from blob container");
RepositoriesService repositoriesSvc = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
@SuppressWarnings("unchecked") BlobStoreRepository repository = (BlobStoreRepository) repositoriesSvc.repository(repoName);
BlobContainer indicesBlobContainer = repository.blobStore().blobContainer(repository.basePath().add("indices"));
RepositoryData repositoryData = repository.getRepositoryData();
for (IndexId indexId : repositoryData.getIndices().values()) {
if (indexId.getName().equals("test-idx-3")) {
// deleted index
assertFalse(indicesBlobContainer.blobExists(indexId.getId()));
}
}
}
Aggregations