• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java Discovery类的典型用法和代码示例

java 1次浏览

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

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

示例1: waitForCommit

点赞 3

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public void waitForCommit(TimeValue commitTimeout) {
    boolean timedout = false;
    try {
        timedout = committedOrFailedLatch.await(commitTimeout.millis(), TimeUnit.MILLISECONDS) == false;
    } catch (InterruptedException e) {
        // the commit check bellow will either translate to an exception or we are committed and we can safely continue
    }

    if (timedout) {
        markAsFailed("timed out waiting for commit (commit timeout [" + commitTimeout + "])");
    }
    if (isCommitted() == false) {
        throw new Discovery.FailedToCommitClusterStateException("{} enough masters to ack sent cluster state. [{}] left",
                timedout ? "timed out while waiting for" : "failed to get", neededMastersToCommit);
    }
}
 

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

示例2: createAckListener

点赞 3

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public Discovery.AckListener createAckListener(ThreadPool threadPool, ClusterState newClusterState) {
    ArrayList<Discovery.AckListener> ackListeners = new ArrayList<>();

    //timeout straightaway, otherwise we could wait forever as the timeout thread has not started
    nonFailedTasks.stream().filter(task -> task.listener instanceof AckedClusterStateTaskListener).forEach(task -> {
        final AckedClusterStateTaskListener ackedListener = (AckedClusterStateTaskListener) task.listener;
        if (ackedListener.ackTimeout() == null || ackedListener.ackTimeout().millis() == 0) {
            ackedListener.onAckTimeout();
        } else {
            try {
                ackListeners.add(new AckCountDownListener(ackedListener, newClusterState.version(), newClusterState.nodes(),
                    threadPool));
            } catch (EsRejectedExecutionException ex) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Couldn't schedule timeout thread - node might be shutting down", ex);
                }
                //timeout straightaway, otherwise we could wait forever as the timeout thread has not started
                ackedListener.onAckTimeout();
            }
        }
    });

    return new DelegetingAckListener(ackListeners);
}
 

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

示例3: NodeService

点赞 3

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
NodeService(Settings settings, ThreadPool threadPool, MonitorService monitorService, Discovery discovery,
                   TransportService transportService, IndicesService indicesService, PluginsService pluginService,
                   CircuitBreakerService circuitBreakerService, ScriptService scriptService,
                   @Nullable HttpServerTransport httpServerTransport, IngestService ingestService, ClusterService clusterService,
                   SettingsFilter settingsFilter) {
    super(settings);
    this.threadPool = threadPool;
    this.monitorService = monitorService;
    this.transportService = transportService;
    this.indicesService = indicesService;
    this.discovery = discovery;
    this.pluginService = pluginService;
    this.circuitBreakerService = circuitBreakerService;
    this.httpServerTransport = httpServerTransport;
    this.ingestService = ingestService;
    this.settingsFilter = settingsFilter;
    this.scriptService = scriptService;
    clusterService.addStateApplier(ingestService.getPipelineStore());
    clusterService.addStateApplier(ingestService.getPipelineExecutionService());
}
 

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

示例4: testFailToPublishWithLessThanMinMasterNodes

点赞 3

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public void testFailToPublishWithLessThanMinMasterNodes() throws Exception {
    final int masterNodes = randomIntBetween(1, 10);

    MockNode master = createMockNode("master");
    DiscoveryNodes.Builder discoveryNodesBuilder = DiscoveryNodes.builder().add(master.discoveryNode);
    for (int i = 1; i < masterNodes; i++) {
        discoveryNodesBuilder.add(createMockNode("node" + i).discoveryNode);
    }
    final int dataNodes = randomIntBetween(0, 5);
    final Settings dataSettings = Settings.builder().put(Node.NODE_MASTER_SETTING.getKey(), false).build();
    for (int i = 0; i < dataNodes; i++) {
        discoveryNodesBuilder.add(createMockNode("data_" + i, dataSettings, null).discoveryNode);
    }
    discoveryNodesBuilder.localNodeId(master.discoveryNode.getId()).masterNodeId(master.discoveryNode.getId());
    DiscoveryNodes discoveryNodes = discoveryNodesBuilder.build();
    MetaData metaData = MetaData.EMPTY_META_DATA;
    ClusterState clusterState = ClusterState.builder(CLUSTER_NAME).metaData(metaData).nodes(discoveryNodes).build();
    ClusterState previousState = master.clusterState;
    try {
        publishState(master.action, clusterState, previousState, masterNodes + randomIntBetween(1, 5));
        fail("cluster state publishing didn't fail despite of not having enough nodes");
    } catch (Discovery.FailedToCommitClusterStateException expected) {
        logger.debug("failed to publish as expected", expected);
    }
}
 

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

示例5: publish

点赞 3

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public void publish(ClusterChangedEvent clusterChangedEvent, final Discovery.AckListener ackListener) {
    if (!master) {
        throw new IllegalStateException("Shouldn't publish state when not master");
    }
    LocalDiscovery[] members = members();
    if (members.length > 0) {
        Set<DiscoveryNode> nodesToPublishTo = new HashSet<>(members.length);
        for (LocalDiscovery localDiscovery : members) {
            if (localDiscovery.master) {
                continue;
            }
            nodesToPublishTo.add(localDiscovery.localNode());
        }
        publish(members, clusterChangedEvent, new AckClusterStatePublishResponseHandler(nodesToPublishTo, ackListener));
    }
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:18,
代码来源:LocalDiscovery.java

示例6: NodeService

点赞 3

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Inject
public NodeService(Settings settings, ThreadPool threadPool, MonitorService monitorService, Discovery discovery,
                   TransportService transportService, IndicesService indicesService,
                   PluginsService pluginService, CircuitBreakerService circuitBreakerService,
                   Version version) {
    super(settings);
    this.threadPool = threadPool;
    this.monitorService = monitorService;
    this.transportService = transportService;
    this.indicesService = indicesService;
    this.discovery = discovery;
    discovery.setNodeService(this);
    this.version = version;
    this.pluginService = pluginService;
    this.circuitBreakerService = circuitBreakerService;
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:17,
代码来源:NodeService.java

示例7: getDiscoveryTypes

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
                                                          NamedWriteableRegistry namedWriteableRegistry,
                                                          ClusterService clusterService, UnicastHostsProvider hostsProvider) {
    return Collections.singletonMap("test-zen",
        () -> new TestZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, clusterService, hostsProvider));
}
 

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

示例8: SendingController

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
private SendingController(ClusterState clusterState, int minMasterNodes, int totalMasterNodes,
                          BlockingClusterStatePublishResponseHandler publishResponseHandler) {
    this.clusterState = clusterState;
    this.publishResponseHandler = publishResponseHandler;
    this.neededMastersToCommit = Math.max(0, minMasterNodes - 1); // we are one of the master nodes
    this.pendingMasterNodes = totalMasterNodes - 1;
    if (this.neededMastersToCommit > this.pendingMasterNodes) {
        throw new Discovery.FailedToCommitClusterStateException("not enough masters to ack sent cluster state." +
            "[{}] needed , have [{}]", neededMastersToCommit, pendingMasterNodes);
    }
    this.committed = neededMastersToCommit == 0;
    this.committedOrFailedLatch = new CountDownLatch(committed ? 0 : 1);
}
 

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

示例9: Gateway

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public Gateway(Settings settings, ClusterService clusterService, GatewayMetaState metaState,
               TransportNodesListGatewayMetaState listGatewayMetaState, Discovery discovery,
               IndicesService indicesService) {
    super(settings);
    this.indicesService = indicesService;
    this.clusterService = clusterService;
    this.metaState = metaState;
    this.listGatewayMetaState = listGatewayMetaState;
    this.minimumMasterNodesProvider = discovery::getMinimumMasterNodes;
    clusterService.addLowPriorityApplier(this);
}
 

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

示例10: GatewayService

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的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

示例11: stop

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
private Node stop() {
    if (!lifecycle.moveToStopped()) {
        return this;
    }
    Logger logger = Loggers.getLogger(Node.class, NODE_NAME_SETTING.get(settings));
    logger.info("stopping ...");

    injector.getInstance(TribeService.class).stop();
    injector.getInstance(ResourceWatcherService.class).stop();
    if (NetworkModule.HTTP_ENABLED.get(settings)) {
        injector.getInstance(HttpServerTransport.class).stop();
    }

    injector.getInstance(SnapshotsService.class).stop();
    injector.getInstance(SnapshotShardsService.class).stop();
    // stop any changes happening as a result of cluster state changes
    injector.getInstance(IndicesClusterStateService.class).stop();
    // close discovery early to not react to pings anymore.
    // This can confuse other nodes and delay things - mostly if we're the master and we're running tests.
    injector.getInstance(Discovery.class).stop();
    // we close indices first, so operations won't be allowed on it
    injector.getInstance(RoutingService.class).stop();
    injector.getInstance(ClusterService.class).stop();
    injector.getInstance(NodeConnectionsService.class).stop();
    injector.getInstance(MonitorService.class).stop();
    injector.getInstance(GatewayService.class).stop();
    injector.getInstance(SearchService.class).stop();
    injector.getInstance(TransportService.class).stop();
    injector.getInstance(SearchTransportService.class).stop();

    pluginLifecycleComponents.forEach(LifecycleComponent::stop);
    // we should stop this last since it waits for resources to get released
    // if we had scroll searchers etc or recovery going on we wait for to finish.
    injector.getInstance(IndicesService.class).stop();
    logger.info("stopped");

    return this;
}
 

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

示例12: testTimeoutOrCommit

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
/**
 * Tests that cluster is committed or times out. It should never be the case that we fail
 * an update due to a commit timeout, but it ends up being committed anyway
 */
public void testTimeoutOrCommit() throws Exception {
    Settings settings = Settings.builder()
        // short but so we will sometime commit sometime timeout
        .put(DiscoverySettings.COMMIT_TIMEOUT_SETTING.getKey(), "1ms").build();

    MockNode master = createMockNode("master", settings, null);
    MockNode node = createMockNode("node", settings, null);
    ClusterState state = ClusterState.builder(master.clusterState)
            .nodes(DiscoveryNodes.builder(master.clusterState.nodes())
                .add(node.discoveryNode).masterNodeId(master.discoveryNode.getId())).build();

    for (int i = 0; i < 10; i++) {
        state = ClusterState.builder(state).incrementVersion().build();
        logger.debug("--> publishing version [{}], UUID [{}]", state.version(), state.stateUUID());
        boolean success;
        try {
            publishState(master.action, state, master.clusterState, 2).await(1, TimeUnit.HOURS);
            success = true;
        } catch (Discovery.FailedToCommitClusterStateException OK) {
            success = false;
        }
        logger.debug("--> publishing [{}], verifying...", success ? "succeeded" : "failed");

        if (success) {
            assertSameState(node.clusterState, state);
        } else {
            assertThat(node.clusterState.stateUUID(), not(equalTo(state.stateUUID())));
        }
    }
}
 

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

示例13: testHandleNodeJoin_incompatibleClusterState

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public void testHandleNodeJoin_incompatibleClusterState() throws UnknownHostException {
    Settings nodeSettings = Settings.builder()
        .put("discovery.type", "zen") // <-- To override the local setting if set externally
        .build();
    String masterOnlyNode = internalCluster().startMasterOnlyNode(nodeSettings);
    String node1 = internalCluster().startNode(nodeSettings);
    ZenDiscovery zenDiscovery = (ZenDiscovery) internalCluster().getInstance(Discovery.class, masterOnlyNode);
    ClusterService clusterService = internalCluster().getInstance(ClusterService.class, node1);
    final ClusterState state = clusterService.state();
    MetaData.Builder mdBuilder = MetaData.builder(state.metaData());
    mdBuilder.putCustom(CustomMetaData.TYPE, new CustomMetaData("data"));
    ClusterState stateWithCustomMetaData = ClusterState.builder(state).metaData(mdBuilder).build();

    final AtomicReference<IllegalStateException> holder = new AtomicReference<>();
    DiscoveryNode node = state.nodes().getLocalNode();
    zenDiscovery.handleJoinRequest(node, stateWithCustomMetaData, new MembershipAction.JoinCallback() {
        @Override
        public void onSuccess() {
        }

        @Override
        public void onFailure(Exception e) {
            holder.set((IllegalStateException) e);
        }
    });

    assertThat(holder.get(), notNullValue());
    assertThat(holder.get().getMessage(), equalTo("failure when sending a validation request to node"));
}
 

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

示例14: getDiscoveryTypes

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
                                                          NamedWriteableRegistry namedWriteableRegistry,
                                                          ClusterService clusterService, UnicastHostsProvider hostsProvider) {
    // this is for backcompat with pre 5.1, where users would set discovery.type to use ec2 hosts provider
    return Collections.singletonMap(EC2, () ->
        new ZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, clusterService, hostsProvider));
}
 

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

示例15: getDiscoveryTypes

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
                                                          NamedWriteableRegistry namedWriteableRegistry,
                                                          ClusterService clusterService, UnicastHostsProvider hostsProvider) {
    // this is for backcompat with pre 5.1, where users would set discovery.type to use ec2 hosts provider
    return Collections.singletonMap(AZURE, () ->
        new ZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, clusterService, hostsProvider));
}
 

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

示例16: getSettings

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public List<Setting<?>> getSettings() {
    return Arrays.asList(AzureComputeService.Discovery.REFRESH_SETTING,
                        AzureComputeService.Management.KEYSTORE_PASSWORD_SETTING,
                        AzureComputeService.Management.KEYSTORE_PATH_SETTING,
                        AzureComputeService.Management.KEYSTORE_TYPE_SETTING,
                        AzureComputeService.Management.SUBSCRIPTION_ID_SETTING,
                        AzureComputeService.Management.SERVICE_NAME_SETTING,
                        AzureComputeService.Discovery.HOST_TYPE_SETTING,
                        AzureComputeService.Discovery.DEPLOYMENT_NAME_SETTING,
                        AzureComputeService.Discovery.DEPLOYMENT_SLOT_SETTING,
                        AzureComputeService.Discovery.ENDPOINT_NAME_SETTING);
}
 

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

示例17: getDiscoveryTypes

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
                                                          NamedWriteableRegistry namedWriteableRegistry,
                                                          ClusterService clusterService, UnicastHostsProvider hostsProvider) {
    // this is for backcompat with pre 5.1, where users would set discovery.type to use ec2 hosts provider
    return Collections.singletonMap(GCE, () ->
        new ZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, clusterService, hostsProvider));
}
 

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

示例18: NodeSysExpression

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Inject
public NodeSysExpression(ClusterService clusterService,
                         OsService osService,
                         NodeService nodeService,
                         JvmService jvmService,
                         NodeEnvironment nodeEnvironment,
                         Discovery discovery,
                         ThreadPool threadPool,
                         ExtendedNodeInfo extendedNodeInfo) {
    this.nodeService = nodeService;
    this.osService = osService;
    this.jvmService = jvmService;
    this.nodeEnvironment = nodeEnvironment;
    this.extendedNodeInfo = extendedNodeInfo;
    childImplementations.put(SysNodesTableInfo.SYS_COL_HOSTNAME,
            new NodeHostnameExpression(clusterService));
    childImplementations.put(SysNodesTableInfo.SYS_COL_REST_URL,
            new NodeRestUrlExpression(clusterService));
    childImplementations.put(SysNodesTableInfo.SYS_COL_ID,
            new NodeIdExpression(clusterService));
    childImplementations.put(SysNodesTableInfo.SYS_COL_NODE_NAME,
            new NodeNameExpression(discovery));
    childImplementations.put(SysNodesTableInfo.SYS_COL_PORT,
            new NodePortExpression(nodeService));
    childImplementations.put(SysNodesTableInfo.SYS_COL_VERSION,
            new NodeVersionExpression());
    childImplementations.put(SysNodesTableInfo.SYS_COL_THREAD_POOLS,
            new NodeThreadPoolsExpression(threadPool));
    childImplementations.put(SysNodesTableInfo.SYS_COL_OS_INFO,
            new NodeOsInfoExpression(osService.info()));
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:32,
代码来源:NodeSysExpression.java

示例19: publish

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public void publish(ClusterChangedEvent clusterChangedEvent, final Discovery.AckListener ackListener) {
    Set<DiscoveryNode> nodesToPublishTo = new HashSet<>(clusterChangedEvent.state().nodes().size());
    DiscoveryNode localNode = nodesProvider.nodes().localNode();
    for (final DiscoveryNode node : clusterChangedEvent.state().nodes()) {
        if (node.equals(localNode)) {
            continue;
        }
        nodesToPublishTo.add(node);
    }
    publish(clusterChangedEvent, nodesToPublishTo, new AckClusterStatePublishResponseHandler(nodesToPublishTo, ackListener));
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:12,
代码来源:PublishClusterStateAction.java

示例20: getDiscoveryTypes

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
                                                          NamedWriteableRegistry namedWriteableRegistry, ClusterService clusterService, UnicastHostsProvider hostsProvider) {
  // this is for backcompat with pre 5.1, where users would set discovery.type to use ec2 hosts provider
  return Collections.singletonMap(KUBERNETES, () ->
    new ZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, clusterService, hostsProvider));
}
 

开发者ID:fabric8io,
项目名称:elasticsearch-cloud-kubernetes,
代码行数:8,
代码来源:KubernetesDiscoveryPlugin.java

示例21: afterInternal

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
protected final void afterInternal(boolean afterClass) throws Exception {
    boolean success = false;
    try {
        final Scope currentClusterScope = getCurrentClusterScope();
        clearDisruptionScheme();
        try {
            if (cluster() != null) {
                if (currentClusterScope != Scope.TEST) {
                    MetaData metaData = client().admin().cluster().prepareState().execute().actionGet().getState().getMetaData();
                    final Map<String, String> persistent = metaData.persistentSettings().getAsMap();
                    assertThat("test leaves persistent cluster metadata behind: " + persistent, persistent.size(), equalTo(0));
                    final Map<String, String> transientSettings =  new HashMap<>(metaData.transientSettings().getAsMap());
                    if (isInternalCluster() && internalCluster().getAutoManageMinMasterNode()) {
                        // this is set by the test infra
                        transientSettings.remove(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey());
                    }
                    assertThat("test leaves transient cluster metadata behind: " + transientSettings,
                        transientSettings.keySet(), empty());
                }
                ensureClusterSizeConsistency();
                ensureClusterStateConsistency();
                if (isInternalCluster()) {
                    // check no pending cluster states are leaked
                    for (Discovery discovery : internalCluster().getInstances(Discovery.class)) {
                        if (discovery instanceof ZenDiscovery) {
                            final ZenDiscovery zenDiscovery = (ZenDiscovery) discovery;
                            assertBusy(() -> {
                                final ClusterState[] states = zenDiscovery.pendingClusterStates();
                                assertThat(zenDiscovery.localNode().getName() + " still having pending states:\n" +
                                        Stream.of(states).map(ClusterState::toString).collect(Collectors.joining("\n")),
                                    states, emptyArray());
                            });
                        }
                    }
                }
                beforeIndexDeletion();
                cluster().wipe(excludeTemplates()); // wipe after to make sure we fail in the test that didn't ack the delete
                if (afterClass || currentClusterScope == Scope.TEST) {
                    cluster().close();
                }
                cluster().assertAfterTest();
            }
        } finally {
            if (currentClusterScope == Scope.TEST) {
                clearClusters(); // it is ok to leave persistent / transient cluster state behind if scope is TEST
            }
        }
        success = true;
    } finally {
        if (!success) {
            // if we failed here that means that something broke horribly so we should clear all clusters
            // TODO: just let the exception happen, WTF is all this horseshit
            // afterTestRule.forceFailure();
        }
    }
}
 

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

示例22: setClusterStatePublisher

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public synchronized void setClusterStatePublisher(BiConsumer<ClusterChangedEvent, Discovery.AckListener> publisher) {
    clusterStatePublisher = publisher;
}
 

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

示例23: publishingFailed

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public void publishingFailed(Discovery.FailedToCommitClusterStateException t) {
    nonFailedTasks.forEach(task -> task.listener.onFailure(task.source, t));
}
 

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

示例24: DelegetingAckListener

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
private DelegetingAckListener(List<Discovery.AckListener> listeners) {
    this.listeners = listeners;
}
 

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

示例25: onNodeAck

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public void onNodeAck(DiscoveryNode node, @Nullable Exception e) {
    for (Discovery.AckListener listener : listeners) {
        listener.onNodeAck(node, e);
    }
}
 

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

示例26: doStart

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
protected void doStart(ClusterState clusterState) {
    final Predicate<ClusterState> masterChangePredicate = MasterNodeChangePredicate.build(clusterState);
    final DiscoveryNodes nodes = clusterState.nodes();
    if (nodes.isLocalNodeElectedMaster() || localExecute(request)) {
        // check for block, if blocked, retry, else, execute locally
        final ClusterBlockException blockException = checkBlock(request, clusterState);
        if (blockException != null) {
            if (!blockException.retryable()) {
                listener.onFailure(blockException);
            } else {
                logger.trace("can't execute due to a cluster block, retrying", blockException);
                retry(blockException, newState -> {
                    ClusterBlockException newException = checkBlock(request, newState);
                    return (newException == null || !newException.retryable());
                });
            }
        } else {
            ActionListener<Response> delegate = new ActionListener<Response>() {
                @Override
                public void onResponse(Response response) {
                    listener.onResponse(response);
                }

                @Override
                public void onFailure(Exception t) {
                    if (t instanceof Discovery.FailedToCommitClusterStateException
                            || (t instanceof NotMasterException)) {
                        logger.debug((org.apache.logging.log4j.util.Supplier<?>) () -> new ParameterizedMessage("master could not publish cluster state or stepped down before publishing action [{}], scheduling a retry", actionName), t);
                        retry(t, masterChangePredicate);
                    } else {
                        listener.onFailure(t);
                    }
                }
            };
            threadPool.executor(executor).execute(new ActionRunnable(delegate) {
                @Override
                protected void doRun() throws Exception {
                    masterOperation(task, request, clusterState, delegate);
                }
            });
        }
    } else {
        if (nodes.getMasterNode() == null) {
            logger.debug("no known master node, scheduling a retry");
            retry(null, masterChangePredicate);
        } else {
            transportService.sendRequest(nodes.getMasterNode(), actionName, request, new ActionListenerResponseHandler<Response>(listener, TransportMasterNodeAction.this::newResponse) {
                @Override
                public void handleException(final TransportException exp) {
                    Throwable cause = exp.unwrapCause();
                    if (cause instanceof ConnectTransportException) {
                        // we want to retry here a bit to see if a new master is elected
                        logger.debug("connection exception while trying to forward request with action name [{}] to master node [{}], scheduling a retry. Error: [{}]",
                                actionName, nodes.getMasterNode(), exp.getDetailedMessage());
                        retry(cause, masterChangePredicate);
                    } else {
                        listener.onFailure(exp);
                    }
                }
            });
        }
    }
}
 

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

示例27: testSerializationFailureDuringDiffPublishing

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的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

示例28: testNodesUpdatedAfterClusterStatePublished

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public void testNodesUpdatedAfterClusterStatePublished() throws Exception {
    ThreadPool threadPool = new TestThreadPool(getClass().getName());
    // randomly make minimum_master_nodes a value higher than we have nodes for, so it will force failure
    int minMasterNodes = randomBoolean() ? 3 : 1;
    Settings settings = Settings.builder()
                            .put(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.toString(minMasterNodes)).build();

    ArrayDeque<Closeable> toClose = new ArrayDeque<>();
    try {
        Set<DiscoveryNode> expectedFDNodes = null;

        final MockTransportService masterTransport = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null);
        masterTransport.start();
        DiscoveryNode masterNode = masterTransport.getLocalNode();
        toClose.addFirst(masterTransport);
        ClusterState state = ClusterStateCreationUtils.state(masterNode, masterNode, masterNode);
        // build the zen discovery and cluster service
        ClusterService masterClusterService = createClusterService(threadPool, masterNode);
        toClose.addFirst(masterClusterService);
        // TODO: clustername shouldn't be stored twice in cluster service, but for now, work around it
        state = ClusterState.builder(masterClusterService.getClusterName()).nodes(state.nodes()).build();
        setState(masterClusterService, state);
        ZenDiscovery masterZen = buildZenDiscovery(settings, masterTransport, masterClusterService, threadPool);
        toClose.addFirst(masterZen);
        masterTransport.acceptIncomingRequests();

        final MockTransportService otherTransport = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null);
        otherTransport.start();
        toClose.addFirst(otherTransport);
        DiscoveryNode otherNode = otherTransport.getLocalNode();
        final ClusterState otherState = ClusterState.builder(masterClusterService.getClusterName())
            .nodes(DiscoveryNodes.builder().add(otherNode).localNodeId(otherNode.getId())).build();
        ClusterService otherClusterService = createClusterService(threadPool, masterNode);
        toClose.addFirst(otherClusterService);
        setState(otherClusterService, otherState);
        ZenDiscovery otherZen = buildZenDiscovery(settings, otherTransport, otherClusterService, threadPool);
        toClose.addFirst(otherZen);
        otherTransport.acceptIncomingRequests();

        masterTransport.connectToNode(otherNode);
        otherTransport.connectToNode(masterNode);

        // a new cluster state with a new discovery node (we will test if the cluster state
        // was updated by the presence of this node in NodesFaultDetection)
        ClusterState newState = ClusterState.builder(masterClusterService.state()).incrementVersion().nodes(
            DiscoveryNodes.builder(state.nodes()).add(otherNode).masterNodeId(masterNode.getId())
        ).build();

        try {
            // publishing a new cluster state
            ClusterChangedEvent clusterChangedEvent = new ClusterChangedEvent("testing", newState, state);
            AssertingAckListener listener = new AssertingAckListener(newState.nodes().getSize() - 1);
            expectedFDNodes = masterZen.getFaultDetectionNodes();
            masterZen.publish(clusterChangedEvent, listener);
            listener.await(1, TimeUnit.HOURS);
            // publish was a success, update expected FD nodes based on new cluster state
            expectedFDNodes = fdNodesForState(newState, masterNode);
        } catch (Discovery.FailedToCommitClusterStateException e) {
            // not successful, so expectedFDNodes above should remain what it was originally assigned
            assertEquals(3, minMasterNodes); // ensure min master nodes is the higher value, otherwise we shouldn't fail
        }

        assertEquals(expectedFDNodes, masterZen.getFaultDetectionNodes());
    } finally {
        IOUtils.close(toClose);
        terminate(threadPool);
    }
}
 

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

示例29: testPendingCSQueueIsClearedWhenClusterStatePublished

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public void testPendingCSQueueIsClearedWhenClusterStatePublished() throws Exception {
    ThreadPool threadPool = new TestThreadPool(getClass().getName());
    // randomly make minimum_master_nodes a value higher than we have nodes for, so it will force failure
    int minMasterNodes =  randomBoolean() ? 3 : 1;
    Settings settings = Settings.builder()
        .put(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.toString(minMasterNodes)).build();

    ArrayDeque<Closeable> toClose = new ArrayDeque<>();
    try {
        final MockTransportService masterTransport = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null);
        masterTransport.start();
        DiscoveryNode masterNode = masterTransport.getLocalNode();
        toClose.addFirst(masterTransport);
        ClusterState state = ClusterStateCreationUtils.state(masterNode, null, masterNode);
        // build the zen discovery and cluster service
        ClusterService masterClusterService = createClusterService(threadPool, masterNode);
        toClose.addFirst(masterClusterService);
        state = ClusterState.builder(masterClusterService.getClusterName()).nodes(state.nodes()).build();
        setState(masterClusterService, state);
        ZenDiscovery masterZen = buildZenDiscovery(settings, masterTransport, masterClusterService, threadPool);
        toClose.addFirst(masterZen);
        masterTransport.acceptIncomingRequests();

        // inject a pending cluster state
        masterZen.pendingClusterStatesQueue().addPending(ClusterState.builder(new ClusterName("foreign")).build());

        // a new cluster state with a new discovery node (we will test if the cluster state
        // was updated by the presence of this node in NodesFaultDetection)
        ClusterState newState = ClusterState.builder(masterClusterService.state()).incrementVersion().nodes(
            DiscoveryNodes.builder(masterClusterService.state().nodes()).masterNodeId(masterNode.getId())
        ).build();


        try {
            // publishing a new cluster state
            ClusterChangedEvent clusterChangedEvent = new ClusterChangedEvent("testing", newState, state);
            AssertingAckListener listener = new AssertingAckListener(newState.nodes().getSize() - 1);
            masterZen.publish(clusterChangedEvent, listener);
            listener.await(1, TimeUnit.HOURS);
            // publish was a success, check that queue as cleared
            assertThat(masterZen.pendingClusterStates(), emptyArray());
        } catch (Discovery.FailedToCommitClusterStateException e) {
            // not successful, so the pending queue should stay
            assertThat(masterZen.pendingClusterStates(), arrayWithSize(1));
            assertThat(masterZen.pendingClusterStates()[0].getClusterName().value(), equalTo("foreign"));
        }
    } finally {
        IOUtils.close(toClose);
        terminate(threadPool);
    }
}
 

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

示例30: getLocalNodeId

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
private String getLocalNodeId(String name) {
    Discovery discovery = internalCluster().getInstance(Discovery.class, name);
    String nodeId = discovery.localNode().getId();
    assertThat(nodeId, not(nullValue()));
    return nodeId;
}
 

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

示例31: NodeNameExpression

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
public NodeNameExpression(Discovery discovery) {
    this.discovery = discovery;
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:4,
代码来源:NodeNameExpression.java

示例32: onNodeAck

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
public void onNodeAck(DiscoveryNode node, @Nullable Throwable t) {
    for (Discovery.AckListener listener : listeners) {
        listener.onNodeAck(node, t);
    }
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:7,
代码来源:InternalClusterService.java

示例33: start

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
/**
 * Start the node. If the node is already started, this method is no-op.
 */
public Node start() {
    if (!lifecycle.moveToStarted()) {
        return this;
    }

    ESLogger logger = Loggers.getLogger(Node.class, settings.get("name"));
    logger.info("starting ...");
    // hack around dependency injection problem (for now...)
    injector.getInstance(Discovery.class).setRoutingService(injector.getInstance(RoutingService.class));
    for (Class<? extends LifecycleComponent> plugin : pluginsService.nodeServices()) {
        injector.getInstance(plugin).start();
    }

    injector.getInstance(MappingUpdatedAction.class).setClient(client);
    injector.getInstance(IndicesService.class).start();
    injector.getInstance(IndexingMemoryController.class).start();
    injector.getInstance(IndicesClusterStateService.class).start();
    injector.getInstance(IndicesTTLService.class).start();
    injector.getInstance(SnapshotsService.class).start();
    injector.getInstance(SnapshotShardsService.class).start();
    injector.getInstance(RoutingService.class).start();
    injector.getInstance(SearchService.class).start();
    injector.getInstance(MonitorService.class).start();
    injector.getInstance(RestController.class).start();

    // TODO hack around circular dependencies problems
    injector.getInstance(GatewayAllocator.class).setReallocation(injector.getInstance(ClusterService.class), injector.getInstance(RoutingService.class));

    injector.getInstance(ResourceWatcherService.class).start();
    injector.getInstance(GatewayService.class).start();
    injector.getInstance(TenantManagementService.class).start();

    // Start the transport service now so the publish address will be added to the local disco node in ClusterService
    TransportService transportService = injector.getInstance(TransportService.class);
    transportService.start();
    injector.getInstance(ClusterService.class).start();

    // start after cluster service so the local disco is known
    DiscoveryService discoService = injector.getInstance(DiscoveryService.class).start();


    transportService.acceptIncomingRequests();
    discoService.joinClusterAndWaitForInitialState();

    if (settings.getAsBoolean("http.enabled", true)) {
        injector.getInstance(HttpServer.class).start();
    }
    injector.getInstance(TribeService.class).start();
    if (settings.getAsBoolean("node.portsfile", false)) {
        if (settings.getAsBoolean("http.enabled", true)) {
            HttpServerTransport http = injector.getInstance(HttpServerTransport.class);
            writePortsFile("http", http.boundAddress());
        }
        TransportService transport = injector.getInstance(TransportService.class);
        writePortsFile("transport", transport.boundAddress());
    }
    logger.info("started");

    return this;
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:64,
代码来源:Node.java

示例34: bindDiscovery

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
protected void bindDiscovery() {
    bind(Discovery.class).to(SrvtestDiscovery.class).asEagerSingleton();
}
 

开发者ID:github,
项目名称:elasticsearch-srv-discovery,
代码行数:5,
代码来源:SrvtestDiscoveryModule.java

示例35: bindDiscovery

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
protected void bindDiscovery() {
    bind(Discovery.class).to(SrvDiscovery.class).asEagerSingleton();
}
 

开发者ID:github,
项目名称:elasticsearch-srv-discovery,
代码行数:5,
代码来源:SrvDiscoveryModule.java

示例36: bindDiscovery

点赞 2

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
@Override
protected void bindDiscovery() {
    bind(Discovery.class).to(CloudServersDiscovery.class).asEagerSingleton();
}
 

开发者ID:jlinn,
项目名称:elasticsearch-cloud-rackspace,
代码行数:5,
代码来源:CloudServersDiscoveryModule.java

示例37: getDiscoveryTypes

点赞 1

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
/**
 * Returns custom discovery implementations added by this plugin.
 *
 * The key of the returned map is the name of the discovery implementation
 * (see {@link org.elasticsearch.discovery.DiscoveryModule#DISCOVERY_TYPE_SETTING}, and
 * the value is a supplier to construct the {@link Discovery}.
 *
 * @param threadPool Use to schedule ping actions
 * @param transportService Use to communicate with other nodes
 * @param clusterService Use to find current nodes in the cluster
 * @param hostsProvider Use to find configured hosts which should be pinged for initial discovery
 */
default Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
                                                           NamedWriteableRegistry namedWriteableRegistry,
                                                           ClusterService clusterService, UnicastHostsProvider hostsProvider) {
    return Collections.emptyMap();
}
 

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

示例38: getDiscoverySettings

点赞 1

import org.elasticsearch.discovery.Discovery; //导入依赖的package包/类
private DiscoverySettings getDiscoverySettings() {return internalCluster().getInstance(Discovery.class).getDiscoverySettings();} 

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


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)