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


Java SearchShardTarget类代码示例

本文整理汇总了Java中org.elasticsearch.search.SearchShardTarget的典型用法代码示例。如果您正苦于以下问题:Java SearchShardTarget类的具体用法?Java SearchShardTarget怎么用?Java SearchShardTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onShardResult

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
private void onShardResult(int shardIndex, String nodeId, FirstResult result, ShardIterator shardIt) {
    result.shardTarget(new SearchShardTarget(nodeId, shardIt.shardId()));
    onShardSuccess(shardIndex, result);
    // we need to increment successful ops first before we compare the exit condition otherwise if we
    // are fast we could concurrently update totalOps but then preempt one of the threads which can
    // cause the successor to read a wrong value from successfulOps if second phase is very fast ie. count etc.
    // increment all the "future" shards to update the total ops since we some may work and some may not...
    // and when that happens, we break on total ops, so we must maintain them
    final int xTotalOps = totalOps.addAndGet(shardIt.remaining() + 1);
    if (xTotalOps == expectedTotalOps) {
        onPhaseDone();
    } else if (xTotalOps > expectedTotalOps) {
        throw new AssertionError("unexpected higher total ops [" + xTotalOps + "] compared to expected ["
            + expectedTotalOps + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InitialSearchPhase.java

示例2: testToXContent

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
public void testToXContent() throws IOException {
    ShardSearchFailure failure = new ShardSearchFailure(new ParsingException(0, 0, "some message", null),
            new SearchShardTarget("nodeId", new ShardId(new Index("indexName", "indexUuid"), 123)));
    BytesReference xContent = toXContent(failure, XContentType.JSON, randomBoolean());
    assertEquals(
            "{\"shard\":123,"
                    + "\"index\":\"indexName\","
                    + "\"node\":\"nodeId\","
                    + "\"reason\":{"
                        + "\"type\":\"parsing_exception\","
                        + "\"reason\":\"some message\","
                        + "\"line\":0,"
                        + "\"col\":0"
                    + "}"
            + "}",
            xContent.utf8ToString());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ShardSearchFailureTests.java

示例3: CrateSearchContext

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
public CrateSearchContext(long id,
                          final long nowInMillis,
                          SearchShardTarget shardTarget,
                          Engine.Searcher engineSearcher,
                          IndexService indexService,
                          final IndexShard indexShard,
                          ScriptService scriptService,
                          PageCacheRecycler pageCacheRecycler,
                          BigArrays bigArrays,
                          Counter timeEstimateCounter,
                          Optional<Scroll> scroll) {
    super(id, new CrateSearchShardRequest(nowInMillis, scroll, indexShard),
            shardTarget, engineSearcher, indexService,
            indexShard, scriptService, pageCacheRecycler,
            bigArrays, timeEstimateCounter, ParseFieldMatcher.STRICT, SearchService.NO_TIMEOUT);
    this.engineSearcher = engineSearcher;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:CrateSearchContext.java

示例4: PercolateContext

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
public PercolateContext(PercolateShardRequest request, SearchShardTarget searchShardTarget, IndexShard indexShard,
                        IndexService indexService, PageCacheRecycler pageCacheRecycler,
                        BigArrays bigArrays, ScriptService scriptService, Query aliasFilter, ParseFieldMatcher parseFieldMatcher) {
    super(parseFieldMatcher, request);
    this.indexShard = indexShard;
    this.indexService = indexService;
    this.fieldDataService = indexService.fieldData();
    this.searchShardTarget = searchShardTarget;
    this.percolateQueries = indexShard.percolateRegistry().percolateQueries();
    this.types = new String[]{request.documentType()};
    this.pageCacheRecycler = pageCacheRecycler;
    this.bigArrays = bigArrays.withCircuitBreaking();
    this.querySearchResult = new QuerySearchResult(0, searchShardTarget);
    this.engineSearcher = indexShard.acquireSearcher("percolate");
    this.searcher = new ContextIndexSearcher(engineSearcher, indexService.cache().query(), indexShard.getQueryCachingPolicy());
    this.scriptService = scriptService;
    this.numberOfShards = request.getNumberOfShards();
    this.aliasFilter = aliasFilter;
    this.startTime = request.getStartTime();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:PercolateContext.java

示例5: DefaultSearchContext

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
public DefaultSearchContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget,
                            Engine.Searcher engineSearcher, IndexService indexService, IndexShard indexShard,
                            ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
                            BigArrays bigArrays, Counter timeEstimateCounter, ParseFieldMatcher parseFieldMatcher,
                            TimeValue timeout
) {
    super(parseFieldMatcher, request);
    this.id = id;
    this.request = request;
    this.searchType = request.searchType();
    this.shardTarget = shardTarget;
    this.engineSearcher = engineSearcher;
    this.scriptService = scriptService;
    this.pageCacheRecycler = pageCacheRecycler;
    // SearchContexts use a BigArrays that can circuit break
    this.bigArrays = bigArrays.withCircuitBreaking();
    this.dfsResult = new DfsSearchResult(id, shardTarget);
    this.queryResult = new QuerySearchResult(id, shardTarget);
    this.fetchResult = new FetchSearchResult(id, shardTarget);
    this.indexShard = indexShard;
    this.indexService = indexService;
    this.searcher = new ContextIndexSearcher(engineSearcher, indexService.cache().query(), indexShard.getQueryCachingPolicy());
    this.timeEstimateCounter = timeEstimateCounter;
    this.timeoutInMillis = timeout.millis();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:DefaultSearchContext.java

示例6: onFirstPhaseResult

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
void onFirstPhaseResult(int shardIndex, ShardRouting shard, FirstResult result, ShardIterator shardIt) {
    result.shardTarget(new SearchShardTarget(shard.currentNodeId(), shard.index(), shard.id()));
    processFirstPhaseResult(shardIndex, result);
    // we need to increment successful ops first before we compare the exit condition otherwise if we
    // are fast we could concurrently update totalOps but then preempt one of the threads which can
    // cause the successor to read a wrong value from successfulOps if second phase is very fast ie. count etc.
    successfulOps.incrementAndGet();
    // increment all the "future" shards to update the total ops since we some may work and some may not...
    // and when that happens, we break on total ops, so we must maintain them
    final int xTotalOps = totalOps.addAndGet(shardIt.remaining() + 1);
    if (xTotalOps == expectedTotalOps) {
        try {
            innerMoveToSecondPhase();
        } catch (Throwable e) {
            if (logger.isDebugEnabled()) {
                logger.debug(shardIt.shardId() + ": Failed to execute [" + request + "] while moving to second phase", e);
            }
            raiseEarlyFailure(new ReduceSearchPhaseException(firstPhaseName(), "", e, buildShardFailures()));
        }
    } else if (xTotalOps > expectedTotalOps) {
        raiseEarlyFailure(new IllegalStateException("unexpected higher total ops [" + xTotalOps + "] compared to expected [" + expectedTotalOps + "]"));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:AbstractSearchAsyncAction.java

示例7: addShardFailure

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
protected final void addShardFailure(final int shardIndex, @Nullable SearchShardTarget shardTarget, Throwable t) {
    // we don't aggregate shard failures on non active shards (but do keep the header counts right)
    if (TransportActions.isShardNotAvailableException(t)) {
        return;
    }

    // lazily create shard failures, so we can early build the empty shard failure list in most cases (no failures)
    if (shardFailures == null) {
        synchronized (shardFailuresMutex) {
            if (shardFailures == null) {
                shardFailures = new AtomicArray<>(shardsIts.size());
            }
        }
    }
    ShardSearchFailure failure = shardFailures.get(shardIndex);
    if (failure == null) {
        shardFailures.set(shardIndex, new ShardSearchFailure(t, shardTarget));
    } else {
        // 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)) {
            shardFailures.set(shardIndex, new ShardSearchFailure(t, shardTarget));
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:AbstractSearchAsyncAction.java

示例8: executeFetch

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
void executeFetch(final int shardIndex, final SearchShardTarget shardTarget, final AtomicInteger counter,
                  final ShardFetchSearchRequest fetchSearchRequest, DiscoveryNode node) {
    searchService.sendExecuteFetch(node, fetchSearchRequest, new ActionListener<FetchSearchResult>() {
        @Override
        public void onResponse(FetchSearchResult result) {
            result.shardTarget(shardTarget);
            fetchResults.set(shardIndex, result);
            if (counter.decrementAndGet() == 0) {
                finishHim();
            }
        }

        @Override
        public void onFailure(Throwable t) {
            // the search context might not be cleared on the node where the fetch was executed for example
            // because the action was rejected by the thread pool. in this case we need to send a dedicated
            // request to clear the search context. by setting docIdsToLoad to null, the context will be cleared
            // in TransportSearchTypeAction.releaseIrrelevantSearchContexts() after the search request is done.
            docIdsToLoad.set(shardIndex, null);
            onFetchFailure(t, fetchSearchRequest, shardIndex, shardTarget, counter);
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:SearchDfsQueryThenFetchAsyncAction.java

示例9: readFrom

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    shardTarget = new SearchShardTarget(in);
    queryResult = readQuerySearchResult(in);
    queryResult.shardTarget(shardTarget);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ScrollQuerySearchResult.java

示例10: readFrom

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    shardTarget = new SearchShardTarget(in);
    result = readQueryFetchSearchResult(in);
    result.shardTarget(shardTarget);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ScrollQueryFetchSearchResult.java

示例11: endSnapshot

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
/**
 * Finalizes the shard in repository and then removes it from cluster state
 * <p>
 * This is non-blocking method that runs on a thread from SNAPSHOT thread pool
 *
 * @param entry   snapshot
 * @param failure failure reason or null if snapshot was successful
 */
private void endSnapshot(final SnapshotsInProgress.Entry entry, final String failure) {
    threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(new Runnable() {
        @Override
        public void run() {
            final Snapshot snapshot = entry.snapshot();
            try {
                final Repository repository = repositoriesService.repository(snapshot.getRepository());
                logger.trace("[{}] finalizing snapshot in repository, state: [{}], failure[{}]", snapshot, entry.state(), failure);
                ArrayList<ShardSearchFailure> failures = new ArrayList<>();
                ArrayList<SnapshotShardFailure> shardFailures = new ArrayList<>();
                for (ObjectObjectCursor<ShardId, ShardSnapshotStatus> shardStatus : entry.shards()) {
                    ShardId shardId = shardStatus.key;
                    ShardSnapshotStatus status = shardStatus.value;
                    if (status.state().failed()) {
                        failures.add(new ShardSearchFailure(status.reason(), new SearchShardTarget(status.nodeId(), shardId)));
                        shardFailures.add(new SnapshotShardFailure(status.nodeId(), shardId, status.reason()));
                    }
                }
                SnapshotInfo snapshotInfo = repository.finalizeSnapshot(
                    snapshot.getSnapshotId(),
                    entry.indices(),
                    entry.startTime(),
                    failure,
                    entry.shards().size(),
                    Collections.unmodifiableList(shardFailures),
                    entry.getRepositoryStateId());
                removeSnapshotFromClusterState(snapshot, snapshotInfo, null);
            } catch (Exception e) {
                logger.warn((Supplier<?>) () -> new ParameterizedMessage("[{}] failed to finalize snapshot", snapshot), e);
                removeSnapshotFromClusterState(snapshot, null, e);
            }
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:43,代码来源:SnapshotsService.java

示例12: onShardFailure

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
public final void onShardFailure(final int shardIndex, @Nullable SearchShardTarget shardTarget, Exception e) {
    // we don't aggregate shard failures on non active shards (but do keep the header counts right)
    if (TransportActions.isShardNotAvailableException(e)) {
        return;
    }
    AtomicArray<ShardSearchFailure> shardFailures = this.shardFailures.get();
    // lazily create shard failures, so we can early build the empty shard failure list in most cases (no failures)
    if (shardFailures == null) { // this is double checked locking but it's fine since SetOnce uses a volatile read internally
        synchronized (shardFailuresMutex) {
            shardFailures = this.shardFailures.get(); // read again otherwise somebody else has created it?
            if (shardFailures == null) { // still null so we are the first and create a new instance
                shardFailures = new AtomicArray<>(getNumShards());
                this.shardFailures.set(shardFailures);
            }
        }
    }
    ShardSearchFailure failure = shardFailures.get(shardIndex);
    if (failure == null) {
        shardFailures.set(shardIndex, new ShardSearchFailure(e, shardTarget));
    } else {
        // 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)) {
            shardFailures.set(shardIndex, new ShardSearchFailure(e, shardTarget));
        }
    }

    if (results.hasResult(shardIndex)) {
        assert failure == null : "shard failed before but shouldn't: " + failure;
        successfulOps.decrementAndGet(); // if this shard was successful before (initial phase) we have to adjust the counter
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:AbstractSearchAsyncAction.java

示例13: executeFetch

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
private void executeFetch(final int shardIndex, final SearchShardTarget shardTarget,
                          final CountedCollector<FetchSearchResult> counter,
                          final ShardFetchSearchRequest fetchSearchRequest, final QuerySearchResult querySearchResult,
                          final Transport.Connection connection) {
    context.getSearchTransport().sendExecuteFetch(connection, fetchSearchRequest, context.getTask(),
        new ActionListener<FetchSearchResult>() {
            @Override
            public void onResponse(FetchSearchResult result) {
                counter.onResult(shardIndex, result, shardTarget);
            }

            @Override
            public void onFailure(Exception e) {
                try {
                    if (logger.isDebugEnabled()) {
                        logger.debug((Supplier<?>) () -> new ParameterizedMessage("[{}] Failed to execute fetch phase",
                            fetchSearchRequest.id()), e);
                    }
                    counter.onFailure(shardIndex, shardTarget, e);
                } finally {
                    // the search context might not be cleared on the node where the fetch was executed for example
                    // because the action was rejected by the thread pool. in this case we need to send a dedicated
                    // request to clear the search context.
                    releaseIrrelevantSearchContext(querySearchResult);
                }
            }
        });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:FetchSearchPhase.java

示例14: ShardSearchFailure

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
public ShardSearchFailure(Exception e, @Nullable SearchShardTarget shardTarget) {
    final Throwable actual = ExceptionsHelper.unwrapCause(e);
    if (actual != null && actual instanceof SearchException) {
        this.shardTarget = ((SearchException) actual).shard();
    } else if (shardTarget != null) {
        this.shardTarget = shardTarget;
    }
    status = ExceptionsHelper.status(actual);
    this.reason = ExceptionsHelper.detailedMessage(e);
    this.cause = actual;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ShardSearchFailure.java

示例15: readFrom

import org.elasticsearch.search.SearchShardTarget; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    if (in.readBoolean()) {
        shardTarget = new SearchShardTarget(in);
    }
    reason = in.readString();
    status = RestStatus.readFrom(in);
    cause = in.readException();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ShardSearchFailure.java


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