Package org.elasticsearch.cluster.routing

Examples of org.elasticsearch.cluster.routing.GroupShardsIterator


            if (indexShard == null) {
                throw new IndexShardMissingException(new ShardId(index, shardId));
            }
            set.add(indexShard.shardsRandomIt());
        }
        return new GroupShardsIterator(set);
    }
View Full Code Here


                        // we might get duplicates, but that's ok, they will override one another
                        set.add(preferenceActiveShardIterator(indexShard, clusterState.nodes().localNodeId(), preference));
                    }
                }
            }
            return new GroupShardsIterator(set);
        } else {
            // we use list here since we know we are not going to create duplicates
            ArrayList<ShardIterator> set = new ArrayList<ShardIterator>();
            for (String index : concreteIndices) {
                IndexRoutingTable indexRouting = indexRoutingTable(clusterState, index);
                for (IndexShardRoutingTable indexShard : indexRouting) {
                    set.add(preferenceActiveShardIterator(indexShard, clusterState.nodes().localNodeId(), preference));
                }
            }
            return new GroupShardsIterator(set);
        }
    }
View Full Code Here

        // update to concrete index
        request.index(clusterState.metaData().concreteIndex(request.index()));

        checkBlock(request, clusterState);

        GroupShardsIterator groups;
        try {
            groups = shards(request);
        } catch (Exception e) {
            listener.onFailure(e);
            return;
        }
        final AtomicInteger indexCounter = new AtomicInteger();
        final AtomicInteger completionCounter = new AtomicInteger(groups.size());
        final AtomicReferenceArray<Object> shardsResponses = new AtomicReferenceArray<Object>(groups.size());

        for (final ShardIterator shardIt : groups) {
            ShardRequest shardRequest = newShardRequestInstance(request, shardIt.shardId().id());

            // TODO for now, we fork operations on shardIt of the index
View Full Code Here

            } else if (request instanceof DeleteRequest) {
                DeleteRequest deleteRequest = (DeleteRequest) request;
                MappingMetaData mappingMd = clusterState.metaData().index(deleteRequest.index()).mapping(deleteRequest.type());
                if (mappingMd != null && mappingMd.routing().required() && deleteRequest.routing() == null) {
                    // if routing is required, and no routing on the delete request, we need to broadcast it....
                    GroupShardsIterator groupShards = clusterService.operationRouting().broadcastDeleteShards(clusterState, deleteRequest.index());
                    for (ShardIterator shardIt : groupShards) {
                        List<BulkItemRequest> list = requestsByShard.get(shardIt.shardId());
                        if (list == null) {
                            list = Lists.newArrayList();
                            requestsByShard.put(shardIt.shardId(), list);
View Full Code Here

        ShardDeleteByQueryRequest request = shardRequest.request;
        indexShard(shardRequest).deleteByQuery(request.querySource(), request.filteringAliases(), request.types());
    }

    @Override protected ShardIterator shards(ClusterState clusterState, ShardDeleteByQueryRequest request) {
        GroupShardsIterator group = clusterService.operationRouting().deleteByQueryShards(clusterService.state(), request.index(), request.routing());
        for (ShardIterator shardIt : group) {
            if (shardIt.shardId().id() == request.shardId()) {
                return shardIt;
            }
        }
View Full Code Here

        }

    }

    @Override protected ShardIterator shards(ClusterState clusterState, ShardDeleteRequest request) {
        GroupShardsIterator group = clusterService.operationRouting().broadcastDeleteShards(clusterService.state(), request.index());
        for (ShardIterator shardIt : group) {
            if (shardIt.shardId().id() == request.shardId()) {
                return shardIt;
            }
        }
View Full Code Here

        if (whereClause.clusteredBy().isPresent()) {
            routingMap = clusterState.metaData().resolveSearchRouting(
                    whereClause.clusteredBy().get(), routingIndices);
        }

        GroupShardsIterator shardIterators;
        try {
            shardIterators = clusterService.operationRouting().searchShards(
                    clusterState,
                    indices,
                    routingIndices,
View Full Code Here

    }

    @Override
    public Routing getRouting(WhereClause whereClause) {
        Map<String, Map<String, Set<Integer>>> locations = new HashMap<>();
        GroupShardsIterator shardIterators = clusterService.operationRouting().searchShards(
                clusterService.state(),
                Strings.EMPTY_ARRAY,
                new String[]{index},
                null,
                null // preference
View Full Code Here

    protected void masterOperation(final ClusterSearchShardsRequest request, final ClusterState state, final ActionListener<ClusterSearchShardsResponse> listener) throws ElasticsearchException {
        ClusterState clusterState = clusterService.state();
        String[] concreteIndices = clusterState.metaData().concreteIndices(request.indicesOptions(), request.indices());
        Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
        Set<String> nodeIds = newHashSet();
        GroupShardsIterator groupShardsIterator = clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, request.preference());
        ShardRouting shard;
        ClusterSearchShardsGroup[] groupResponses = new ClusterSearchShardsGroup[groupShardsIterator.size()];
        int currentGroup = 0;
        for (ShardIterator shardIt : groupShardsIterator) {
            String index = shardIt.shardId().getIndex();
            int shardId = shardIt.shardId().getId();
            ShardRouting[] shardRoutings = new ShardRouting[shardIt.size()];
View Full Code Here

        }
    }

    @Override
    protected ShardIterator shards(ClusterState clusterState, InternalRequest request) {
        GroupShardsIterator group = clusterService.operationRouting().deleteByQueryShards(clusterService.state(), request.concreteIndex(), request.request().routing());
        for (ShardIterator shardIt : group) {
            if (shardIt.shardId().id() == request.request().shardId()) {
                return shardIt;
            }
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.cluster.routing.GroupShardsIterator

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.