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

Java ClusterBlocks类代码示例

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

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



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

示例1: readFrom

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public static ClusterState readFrom(StreamInput in, DiscoveryNode localNode) throws IOException {
    ClusterName clusterName = new ClusterName(in);
    Builder builder = new Builder(clusterName);
    builder.version = in.readLong();
    builder.uuid = in.readString();
    builder.metaData = MetaData.readFrom(in);
    builder.routingTable = RoutingTable.readFrom(in);
    builder.nodes = DiscoveryNodes.readFrom(in, localNode);
    builder.blocks = new ClusterBlocks(in);
    int customSize = in.readVInt();
    for (int i = 0; i < customSize; i++) {
        Custom customIndexMetaData = in.readNamedWriteable(Custom.class);
        builder.putCustom(customIndexMetaData.getWriteableName(), customIndexMetaData);
    }
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:ClusterState.java


示例2: ClusterService

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public ClusterService(Settings settings,
                      ClusterSettings clusterSettings, ThreadPool threadPool, Supplier<DiscoveryNode> localNodeSupplier) {
    super(settings);
    this.localNodeSupplier = localNodeSupplier;
    this.operationRouting = new OperationRouting(settings, clusterSettings);
    this.threadPool = threadPool;
    this.clusterSettings = clusterSettings;
    this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
    // will be replaced on doStart.
    this.state = new AtomicReference<>(ClusterState.builder(clusterName).build());

    this.clusterSettings.addSettingsUpdateConsumer(CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING,
            this::setSlowTaskLoggingThreshold);

    this.slowTaskLoggingThreshold = CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings);

    localNodeMasterListeners = new LocalNodeMasterListeners(threadPool);

    initialBlocks = ClusterBlocks.builder();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ClusterService.java


示例3: testUnexpectedDiffPublishing

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public void testUnexpectedDiffPublishing() throws Exception {
    MockNode nodeA = createMockNode("nodeA", Settings.EMPTY, event -> {
        fail("Shouldn't send cluster state to myself");
    }).setAsMaster();

    MockNode nodeB = createMockNode("nodeB");

    // Initial cluster state with both states - the second node still shouldn't
    // get diff even though it's present in the previous cluster state
    DiscoveryNodes discoveryNodes = DiscoveryNodes.builder(nodeA.nodes()).add(nodeB.discoveryNode).build();
    ClusterState previousClusterState = ClusterState.builder(CLUSTER_NAME).nodes(discoveryNodes).build();
    ClusterState clusterState = ClusterState.builder(previousClusterState).incrementVersion().build();
    publishStateAndWait(nodeA.action, clusterState, previousClusterState);
    assertSameStateFromFull(nodeB.clusterState, clusterState);

    // cluster state update - add block
    previousClusterState = clusterState;
    clusterState = ClusterState.builder(clusterState).blocks(ClusterBlocks.builder()
        .addGlobalBlock(MetaData.CLUSTER_READ_ONLY_BLOCK)).incrementVersion().build();
    publishStateAndWait(nodeA.action, clusterState, previousClusterState);
    assertSameStateFromDiff(nodeB.clusterState, clusterState);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:PublishClusterStateActionTests.java


示例4: createClusterState

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
private ClusterState createClusterState(String name, int numShards, int numReplicas, Settings settings) {
    MetaData.Builder metaBuilder = MetaData.builder();
    IndexMetaData indexMetaData = IndexMetaData.builder(name).settings(settings(Version.CURRENT)
        .put(settings))
        .numberOfShards(numShards).numberOfReplicas(numReplicas).build();
    metaBuilder.put(indexMetaData, false);
    MetaData metaData = metaBuilder.build();
    RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
    routingTableBuilder.addAsNew(metaData.index(name));

    RoutingTable routingTable = routingTableBuilder.build();
    ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
        .getDefault(Settings.EMPTY))
        .metaData(metaData).routingTable(routingTable).blocks(ClusterBlocks.builder().addBlocks(indexMetaData)).build();
    return clusterState;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:MetaDataCreateIndexServiceTests.java


示例5: testGlobalBlock

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public void testGlobalBlock() {
    Request request = new Request();
    PlainActionFuture<Response> listener = new PlainActionFuture<>();
    ClusterBlocks.Builder block = ClusterBlocks.builder()
            .addGlobalBlock(new ClusterBlock(1, "", false, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL));
    setState(clusterService, ClusterState.builder(clusterService.state()).blocks(block));
    try {
        action.new AsyncSingleAction(request, listener).start();
        listener.get();
        fail("expected ClusterBlockException");
    } catch (Exception e) {
        if (ExceptionsHelper.unwrap(e, ClusterBlockException.class) == null) {
            logger.info("expected ClusterBlockException  but got ", e);
            fail("expected ClusterBlockException");
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:TransportInstanceSingleOperationActionTests.java


示例6: readFrom

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public ClusterState readFrom(StreamInput in, DiscoveryNode localNode) throws IOException {
    ClusterName clusterName = ClusterName.readClusterName(in);
    Builder builder = new Builder(clusterName);
    builder.version = in.readLong();
    builder.uuid = in.readString();
    builder.metaData = MetaData.Builder.readFrom(in);
    builder.routingTable = RoutingTable.Builder.readFrom(in);
    builder.nodes = DiscoveryNodes.Builder.readFrom(in, localNode);
    builder.blocks = ClusterBlocks.Builder.readClusterBlocks(in);
    int customSize = in.readVInt();
    for (int i = 0; i < customSize; i++) {
        String type = in.readString();
        Custom customIndexMetaData = lookupPrototypeSafe(type).readFrom(in);
        builder.putCustom(type, customIndexMetaData);
    }
    return builder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:ClusterState.java


示例7: addNewIndex

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
private void addNewIndex(ClusterState tribeState, ClusterBlocks.Builder blocks, MetaData.Builder metaData,
                         RoutingTable.Builder routingTable, IndexMetaData tribeIndex) {
    Settings tribeSettings = Settings.builder().put(tribeIndex.getSettings()).put(TRIBE_NAME_SETTING.getKey(), tribeName).build();
    metaData.put(IndexMetaData.builder(tribeIndex).settings(tribeSettings));
    routingTable.add(tribeState.routingTable().index(tribeIndex.getIndex()));
    if (Regex.simpleMatch(blockIndicesMetadata, tribeIndex.getIndex().getName())) {
        blocks.addIndexBlock(tribeIndex.getIndex().getName(), IndexMetaData.INDEX_METADATA_BLOCK);
    }
    if (Regex.simpleMatch(blockIndicesRead, tribeIndex.getIndex().getName())) {
        blocks.addIndexBlock(tribeIndex.getIndex().getName(), IndexMetaData.INDEX_READ_BLOCK);
    }
    if (Regex.simpleMatch(blockIndicesWrite, tribeIndex.getIndex().getName())) {
        blocks.addIndexBlock(tribeIndex.getIndex().getName(), IndexMetaData.INDEX_WRITE_BLOCK);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:TribeService.java


示例8: ClusterState

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public ClusterState(ClusterName clusterName, long version, String stateUUID, MetaData metaData, RoutingTable routingTable,
                    DiscoveryNodes nodes, ClusterBlocks blocks, ImmutableOpenMap<String, Custom> customs, boolean wasReadFromDiff) {
    this.version = version;
    this.stateUUID = stateUUID;
    this.clusterName = clusterName;
    this.metaData = metaData;
    this.routingTable = routingTable;
    this.nodes = nodes;
    this.blocks = blocks;
    this.customs = customs;
    this.wasReadFromDiff = wasReadFromDiff;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:ClusterState.java


示例9: ClusterStateDiff

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
ClusterStateDiff(StreamInput in, DiscoveryNode localNode) throws IOException {
    clusterName = new ClusterName(in);
    fromUuid = in.readString();
    toUuid = in.readString();
    toVersion = in.readLong();
    routingTable = RoutingTable.readDiffFrom(in);
    nodes = DiscoveryNodes.readDiffFrom(in, localNode);
    metaData = MetaData.readDiffFrom(in);
    blocks = ClusterBlocks.readDiffFrom(in);
    customs = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), CUSTOM_VALUE_SERIALIZER);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ClusterState.java


示例10: maybeUpdateClusterBlock

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
/**
 * Updates the cluster block only iff the setting exists in the given settings
 */
private static void maybeUpdateClusterBlock(String[] actualIndices, ClusterBlocks.Builder blocks, ClusterBlock block, Setting<Boolean> setting, Settings openSettings) {
    if (setting.exists(openSettings)) {
        final boolean updateReadBlock = setting.get(openSettings);
        for (String index : actualIndices) {
            if (updateReadBlock) {
                blocks.addIndexBlock(index, block);
            } else {
                blocks.removeIndexBlock(index, block);
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:MetaDataUpdateSettingsService.java


示例11: createTimedClusterService

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
TimedClusterService createTimedClusterService(boolean makeMaster) throws InterruptedException {
    TimedClusterService timedClusterService = new TimedClusterService(Settings.builder().put("cluster.name",
        "ClusterServiceTests").build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
        threadPool, () -> new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(),
        emptySet(), Version.CURRENT));
    timedClusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {
        @Override
        public void connectToNodes(DiscoveryNodes discoveryNodes) {
            // skip
        }

        @Override
        public void disconnectFromNodesExcept(DiscoveryNodes nodesToKeep) {
            // skip
        }
    });
    timedClusterService.setClusterStatePublisher((event, ackListener) -> {
    });
    timedClusterService.setDiscoverySettings(new DiscoverySettings(Settings.EMPTY,
        new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
    timedClusterService.start();
    ClusterState state = timedClusterService.state();
    final DiscoveryNodes nodes = state.nodes();
    final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(nodes)
        .masterNodeId(makeMaster ? nodes.getLocalNodeId() : null);
    state = ClusterState.builder(state).blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK)
        .nodes(nodesBuilder).build();
    setState(timedClusterService, state);
    return timedClusterService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:ClusterServiceTests.java


示例12: clusterState

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
private ClusterState clusterState(String index) {
    IndexMetaData indexMetaData = IndexMetaData.builder(index)
            .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random())))
            .numberOfShards(1)
            .numberOfReplicas(1)
            .build();
    return ClusterState.builder(ClusterName.DEFAULT)
            .metaData(MetaData.builder().put(indexMetaData, false))
            .routingTable(RoutingTable.builder().addAsNew(indexMetaData).build())
            .blocks(ClusterBlocks.builder().addBlocks(indexMetaData))
            .build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:MetaDataDeleteIndexServiceTests.java


示例13: createClusterState

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
private ClusterState createClusterState(String name, int numShards, int numReplicas, Settings settings) {
    MetaData.Builder metaBuilder = MetaData.builder();
    IndexMetaData indexMetaData = IndexMetaData.builder(name).settings(settings(Version.CURRENT)
        .put(settings))
        .numberOfShards(numShards).numberOfReplicas(numReplicas).build();
    metaBuilder.put(indexMetaData, false);
    MetaData metaData = metaBuilder.build();
    RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
    routingTableBuilder.addAsNew(metaData.index(name));

    RoutingTable routingTable = routingTableBuilder.build();
    ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
        .metaData(metaData).routingTable(routingTable).blocks(ClusterBlocks.builder().addBlocks(indexMetaData)).build();
    return clusterState;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:TransportShrinkActionTests.java


示例14: testGlobalBlock

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public void testGlobalBlock() {
    Request request = new Request(new String[]{TEST_INDEX});
    PlainActionFuture<Response> listener = new PlainActionFuture<>();

    ClusterBlocks.Builder block = ClusterBlocks.builder()
            .addGlobalBlock(new ClusterBlock(1, "test-block", false, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL));
    setState(clusterService, ClusterState.builder(clusterService.state()).blocks(block));
    try {
        action.new AsyncAction(null, request, listener).start();
        fail("expected ClusterBlockException");
    } catch (ClusterBlockException expected) {
        assertEquals("blocked by: [SERVICE_UNAVAILABLE/1/test-block];", expected.getMessage());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:TransportBroadcastByNodeActionTests.java


示例15: testRequestBlock

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public void testRequestBlock() {
    Request request = new Request(new String[]{TEST_INDEX});
    PlainActionFuture<Response> listener = new PlainActionFuture<>();

    ClusterBlocks.Builder block = ClusterBlocks.builder()
            .addIndexBlock(TEST_INDEX, new ClusterBlock(1, "test-block", false, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL));
    setState(clusterService, ClusterState.builder(clusterService.state()).blocks(block));
    try {
        action.new AsyncAction(null, request, listener).start();
        fail("expected ClusterBlockException");
    } catch (ClusterBlockException expected) {
        assertEquals("blocked by: [SERVICE_UNAVAILABLE/1/test-block];", expected.getMessage());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:TransportBroadcastByNodeActionTests.java


示例16: addNewIndex

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
private void addNewIndex(ClusterState tribeState, ClusterBlocks.Builder blocks, MetaData.Builder metaData, RoutingTable.Builder routingTable, IndexMetaData tribeIndex) {
    Settings tribeSettings = Settings.builder().put(tribeIndex.getSettings()).put(TRIBE_NAME, tribeName).build();
    metaData.put(IndexMetaData.builder(tribeIndex).settings(tribeSettings));
    routingTable.add(tribeState.routingTable().index(tribeIndex.getIndex()));
    if (Regex.simpleMatch(blockIndicesMetadata, tribeIndex.getIndex())) {
        blocks.addIndexBlock(tribeIndex.getIndex(), IndexMetaData.INDEX_METADATA_BLOCK);
    }
    if (Regex.simpleMatch(blockIndicesRead, tribeIndex.getIndex())) {
        blocks.addIndexBlock(tribeIndex.getIndex(), IndexMetaData.INDEX_READ_BLOCK);
    }
    if (Regex.simpleMatch(blockIndicesWrite, tribeIndex.getIndex())) {
        blocks.addIndexBlock(tribeIndex.getIndex(), IndexMetaData.INDEX_WRITE_BLOCK);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:TribeService.java


示例17: ClusterState

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
public ClusterState(ClusterName clusterName, long version, String stateUUID, MetaData metaData, RoutingTable routingTable, DiscoveryNodes nodes, ClusterBlocks blocks, ImmutableOpenMap<String, Custom> customs, boolean wasReadFromDiff) {
    this.version = version;
    this.stateUUID = stateUUID;
    this.clusterName = clusterName;
    this.metaData = metaData;
    this.routingTable = routingTable;
    this.nodes = nodes;
    this.blocks = blocks;
    this.customs = customs;
    this.status = ClusterStateStatus.UNKNOWN;
    this.wasReadFromDiff = wasReadFromDiff;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:ClusterState.java


示例18: InternalClusterService

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
@Inject
public InternalClusterService(Settings settings, DiscoveryService discoveryService, OperationRouting operationRouting, TransportService transportService,
                              NodeSettingsService nodeSettingsService, ThreadPool threadPool, ClusterName clusterName, DiscoveryNodeService discoveryNodeService, Version version) {
    super(settings);
    this.operationRouting = operationRouting;
    this.transportService = transportService;
    this.discoveryService = discoveryService;
    this.threadPool = threadPool;
    this.nodeSettingsService = nodeSettingsService;
    this.discoveryNodeService = discoveryNodeService;
    this.version = version;

    // will be replaced on doStart.
    this.clusterState = ClusterState.builder(clusterName).build();

    this.nodeSettingsService.setClusterService(this);
    this.nodeSettingsService.addListener(new ApplySettings());

    this.reconnectInterval = this.settings.getAsTime(SETTING_CLUSTER_SERVICE_RECONNECT_INTERVAL, TimeValue.timeValueSeconds(10));

    this.slowTaskLoggingThreshold = this.settings.getAsTime(SETTING_CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD, TimeValue.timeValueSeconds(30));

    localNodeMasterListeners = new LocalNodeMasterListeners(threadPool);

    initialBlocks = ClusterBlocks.builder().addGlobalBlock(discoveryService.getNoMasterBlock());

    taskManager = transportService.getTaskManager();

    this.auditService = new AuditService(nodeSettingsService);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:InternalClusterService.java


示例19: StubClusterHealthResponse

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
private StubClusterHealthResponse(ClusterHealthStatus status) {
	super("test-cluster", new String[0],
			new ClusterState(null, 0, null, null, RoutingTable.builder().build(),
					DiscoveryNodes.builder().build(),
					ClusterBlocks.builder().build(), null, false));
	this.status = status;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ElasticsearchHealthIndicatorTests.java


示例20: StubClusterHealthResponse

import org.elasticsearch.cluster.block.ClusterBlocks; //导入依赖的package包/类
private StubClusterHealthResponse(ClusterHealthStatus status) {
	super("test-cluster", new String[0],
			new ClusterState(null, 0, null, RoutingTable.builder().build(),
					DiscoveryNodes.builder().build(),
					ClusterBlocks.builder().build(), null));
	this.status = status;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:8,代码来源:ElasticsearchHealthIndicatorTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java XdmNodeKind类代码示例发布时间:2022-05-23
下一篇:
Java TextInputCell类代码示例发布时间: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