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


Java ClusterSettings类代码示例

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


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

示例1: nettyFromThreadPool

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
public static MockTransportService nettyFromThreadPool(Settings settings, ThreadPool threadPool, final Version version,
        ClusterSettings clusterSettings, boolean doHandshake) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    Transport transport = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()),
        BigArrays.NON_RECYCLING_INSTANCE, namedWriteableRegistry, new NoneCircuitBreakerService()) {

        @Override
        protected Version executeHandshake(DiscoveryNode node, Channel channel, TimeValue timeout) throws IOException,
            InterruptedException {
            if (doHandshake) {
                return super.executeHandshake(node, channel, timeout);
            } else {
                return version.minimumCompatibilityVersion();
            }
        }

        @Override
        protected Version getCurrentVersion() {
            return version;
        }
    };
    MockTransportService mockTransportService =
        MockTransportService.createNewService(Settings.EMPTY, transport, version, threadPool, clusterSettings);
    mockTransportService.start();
    return mockTransportService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:SimpleNetty4TransportTests.java

示例2: testBindUnavailableAddress

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
public void testBindUnavailableAddress() {
    // this is on a lower level since it needs access to the TransportService before it's started
    int port = serviceA.boundAddress().publishAddress().getPort();
    Settings settings = Settings.builder()
        .put(Node.NODE_NAME_SETTING.getKey(), "foobar")
        .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "")
        .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING")
        .put("transport.tcp.port", port)
        .build();
    ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    BindTransportException bindTransportException = expectThrows(BindTransportException.class, () -> {
        MockTransportService transportService = nettyFromThreadPool(settings, threadPool, Version.CURRENT, clusterSettings, true);
        try {
            transportService.start();
        } finally {
            transportService.stop();
            transportService.close();
        }
    });
    assertEquals("Failed to bind to ["+ port + "]", bindTransportException.getMessage());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SimpleNetty4TransportTests.java

示例3: buildService

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
private MockTransportService buildService(final String name, final Version version, ClusterSettings clusterSettings,
                                          Settings settings, boolean acceptRequests, boolean doHandshake) {
    MockTransportService service = build(
        Settings.builder()
            .put(settings)
            .put(Node.NODE_NAME_SETTING.getKey(), name)
            .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "")
            .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING")
            .build(),
        version,
        clusterSettings, doHandshake);
    if (acceptRequests) {
        service.acceptIncomingRequests();
    }
    return service;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AbstractSimpleTransportTestCase.java

示例4: createClusterService

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
public static ClusterService createClusterService(Settings settings, ThreadPool threadPool, DiscoveryNode localNode) {
    ClusterService clusterService = new ClusterService(
        Settings.builder().put("cluster.name", "ClusterServiceTests").put(settings).build(),
            new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
            threadPool, () -> localNode);
    clusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {
        @Override
        public void connectToNodes(DiscoveryNodes discoveryNodes) {
            // skip
        }

        @Override
        public void disconnectFromNodesExcept(DiscoveryNodes nodesToKeep) {
            // skip
        }
    });
    clusterService.setClusterStatePublisher((event, ackListener) -> {
    });
    clusterService.setDiscoverySettings(new DiscoverySettings(Settings.EMPTY,
        new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
    clusterService.start();
    final DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterService.state().nodes());
    nodes.masterNodeId(clusterService.localNode().getId());
    setState(clusterService, ClusterState.builder(clusterService.state()).nodes(nodes));
    return clusterService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ClusterServiceUtils.java

示例5: build

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
@Override
protected MockTransportService build(Settings settings, Version version, ClusterSettings clusterSettings, boolean doHandshake) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
        new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(settings, Collections.emptyList()), version) {
        @Override
        protected Version executeHandshake(DiscoveryNode node, MockChannel mockChannel, TimeValue timeout) throws IOException,
            InterruptedException {
            if (doHandshake) {
                return super.executeHandshake(node, mockChannel, timeout);
            } else {
                return version.minimumCompatibilityVersion();
            }
        }
    };
    MockTransportService mockTransportService =
        MockTransportService.createNewService(Settings.EMPTY, transport, version, threadPool, clusterSettings);
    mockTransportService.start();
    return mockTransportService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:MockTcpTransportTests.java

示例6: createAllocationDeciders

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
/** Return a new {@link AllocationDecider} instance with builtin deciders as well as those from plugins. */
public static Collection<AllocationDecider> createAllocationDeciders(Settings settings, ClusterSettings clusterSettings,
                                                                     List<ClusterPlugin> clusterPlugins) {
    // collect deciders by class so that we can detect duplicates
    Map<Class, AllocationDecider> deciders = new LinkedHashMap<>();
    addAllocationDecider(deciders, new MaxRetryAllocationDecider(settings));
    addAllocationDecider(deciders, new ReplicaAfterPrimaryActiveAllocationDecider(settings));
    addAllocationDecider(deciders, new RebalanceOnlyWhenActiveAllocationDecider(settings));
    addAllocationDecider(deciders, new ClusterRebalanceAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new ConcurrentRebalanceAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new EnableAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new NodeVersionAllocationDecider(settings));
    addAllocationDecider(deciders, new SnapshotInProgressAllocationDecider(settings));
    addAllocationDecider(deciders, new FilterAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new SameShardAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new DiskThresholdDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new ThrottlingAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new ShardsLimitAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new AwarenessAllocationDecider(settings, clusterSettings));

    clusterPlugins.stream()
        .flatMap(p -> p.createAllocationDeciders(settings, clusterSettings).stream())
        .forEach(d -> addAllocationDecider(deciders, d));

    return deciders.values();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ClusterModule.java

示例7: createShardsAllocator

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
private static ShardsAllocator createShardsAllocator(Settings settings, ClusterSettings clusterSettings,
                                                     List<ClusterPlugin> clusterPlugins) {
    Map<String, Supplier<ShardsAllocator>> allocators = new HashMap<>();
    allocators.put(BALANCED_ALLOCATOR, () -> new BalancedShardsAllocator(settings, clusterSettings));

    for (ClusterPlugin plugin : clusterPlugins) {
        plugin.getShardsAllocators(settings, clusterSettings).forEach((k, v) -> {
            if (allocators.put(k, v) != null) {
                throw new IllegalArgumentException("ShardsAllocator [" + k + "] already defined");
            }
        });
    }
    String allocatorName = SHARDS_ALLOCATOR_TYPE_SETTING.get(settings);
    Supplier<ShardsAllocator> allocatorSupplier = allocators.get(allocatorName);
    if (allocatorSupplier == null) {
        throw new IllegalArgumentException("Unknown ShardsAllocator [" + allocatorName + "]");
    }
    return Objects.requireNonNull(allocatorSupplier.get(),
        "ShardsAllocator factory for [" + allocatorName + "] returned null");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ClusterModule.java

示例8: InternalClusterInfoService

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
public InternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client) {
    super(settings);
    this.leastAvailableSpaceUsages = ImmutableOpenMap.of();
    this.mostAvailableSpaceUsages = ImmutableOpenMap.of();
    this.shardRoutingToDataPath = ImmutableOpenMap.of();
    this.shardSizes = ImmutableOpenMap.of();
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.client = client;
    this.updateFrequency = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings);
    this.fetchTimeout = INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING.get(settings);
    this.enabled = DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
    ClusterSettings clusterSettings = clusterService.getClusterSettings();
    clusterSettings.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, this::setFetchTimeout);
    clusterSettings.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING, this::setUpdateFrequency);
    clusterSettings.addSettingsUpdateConsumer(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);

    // Add InternalClusterInfoService to listen for Master changes
    this.clusterService.addLocalNodeMasterListener(this);
    // Add to listen for state changes (when nodes are added)
    this.clusterService.addListener(this);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:InternalClusterInfoService.java

示例9: ThrottlingAllocationDecider

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
public ThrottlingAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
    super(settings);
    this.primariesInitialRecoveries = CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING.get(settings);
    concurrentIncomingRecoveries = CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_INCOMING_RECOVERIES_SETTING.get(settings);
    concurrentOutgoingRecoveries = CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.get(settings);

    clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING,
            this::setPrimariesInitialRecoveries);
    clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_INCOMING_RECOVERIES_SETTING,
            this::setConcurrentIncomingRecoverries);
    clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING,
            this::setConcurrentOutgoingRecoverries);

    logger.debug("using node_concurrent_outgoing_recoveries [{}], node_concurrent_incoming_recoveries [{}], " +
                    "node_initial_primaries_recoveries [{}]",
            concurrentOutgoingRecoveries, concurrentIncomingRecoveries, primariesInitialRecoveries);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ThrottlingAllocationDecider.java

示例10: ClusterService

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的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

示例11: buildPublishClusterStateAction

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
private static MockPublishAction buildPublishClusterStateAction(
        Settings settings,
        MockTransportService transportService,
        Supplier<ClusterState> clusterStateSupplier,
        PublishClusterStateAction.NewPendingClusterStateListener listener
) {
    DiscoverySettings discoverySettings =
            new DiscoverySettings(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
    return new MockPublishAction(
            settings,
            transportService,
            namedWriteableRegistry,
            clusterStateSupplier,
            listener,
            discoverySettings,
            CLUSTER_NAME);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:PublishClusterStateActionTests.java

示例12: setUp

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    Settings settings = Settings.builder()
            .put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false)
            .build();
    clusterService = createClusterService(threadPool);
    Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
            new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()),
            new NetworkService(settings, Collections.emptyList()));
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool,
        TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    ShardStateAction shardStateAction = new ShardStateAction(settings, clusterService, transportService, null, null, threadPool);
    ActionFilters actionFilters = new ActionFilters(Collections.emptySet());
    IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
    AutoCreateIndex autoCreateIndex = new AutoCreateIndex(settings, new ClusterSettings(settings,
            ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), indexNameExpressionResolver);
    UpdateHelper updateHelper = new UpdateHelper(settings, null);
    TransportShardBulkAction shardBulkAction = new TransportShardBulkAction(settings, transportService, clusterService,
            indicesService, threadPool, shardStateAction, null, updateHelper, actionFilters, indexNameExpressionResolver);
    transportBulkAction = new TransportBulkAction(settings, threadPool, transportService, clusterService,
            null, shardBulkAction, null, actionFilters, indexNameExpressionResolver, autoCreateIndex, System::currentTimeMillis);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:DynamicMappingDisabledTests.java

示例13: setup

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
@Before
public void setup() {
    Settings settings = Settings.EMPTY;
    circuitBreakerService = new HierarchyCircuitBreakerService(
        Settings.builder()
            .put(HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), BREAKER_LIMIT)
            .build(),
        new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
    // we can do this here only because we know that we don't adjust breaker settings dynamically in the test
    inFlightRequestsBreaker = circuitBreakerService.getBreaker(CircuitBreaker.IN_FLIGHT_REQUESTS);

    HttpServerTransport httpServerTransport = new TestHttpServerTransport();
    restController = new RestController(settings, Collections.emptySet(), null, null, circuitBreakerService);
    restController.registerHandler(RestRequest.Method.GET, "/",
        (request, channel, client) -> channel.sendResponse(
            new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY)));
    restController.registerHandler(RestRequest.Method.GET, "/error", (request, channel, client) -> {
        throw new IllegalArgumentException("test error");
    });

    httpServerTransport.start();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:RestControllerTests.java

示例14: testAllocationDeciderOrder

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
public void testAllocationDeciderOrder() {
    List<Class<? extends AllocationDecider>> expectedDeciders = Arrays.asList(
        MaxRetryAllocationDecider.class,
        ReplicaAfterPrimaryActiveAllocationDecider.class,
        RebalanceOnlyWhenActiveAllocationDecider.class,
        ClusterRebalanceAllocationDecider.class,
        ConcurrentRebalanceAllocationDecider.class,
        EnableAllocationDecider.class,
        NodeVersionAllocationDecider.class,
        SnapshotInProgressAllocationDecider.class,
        FilterAllocationDecider.class,
        SameShardAllocationDecider.class,
        DiskThresholdDecider.class,
        ThrottlingAllocationDecider.class,
        ShardsLimitAllocationDecider.class,
        AwarenessAllocationDecider.class);
    Collection<AllocationDecider> deciders = ClusterModule.createAllocationDeciders(Settings.EMPTY,
        new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), Collections.emptyList());
    Iterator<AllocationDecider> iter = deciders.iterator();
    int idx = 0;
    while (iter.hasNext()) {
        AllocationDecider decider = iter.next();
        assertSame(decider.getClass(), expectedDeciders.get(idx++));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:ClusterModuleTests.java

示例15: testUpdate

import org.elasticsearch.common.settings.ClusterSettings; //导入依赖的package包/类
public void testUpdate() {
    ClusterSettings nss = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    DiskThresholdSettings diskThresholdSettings = new DiskThresholdSettings(Settings.EMPTY, nss);

    Settings newSettings = Settings.builder()
        .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), false)
        .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), false)
        .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "70%")
        .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "500mb")
        .put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.getKey(), "30s")
        .build();
    nss.applySettings(newSettings);

    assertEquals(ByteSizeValue.parseBytesSizeValue("0b", "test"), diskThresholdSettings.getFreeBytesThresholdHigh());
    assertEquals(30.0D, diskThresholdSettings.getFreeDiskThresholdHigh(), 0.0D);
    assertEquals(ByteSizeValue.parseBytesSizeValue("500mb", "test"), diskThresholdSettings.getFreeBytesThresholdLow());
    assertEquals(0.0D, diskThresholdSettings.getFreeDiskThresholdLow(), 0.0D);
    assertEquals(30L, diskThresholdSettings.getRerouteInterval().seconds());
    assertFalse(diskThresholdSettings.isEnabled());
    assertFalse(diskThresholdSettings.includeRelocations());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:DiskThresholdSettingsTests.java


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