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


Java ShardRouting.shardId方法代码示例

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


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

示例1: fetchData

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
protected AsyncShardFetch.FetchResult<NodeGatewayStartedShards> fetchData(ShardRouting shard, RoutingAllocation allocation) {
    // for now always return immediately what we know
    final ShardId shardId = shard.shardId();
    final Set<String> ignoreNodes = allocation.getIgnoreNodes(shardId);
    Map<DiscoveryNode, NodeGatewayStartedShards> foundShards = knownAllocations.values().stream()
        .flatMap(shardMap -> shardMap.values().stream())
        .filter(ks -> ks.shardId().equals(shardId))
        .filter(ks -> ignoreNodes.contains(ks.currentNodeId()) == false)
        .filter(ks -> currentNodes.nodeExists(ks.currentNodeId()))
        .collect(Collectors.toMap(
            routing -> currentNodes.get(routing.currentNodeId()),
            routing ->
                new NodeGatewayStartedShards(
                    currentNodes.get(routing.currentNodeId()), routing.allocationId().getId(), routing.primary())));

    return new AsyncShardFetch.FetchResult<>(shardId, foundShards, Collections.emptySet(), ignoreNodes);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:TestGatewayAllocator.java

示例2: onShardOperation

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
private void onShardOperation(final NodeRequest request, final Object[] shardResults, final int shardIndex, final ShardRouting shardRouting) {
    try {
        if (logger.isTraceEnabled()) {
            logger.trace("[{}]  executing operation for shard [{}]", actionName, shardRouting.shortSummary());
        }
        ShardOperationResult result = shardOperation(request.indicesLevelRequest, shardRouting);
        shardResults[shardIndex] = result;
        if (logger.isTraceEnabled()) {
            logger.trace("[{}]  completed operation for shard [{}]", actionName, shardRouting.shortSummary());
        }
    } catch (Throwable t) {
        BroadcastShardOperationFailedException e = new BroadcastShardOperationFailedException(shardRouting.shardId(), "operation " + actionName + " failed", t);
        e.setIndex(shardRouting.getIndex());
        e.setShard(shardRouting.shardId());
        shardResults[shardIndex] = e;
        if (TransportActions.isShardNotAvailableException(t)) {
            if (logger.isTraceEnabled()) {
                logger.trace("[{}] failed to execute operation for shard [{}]", t, actionName, shardRouting.shortSummary());
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("[{}] failed to execute operation for shard [{}]", t, actionName, shardRouting.shortSummary());
            }
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:TransportBroadcastByNodeAction.java

示例3: newShard

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
/**
 * creates a new initializing shard. The shard will will be put in its proper path under the
 * current node id the shard is assigned to.
 *
 * @param routing                shard routing to use
 * @param indexMetaData          indexMetaData for the shard, including any mapping
 * @param indexSearcherWrapper   an optional wrapper to be used during searchers
 * @param globalCheckpointSyncer an runnable to run when the global check point needs syncing
 * @param listeners              an optional set of listeners to add to the shard
 */
protected IndexShard newShard(ShardRouting routing, IndexMetaData indexMetaData,
                              @Nullable IndexSearcherWrapper indexSearcherWrapper, Runnable globalCheckpointSyncer,
                              @Nullable EngineFactory engineFactory,
                              IndexingOperationListener... listeners)
    throws IOException {
    // add node id as name to settings for popper logging
    final ShardId shardId = routing.shardId();
    final NodeEnvironment.NodePath nodePath = new NodeEnvironment.NodePath(createTempDir());
    ShardPath shardPath = new ShardPath(false, nodePath.resolve(shardId), nodePath.resolve(shardId), shardId);
    return newShard(routing, shardPath, indexMetaData, indexSearcherWrapper, globalCheckpointSyncer, engineFactory, listeners);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:IndexShardTestCase.java

示例4: shardOperation

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
protected ShardUpgradeResult shardOperation(UpgradeRequest request, ShardRouting shardRouting) throws IOException {
    IndexShard indexShard = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()).getShard(shardRouting.shardId().id());
    org.apache.lucene.util.Version oldestLuceneSegment = indexShard.upgrade(request);
    // We are using the current version of Elasticsearch as upgrade version since we update mapping to match the current version
    return new ShardUpgradeResult(shardRouting.shardId(), indexShard.routingEntry().primary(), Version.CURRENT, oldestLuceneSegment);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TransportUpgradeAction.java

示例5: ShardUpgradeStatus

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
ShardUpgradeStatus(ShardRouting shardRouting, long totalBytes, long toUpgradeBytes, long upgradeBytesAncient) {
    super(shardRouting.shardId());
    this.shardRouting = shardRouting;
    this.totalBytes = totalBytes;
    this.toUpgradeBytes = toUpgradeBytes;
    this.toUpgradeBytesAncient = upgradeBytesAncient;

}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:ShardUpgradeStatus.java

示例6: testFillShardLevelInfo

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
public void testFillShardLevelInfo() {
    final Index index = new Index("test", "0xdeadbeef");
    ShardRouting test_0 = ShardRouting.newUnassigned(new ShardId(index, 0), false, PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
    test_0 = ShardRoutingHelper.initialize(test_0, "node1");
    test_0 = ShardRoutingHelper.moveToStarted(test_0);
    Path test0Path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve("0");
    CommonStats commonStats0 = new CommonStats();
    commonStats0.store = new StoreStats(100);
    ShardRouting test_1 = ShardRouting.newUnassigned(new ShardId(index, 1), false, PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
    test_1 = ShardRoutingHelper.initialize(test_1, "node2");
    test_1 = ShardRoutingHelper.moveToStarted(test_1);
    Path test1Path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve("1");
    CommonStats commonStats1 = new CommonStats();
    commonStats1.store = new StoreStats(1000);
    ShardStats[] stats  = new ShardStats[] {
            new ShardStats(test_0, new ShardPath(false, test0Path, test0Path, test_0.shardId()), commonStats0 , null, null),
            new ShardStats(test_1, new ShardPath(false, test1Path, test1Path, test_1.shardId()), commonStats1 , null, null)
    };
    ImmutableOpenMap.Builder<String, Long> shardSizes = ImmutableOpenMap.builder();
    ImmutableOpenMap.Builder<ShardRouting, String> routingToPath = ImmutableOpenMap.builder();
    ClusterState state = ClusterState.builder(new ClusterName("blarg")).version(0).build();
    InternalClusterInfoService.buildShardLevelInfo(logger, stats, shardSizes, routingToPath, state);
    assertEquals(2, shardSizes.size());
    assertTrue(shardSizes.containsKey(ClusterInfo.shardIdentifierFromRouting(test_0)));
    assertTrue(shardSizes.containsKey(ClusterInfo.shardIdentifierFromRouting(test_1)));
    assertEquals(100L, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(test_0)).longValue());
    assertEquals(1000L, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(test_1)).longValue());

    assertEquals(2, routingToPath.size());
    assertTrue(routingToPath.containsKey(test_0));
    assertTrue(routingToPath.containsKey(test_1));
    assertEquals(test0Path.getParent().getParent().getParent().toAbsolutePath().toString(), routingToPath.get(test_0));
    assertEquals(test1Path.getParent().getParent().getParent().toAbsolutePath().toString(), routingToPath.get(test_1));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:DiskUsageTests.java

示例7: testNoLongerPrimaryShardException

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
public void testNoLongerPrimaryShardException() throws InterruptedException {
    final String index = "test";

    setState(clusterService, ClusterStateCreationUtils.stateWithActivePrimary(index, true, randomInt(5)));

    ShardRouting failedShard = getRandomShardRouting(index);

    AtomicReference<Throwable> failure = new AtomicReference<>();
    CountDownLatch latch = new CountDownLatch(1);

    long primaryTerm = clusterService.state().metaData().index(index).primaryTerm(failedShard.id());
    assertThat(primaryTerm, greaterThanOrEqualTo(1L));
    shardStateAction.remoteShardFailed(failedShard.shardId(), failedShard.allocationId().getId(), primaryTerm + 1, "test",
        getSimulatedFailure(), new ShardStateAction.Listener() {
        @Override
        public void onSuccess() {
            failure.set(null);
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            failure.set(e);
            latch.countDown();
        }
    });

    ShardStateAction.NoLongerPrimaryShardException catastrophicError =
            new ShardStateAction.NoLongerPrimaryShardException(failedShard.shardId(), "dummy failure");
    CapturingTransport.CapturedRequest[] capturedRequests = transport.getCapturedRequestsAndClear();
    transport.handleRemoteError(capturedRequests[0].requestId, catastrophicError);

    latch.await();
    assertNotNull(failure.get());
    assertThat(failure.get(), instanceOf(ShardStateAction.NoLongerPrimaryShardException.class));
    assertThat(failure.get().getMessage(), equalTo(catastrophicError.getMessage()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:ShardStateActionTests.java

示例8: ShardSearchLocalRequest

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
ShardSearchLocalRequest(SearchRequest searchRequest, ShardRouting shardRouting, int numberOfShards,
                        String[] filteringAliases, long nowInMillis) {
    this(shardRouting.shardId(), numberOfShards, searchRequest.searchType(),
            searchRequest.source(), searchRequest.types(), searchRequest.requestCache());
    this.extraSource = searchRequest.extraSource();
    this.templateSource = searchRequest.templateSource();
    this.template = searchRequest.template();
    this.scroll = searchRequest.scroll();
    this.filteringAliases = filteringAliases;
    this.nowInMillis = nowInMillis;
    copyContextAndHeadersFrom(searchRequest);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:ShardSearchLocalRequest.java

示例9: fetchData

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
protected AsyncShardFetch.FetchResult<TransportNodesListGatewayStartedShards.NodeGatewayStartedShards> fetchData(ShardRouting shard, RoutingAllocation allocation) {
    AsyncShardFetch<TransportNodesListGatewayStartedShards.NodeGatewayStartedShards> fetch = asyncFetchStarted.get(shard.shardId());
    if (fetch == null) {
        fetch = new InternalAsyncFetch<>(logger, "shard_started", shard.shardId(), startedAction);
        asyncFetchStarted.put(shard.shardId(), fetch);
    }
    AsyncShardFetch.FetchResult<TransportNodesListGatewayStartedShards.NodeGatewayStartedShards> shardState =
            fetch.fetchData(allocation.nodes(), allocation.metaData(), allocation.getIgnoreNodes(shard.shardId()));

    if (shardState.hasData() == true) {
        shardState.processAllocation(allocation);
    }
    return shardState;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:GatewayAllocator.java

示例10: newShardRequest

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
protected PercolateShardRequest newShardRequest(int numShards, ShardRouting shard, PercolateRequest request) {
    return new PercolateShardRequest(shard.shardId(), numShards, request);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:TransportPercolateAction.java

示例11: shardStarted

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
public void shardStarted(final ShardRouting shardRouting, final String message, Listener listener, ClusterState currentState) {
    ShardEntry shardEntry = new ShardEntry(shardRouting.shardId(), shardRouting.allocationId().getId(), 0L, message, null);
    sendShardAction(SHARD_STARTED_ACTION_NAME, currentState, shardEntry, listener);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ShardStateAction.java

示例12: newShardRequest

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
protected ShardSuggestRequest newShardRequest(int numShards, ShardRouting shard, SuggestRequest request) {
    return new ShardSuggestRequest(shard.shardId(), request);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:TransportSuggestAction.java

示例13: newShardRequest

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
protected ShardValidateQueryRequest newShardRequest(int numShards, ShardRouting shard, ValidateQueryRequest request) {
    final AliasFilter aliasFilter = searchService.buildAliasFilter(clusterService.state(), shard.getIndexName(),
        request.indices());
    return new ShardValidateQueryRequest(shard.shardId(), aliasFilter, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:TransportValidateQueryAction.java

示例14: newShardRequest

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
protected FieldStatsShardRequest newShardRequest(int numShards, ShardRouting shard, FieldStatsRequest request) {
    return new FieldStatsShardRequest(shard.shardId(), request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TransportFieldStatsAction.java

示例15: perform

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
private void perform(@Nullable final Throwable currentFailure) {
    Throwable lastFailure = this.lastFailure;
    if (lastFailure == null || TransportActions.isReadOverrideException(currentFailure)) {
        lastFailure = currentFailure;
        this.lastFailure = currentFailure;
    }
    final ShardRouting shardRouting = shardIt.nextOrNull();
    if (shardRouting == null) {
        Throwable failure = lastFailure;
        if (failure == null || isShardNotAvailableException(failure)) {
            failure = new NoShardAvailableActionException(null, LoggerMessageFormat.format("No shard available for [{}]", internalRequest.request()), failure);
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("{}: failed to execute [{}]", failure, null, internalRequest.request());
            }
        }
        listener.onFailure(failure);
        return;
    }
    DiscoveryNode node = nodes.get(shardRouting.currentNodeId());
    if (node == null) {
        onFailure(shardRouting, new NoShardAvailableActionException(shardRouting.shardId()));
    } else {
        internalRequest.request().internalShardId = shardRouting.shardId();
        if (logger.isTraceEnabled()) {
            logger.trace(
                    "sending request [{}] to shard [{}] on node [{}]",
                    internalRequest.request(),
                    internalRequest.request().internalShardId,
                    node
            );
        }
        transportService.sendRequest(node, transportShardAction, internalRequest.request(), new BaseTransportResponseHandler<Response>() {

            @Override
            public Response newInstance() {
                return newResponse();
            }

            @Override
            public String executor() {
                return ThreadPool.Names.SAME;
            }

            @Override
            public void handleResponse(final Response response) {
                listener.onResponse(response);
            }

            @Override
            public void handleException(TransportException exp) {
                onFailure(shardRouting, exp);
            }
        });
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:57,代码来源:TransportSingleShardAction.java


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