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


Java Settings.Builder方法代码示例

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


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

示例1: EmbeddedElasticsearchServer

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
public EmbeddedElasticsearchServer(String storagePath) {
    this.storagePath = storagePath;
    try {
        tempFile = File.createTempFile("elasticsearch", "test");
        this.storagePath = tempFile.getParent();
        tempFile.deleteOnExit();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Settings.Builder elasticsearchSettings = Settings.builder()
            .put("http.enabled", "false")
            .put("path.data", this.storagePath)
            .put("path.home", System.getProperty("user.dir"))
            .put("transport.type", "local");

    node = new Node(elasticsearchSettings.build());
    client = node.client();
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:20,代码来源:BulkProcessorObjectFactoryTest.java

示例2: testMissingSetting

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
public void testMissingSetting() throws InterruptedException {
    String collector = randomAsciiOfLength(5);
    Set<AbstractMap.SimpleEntry<String, String>> entries = new HashSet<>();
    entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".warn", randomPositiveTimeValue()));
    entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".info", randomPositiveTimeValue()));
    entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".debug", randomPositiveTimeValue()));
    Settings.Builder builder = Settings.builder();

    // drop a random setting or two
    for (@SuppressWarnings("unchecked") AbstractMap.SimpleEntry<String, String> entry : randomSubsetOf(randomIntBetween(1, 2), entries.toArray(new AbstractMap.SimpleEntry[0]))) {
        builder.put(entry.getKey(), entry.getValue());
    }

    // we should get an exception that a setting is missing
    execute(builder.build(), (command, interval, name) -> null, e -> {
        assertThat(e, instanceOf(IllegalArgumentException.class));
        assertThat(e.getMessage(), containsString("missing gc_threshold for [monitor.jvm.gc.collector." + collector + "."));
    }, true, null);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:JvmGcMonitorServiceSettingsTests.java

示例3: analyze

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
public static SetAnalyzedStatement analyze(SetStatement node, ParameterContext parameterContext) {

        // Add SQL Authentication
        // GaoPan 2016/06/16
        AuthResult authResult = AuthService.sqlAuthenticate(parameterContext.getLoginUserContext(),
                VirtualTableNames.sys.name(), VirtualTableNames.cluster.name(), PrivilegeType.READ_WRITE);
        if (authResult.getStatus() != RestStatus.OK) {
            throw new NoPermissionException(authResult.getStatus().getStatus(), authResult.getMessage());
        }

        Settings.Builder builder = Settings.builder();
        for (Assignment assignment : node.assignments()) {
            String settingsName = ExpressionToStringVisitor.convert(assignment.columnName(),
                    parameterContext.parameters());

            SettingsApplier settingsApplier = CrateSettings.getSettingsApplier(settingsName);
            for (String setting : ExpressionToSettingNameListVisitor.convert(assignment)) {
                checkIfSettingIsRuntime(setting);
            }

            settingsApplier.apply(builder, parameterContext.parameters(), assignment.expression());
        }
        return new SetAnalyzedStatement(builder.build(), node.settingType().equals(SetStatement.SettingType.PERSISTENT));
    }
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:SetStatementAnalyzer.java

示例4: testDefaultBehaviourFineGrainedSettings

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
public void testDefaultBehaviourFineGrainedSettings() throws IOException {
    Settings.Builder builder = Settings.builder();
    //rarely inject the default settings, which have no effect
    if (rarely()) {
        builder.put("script.file", "true");
    }
    buildScriptService(builder.build());
    createFileScripts("mustache", "dtest");

    for (ScriptContext scriptContext : scriptContexts) {
        // only file scripts are accepted by default
        assertCompileRejected("dtest", "script", ScriptType.INLINE, scriptContext);
        assertCompileRejected("dtest", "script", ScriptType.STORED, scriptContext);
        assertCompileAccepted("dtest", "file_script", ScriptType.FILE, scriptContext);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:ScriptServiceTests.java

示例5: addDefaultUnitsIfNeeded

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
/** As of 2.0 we require units for time and byte-sized settings.
 * This methods adds default units to any settings that are part of timeSettings or byteSettings and don't specify a unit.
 **/
@Nullable
public static Settings addDefaultUnitsIfNeeded(Set<String> timeSettings, Set<String> byteSettings, ESLogger logger, Settings settings) {
    Settings.Builder newSettingsBuilder = null;
    for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
        String settingName = entry.getKey();
        String settingValue = entry.getValue();

        String newSettingValue = convertedValue(timeSettings, settingName, settingValue, logger, "ms", "time");
        if (settingValue.equals(newSettingValue) == false) {
            newSettingsBuilder = initSettingsBuilder(settings, newSettingsBuilder);
            newSettingsBuilder.put(settingName, newSettingValue);
        }

        newSettingValue = convertedValue(byteSettings, settingName, settingValue, logger, "b", "byte-sized");
        if (settingValue.equals(newSettingValue) == false) {
            newSettingsBuilder = initSettingsBuilder(settings, newSettingsBuilder);
            newSettingsBuilder.put(settingName, newSettingValue);
        }
    }

    if (newSettingsBuilder == null) {
        return settings;
    }
    return newSettingsBuilder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:MetaData.java

示例6: testIndexBalance

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
public void testIndexBalance() {
    /* Tests balance over indices only */
    final float indexBalance = 1.0f;
    final float replicaBalance = 0.0f;
    final float balanceTreshold = 1.0f;

    Settings.Builder settings = Settings.builder();
    settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), indexBalance);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), replicaBalance);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), balanceTreshold);

    AllocationService strategy = createAllocationService(settings.build(), new NoopGatewayAllocator());

    ClusterState clusterState = initCluster(strategy);
    assertIndexBalance(clusterState.getRoutingTable(), clusterState.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);

    clusterState = addNode(clusterState, strategy);
    assertIndexBalance(clusterState.getRoutingTable(), clusterState.getRoutingNodes(), numberOfNodes + 1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);

    clusterState = removeNodes(clusterState, strategy);
    assertIndexBalance(clusterState.getRoutingTable(), clusterState.getRoutingNodes(), (numberOfNodes + 1) - (numberOfNodes + 1) / 2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:BalanceConfigurationTests.java

示例7: createIndexBasedOnFieldSettings

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
protected void createIndexBasedOnFieldSettings(String index, String alias, TestFieldSetting[] fieldSettings) throws IOException {
    XContentBuilder mappingBuilder = jsonBuilder();
    mappingBuilder.startObject().startObject("type1").startObject("properties");
    for (TestFieldSetting field : fieldSettings) {
        field.addToMappings(mappingBuilder);
    }
    mappingBuilder.endObject().endObject().endObject();
    Settings.Builder settings = Settings.builder()
            .put(indexSettings())
            .put("index.analysis.analyzer.tv_test.tokenizer", "standard")
            .putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase");
    assertAcked(prepareCreate(index).addMapping("type1", mappingBuilder).setSettings(settings).addAlias(new Alias(alias)));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:AbstractTermVectorsTestCase.java

示例8: testReplaceTextPromptPlaceholderWithNullTerminal

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
public void testReplaceTextPromptPlaceholderWithNullTerminal() {
    Settings.Builder builder = Settings.builder()
            .put(baseEnvSettings)
            .put("replace_me1", InternalSettingsPreparer.TEXT_PROMPT_VALUE);
    try {
        InternalSettingsPreparer.prepareEnvironment(builder.build(), null);
        fail("an exception should have been thrown since no terminal was provided!");
    } catch (UnsupportedOperationException e) {
        assertThat(e.getMessage(), containsString("with value [" + InternalSettingsPreparer.TEXT_PROMPT_VALUE + "]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:InternalSettingsPreparerTests.java

示例9: buildIndexSettings

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
private Settings buildIndexSettings(IndexMetaData metaData) {
    // play safe here and make sure that we take node level settings into account.
    // we might run on nodes where we use shard FS and then in the future don't delete
    // actual content.
    Settings.Builder builder = settingsBuilder();
    builder.put(settings);
    builder.put(metaData.getSettings());
    return builder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:IndicesService.java

示例10: nodeSettings

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
@Override
protected Settings nodeSettings(int nodeOrdinal) {
    Settings.Builder builder = Settings.builder()
        .put(super.nodeSettings(nodeOrdinal))
        .put("discovery.type", "azure");

    // We add a fake subscription_id to start mock compute service
    builder.put(Management.SUBSCRIPTION_ID_SETTING.getKey(), "fake")
        .put(Discovery.REFRESH_SETTING.getKey(), "5s")
        .put(Management.KEYSTORE_PATH_SETTING.getKey(), "dummy")
        .put(Management.KEYSTORE_PASSWORD_SETTING.getKey(), "dummy")
        .put(Management.SERVICE_NAME_SETTING.getKey(), "dummy");
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:AbstractAzureComputeServiceTestCase.java

示例11: initSettingsBuilder

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
private static Settings.Builder initSettingsBuilder(Settings settings, Settings.Builder newSettingsBuilder) {
    if (newSettingsBuilder == null) {
        newSettingsBuilder = Settings.builder();
        newSettingsBuilder.put(settings);
    }
    return newSettingsBuilder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:MetaData.java

示例12: setSettings

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
/**
 * The settings to created the index template with.
 */
public PutIndexTemplateRequestBuilder setSettings(Settings.Builder settings) {
    request.settings(settings);
    return this;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:PutIndexTemplateRequestBuilder.java

示例13: createMetaData

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
private static IndexMetaData createMetaData(int maxThreadCount, int maxMergeCount, int numProc) {
    Settings.Builder builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT);
    if (maxThreadCount != -1) {
        builder.put(MAX_THREAD_COUNT_SETTING.getKey(), maxThreadCount);
    }
    if (maxMergeCount != -1) {
        builder.put(MAX_MERGE_COUNT_SETTING.getKey(), maxMergeCount);
    }
    if (numProc != -1) {
        builder.put(PROCESSORS_SETTING.getKey(), numProc);
    }
    return newIndexMeta("index", builder.build());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:MergeSchedulerSettingsTests.java

示例14: newPluginService

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
private static PluginsService newPluginService(final Settings settings, Collection<Class<? extends Plugin>> plugins) {
    final Settings.Builder settingsBuilder = Settings.builder()
            .put(TcpTransport.PING_SCHEDULE.getKey(), "5s") // enable by default the transport schedule ping interval
            .put(InternalSettingsPreparer.prepareSettings(settings))
            .put(NetworkService.NETWORK_SERVER.getKey(), false)
            .put(CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE);
    return new PluginsService(settingsBuilder.build(), null, null, plugins);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportClient.java

示例15: visitTokenFilters

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
@Override
public CreateAnalyzerAnalyzedStatement visitTokenFilters(TokenFilters tokenFilters, Context context) {
    for (NamedProperties tokenFilterNode : tokenFilters.tokenFilters()) {

        String name = tokenFilterNode.ident();
        Optional<GenericProperties> properties = tokenFilterNode.properties();

        String underscoreName = Strings.toUnderscoreCase(name);
        if (!underscoreName.equalsIgnoreCase(name)) {
            deprecationLogger.deprecated("Deprecated token_filter name [{}], use [{}] instead", name, underscoreName);
        }

        // use a builtin token-filter without parameters
        if (!properties.isPresent()) {
            // validate
            if (!context.statement.analyzerService().hasBuiltInTokenFilter(name)) {
                throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Non-existing built-in token-filter '%s'", name));
            }
            // build
            context.statement.addTokenFilter(name, Settings.EMPTY);
        } else {
            // validate
            if (!context.statement.analyzerService().hasBuiltInTokenFilter(name)) {
                // type mandatory when name is not a builtin filter
                String evaluatedType = extractType(properties.get(), context.analysis.parameterContext());
                if (!context.statement.analyzerService().hasBuiltInTokenFilter(evaluatedType)) {
                    // only builtin token-filters can be extended, for now
                    throw new IllegalArgumentException(String.format(Locale.ENGLISH,
                        "Non-existing built-in token-filter type '%s'", evaluatedType));
                }
            } else {
                if (properties.get().get("type") != null) {
                    throw new IllegalArgumentException(String.format(Locale.ENGLISH,
                        "token-filter name '%s' is reserved, 'type' property forbidden here", name));
                }
            }

            // build
            // transform name as token-filter is not publicly available
            name = String.format(Locale.ENGLISH, "%s_%s", context.statement.ident(), name);
            Settings.Builder builder = Settings.builder();
            for (Map.Entry<String, Expression> tokenFilterProperty : properties.get().properties().entrySet()) {
                GenericPropertiesConverter.genericPropertyToSetting(builder,
                    context.statement.getSettingsKey("index.analysis.filter.%s.%s", name, tokenFilterProperty.getKey()),
                    tokenFilterProperty.getValue(),
                    context.analysis.parameterContext());
            }
            context.statement.addTokenFilter(name, builder.build());
        }
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:53,代码来源:CreateAnalyzerStatementAnalyzer.java


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