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


Java ClusterSettings.BUILT_IN_CLUSTER_SETTINGS属性代码示例

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


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

示例1: createClusterService

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,代码行数:26,代码来源:ClusterServiceUtils.java

示例2: setUp

@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,代码行数:24,代码来源:DynamicMappingDisabledTests.java

示例3: setup

@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,代码行数:22,代码来源:RestControllerTests.java

示例4: testUpdate

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,代码行数:21,代码来源:DiskThresholdSettingsTests.java

示例5: testUpdate

public void testUpdate() {
    boolean value = randomBoolean();
    Settings settings;
    if (value && randomBoolean()) {
        settings = Settings.EMPTY;
    } else {
        settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), value).build();
    }

    ClusterSettings clusterSettings = new ClusterSettings(settings,
            ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    AutoCreateIndex  autoCreateIndex = new AutoCreateIndex(settings, clusterSettings, new IndexNameExpressionResolver(settings));
    assertThat(autoCreateIndex.getAutoCreate().isAutoCreateIndex(), equalTo(value));

    Settings newSettings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), !value).build();
    clusterSettings.applySettings(newSettings);
    assertThat(autoCreateIndex.getAutoCreate().isAutoCreateIndex(), equalTo(!value));

    newSettings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), "logs-*").build();
    clusterSettings.applySettings(newSettings);
    assertThat(autoCreateIndex.getAutoCreate().isAutoCreateIndex(), equalTo(true));
    assertThat(autoCreateIndex.getAutoCreate().getExpressions().size(), equalTo(1));
    assertThat(autoCreateIndex.getAutoCreate().getExpressions().get(0).v1(), equalTo("logs-*"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:AutoCreateIndexTests.java

示例6: testMaxSizeExceededOnNew

public void testMaxSizeExceededOnNew() throws Exception {
    final int size = scaledRandomIntBetween(5, 1 << 22);
    for (String type : Arrays.asList("Byte", "Int", "Long", "Float", "Double", "Object")) {
        HierarchyCircuitBreakerService hcbs = new HierarchyCircuitBreakerService(
                Settings.builder()
                        .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), size - 1, ByteSizeUnit.BYTES)
                        .build(),
                new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
        BigArrays bigArrays = new BigArrays(null, hcbs, false).withCircuitBreaking();
        Method create = BigArrays.class.getMethod("new" + type + "Array", long.class);
        try {
            create.invoke(bigArrays, size);
            fail("expected an exception on " + create);
        } catch (InvocationTargetException e) {
            assertTrue(e.getCause() instanceof CircuitBreakingException);
        }
        assertEquals(0, hcbs.getBreaker(CircuitBreaker.REQUEST).getUsed());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:BigArraysTests.java

示例7: runScalingThreadPoolTest

public void runScalingThreadPoolTest(
        final Settings settings,
        final BiConsumer<ClusterSettings, ThreadPool> consumer) throws InterruptedException {
    ThreadPool threadPool = null;
    try {
        final String test = Thread.currentThread().getStackTrace()[2].getMethodName();
        final Settings nodeSettings = Settings.builder().put(settings).put("node.name", test).build();
        threadPool = new ThreadPool(nodeSettings);
        final ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
        consumer.accept(clusterSettings, threadPool);
    } finally {
        terminateThreadPoolIfNeeded(threadPool);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:ScalingThreadPoolTests.java

示例8: testMaxSizeExceededOnResize

public void testMaxSizeExceededOnResize() throws Exception {
    for (String type : Arrays.asList("Byte", "Int", "Long", "Float", "Double", "Object")) {
        final long maxSize = randomIntBetween(1 << 10, 1 << 22);
        HierarchyCircuitBreakerService hcbs = new HierarchyCircuitBreakerService(
                Settings.builder()
                        .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), maxSize, ByteSizeUnit.BYTES)
                        .build(),
                new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
        BigArrays bigArrays = new BigArrays(null, hcbs, false).withCircuitBreaking();
        Method create = BigArrays.class.getMethod("new" + type + "Array", long.class);
        final int size = scaledRandomIntBetween(1, 20);
        BigArray array = (BigArray) create.invoke(bigArrays, size);
        Method resize = BigArrays.class.getMethod("resize", array.getClass().getInterfaces()[0], long.class);
        while (true) {
            long newSize = array.size() * 2;
            try {
                array = (BigArray) resize.invoke(bigArrays, array, newSize);
            } catch (InvocationTargetException e) {
                assertTrue(e.getCause() instanceof CircuitBreakingException);
                break;
            }
        }
        assertEquals(array.ramBytesUsed(), hcbs.getBreaker(CircuitBreaker.REQUEST).getUsed());
        array.close();
        assertEquals(0, hcbs.getBreaker(CircuitBreaker.REQUEST).getUsed());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:BigArraysTests.java

示例9: setupDummyServices

@Before
public void setupDummyServices() {
    transportService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, null, null);
    clusterService = mock(ClusterService.class);
    namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
    threadPool = mock(ThreadPool.class);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:DiscoveryModuleTests.java

示例10: createService

private GatewayService createService(Settings.Builder settings) {
    ClusterService clusterService = new ClusterService(Settings.builder().put("cluster.name", "GatewayServiceTests").build(),
            new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
            null, () -> new DiscoveryNode(UUIDs.randomBase64UUID(), buildNewFakeTransportAddress(), Version.CURRENT));
    return new GatewayService(settings.build(),
            null, clusterService, null, null, null, new NoopDiscovery(), null);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:GatewayServiceTests.java

示例11: testBackwardCompatibility

public void testBackwardCompatibility() throws Exception {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(RoutingBackwardCompatibilityTests.class
        .getResourceAsStream("/org/elasticsearch/cluster/routing/shard_routes.txt"), "UTF-8"))) {
        for (String line = reader.readLine(); line != null; line = reader.readLine()) {
            if (line.startsWith("#")) { // comment
                continue;
            }
            String[] parts = line.split("\t");
            assertEquals(Arrays.toString(parts), 7, parts.length);
            final String index = parts[0];
            final int numberOfShards = Integer.parseInt(parts[1]);
            final String type = parts[2];
            final String id = parts[3];
            final String routing = "null".equals(parts[4]) ? null : parts[4];
            final int pre20ExpectedShardId = Integer.parseInt(parts[5]); // not needed anymore - old hashing is gone
            final int currentExpectedShard = Integer.parseInt(parts[6]);

            OperationRouting operationRouting = new OperationRouting(Settings.EMPTY, new ClusterSettings(Settings.EMPTY,
                ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
            for (Version version : VersionUtils.allReleasedVersions()) {
                if (version.onOrAfter(Version.V_2_0_0) == false) {
                    // unsupported version, no need to test
                    continue;
                }
                final Settings settings = settings(version).build();
                IndexMetaData indexMetaData = IndexMetaData.builder(index).settings(settings).numberOfShards(numberOfShards)
                    .numberOfReplicas(randomInt(3)).build();
                MetaData.Builder metaData = MetaData.builder().put(indexMetaData, false);
                RoutingTable routingTable = RoutingTable.builder().addAsNew(indexMetaData).build();
                ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
                    .metaData(metaData).routingTable(routingTable).build();
                final int shardId = operationRouting.indexShards(clusterState, index, id, routing).shardId().getId();
                assertEquals(currentExpectedShard, shardId);
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:RoutingBackwardCompatibilityTests.java

示例12: testPersistedSettings

public void testPersistedSettings() {
    Settings.Builder settings = Settings.builder();
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
    ClusterSettings service = new ClusterSettings(Settings.builder().build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    BalancedShardsAllocator allocator = new BalancedShardsAllocator(settings.build(), service);
    assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f));
    assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
    assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f));

    settings = Settings.builder();
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
    settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
    service.applySettings(settings.build());
    assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f));
    assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
    assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f));

    settings = Settings.builder();
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.5);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.1);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 3.0);
    service.applySettings(settings.build());
    assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.5f));
    assertThat(allocator.getShardBalance(), Matchers.equalTo(0.1f));
    assertThat(allocator.getThreshold(), Matchers.equalTo(3.0f));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:BalanceConfigurationTests.java

示例13: testDefaults

public void testDefaults() {
    ClusterSettings nss = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    DiskThresholdSettings diskThresholdSettings = new DiskThresholdSettings(Settings.EMPTY, nss);

    ByteSizeValue zeroBytes = ByteSizeValue.parseBytesSizeValue("0b", "test");
    assertEquals(zeroBytes, diskThresholdSettings.getFreeBytesThresholdHigh());
    assertEquals(10.0D, diskThresholdSettings.getFreeDiskThresholdHigh(), 0.0D);
    assertEquals(zeroBytes, diskThresholdSettings.getFreeBytesThresholdLow());
    assertEquals(15.0D, diskThresholdSettings.getFreeDiskThresholdLow(), 0.0D);
    assertEquals(60L, diskThresholdSettings.getRerouteInterval().seconds());
    assertTrue(diskThresholdSettings.isEnabled());
    assertTrue(diskThresholdSettings.includeRelocations());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:DiskThresholdSettingsTests.java

示例14: BalancedShardsAllocator

public BalancedShardsAllocator(Settings settings) {
    this(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:3,代码来源:BalancedShardsAllocator.java

示例15: newAutoCreateIndex

private AutoCreateIndex newAutoCreateIndex(Settings settings) {
    return new AutoCreateIndex(settings, new ClusterSettings(settings,
            ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), new IndexNameExpressionResolver(settings));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:AutoCreateIndexTests.java


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