Package org.elasticsearch.indices.recovery

Examples of org.elasticsearch.indices.recovery.RecoveryState


        ensureGreen();

        RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").get();

        for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) {
            RecoveryState recoveryState = response.recoveryState();
            if (!recoveryState.getPrimary()) {
                logger.info("--> shard {}, recovered {}, reuse {}", response.getShardId(), recoveryState.getIndex().recoveredTotalSize(), recoveryState.getIndex().reusedByteCount());
                assertThat(recoveryState.getIndex().recoveredByteCount(), equalTo(0l));
                assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(0l));
                assertThat(recoveryState.getIndex().reusedByteCount(), equalTo(recoveryState.getIndex().totalByteCount()));
                assertThat(recoveryState.getIndex().recoveredFileCount(), equalTo(0));
                assertThat(recoveryState.getIndex().reusedFileCount(), equalTo(recoveryState.getIndex().totalFileCount()));
                assertThat(recoveryState.getIndex().reusedFileCount(), greaterThan(0));
                assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(recoveryState.getIndex().numberOfRecoveredBytes()));
            } else {
                assertThat(recoveryState.getIndex().recoveredByteCount(), equalTo(recoveryState.getIndex().reusedByteCount()));
                assertThat(recoveryState.getIndex().recoveredFileCount(), equalTo(recoveryState.getIndex().reusedFileCount()));
            }
        }

    }
View Full Code Here


        countResponse = client().prepareCount().get();
        assertHitCount(countResponse, numDocs);

        RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").setDetailed(true).get();
        for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) {
            RecoveryState recoveryState = response.recoveryState();
            if (!recoveryState.getPrimary()) {
                RecoveryState.Index index = recoveryState.getIndex();
                if (compatibilityVersion().onOrAfter(Version.V_1_2_0)) {
                    assertThat(index.toString(), index.recoveredByteCount(), equalTo(0l));
                    assertThat(index.toString(), index.reusedByteCount(), greaterThan(0l));
                    assertThat(index.toString(), index.reusedByteCount(), equalTo(index.totalByteCount()));
                    assertThat(index.toString(), index.recoveredFileCount(), equalTo(0));
View Full Code Here

        super(shardId, indexSettings);
        this.threadPool = threadPool;
        this.indexShard = (InternalIndexShard) indexShard;
        this.shardGateway = shardGateway;
        this.snapshotService = snapshotService;
        this.recoveryState = new RecoveryState(shardId);
        this.recoveryState.setType(RecoveryState.Type.GATEWAY);
        this.clusterService = clusterService;
    }
View Full Code Here

                }
            });

            for (ShardRecoveryResponse shardResponse : shardRecoveryResponses) {

                RecoveryState state = shardResponse.recoveryState();
                t.startRow();
                t.addCell(index);
                t.addCell(shardResponse.getShardId());
                t.addCell(state.getTimer().time());
                t.addCell(state.getType().toString().toLowerCase(Locale.ROOT));
                t.addCell(state.getStage().toString().toLowerCase(Locale.ROOT));
                t.addCell(state.getSourceNode() == null ? "n/a" : state.getSourceNode().getHostName());
                t.addCell(state.getTargetNode().getHostName());
                t.addCell(state.getRestoreSource() == null ? "n/a" : state.getRestoreSource().snapshotId().getRepository());
                t.addCell(state.getRestoreSource() == null ? "n/a" : state.getRestoreSource().snapshotId().getSnapshot());
                t.addCell(state.getIndex().totalFileCount());
                t.addCell(String.format(Locale.ROOT, "%1.1f%%", state.getIndex().percentFilesRecovered()));
                t.addCell(state.getIndex().totalByteCount());
                t.addCell(String.format(Locale.ROOT, "%1.1f%%", state.getIndex().percentBytesRecovered()));
                t.endRow();
            }
        }

        return t;
View Full Code Here

        InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.shardId().getIndex());
        InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId().id());
        ShardRecoveryResponse shardRecoveryResponse = new ShardRecoveryResponse(request.shardId());

        RecoveryState state = indexShard.recoveryState();

        if (state == null) {
            state = recoveryTarget.recoveryState(indexShard);
        }
View Full Code Here

                    // closing the shard will also cancel any ongoing recovery.
                    indexService.removeShard(shardRouting.id(), "removing shard (different instance of it allocated on this node)");
                    shardHasBeenRemoved = true;
                } else if (isPeerRecovery(shardRouting)) {
                    // check if there is an existing recovery going, and if so, and the source node is not the same, cancel the recovery to restart it
                    RecoveryState recoveryState = recoveryTarget.recoveryState(indexShard);
                    if (recoveryState != null && recoveryState.getStage() != RecoveryState.Stage.DONE) {
                        // we have an ongoing recovery, find the source based on current routing and compare them
                        DiscoveryNode sourceNode = findSourceNodeForPeerRecovery(routingTable, nodes, shardRouting);
                        if (!recoveryState.getSourceNode().equals(sourceNode)) {
                            logger.debug("[{}][{}] removing shard (recovery source changed), current [{}], global [{}])", shardRouting.index(), shardRouting.id(), currentRoutingEntry, shardRouting);
                            // closing the shard will also cancel any ongoing recovery.
                            indexService.removeShard(shardRouting.id(), "removing shard (recovery source node changed)");
                            shardHasBeenRemoved = true;
                        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.indices.recovery.RecoveryState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.