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


Java ClusterService.addListener方法代码示例

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


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

示例1: IndicesStore

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的package包/类
@Inject
public IndicesStore(Settings settings, IndicesService indicesService,
                    ClusterService clusterService, TransportService transportService, ThreadPool threadPool) {
    super(settings);
    this.indicesService = indicesService;
    this.clusterService = clusterService;
    this.transportService = transportService;
    this.threadPool = threadPool;
    transportService.registerRequestHandler(ACTION_SHARD_EXISTS, ShardActiveRequest::new, ThreadPool.Names.SAME, new ShardActiveRequestHandler());
    this.deleteShardTimeout = INDICES_STORE_DELETE_SHARD_TIMEOUT.get(settings);
    // Doesn't make sense to delete shards on non-data nodes
    if (DiscoveryNode.isDataNode(settings)) {
        // we double check nothing has changed when responses come back from other nodes.
        // it's easier to do that check when the current cluster state is visible.
        // also it's good in general to let things settle down
        clusterService.addListener(this);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:IndicesStore.java

示例2: DanglingIndicesState

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的package包/类
@Inject
public DanglingIndicesState(Settings settings, NodeEnvironment nodeEnv, MetaStateService metaStateService,
                            LocalAllocateDangledIndices allocateDangledIndices, ClusterService clusterService) {
    super(settings);
    this.nodeEnv = nodeEnv;
    this.metaStateService = metaStateService;
    this.allocateDangledIndices = allocateDangledIndices;
    clusterService.addListener(this);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:DanglingIndicesState.java

示例3: DelayedAllocationService

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的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

示例4: testBatchingShardUpdateTask

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的package包/类
public void testBatchingShardUpdateTask() throws Exception {
    final Client client = client();

    logger.info("-->  creating repository");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder()
                    .put("location", randomRepoPath())
                    .put("compress", randomBoolean())
                    .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)));

    assertAcked(prepareCreate("test-idx", 0, Settings.builder().put("number_of_shards", between(1, 10))
            .put("number_of_replicas", 0)));
    ensureGreen();

    logger.info("--> indexing some data");
    final int numdocs = randomIntBetween(10, 100);
    IndexRequestBuilder[] builders = new IndexRequestBuilder[numdocs];
    for (int i = 0; i < builders.length; i++) {
        builders[i] = client().prepareIndex("test-idx", "type1", Integer.toString(i)).setSource("field1", "bar " + i);
    }
    indexRandom(true, builders);
    flushAndRefresh();

    final int numberOfShards = getNumShards("test-idx").numPrimaries;
    logger.info("number of shards: {}", numberOfShards);

    final ClusterService clusterService = internalCluster().clusterService(internalCluster().getMasterName());
    BlockingClusterStateListener snapshotListener = new BlockingClusterStateListener(clusterService, "update_snapshot [", "update snapshot state", Priority.HIGH);
    try {
        clusterService.addListener(snapshotListener);
        logger.info("--> snapshot");
        ListenableActionFuture<CreateSnapshotResponse> snapshotFuture = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").execute();

        // Await until shard updates are in pending state.
        assertBusyPendingTasks("update snapshot state", numberOfShards);
        snapshotListener.unblock();

        // Check that the snapshot was successful
        CreateSnapshotResponse createSnapshotResponse = snapshotFuture.actionGet();
        assertEquals(SnapshotState.SUCCESS, createSnapshotResponse.getSnapshotInfo().state());
        assertEquals(numberOfShards, createSnapshotResponse.getSnapshotInfo().totalShards());
        assertEquals(numberOfShards, createSnapshotResponse.getSnapshotInfo().successfulShards());

    } finally {
        clusterService.removeListener(snapshotListener);
    }

    // Check that we didn't timeout
    assertFalse(snapshotListener.timedOut());
    // Check that cluster state update task was called only once
    assertEquals(1, snapshotListener.count());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:53,代码来源:SharedClusterSnapshotRestoreIT.java


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