当前位置: 首页>>代码示例>>Java>>正文


Java ShardIterator.shardId方法代码示例

本文整理汇总了Java中org.elasticsearch.cluster.routing.ShardIterator.shardId方法的典型用法代码示例。如果您正苦于以下问题:Java ShardIterator.shardId方法的具体用法?Java ShardIterator.shardId怎么用?Java ShardIterator.shardId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.cluster.routing.ShardIterator的用法示例。


在下文中一共展示了ShardIterator.shardId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillLocationsFromShardIterators

import org.elasticsearch.cluster.routing.ShardIterator; //导入方法依赖的package包/类
private void fillLocationsFromShardIterators(Map<String, Map<String, List<Integer>>> locations,
                                             GroupShardsIterator shardIterators,
                                             List<ShardId> missingShards) {
    ShardRouting shardRouting;
    for (ShardIterator shardIterator : shardIterators) {
        shardRouting = shardIterator.nextOrNull();
        if (shardRouting != null) {
            if (shardRouting.active()) {
                processShardRouting(locations, shardRouting);
            } else {
                missingShards.add(shardIterator.shardId());
            }
        } else {
            if (isPartitioned) {
                // if the table is partitioned maybe a index/shard just got newly created ...
                missingShards.add(shardIterator.shardId());
            } else {
                throw new UnavailableShardsException(shardIterator.shardId());
            }
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:DocTableInfo.java

示例2: masterOperation

import org.elasticsearch.cluster.routing.ShardIterator; //导入方法依赖的package包/类
@Override
protected void masterOperation(final ClusterSearchShardsRequest request, final ClusterState state,
                               final ActionListener<ClusterSearchShardsResponse> listener) {
    ClusterState clusterState = clusterService.state();
    String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request);
    Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(state, request.routing(), request.indices());
    Map<String, AliasFilter> indicesAndFilters = new HashMap<>();
    for (String index : concreteIndices) {
        AliasFilter aliasFilter = indicesService.buildAliasFilter(clusterState, index, request.indices());
        indicesAndFilters.put(index, aliasFilter);
    }

    Set<String> nodeIds = new HashSet<>();
    GroupShardsIterator groupShardsIterator = clusterService.operationRouting().searchShards(clusterState, concreteIndices,
            routingMap, request.preference());
    ShardRouting shard;
    ClusterSearchShardsGroup[] groupResponses = new ClusterSearchShardsGroup[groupShardsIterator.size()];
    int currentGroup = 0;
    for (ShardIterator shardIt : groupShardsIterator) {
        ShardId shardId = shardIt.shardId();
        ShardRouting[] shardRoutings = new ShardRouting[shardIt.size()];
        int currentShard = 0;
        shardIt.reset();
        while ((shard = shardIt.nextOrNull()) != null) {
            shardRoutings[currentShard++] = shard;
            nodeIds.add(shard.currentNodeId());
        }
        groupResponses[currentGroup++] = new ClusterSearchShardsGroup(shardId, shardRoutings);
    }
    DiscoveryNode[] nodes = new DiscoveryNode[nodeIds.size()];
    int currentNode = 0;
    for (String nodeId : nodeIds) {
        nodes[currentNode++] = clusterState.getNodes().get(nodeId);
    }
    listener.onResponse(new ClusterSearchShardsResponse(groupResponses, nodes, indicesAndFilters));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:TransportClusterSearchShardsAction.java

示例3: setFailure

import org.elasticsearch.cluster.routing.ShardIterator; //导入方法依赖的package包/类
void setFailure(ShardIterator shardIt, int shardIndex, Exception e) {
    // we don't aggregate shard failures on non active shards (but do keep the header counts right)
    if (TransportActions.isShardNotAvailableException(e)) {
        return;
    }

    if (!(e instanceof BroadcastShardOperationFailedException)) {
        e = new BroadcastShardOperationFailedException(shardIt.shardId(), e);
    }

    Object response = shardsResponses.get(shardIndex);
    if (response == null) {
        // just override it and return
        shardsResponses.set(shardIndex, e);
    }

    if (!(response instanceof Throwable)) {
        // we should never really get here...
        return;
    }

    // the failure is already present, try and not override it with an exception that is less meaningless
    // for example, getting illegal shard state
    if (TransportActions.isReadOverrideException(e)) {
        shardsResponses.set(shardIndex, e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:TransportBroadcastAction.java

示例4: executionFailureMsg

import org.elasticsearch.cluster.routing.ShardIterator; //导入方法依赖的package包/类
private String executionFailureMsg(@Nullable ShardRouting shard, final ShardIterator shardIt, SearchRequest request, boolean lastShard) {
    if (shard != null) {
        return shard.shortSummary() + ": Failed to execute [" + request + "] lastShard [" + lastShard + "]";
    } else {
        return shardIt.shardId() + ": Failed to execute [" + request + "] lastShard [" + lastShard + "]";
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:AbstractSearchAsyncAction.java

示例5: setFailure

import org.elasticsearch.cluster.routing.ShardIterator; //导入方法依赖的package包/类
void setFailure(ShardIterator shardIt, int shardIndex, Throwable t) {
    // we don't aggregate shard failures on non active shards (but do keep the header counts right)
    if (TransportActions.isShardNotAvailableException(t)) {
        return;
    }

    if (!(t instanceof BroadcastShardOperationFailedException)) {
        t = new BroadcastShardOperationFailedException(shardIt.shardId(), t);
    }

    Object response = shardsResponses.get(shardIndex);
    if (response == null) {
        // just override it and return
        shardsResponses.set(shardIndex, t);
    }

    if (!(response instanceof Throwable)) {
        // we should never really get here...
        return;
    }

    // the failure is already present, try and not override it with an exception that is less meaningless
    // for example, getting illegal shard state
    if (TransportActions.isReadOverrideException(t)) {
        shardsResponses.set(shardIndex, t);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:TransportBroadcastAction.java

示例6: onShardFailure

import org.elasticsearch.cluster.routing.ShardIterator; //导入方法依赖的package包/类
private void onShardFailure(final int shardIndex, @Nullable ShardRouting shard, @Nullable String nodeId,
                            final ShardIterator shardIt, Exception e) {
    // we always add the shard failure for a specific shard instance
    // we do make sure to clean it on a successful response from a shard
    SearchShardTarget shardTarget = new SearchShardTarget(nodeId, shardIt.shardId());
    onShardFailure(shardIndex, shardTarget, e);

    if (totalOps.incrementAndGet() == expectedTotalOps) {
        if (logger.isDebugEnabled()) {
            if (e != null && !TransportActions.isShardNotAvailableException(e)) {
                logger.debug(
                    (Supplier<?>) () -> new ParameterizedMessage(
                        "{}: Failed to execute [{}]",
                        shard != null ? shard.shortSummary() :
                            shardIt.shardId(),
                        request),
                    e);
            } else if (logger.isTraceEnabled()) {
                logger.trace((Supplier<?>) () -> new ParameterizedMessage("{}: Failed to execute [{}]", shard, request), e);
            }
        }
        onPhaseDone();
    } else {
        final ShardRouting nextShard = shardIt.nextOrNull();
        final boolean lastShard = nextShard == null;
        // trace log this exception
        logger.trace(
            (Supplier<?>) () -> new ParameterizedMessage(
                "{}: Failed to execute [{}] lastShard [{}]",
                shard != null ? shard.shortSummary() : shardIt.shardId(),
                request,
                lastShard),
            e);
        if (!lastShard) {
            try {
                performPhaseOnShard(shardIndex, shardIt, nextShard);
            } catch (Exception inner) {
                inner.addSuppressed(e);
                onShardFailure(shardIndex, shard, shard.currentNodeId(), shardIt, inner);
            }
        } else {
            // no more shards active, add a failure
            if (logger.isDebugEnabled() && !logger.isTraceEnabled()) { // do not double log this exception
                if (e != null && !TransportActions.isShardNotAvailableException(e)) {
                    logger.debug(
                        (Supplier<?>) () -> new ParameterizedMessage(
                            "{}: Failed to execute [{}] lastShard [{}]",
                            shard != null ? shard.shortSummary() :
                                shardIt.shardId(),
                            request,
                            lastShard),
                        e);
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:58,代码来源:InitialSearchPhase.java

示例7: shardId

import org.elasticsearch.cluster.routing.ShardIterator; //导入方法依赖的package包/类
public ShardId shardId(String digest) {
    ShardIterator si = operationRouting.getShards(clusterService.state(), index.getName(), null, null, digest, "_only_local");
    // TODO: check null and raise
    return si.shardId();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:BlobIndex.java


注:本文中的org.elasticsearch.cluster.routing.ShardIterator.shardId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。