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


Java ClusterName类代码示例

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


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

示例1: testProperties

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public void testProperties() throws IOException, UserException {
    final Settings.Builder builder = Settings.builder().put("cluster.name", randomAsciiOfLength(16));
    if (randomBoolean()) {
        builder.put("node.name", randomAsciiOfLength(16));
    }
    final Settings settings = builder.build();
    setupLogging("minimal", settings);

    assertNotNull(System.getProperty("es.logs.base_path"));

    assertThat(System.getProperty("es.logs.cluster_name"), equalTo(ClusterName.CLUSTER_NAME_SETTING.get(settings).value()));
    if (Node.NODE_NAME_SETTING.exists(settings)) {
        assertThat(System.getProperty("es.logs.node_name"), equalTo(Node.NODE_NAME_SETTING.get(settings)));
    } else {
        assertNull(System.getProperty("es.logs.node_name"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:EvilLoggerTests.java

示例2: NodesFailureDetectionService

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public NodesFailureDetectionService(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName, ClusterService clusterService, 
        RoutingService routingService, JoinClusterAction joinClusterAction, ClusterStateOpLog clusterStateOpLog) {
    super(settings);
    this.pingInterval = settings.getAsTime(SETTING_PING_INTERVAL, timeValueSeconds(1));
    this.pingTimeout = settings.getAsTime(SETTING_PING_TIMEOUT, timeValueSeconds(5));
    this.pingRetryCount = settings.getAsInt(SETTING_PING_RETRIES, 3);
    this.threadPool = threadPool;
    this.transportService = transportService;
    this.clusterName = clusterName;
    this.clusterService = clusterService;
    this.routingService = routingService;
    this.joinClusterAction = joinClusterAction;
    this.clusterStateOpLog = clusterStateOpLog;
    this.localNode = clusterService.localNode();
    logger.debug("[node  ] uses ping_interval [{}], ping_timeout [{}], ping_retries [{}]", pingInterval, pingTimeout, pingRetryCount);
    transportService.registerRequestHandler(PING_ACTION_NAME, PingRequest.class, ThreadPool.Names.SAME, new PingRequestHandler());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:NodesFailureDetectionService.java

示例3: FaultDetection

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public FaultDetection(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName) {
    super(settings);
    this.threadPool = threadPool;
    this.transportService = transportService;
    this.clusterName = clusterName;

    this.connectOnNetworkDisconnect = settings.getAsBoolean(SETTING_CONNECT_ON_NETWORK_DISCONNECT, false);
    this.pingInterval = settings.getAsTime(SETTING_PING_INTERVAL, timeValueSeconds(1));
    this.pingRetryTimeout = settings.getAsTime(SETTING_PING_TIMEOUT, timeValueSeconds(30));
    this.pingRetryCount = settings.getAsInt(SETTING_PING_RETRIES, 3);
    this.registerConnectionListener = settings.getAsBoolean(SETTING_REGISTER_CONNECTION_LISTENER, true);

    this.connectionListener = new FDConnectionListener();
    if (registerConnectionListener) {
        transportService.addConnectionListener(connectionListener);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:FaultDetection.java

示例4: PublishClusterStateAction

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public PublishClusterStateAction(
        Settings settings,
        TransportService transportService,
        NamedWriteableRegistry namedWriteableRegistry,
        Supplier<ClusterState> clusterStateSupplier,
        NewPendingClusterStateListener listener,
        DiscoverySettings discoverySettings,
        ClusterName clusterName) {
    super(settings);
    this.transportService = transportService;
    this.namedWriteableRegistry = namedWriteableRegistry;
    this.clusterStateSupplier = clusterStateSupplier;
    this.newPendingClusterStatelistener = listener;
    this.discoverySettings = discoverySettings;
    this.clusterName = clusterName;
    this.pendingStatesQueue = new PendingClusterStatesQueue(logger, settings.getAsInt(SETTINGS_MAX_PENDING_CLUSTER_STATES, 25));
    transportService.registerRequestHandler(SEND_ACTION_NAME, BytesTransportRequest::new, ThreadPool.Names.SAME, false, false,
        new SendClusterStateRequestHandler());
    transportService.registerRequestHandler(COMMIT_ACTION_NAME, CommitClusterStateRequest::new, ThreadPool.Names.SAME, false, false,
        new CommitClusterStateRequestHandler());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:PublishClusterStateAction.java

示例5: createInitialClusterState

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
private ClusterState createInitialClusterState() {
    MetaData.Builder metaBuilder = MetaData.builder();
    metaBuilder.put(IndexMetaData.builder("idx").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0));
    MetaData metaData = metaBuilder.build();
    RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
    routingTableBuilder.addAsNew(metaData.index("idx"));

    RoutingTable routingTable = routingTableBuilder.build();
    ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
        .metaData(metaData).routingTable(routingTable).build();
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")))
        .build();
    RoutingTable prevRoutingTable = routingTable;
    routingTable = strategy.reroute(clusterState, "reroute", false).routingTable();
    clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();

    assertEquals(prevRoutingTable.index("idx").shards().size(), 1);
    assertEquals(prevRoutingTable.index("idx").shard(0).shards().get(0).state(), UNASSIGNED);

    assertEquals(routingTable.index("idx").shards().size(), 1);
    assertEquals(routingTable.index("idx").shard(0).shards().get(0).state(), INITIALIZING);
    return clusterState;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:MaxRetryAllocationDeciderTests.java

示例6: TransportService

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
/**
 * Build the service.
 *
 * @param clusterSettings if non null the the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings
 *        updates for {@link #TRACE_LOG_EXCLUDE_SETTING} and {@link #TRACE_LOG_INCLUDE_SETTING}.
 */
public TransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor transportInterceptor,
                        Function<BoundTransportAddress, DiscoveryNode> localNodeFactory, @Nullable ClusterSettings clusterSettings) {
    super(settings);
    this.transport = transport;
    this.threadPool = threadPool;
    this.localNodeFactory = localNodeFactory;
    this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
    setTracerLogInclude(TRACE_LOG_INCLUDE_SETTING.get(settings));
    setTracerLogExclude(TRACE_LOG_EXCLUDE_SETTING.get(settings));
    tracerLog = Loggers.getLogger(logger, ".tracer");
    adapter = createAdapter();
    taskManager = createTaskManager();
    this.interceptor = transportInterceptor;
    this.asyncSender = interceptor.interceptSender(this::sendRequestInternal);
    if (clusterSettings != null) {
        clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude);
        clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_EXCLUDE_SETTING, this::setTracerLogExclude);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TransportService.java

示例7: simulateIndexCreationStates

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
private List<ClusterState> simulateIndexCreationStates(final String indexName, final boolean withPrimaryAllocationFailures) {
    final int numberOfShards = randomIntBetween(1, 5);
    final int numberOfReplicas = randomIntBetween(1, numberOfShards);
    // initial index creation and new routing table info
    final IndexMetaData indexMetaData = IndexMetaData.builder(indexName)
                                                     .settings(settings(Version.CURRENT)
                                                                   .put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()))
                                                     .numberOfShards(numberOfShards)
                                                     .numberOfReplicas(numberOfReplicas)
                                                     .build();
    final MetaData metaData = MetaData.builder().put(indexMetaData, true).build();
    final RoutingTable routingTable = RoutingTable.builder().addAsNew(indexMetaData).build();

    ClusterState clusterState = ClusterState.builder(new ClusterName("test_cluster"))
                                            .metaData(metaData)
                                            .routingTable(routingTable)
                                            .build();
    return generateClusterStates(clusterState, indexName, numberOfReplicas, withPrimaryAllocationFailures);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:ClusterStateHealthTests.java

示例8: testConvertWildcardsTests

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public void testConvertWildcardsTests() {
    MetaData.Builder mdBuilder = MetaData.builder()
            .put(indexBuilder("testXXX").putAlias(AliasMetaData.builder("alias1")).putAlias(AliasMetaData.builder("alias2")))
            .put(indexBuilder("testXYY").putAlias(AliasMetaData.builder("alias2")))
            .put(indexBuilder("testYYY").putAlias(AliasMetaData.builder("alias3")))
            .put(indexBuilder("kuku"));
    ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
    IndexNameExpressionResolver.WildcardExpressionResolver resolver = new IndexNameExpressionResolver.WildcardExpressionResolver();

    IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.lenientExpandOpen());
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("testYY*", "alias*"))), equalTo(newHashSet("testXXX", "testXYY", "testYYY")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("-kuku"))), equalTo(newHashSet("-kuku")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("+test*", "-testYYY"))), equalTo(newHashSet("testXXX", "testXYY")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("+testX*", "+testYYY"))), equalTo(newHashSet("testXXX", "testXYY", "testYYY")));
    assertThat(newHashSet(resolver.resolve(context, Arrays.asList("+testYYY", "+testX*"))), equalTo(newHashSet("testXXX", "testXYY", "testYYY")));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:WildcardExpressionResolverTests.java

示例9: ClusterService

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public ClusterService(Settings settings,
                      ClusterSettings clusterSettings, ThreadPool threadPool, Supplier<DiscoveryNode> localNodeSupplier) {
    super(settings);
    this.localNodeSupplier = localNodeSupplier;
    this.operationRouting = new OperationRouting(settings, clusterSettings);
    this.threadPool = threadPool;
    this.clusterSettings = clusterSettings;
    this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
    // will be replaced on doStart.
    this.state = new AtomicReference<>(ClusterState.builder(clusterName).build());

    this.clusterSettings.addSettingsUpdateConsumer(CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING,
            this::setSlowTaskLoggingThreshold);

    this.slowTaskLoggingThreshold = CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings);

    localNodeMasterListeners = new LocalNodeMasterListeners(threadPool);

    initialBlocks = ClusterBlocks.builder();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ClusterService.java

示例10: DLDiscovery

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
@Inject
public DLDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool,
        TransportService transportService, final ClusterService clusterService, 
        DiscoverySettings discoverySettings, Environment nodeEnvironment) {
    super(settings);
    this.clusterService = clusterService;
    this.clusterName = clusterName;
    this.discoverySettings = discoverySettings;
    this.threadPool = threadPool;
    this.nodeEnvironment = nodeEnvironment;
    this.transportService = transportService;
    this.clusterStateOpLog = null;
    this.publishClusterStateVersionAction = null;
    this.joinClusterAction = null;
    this.nodesFailureDetectionService = null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:DLDiscovery.java

示例11: testNumberOfDelayedUnassigned

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public void testNumberOfDelayedUnassigned() throws Exception {
    MockAllocationService allocation = createAllocationService(Settings.EMPTY, new DelayedShardsMockGatewayAllocator());
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
            .put(IndexMetaData.builder("test2").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
            .build();
    ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
            .metaData(metaData)
            .routingTable(RoutingTable.builder().addAsNew(metaData.index("test1")).addAsNew(metaData.index("test2")).build()).build();
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2"))).build();
    clusterState = allocation.reroute(clusterState, "reroute");
    assertThat(UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), equalTo(0));
    // starting primaries
    clusterState = allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    // starting replicas
    clusterState = allocation.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(false));
    // remove node2 and reroute
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
    // make sure both replicas are marked as delayed (i.e. not reallocated)
    clusterState = allocation.deassociateDeadNodes(clusterState, true, "reroute");
    assertThat(clusterState.toString(), UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), equalTo(2));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:UnassignedInfoTests.java

示例12: randomStates

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
List<ClusterState> randomStates(int count, String... masters) {
    ArrayList<ClusterState> states = new ArrayList<>(count);
    ClusterState[] lastClusterStatePerMaster = new ClusterState[masters.length];
    for (; count > 0; count--) {
        int masterIndex = randomInt(masters.length - 1);
        ClusterState state = lastClusterStatePerMaster[masterIndex];
        if (state == null) {
            state = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(DiscoveryNodes.builder()
                            .add(new DiscoveryNode(masters[masterIndex], buildNewFakeTransportAddress(),
                                    emptyMap(), emptySet(),Version.CURRENT)).masterNodeId(masters[masterIndex]).build()
            ).build();
        } else {
            state = ClusterState.builder(state).incrementVersion().build();
        }
        states.add(state);
        lastClusterStatePerMaster[masterIndex] = state;
    }
    return states;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:PendingClusterStatesQueueTests.java

示例13: testFilterNonMasterPingResponse

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public void testFilterNonMasterPingResponse() {
    ArrayList<ZenPing.PingResponse> responses = new ArrayList<>();
    ArrayList<DiscoveryNode> masterNodes = new ArrayList<>();
    ArrayList<DiscoveryNode> allNodes = new ArrayList<>();
    for (int i = randomIntBetween(10, 20); i >= 0; i--) {
        Set<Role> roles = new HashSet<>(randomSubsetOf(Arrays.asList(Role.values())));
        DiscoveryNode node = new DiscoveryNode("node_" + i, "id_" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
                roles, Version.CURRENT);
        responses.add(new ZenPing.PingResponse(node, randomBoolean() ? null : node, new ClusterName("test"), randomLong()));
        allNodes.add(node);
        if (node.isMasterNode()) {
            masterNodes.add(node);
        }
    }

    boolean ignore = randomBoolean();
    List<ZenPing.PingResponse> filtered = ZenDiscovery.filterPingResponses(responses, ignore, logger);
    final List<DiscoveryNode> filteredNodes = filtered.stream().map(ZenPing.PingResponse::node).collect(Collectors.toList());
    if (ignore) {
        assertThat(filteredNodes, equalTo(masterNodes));
    } else {
        assertThat(filteredNodes, equalTo(allNodes));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ZenDiscoveryUnitTests.java

示例14: testRemovingNonExistentNodes

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
public void testRemovingNonExistentNodes() throws Exception {
    final ZenDiscovery.NodeRemovalClusterStateTaskExecutor executor =
            new ZenDiscovery.NodeRemovalClusterStateTaskExecutor(null, null, null, logger);
    final DiscoveryNodes.Builder builder = DiscoveryNodes.builder();
    final int nodes = randomIntBetween(2, 16);
    for (int i = 0; i < nodes; i++) {
        builder.add(node(i));
    }
    final ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(builder).build();

    final DiscoveryNodes.Builder removeBuilder = DiscoveryNodes.builder();
    for (int i = nodes; i < nodes + randomIntBetween(1, 16); i++) {
        removeBuilder.add(node(i));
    }
    final List<ZenDiscovery.NodeRemovalClusterStateTaskExecutor.Task> tasks =
            StreamSupport
                    .stream(removeBuilder.build().spliterator(), false)
                    .map(node -> new ZenDiscovery.NodeRemovalClusterStateTaskExecutor.Task(node, randomBoolean() ? "left" : "failed"))
                    .collect(Collectors.toList());

    final ClusterStateTaskExecutor.ClusterTasksResult<ZenDiscovery.NodeRemovalClusterStateTaskExecutor.Task> result
            = executor.execute(clusterState, tasks);
    assertThat(result.resultingState, equalTo(clusterState));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:NodeRemovalClusterStateTaskExecutorTests.java

示例15: setUp

import org.elasticsearch.cluster.ClusterName; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();
    allocationService = createAllocationService(Settings.builder()
        .put("cluster.routing.allocation.node_concurrent_recoveries", 8)
        .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
        .build());
    numberOfReplicas = randomIntBetween(2, 16);
    metaData = MetaData.builder()
        .put(IndexMetaData.builder(INDEX).settings(settings(Version.CURRENT))
            .numberOfShards(1).numberOfReplicas(numberOfReplicas).primaryTerm(0, randomIntBetween(2, 10)))
        .build();
    routingTable = RoutingTable.builder()
        .addAsNew(metaData.index(INDEX))
        .build();
    clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
    executor = new ShardStateAction.ShardFailedClusterStateTaskExecutor(allocationService, null, logger);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ShardFailedClusterStateTaskExecutorTests.java


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