• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClusterBlockLevel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: doExecute

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected void doExecute(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener) {
    ClusterState clusterState = clusterService.state();
    clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.READ);

    int maxConcurrentSearches = request.maxConcurrentSearchRequests();
    if (maxConcurrentSearches == 0) {
        maxConcurrentSearches = defaultMaxConcurrentSearches(availableProcessors, clusterState);
    }

    Queue<SearchRequestSlot> searchRequestSlots = new ConcurrentLinkedQueue<>();
    for (int i = 0; i < request.requests().size(); i++) {
        SearchRequest searchRequest = request.requests().get(i);
        searchRequestSlots.add(new SearchRequestSlot(searchRequest, i));
    }

    int numRequests = request.requests().size();
    final AtomicArray<MultiSearchResponse.Item> responses = new AtomicArray<>(numRequests);
    final AtomicInteger responseCounter = new AtomicInteger(numRequests);
    int numConcurrentSearches = Math.min(numRequests, maxConcurrentSearches);
    for (int i = 0; i < numConcurrentSearches; i++) {
        executeSearch(searchRequestSlots, responses, responseCounter, listener);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:TransportMultiSearchAction.java


示例2: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(IndicesAliasesRequest request, ClusterState state) {
    Set<String> indices = new HashSet<>();
    for (AliasActions aliasAction : request.aliasActions()) {
        for (String index : aliasAction.indices()) {
            indices.add(index);
        }
    }
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indices.toArray(new String[indices.size()]));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:TransportIndicesAliasesAction.java


示例3: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(PutMappingRequest request, ClusterState state) {
    String[] indices;
    if (request.getConcreteIndex() == null) {
        indices = indexNameExpressionResolver.concreteIndexNames(state, request);
    } else {
        indices = new String[] {request.getConcreteIndex().getName()};
    }
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indices);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:TransportPutMappingAction.java


示例4: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(RolloverRequest request, ClusterState state) {
    IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true,
        request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed());
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE,
        indexNameExpressionResolver.concreteIndexNames(state, indicesOptions, request.indices()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TransportRolloverAction.java


示例5: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(RestoreSnapshotRequest request, ClusterState state) {
    // Restoring a snapshot might change the global state and create/change an index,
    // so we need to check for METADATA_WRITE and WRITE blocks
    ClusterBlockException blockException = state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
    if (blockException != null) {
        return blockException;
    }
    return state.blocks().globalBlockedException(ClusterBlockLevel.WRITE);

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:TransportRestoreSnapshotAction.java


示例6: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(CreateSnapshotRequest request, ClusterState state) {
    // We are reading the cluster metadata and indices - so we need to check both blocks
    ClusterBlockException clusterBlockException = state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
    if (clusterBlockException != null) {
        return clusterBlockException;
    }
    return state.blocks().indicesBlockedException(ClusterBlockLevel.READ, indexNameExpressionResolver.concreteIndexNames(state, request));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:TransportCreateSnapshotAction.java


示例7: globalBlockLevel

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
/**
 * Cluster level block to check before request execution. Returning null means that no blocks need to be checked.
 */
@Nullable
protected ClusterBlockLevel globalBlockLevel() {
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TransportReplicationAction.java


示例8: handleBlockExceptions

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
private boolean handleBlockExceptions(ClusterState state) {
    ClusterBlockException blockException = state.blocks().globalBlockedException(ClusterBlockLevel.WRITE);
    if (blockException != null) {
        if (blockException.retryable()) {
            logger.trace("cluster is blocked, scheduling a retry", blockException);
            retry(blockException);
        } else {
            onFailure(blockException);
        }
        return true;
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:TransportBulkAction.java


示例9: doExecute

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected void doExecute(final MultiSearchRequest request, final ActionListener<MultiSearchResponse> listener) {
    ClusterState clusterState = clusterService.state();
    clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.READ);

    final AtomicArray<MultiSearchResponse.Item> responses = new AtomicArray<>(request.requests().size());
    final AtomicInteger counter = new AtomicInteger(responses.length());
    for (int i = 0; i < responses.length(); i++) {
        final int index = i;
        SearchRequest searchRequest = new SearchRequest(request.requests().get(i), request);
        searchAction.execute(searchRequest, new ActionListener<SearchResponse>() {
            @Override
            public void onResponse(SearchResponse searchResponse) {
                responses.set(index, new MultiSearchResponse.Item(searchResponse, null));
                if (counter.decrementAndGet() == 0) {
                    finishHim();
                }
            }

            @Override
            public void onFailure(Throwable e) {
                responses.set(index, new MultiSearchResponse.Item(null, e));
                if (counter.decrementAndGet() == 0) {
                    finishHim();
                }
            }

            private void finishHim() {
                listener.onResponse(new MultiSearchResponse(responses.toArray(new MultiSearchResponse.Item[responses.length()])));
            }
        });
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:34,代码来源:TransportMultiSearchAction.java


示例10: testClosedIndexOnReroute

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
public void testClosedIndexOnReroute() throws InterruptedException {
    final String index = "test";
    // no replicas in oder to skip the replication part
    setState(clusterService, new ClusterStateChanges(xContentRegistry(), threadPool).closeIndices(state(index, true,
        ShardRoutingState.UNASSIGNED), new CloseIndexRequest(index)));
    logger.debug("--> using initial state:\n{}", clusterService.state());
    Request request = new Request(new ShardId("test", "_na_", 0)).timeout("1ms");
    PlainActionFuture<TestResponse> listener = new PlainActionFuture<>();
    ReplicationTask task = maybeTask();

    ClusterBlockLevel indexBlockLevel = randomBoolean() ? ClusterBlockLevel.WRITE : null;
    TestAction action = new TestAction(Settings.EMPTY, "testActionWithBlocks", transportService,
            clusterService, shardStateAction, threadPool) {
        @Override
        protected ClusterBlockLevel indexBlockLevel() {
            return indexBlockLevel;
        }
    };
    TestAction.ReroutePhase reroutePhase = action.new ReroutePhase(task, request, listener);
    reroutePhase.run();
    if (indexBlockLevel == ClusterBlockLevel.WRITE) {
        assertListenerThrows("must throw block exception", listener, ClusterBlockException.class);
    } else {
        assertListenerThrows("must throw index closed exception", listener, IndexClosedException.class);
    }
    assertPhase(task, "failed");
    assertFalse(request.isRetrySet.get());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:TransportReplicationActionTests.java


示例11: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(IndicesAliasesRequest request, ClusterState state) {
    Set<String> indices = Sets.newHashSet();
    for (AliasActions aliasAction : request.aliasActions()) {
        for (String index : aliasAction.indices()) {
            indices.add(index);
        }
    }
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indices.toArray(new String[indices.size()]));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:TransportIndicesAliasesAction.java


示例12: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(CreateSnapshotRequest request, ClusterState state) {
    // We are reading the cluster metadata and indices - so we need to check both blocks
    ClusterBlockException clusterBlockException = state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
    if (clusterBlockException != null) {
        return clusterBlockException;
    }
    return state.blocks().indicesBlockedException(ClusterBlockLevel.READ, indexNameExpressionResolver.concreteIndices(state, request));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:TransportCreateSnapshotAction.java


示例13: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) {
    //make sure through indices options that the concrete indices call never throws IndexMissingException
    IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true, request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed());
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndexNames(state, indicesOptions, request.indices()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:TransportIndicesExistsAction.java


示例14: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(TypesExistsRequest request, ClusterState state) {
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndexNames(state, request));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TransportTypesExistsAction.java


示例15: checkBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndexNames(state, request));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TransportAliasesExistAction.java


示例16: checkRequestBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkRequestBlock(ClusterState state, IndicesStatsRequest request, String[] concreteIndices) {
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, concreteIndices);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:TransportIndicesStatsAction.java


示例17: indexBlockLevel

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockLevel indexBlockLevel() {
    return ClusterBlockLevel.METADATA_WRITE;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:TransportShardRefreshAction.java


示例18: checkRequestBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkRequestBlock(ClusterState state, ForceMergeRequest request, String[] concreteIndices) {
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TransportForceMergeAction.java


示例19: checkRequestBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkRequestBlock(ClusterState state, InternalRequest request) {
    return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_READ, request.concreteIndex());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TransportGetFieldMappingsIndexAction.java


示例20: checkRequestBlock

import org.elasticsearch.cluster.block.ClusterBlockLevel; //导入依赖的package包/类
@Override
protected ClusterBlockException checkRequestBlock(ClusterState state, FieldStatsRequest request, String[] concreteIndices) {
    return state.blocks().indicesBlockedException(ClusterBlockLevel.READ, concreteIndices);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:TransportFieldStatsTransportAction.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReceivePack类代码示例发布时间:2022-05-23
下一篇:
Java MutationProto类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap