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

Java AllocationService类代码示例

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

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



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

示例1: configure

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Override
protected void configure() {
    bind(GatewayAllocator.class).asEagerSingleton();
    bind(AllocationService.class).asEagerSingleton();
    bind(ClusterService.class).toInstance(clusterService);
    bind(NodeConnectionsService.class).asEagerSingleton();
    bind(MetaDataCreateIndexService.class).asEagerSingleton();
    bind(MetaDataDeleteIndexService.class).asEagerSingleton();
    bind(MetaDataIndexStateService.class).asEagerSingleton();
    bind(MetaDataMappingService.class).asEagerSingleton();
    bind(MetaDataIndexAliasesService.class).asEagerSingleton();
    bind(MetaDataUpdateSettingsService.class).asEagerSingleton();
    bind(MetaDataIndexTemplateService.class).asEagerSingleton();
    bind(IndexNameExpressionResolver.class).toInstance(indexNameExpressionResolver);
    bind(RoutingService.class).asEagerSingleton();
    bind(DelayedAllocationService.class).asEagerSingleton();
    bind(ShardStateAction.class).asEagerSingleton();
    bind(NodeMappingRefreshAction.class).asEagerSingleton();
    bind(MappingUpdatedAction.class).asEagerSingleton();
    bind(TaskResultsService.class).asEagerSingleton();
    bind(AllocationDeciders.class).toInstance(new AllocationDeciders(settings, allocationDeciders));
    bind(ShardsAllocator.class).toInstance(shardsAllocator);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ClusterModule.java


示例2: MetaDataCreateIndexService

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public MetaDataCreateIndexService(Settings settings, ClusterService clusterService,
                                  IndicesService indicesService, AllocationService allocationService,
                                  AliasValidator aliasValidator, Environment env,
                                  IndexScopedSettings indexScopedSettings, ThreadPool threadPool,
                                  NamedXContentRegistry xContentRegistry) {
    super(settings);
    this.clusterService = clusterService;
    this.indicesService = indicesService;
    this.allocationService = allocationService;
    this.aliasValidator = aliasValidator;
    this.env = env;
    this.indexScopedSettings = indexScopedSettings;
    this.activeShardsObserver = new ActiveShardsObserver(settings, clusterService, threadPool);
    this.threadPool = threadPool;
    this.xContentRegistry = xContentRegistry;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:MetaDataCreateIndexService.java


示例3: testClusterStateSerialization

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
public void testClusterStateSerialization() throws Exception {
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
            .build();

    RoutingTable routingTable = RoutingTable.builder()
            .addAsNew(metaData.index("test"))
            .build();

    DiscoveryNodes nodes = DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")).add(newNode("node3")).localNodeId("node1").masterNodeId("node2").build();

    ClusterState clusterState = ClusterState.builder(new ClusterName("clusterName1")).nodes(nodes).metaData(metaData).routingTable(routingTable).build();

    AllocationService strategy = createAllocationService();
    clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build();

    ClusterState serializedClusterState = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), newNode("node1"),
        new NamedWriteableRegistry(ClusterModule.getNamedWriteables()));

    assertThat(serializedClusterState.getClusterName().value(), equalTo(clusterState.getClusterName().value()));

    assertThat(serializedClusterState.routingTable().toString(), equalTo(clusterState.routingTable().toString()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ClusterSerializationTests.java


示例4: testRoutingTableSerialization

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
public void testRoutingTableSerialization() throws Exception {
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
            .build();

    RoutingTable routingTable = RoutingTable.builder()
            .addAsNew(metaData.index("test"))
            .build();

    DiscoveryNodes nodes = DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")).add(newNode("node3")).build();

    ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes)
        .metaData(metaData).routingTable(routingTable).build();

    AllocationService strategy = createAllocationService();
    RoutingTable source = strategy.reroute(clusterState, "reroute").routingTable();

    BytesStreamOutput outStream = new BytesStreamOutput();
    source.writeTo(outStream);
    StreamInput inStream = outStream.bytes().streamInput();
    RoutingTable target = RoutingTable.readFrom(inStream);

    assertThat(target.toString(), equalTo(source.toString()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ClusterSerializationTests.java


示例5: testClusterStateSerialization

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
public void testClusterStateSerialization() throws Exception {
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder("test_idx").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
            .put(IndexTemplateMetaData.builder("test_template").build())
            .build();

    RoutingTable routingTable = RoutingTable.builder()
            .addAsNew(metaData.index("test_idx"))
            .build();

    DiscoveryNodes nodes = DiscoveryNodes.builder().add(new DiscoveryNode("node_foo", buildNewFakeTransportAddress(),
            emptyMap(), emptySet(), Version.CURRENT)).localNodeId("node_foo").masterNodeId("node_foo").build();

    ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes)
        .metaData(metaData).routingTable(routingTable).build();

    AllocationService strategy = createAllocationService();
    clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build();

    String clusterStateString = Strings.toString(clusterState);
    assertNotNull(clusterStateString);

    assertThat(clusterStateString, containsString("test_idx"));
    assertThat(clusterStateString, containsString("test_template"));
    assertThat(clusterStateString, containsString("node_foo"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ClusterStateToStringTests.java


示例6: testNodeLeave

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
/**
 * Tests that during reroute when a node is detected as leaving the cluster, the right unassigned meta is set
 */
public void testNodeLeave() {
    AllocationService allocation = createAllocationService();
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
            .build();
    ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
            .metaData(metaData)
            .routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2"))).build();
    clusterState = allocation.reroute(clusterState, "reroute");
    // starting primaries
    clusterState = allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    // starting replicas
    clusterState = allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(false));
    // remove node2 and reroute
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
    clusterState = allocation.deassociateDeadNodes(clusterState, true, "reroute");
    // verify that NODE_LEAVE is the reason for meta
    assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(true));
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(1));
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo(), notNullValue());
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getReason(), equalTo(UnassignedInfo.Reason.NODE_LEFT));
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getUnassignedTimeInMillis(), greaterThan(0L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:UnassignedInfoTests.java


示例7: createInitialClusterState

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
private ClusterState createInitialClusterState(AllocationService service) {
    MetaData.Builder metaBuilder = MetaData.builder();
    metaBuilder.put(IndexMetaData.builder("idx").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0));
    MetaData metaData = metaBuilder.build();
    RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
    routingTableBuilder.addAsNew(metaData.index("idx"));

    RoutingTable routingTable = routingTableBuilder.build();
    ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
        .getDefault(Settings.EMPTY))
        .metaData(metaData).routingTable(routingTable).build();
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")))
        .build();
    RoutingTable prevRoutingTable = routingTable;
    routingTable = service.reroute(clusterState, "reroute").routingTable();
    clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();

    assertEquals(prevRoutingTable.index("idx").shards().size(), 1);
    assertEquals(prevRoutingTable.index("idx").shard(0).shards().get(0).state(), UNASSIGNED);

    assertEquals(routingTable.index("idx").shards().size(), 1);
    assertEquals(routingTable.index("idx").shard(0).shards().get(0).state(), INITIALIZING);
    return clusterState;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ClusterRerouteTests.java


示例8: startRandomInitializingShard

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
protected  static ClusterState startRandomInitializingShard(ClusterState clusterState, AllocationService strategy) {
    List<ShardRouting> initializingShards = clusterState.getRoutingNodes().shardsWithState(INITIALIZING);
    if (initializingShards.isEmpty()) {
        return clusterState;
    }
    return strategy.applyStartedShards(clusterState,
        arrayAsArrayList(initializingShards.get(randomInt(initializingShards.size() - 1))));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:ESAllocationTestCase.java


示例9: applyStartedShardsUntilNoChange

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
protected ClusterState applyStartedShardsUntilNoChange(ClusterState clusterState, AllocationService service) {
    ClusterState lastClusterState;
    do {
        lastClusterState = clusterState;
        logger.debug("ClusterState: {}", clusterState.getRoutingNodes());
        clusterState = service.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    } while (lastClusterState.equals(clusterState) == false);
    return clusterState;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ESAllocationTestCase.java


示例10: NodeJoinController

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
public NodeJoinController(ClusterService clusterService, AllocationService allocationService, ElectMasterService electMaster,
                          Settings settings) {
    super(settings);
    this.clusterService = clusterService;
    this.allocationService = allocationService;
    this.electMaster = electMaster;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:NodeJoinController.java


示例11: NodeRemovalClusterStateTaskExecutor

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
NodeRemovalClusterStateTaskExecutor(
        final AllocationService allocationService,
        final ElectMasterService electMasterService,
        final Consumer<String> rejoin,
        final Logger logger) {
    this.allocationService = allocationService;
    this.electMasterService = electMasterService;
    this.rejoin = rejoin;
    this.logger = logger;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ZenDiscovery.java


示例12: GatewayService

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public GatewayService(Settings settings, AllocationService allocationService, ClusterService clusterService,
                      ThreadPool threadPool, GatewayMetaState metaState,
                      TransportNodesListGatewayMetaState listGatewayMetaState, Discovery discovery,
                      IndicesService indicesService) {
    super(settings);
    this.gateway = new Gateway(settings, clusterService, metaState, listGatewayMetaState, discovery,
        indicesService);
    this.allocationService = allocationService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    // allow to control a delay of when indices will get created
    this.expectedNodes = EXPECTED_NODES_SETTING.get(this.settings);
    this.expectedDataNodes = EXPECTED_DATA_NODES_SETTING.get(this.settings);
    this.expectedMasterNodes = EXPECTED_MASTER_NODES_SETTING.get(this.settings);

    if (RECOVER_AFTER_TIME_SETTING.exists(this.settings)) {
        recoverAfterTime = RECOVER_AFTER_TIME_SETTING.get(this.settings);
    } else if (expectedNodes >= 0 || expectedDataNodes >= 0 || expectedMasterNodes >= 0) {
        recoverAfterTime = DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET;
    } else {
        recoverAfterTime = null;
    }
    this.recoverAfterNodes = RECOVER_AFTER_NODES_SETTING.get(this.settings);
    this.recoverAfterDataNodes = RECOVER_AFTER_DATA_NODES_SETTING.get(this.settings);
    // default the recover after master nodes to the minimum master nodes in the discovery
    if (RECOVER_AFTER_MASTER_NODES_SETTING.exists(this.settings)) {
        recoverAfterMasterNodes = RECOVER_AFTER_MASTER_NODES_SETTING.get(this.settings);
    } else {
        // TODO: change me once the minimum_master_nodes is changed too
        recoverAfterMasterNodes = settings.getAsInt("discovery.zen.minimum_master_nodes", -1);
    }

    // Add the not recovered as initial state block, we don't allow anything until
    this.clusterService.addInitialStateBlock(STATE_NOT_RECOVERED_BLOCK);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:GatewayService.java


示例13: LocalAllocateDangledIndices

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public LocalAllocateDangledIndices(Settings settings, TransportService transportService, ClusterService clusterService,
                                   AllocationService allocationService, MetaDataIndexUpgradeService metaDataIndexUpgradeService) {
    super(settings);
    this.transportService = transportService;
    this.clusterService = clusterService;
    this.allocationService = allocationService;
    this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
    transportService.registerRequestHandler(ACTION_NAME, AllocateDangledRequest::new, ThreadPool.Names.SAME, new AllocateDangledRequestHandler());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:LocalAllocateDangledIndices.java


示例14: DelayedAllocationService

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public DelayedAllocationService(Settings settings, ThreadPool threadPool, ClusterService clusterService,
                                AllocationService allocationService) {
    super(settings);
    this.threadPool = threadPool;
    this.clusterService = clusterService;
    this.allocationService = allocationService;
    clusterService.addListener(this);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:DelayedAllocationService.java


示例15: MetaDataUpdateSettingsService

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public MetaDataUpdateSettingsService(Settings settings, ClusterService clusterService, AllocationService allocationService,
                                     IndexScopedSettings indexScopedSettings, IndicesService indicesService, ThreadPool threadPool) {
    super(settings);
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.clusterService.addListener(this);
    this.allocationService = allocationService;
    this.indexScopedSettings = indexScopedSettings;
    this.indicesService = indicesService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:MetaDataUpdateSettingsService.java


示例16: MetaDataIndexStateService

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public MetaDataIndexStateService(Settings settings, ClusterService clusterService, AllocationService allocationService,
                                 MetaDataIndexUpgradeService metaDataIndexUpgradeService,
                                 IndicesService indicesService) {
    super(settings);
    this.indicesService = indicesService;
    this.clusterService = clusterService;
    this.allocationService = allocationService;
    this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:MetaDataIndexStateService.java


示例17: ShardStateAction

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public ShardStateAction(Settings settings, ClusterService clusterService, TransportService transportService,
                        AllocationService allocationService, RoutingService routingService, ThreadPool threadPool) {
    super(settings);
    this.transportService = transportService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;

    transportService.registerRequestHandler(SHARD_STARTED_ACTION_NAME, ShardEntry::new, ThreadPool.Names.SAME, new ShardStartedTransportHandler(clusterService, new ShardStartedClusterStateTaskExecutor(allocationService, logger), logger));
    transportService.registerRequestHandler(SHARD_FAILED_ACTION_NAME, ShardEntry::new, ThreadPool.Names.SAME, new ShardFailedTransportHandler(clusterService, new ShardFailedClusterStateTaskExecutor(allocationService, routingService, logger), logger));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ShardStateAction.java


示例18: RestoreService

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Inject
public RestoreService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService,
                      AllocationService allocationService, MetaDataCreateIndexService createIndexService,
                      MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings) {
    super(settings);
    this.clusterService = clusterService;
    this.repositoriesService = repositoriesService;
    this.allocationService = allocationService;
    this.createIndexService = createIndexService;
    this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
    clusterService.addStateApplier(this);
    this.clusterSettings = clusterSettings;
    this.cleanRestoreStateTaskExecutor = new CleanRestoreStateTaskExecutor(logger);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:RestoreService.java


示例19: ClusterRerouteResponseAckedClusterStateUpdateTask

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
ClusterRerouteResponseAckedClusterStateUpdateTask(Logger logger, AllocationService allocationService, ClusterRerouteRequest request,
                                                  ActionListener<ClusterRerouteResponse> listener) {
    super(Priority.IMMEDIATE, request, listener);
    this.request = request;
    this.listener = listener;
    this.logger = logger;
    this.allocationService = allocationService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportClusterRerouteAction.java


示例20: execute

import org.elasticsearch.cluster.routing.allocation.AllocationService; //导入依赖的package包/类
@Override
public ClusterState execute(ClusterState currentState) {
    AllocationService.CommandsResult commandsResult =
        allocationService.reroute(currentState, request.getCommands(), request.explain(), request.isRetryFailed());
    clusterStateToSend = commandsResult.getClusterState();
    explanations = commandsResult.explanations();
    if (request.dryRun()) {
        return currentState;
    }
    return commandsResult.getClusterState();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:TransportClusterRerouteAction.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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