當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。