Package org.elasticsearch.index.service

Examples of org.elasticsearch.index.service.InternalIndexService


    @Override protected ShardStatus newShardResponse() {
        return new ShardStatus();
    }

    @Override protected ShardStatus shardOperation(IndexShardStatusRequest request) throws ElasticSearchException {
        InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.index());
        InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId());
        ShardStatus shardStatus = new ShardStatus(indexShard.routingEntry());
        shardStatus.state = indexShard.state();
        try {
            shardStatus.storeSize = indexShard.store().estimateSize();
        } catch (IOException e) {
            // failure to get the store size...
        }
        if (indexShard.state() == IndexShardState.STARTED) {
//            shardStatus.estimatedFlushableMemorySize = indexShard.estimateFlushableMemorySize();
            shardStatus.translogId = indexShard.translog().currentId();
            shardStatus.translogOperations = indexShard.translog().estimatedNumberOfOperations();
            Engine.Searcher searcher = indexShard.searcher();
            try {
                shardStatus.docs = new DocsStatus();
                shardStatus.docs.numDocs = searcher.reader().numDocs();
                shardStatus.docs.maxDoc = searcher.reader().maxDoc();
                shardStatus.docs.deletedDocs = searcher.reader().numDeletedDocs();
            } finally {
                searcher.release();
            }

            shardStatus.mergeStats = indexShard.mergeScheduler().stats();
            shardStatus.refreshStats = indexShard.refreshStats();
        }

        if (request.recovery) {
            // check on going recovery (from peer or gateway)
            RecoveryStatus peerRecoveryStatus = indexShard.peerRecoveryStatus();
            if (peerRecoveryStatus == null) {
                peerRecoveryStatus = peerRecoveryTarget.peerRecoveryStatus(indexShard.shardId());
            }
            if (peerRecoveryStatus != null) {
                PeerRecoveryStatus.Stage stage;
                switch (peerRecoveryStatus.stage()) {
                    case INIT:
                        stage = PeerRecoveryStatus.Stage.INIT;
                        break;
                    case INDEX:
                        stage = PeerRecoveryStatus.Stage.INDEX;
                        break;
                    case TRANSLOG:
                        stage = PeerRecoveryStatus.Stage.TRANSLOG;
                        break;
                    case FINALIZE:
                        stage = PeerRecoveryStatus.Stage.FINALIZE;
                        break;
                    case DONE:
                        stage = PeerRecoveryStatus.Stage.DONE;
                        break;
                    default:
                        stage = PeerRecoveryStatus.Stage.INIT;
                }
                shardStatus.peerRecoveryStatus = new PeerRecoveryStatus(stage, peerRecoveryStatus.startTime(), peerRecoveryStatus.time(),
                        peerRecoveryStatus.phase1TotalSize(), peerRecoveryStatus.phase1ExistingTotalSize(),
                        peerRecoveryStatus.currentFilesSize(), peerRecoveryStatus.currentTranslogOperations());
            }

            IndexShardGatewayService gatewayService = indexService.shardInjector(request.shardId()).getInstance(IndexShardGatewayService.class);
            org.elasticsearch.index.gateway.RecoveryStatus gatewayRecoveryStatus = gatewayService.recoveryStatus();
            if (gatewayRecoveryStatus != null) {
                GatewayRecoveryStatus.Stage stage;
                switch (gatewayRecoveryStatus.stage()) {
                    case INIT:
                        stage = GatewayRecoveryStatus.Stage.INIT;
                        break;
                    case INDEX:
                        stage = GatewayRecoveryStatus.Stage.INDEX;
                        break;
                    case TRANSLOG:
                        stage = GatewayRecoveryStatus.Stage.TRANSLOG;
                        break;
                    case DONE:
                        stage = GatewayRecoveryStatus.Stage.DONE;
                        break;
                    default:
                        stage = GatewayRecoveryStatus.Stage.INIT;
                }
                shardStatus.gatewayRecoveryStatus = new GatewayRecoveryStatus(stage, gatewayRecoveryStatus.startTime(), gatewayRecoveryStatus.time(),
                        gatewayRecoveryStatus.index().totalSize(), gatewayRecoveryStatus.index().reusedTotalSize(), gatewayRecoveryStatus.index().currentFilesSize(), gatewayRecoveryStatus.translog().currentTranslogOperations());
            }
        }

        if (request.snapshot) {
            IndexShardGatewayService gatewayService = indexService.shardInjector(request.shardId()).getInstance(IndexShardGatewayService.class);
            SnapshotStatus snapshotStatus = gatewayService.snapshotStatus();
            if (snapshotStatus != null) {
                GatewaySnapshotStatus.Stage stage;
                switch (snapshotStatus.stage()) {
                    case DONE:
View Full Code Here


    @Override protected ShardSegments newShardResponse() {
        return new ShardSegments();
    }

    @Override protected ShardSegments shardOperation(IndexShardSegmentRequest request) throws ElasticSearchException {
        InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.index());
        InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId());
        return new ShardSegments(indexShard.routingEntry(), indexShard.engine().segments());
    }
View Full Code Here

        return new ShardStats();
    }

    @Override
    protected ShardStats shardOperation(IndexShardStatsRequest request) throws ElasticsearchException {
        InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.shardId().getIndex());
        InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId().id());
        // if we don't have the routing entry yet, we need it stats wise, we treat it as if the shard is not ready yet
        if (indexShard.routingEntry() == null) {
            throw new IndexShardMissingException(indexShard.shardId());
        }
View Full Code Here

    }

    @Override
    protected ShardRecoveryResponse shardOperation(ShardRecoveryRequest request) throws ElasticsearchException {

        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);
        }

        if (state == null) {
            IndexShardGatewayService gatewayService =
                    indexService.shardInjector(request.shardId().id()).getInstance(IndexShardGatewayService.class);
            state = gatewayService.recoveryState();
        }

        shardRecoveryResponse.recoveryState(state);
        return shardRecoveryResponse;
View Full Code Here

        return new ShardSegments();
    }

    @Override
    protected ShardSegments shardOperation(IndexShardSegmentRequest request) throws ElasticsearchException {
        InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.shardId().getIndex());
        InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId().id());
        return new ShardSegments(indexShard.routingEntry(), indexShard.engine().segments());
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.service.InternalIndexService

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.