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

Java ClusterStateListener类代码示例

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

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



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

示例1: setReallocation

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
public void setReallocation(final ClusterService clusterService, final RoutingService routingService) {
    this.routingService = routingService;
    clusterService.add(new ClusterStateListener() {
        @Override
        public void clusterChanged(ClusterChangedEvent event) {
            boolean cleanCache = false;
            DiscoveryNode localNode = event.state().nodes().localNode();
            if (localNode != null) {
                if (localNode.masterNode() == true && event.localNodeMaster() == false) {
                    cleanCache = true;
                }
            } else {
                cleanCache = true;
            }
            if (cleanCache) {
                Releasables.close(asyncFetchStarted.values());
                asyncFetchStarted.clear();
                Releasables.close(asyncFetchStore.values());
                asyncFetchStore.clear();
            }
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:GatewayAllocator.java


示例2: MockNode

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
public MockNode(DiscoveryNode discoveryNode, MockTransportService service,
                @Nullable ClusterStateListener listener, Logger logger) {
    this.discoveryNode = discoveryNode;
    this.service = service;
    this.listener = listener;
    this.logger = logger;
    this.clusterState = ClusterState.builder(CLUSTER_NAME).nodes(DiscoveryNodes.builder()
        .add(discoveryNode).localNodeId(discoveryNode.getId()).build()).build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:PublishClusterStateActionTests.java


示例3: DecommissioningService

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Inject
public DecommissioningService(Settings settings,
                              final ClusterService clusterService,
                              NodeSettingsService nodeSettingsService,
                              TransportSQLAction sqlAction,
                              TransportSQLBulkAction sqlBulkAction,
                              final TransportClusterHealthAction healthAction,
                              final TransportClusterUpdateSettingsAction updateSettingsAction) {
    super(settings);
    this.clusterService = clusterService;
    this.sqlAction = sqlAction;
    this.sqlBulkAction = sqlBulkAction;
    this.healthAction = healthAction;
    this.updateSettingsAction = updateSettingsAction;

    ApplySettings applySettings = new ApplySettings();
    applySettings.onRefreshSettings(settings);
    nodeSettingsService.addListener(applySettings);

    clusterService.add(new ClusterStateListener() {
        @Override
        public void clusterChanged(ClusterChangedEvent event) {
            removeRemovedNodes(event);
        }
    });
    try {
        Signal signal = new Signal("USR2");
        Signal.handle(signal, this);
    } catch (IllegalArgumentException e) {
        logger.warn("SIGUSR2 signal not supported on {}.", System.getProperty("os.name"), e);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:DecommissioningService.java


示例4: remove

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Override
public void remove(ClusterStateListener listener) {
    clusterStateListeners.remove(listener);
    priorityClusterStateListeners.remove(listener);
    lastClusterStateListeners.remove(listener);
    postAppliedListeners.remove(listener);
    for (Iterator<NotifyTimeout> it = onGoingTimeouts.iterator(); it.hasNext(); ) {
        NotifyTimeout timeout = it.next();
        if (timeout.listener.equals(listener)) {
            timeout.cancel();
            it.remove();
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:InternalClusterService.java


示例5: doStart

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Override
protected void doStart() throws ElasticsearchException {
    logger.info("Starting EventHookService");

    clusterService.add((ClusterStateListener) this);
    clusterService.add((LocalNodeMasterListener) this);
}
 
开发者ID:codelibs,项目名称:elasticsearch-eventhook,代码行数:8,代码来源:EventHookService.java


示例6: doStop

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Override
protected void doStop() throws ElasticsearchException {
    logger.info("Stopping EventHookService");

    clusterService.remove((LocalNodeMasterListener) this);
    clusterService.remove((ClusterStateListener) this);
}
 
开发者ID:codelibs,项目名称:elasticsearch-eventhook,代码行数:8,代码来源:EventHookService.java


示例7: addListener

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
/**
 * Add a listener for updated cluster states
 */
public void addListener(ClusterStateListener listener) {
    clusterStateListeners.add(listener);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:ClusterService.java


示例8: removeListener

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
/**
 * Removes a listener for updated cluster states.
 */
public void removeListener(ClusterStateListener listener) {
    clusterStateListeners.remove(listener);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:ClusterService.java


示例9: createMockNode

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
public MockNode createMockNode(String name, final Settings basSettings, @Nullable ClusterStateListener listener) throws Exception {
    return createMockNode(name, basSettings, listener, threadPool, logger, nodes);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:PublishClusterStateActionTests.java


示例10: testSerializationFailureDuringDiffPublishing

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
public void testSerializationFailureDuringDiffPublishing() throws Exception {
    MockNode nodeA = createMockNode("nodeA", Settings.EMPTY, new ClusterStateListener() {
        @Override
        public void clusterChanged(ClusterChangedEvent 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();

    ClusterState unserializableClusterState = new ClusterState(clusterState.version(), clusterState.stateUUID(), clusterState) {
        @Override
        public Diff<ClusterState> diff(ClusterState previousState) {
            return new Diff<ClusterState>() {
                @Override
                public ClusterState apply(ClusterState part) {
                    fail("this diff shouldn't be applied");
                    return part;
                }

                @Override
                public void writeTo(StreamOutput out) throws IOException {
                    throw new IOException("Simulated failure of diff serialization");
                }
            };
        }
    };
    try {
        publishStateAndWait(nodeA.action, unserializableClusterState, previousClusterState);
        fail("cluster state published despite of diff errors");
    } catch (Discovery.FailedToCommitClusterStateException e) {
        assertThat(e.getCause(), notNullValue());
        assertThat(e.getCause().getMessage(), containsString("failed to serialize"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:49,代码来源:PublishClusterStateActionTests.java


示例11: addFirst

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Override
public void addFirst(ClusterStateListener listener) {
    priorityClusterStateListeners.add(listener);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:InternalClusterService.java


示例12: addLast

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Override
public void addLast(ClusterStateListener listener) {
    lastClusterStateListeners.add(listener);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:InternalClusterService.java


示例13: add

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Override
public void add(ClusterStateListener listener) {
    clusterStateListeners.add(listener);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:InternalClusterService.java


示例14: doStart

import org.elasticsearch.cluster.ClusterStateListener; //导入依赖的package包/类
@Override
protected void doStart() throws ElasticsearchException {
    logger.info("doStart()");

    poller = new Thread(new Runnable() {

        @Override
        public void run() {
            while (true) {
                try {
                    final IndexRequest req = queue.take();
                    if (req == null) {
                        break;
                    }
                    bulk.add(req);
                } catch (final InterruptedException e) {
                    Thread.currentThread().interrupt();
                    break;
                }
            }
            logger.info("poller thread died");
        }
    });
    poller.setDaemon(true);
    poller.setName("poller");
    poller.start();

    this.clusterService.add(new ClusterStateListener() {

        @Override
        public void clusterChanged(final ClusterChangedEvent event) {

            if (event.localNodeMaster()) {
                isMaster = true;
            } else {
                isMaster = false;
            }

        }
    });

    this.indicesService.indicesLifecycle().addListener(auditIndicesLsListener);

}
 
开发者ID:salyh,项目名称:elasticsearch-sample-plugin-audit,代码行数:45,代码来源:AuditService.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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