Search in sources :

Example 16 with SnapshotsInProgress

use of org.elasticsearch.cluster.SnapshotsInProgress in project crate by crate.

the class SnapshotRestoreIntegrationTest method waitForCompletion.

private SnapshotInfo waitForCompletion(String repository, String snapshot, TimeValue timeout) throws InterruptedException {
    long start = System.currentTimeMillis();
    SnapshotId snapshotId = new SnapshotId(repository, snapshot);
    while (System.currentTimeMillis() - start < timeout.millis()) {
        List<SnapshotInfo> snapshotInfos = client().admin().cluster().prepareGetSnapshots(repository).setSnapshots(snapshot).get().getSnapshots();
        assertThat(snapshotInfos.size(), equalTo(1));
        if (snapshotInfos.get(0).state().completed()) {
            // Make sure that snapshot clean up operations are finished
            ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get();
            SnapshotsInProgress snapshotsInProgress = stateResponse.getState().getMetaData().custom(SnapshotsInProgress.TYPE);
            if (snapshotsInProgress == null || snapshotsInProgress.snapshot(snapshotId) == null) {
                return snapshotInfos.get(0);
            }
        }
        Thread.sleep(100);
    }
    fail("Timeout waiting for snapshot completion!");
    return null;
}
Also used : SnapshotId(org.elasticsearch.cluster.metadata.SnapshotId) SnapshotInfo(org.elasticsearch.snapshots.SnapshotInfo) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) SnapshotsInProgress(org.elasticsearch.cluster.SnapshotsInProgress)

Aggregations

SnapshotsInProgress (org.elasticsearch.cluster.SnapshotsInProgress)16 ShardSnapshotStatus (org.elasticsearch.cluster.SnapshotsInProgress.ShardSnapshotStatus)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 ClusterState (org.elasticsearch.cluster.ClusterState)6 IndexShardSnapshotStatus (org.elasticsearch.index.snapshots.IndexShardSnapshotStatus)6 ClusterStateUpdateTask (org.elasticsearch.cluster.ClusterStateUpdateTask)5 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)5 IndexId (org.elasticsearch.repositories.IndexId)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 ShardId (org.elasticsearch.index.shard.ShardId)4 RepositoryMissingException (org.elasticsearch.repositories.RepositoryMissingException)4 ObjectObjectCursor (com.carrotsearch.hppc.cursors.ObjectObjectCursor)3 List (java.util.List)3 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)3 Supplier (org.apache.logging.log4j.util.Supplier)3 SnapshotDeletionsInProgress (org.elasticsearch.cluster.SnapshotDeletionsInProgress)3 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)3 Collections.emptyMap (java.util.Collections.emptyMap)2 Collections.unmodifiableMap (java.util.Collections.unmodifiableMap)2