本文整理匯總了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();
}
示例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);
}
示例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));
}
示例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);
}
}
示例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();
}
示例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);
}
示例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)));
}
示例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 + "]"));
}
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}