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


Java DiscoveryNode.isDataNode方法代码示例

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


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

示例1: IndicesStore

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的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: SnapshotShardsService

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Inject
public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService, ThreadPool threadPool,
                             TransportService transportService, IndicesService indicesService) {
    super(settings);
    this.indicesService = indicesService;
    this.snapshotsService = snapshotsService;
    this.transportService = transportService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    if (DiscoveryNode.isDataNode(settings)) {
        // this is only useful on the nodes that can hold data
        // addLowPriorityApplier to make sure that Repository will be created before snapshot
        clusterService.addLowPriorityApplier(this);
    }

    if (DiscoveryNode.isMasterNode(settings)) {
        // This needs to run only on nodes that can become masters
        transportService.registerRequestHandler(UPDATE_SNAPSHOT_ACTION_NAME, UpdateIndexShardSnapshotStatusRequest::new, ThreadPool.Names.SAME, new UpdateSnapshotStateRequestHandler());
    }

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

示例3: doStart

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
protected void doStart() {
    // Doesn't make sense to manage shards on non-master and non-data nodes
    if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) {
        clusterService.addHighPriorityApplier(this);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:IndicesClusterStateService.java

示例4: RepositoriesService

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Inject
public RepositoriesService(Settings settings, ClusterService clusterService, TransportService transportService,
                           Map<String, Repository.Factory> typesRegistry) {
    super(settings);
    this.typesRegistry = typesRegistry;
    this.clusterService = clusterService;
    // Doesn't make sense to maintain repositories on non-master and non-data nodes
    // Nothing happens there anyway
    if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) {
        clusterService.addStateApplier(this);
    }
    this.verifyAction = new VerifyNodeRepositoryAction(settings, transportService, clusterService, this);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:RepositoriesService.java

示例5: explainOrThrowMissingRoutingNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
/**
 * Handle case where a disco node cannot be found in the routing table. Usually means that it's not a data node.
 */
protected RerouteExplanation explainOrThrowMissingRoutingNode(RoutingAllocation allocation, boolean explain, DiscoveryNode discoNode) {
    if (!discoNode.isDataNode()) {
        return explainOrThrowRejectedCommand(explain, allocation, "allocation can only be done on data nodes, not [" + node + "]");
    } else {
        return explainOrThrowRejectedCommand(explain, allocation, "could not find [" + node + "] among the routing nodes");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:AbstractAllocateAllocationCommand.java

示例6: test

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
public boolean test(NodeAndClient nodeAndClient) {
    return DiscoveryNode.isDataNode(nodeAndClient.node.settings());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:InternalTestCluster.java

示例7: ExternalTestCluster

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public ExternalTestCluster(Path tempDir, Settings additionalSettings, Collection<Class<? extends Plugin>> pluginClasses,
                           TransportAddress... transportAddresses) {
    super(0);
    Settings.Builder clientSettingsBuilder = Settings.builder()
        .put(additionalSettings)
        .put("node.name", InternalTestCluster.TRANSPORT_CLIENT_PREFIX + EXTERNAL_CLUSTER_PREFIX + counter.getAndIncrement())
        .put("client.transport.ignore_cluster_name", true)
        .put(Environment.PATH_HOME_SETTING.getKey(), tempDir);
    boolean addMockTcpTransport = additionalSettings.get(NetworkModule.TRANSPORT_TYPE_KEY) == null;

    if (addMockTcpTransport) {
        clientSettingsBuilder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
        if (pluginClasses.contains(MockTcpTransportPlugin.class) == false) {
            pluginClasses = new ArrayList<>(pluginClasses);
            pluginClasses.add(MockTcpTransportPlugin.class);
        }
    }
    Settings clientSettings = clientSettingsBuilder.build();
    TransportClient client = new MockTransportClient(clientSettings, pluginClasses);

    try {
        client.addTransportAddresses(transportAddresses);
        NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().clear().setSettings(true).setHttp(true).get();
        httpAddresses = new InetSocketAddress[nodeInfos.getNodes().size()];
        this.clusterName = nodeInfos.getClusterName().value();
        int dataNodes = 0;
        int masterAndDataNodes = 0;
        for (int i = 0; i < nodeInfos.getNodes().size(); i++) {
            NodeInfo nodeInfo = nodeInfos.getNodes().get(i);
            httpAddresses[i] = nodeInfo.getHttp().address().publishAddress().address();
            if (DiscoveryNode.isDataNode(nodeInfo.getSettings())) {
                dataNodes++;
                masterAndDataNodes++;
            } else if (DiscoveryNode.isMasterNode(nodeInfo.getSettings())) {
                masterAndDataNodes++;
            }
        }
        this.numDataNodes = dataNodes;
        this.numMasterAndDataNodes = masterAndDataNodes;
        this.client = client;
        logger.info("Setup ExternalTestCluster [{}] made of [{}] nodes", nodeInfos.getClusterName().value(), size());
    } catch (Exception e) {
        client.close();
        throw e;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:47,代码来源:ExternalTestCluster.java

示例8: doStop

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
protected void doStop() {
    if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) {
        clusterService.removeApplier(this);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:IndicesClusterStateService.java

示例9: close

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
public void close() {
    if (DiscoveryNode.isDataNode(settings)) {
        clusterService.removeListener(this);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:IndicesStore.java

示例10: GatewayMetaState

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Inject
public GatewayMetaState(Settings settings, NodeEnvironment nodeEnv, MetaStateService metaStateService,
                        TransportNodesListGatewayMetaState nodesListGatewayMetaState,
                        MetaDataIndexUpgradeService metaDataIndexUpgradeService, MetaDataUpgrader metaDataUpgrader)
    throws Exception {
    super(settings);
    this.nodeEnv = nodeEnv;
    this.metaStateService = metaStateService;
    nodesListGatewayMetaState.init(this);

    if (DiscoveryNode.isDataNode(settings)) {
        ensureNoPre019ShardState(nodeEnv);
    }

    if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) {
        nodeEnv.ensureAtomicMoveSupported();
    }
    if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) {
        try {
            ensureNoPre019State();
            IndexFolderUpgrader.upgradeIndicesIfNeeded(settings, nodeEnv);
            final MetaData metaData = metaStateService.loadFullState();
            final MetaData upgradedMetaData = upgradeMetaData(metaData, metaDataIndexUpgradeService, metaDataUpgrader);
            // We finished global state validation and successfully checked all indices for backward compatibility
            // and found no non-upgradable indices, which means the upgrade can continue.
            // Now it's safe to overwrite global and index metadata.
            if (metaData != upgradedMetaData) {
                if (MetaData.isGlobalStateEquals(metaData, upgradedMetaData) == false) {
                    metaStateService.writeGlobalState("upgrade", upgradedMetaData);
                }
                for (IndexMetaData indexMetaData : upgradedMetaData) {
                    if (metaData.hasIndexMetaData(indexMetaData) == false) {
                        metaStateService.writeIndex("upgrade", indexMetaData);
                    }
                }
            }
            long startNS = System.nanoTime();
            metaStateService.loadFullState();
            logger.debug("took {} to load state", TimeValue.timeValueMillis(TimeValue.nsecToMSec(System.nanoTime() - startNS)));
        } catch (Exception e) {
            logger.error("failed to read local state, exiting...", e);
            throw e;
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:46,代码来源:GatewayMetaState.java

示例11: clusterChanged

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
public void clusterChanged(ClusterChangedEvent event) {
    if (!this.enabled) {
        return;
    }

    // Check whether it was a data node that was added
    boolean dataNodeAdded = false;
    for (DiscoveryNode addedNode : event.nodesDelta().addedNodes()) {
        if (addedNode.isDataNode()) {
            dataNodeAdded = true;
            break;
        }
    }

    if (this.isMaster && dataNodeAdded && event.state().getNodes().getDataNodes().size() > 1) {
        if (logger.isDebugEnabled()) {
            logger.debug("data node was added, retrieving new cluster info");
        }
        threadPool.executor(executorName()).execute(() -> maybeRefresh());
    }

    if (this.isMaster && event.nodesRemoved()) {
        for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) {
            if (removedNode.isDataNode()) {
                if (logger.isTraceEnabled()) {
                    logger.trace("Removing node from cluster info: {}", removedNode.getId());
                }
                if (leastAvailableSpaceUsages.containsKey(removedNode.getId())) {
                    ImmutableOpenMap.Builder<String, DiskUsage> newMaxUsages = ImmutableOpenMap.builder(leastAvailableSpaceUsages);
                    newMaxUsages.remove(removedNode.getId());
                    leastAvailableSpaceUsages = newMaxUsages.build();
                }
                if (mostAvailableSpaceUsages.containsKey(removedNode.getId())) {
                    ImmutableOpenMap.Builder<String, DiskUsage> newMinUsages = ImmutableOpenMap.builder(mostAvailableSpaceUsages);
                    newMinUsages.remove(removedNode.getId());
                    mostAvailableSpaceUsages = newMinUsages.build();
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:43,代码来源:InternalClusterInfoService.java


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