org.elasticsearch.common.settings.Settings.getAsArray()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中org.elasticsearch.common.settings.Settings.getAsArray()方法的一些代码示例,展示了Settings.getAsArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getAsArray()方法的具体详情如下:
包路径:org.elasticsearch.common.settings.Settings
类名称:Settings
方法名:getAsArray

Settings.getAsArray介绍

[英]The values associated with a setting prefix as an array. The settings array is in the format of: settingPrefix.[index].

It will also automatically load a comma separated list under the settingPrefix and merge with the numbered format.
[中]与设置前缀关联的值作为数组。设置数组的格式为:settingPrefix。[索引]。
它还会自动在settingPrefix下加载一个逗号分隔的列表,并与编号格式合并。

代码示例

代码示例来源:origin: harbby/presto-connectors

/**
 * The values associated with a setting prefix as an array. The settings array is in the format of:
 * <tt>settingPrefix.[index]</tt>.
 * <p>
 * It will also automatically load a comma separated list under the settingPrefix and merge with
 * the numbered format.
 *
 * @param settingPrefix The setting prefix to load the array by
 * @return The setting array values
 */
public String[] getAsArray(String settingPrefix) throws SettingsException {
  return getAsArray(settingPrefix, Strings.EMPTY_ARRAY, true);
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * The values associated with a setting prefix as an array. The settings array is in the format of:
 * <tt>settingPrefix.[index]</tt>.
 * <p>
 * It will also automatically load a comma separated list under the settingPrefix and merge with
 * the numbered format.
 *
 * @param settingPrefix The setting prefix to load the array by
 * @return The setting array values
 */
public String[] getAsArray(String settingPrefix) throws SettingsException {
  return getAsArray(settingPrefix, Strings.EMPTY_ARRAY, true);
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * The values associated with a setting prefix as an array. The settings array is in the format of:
 * <tt>settingPrefix.[index]</tt>.
 * <p>
 * If commaDelimited is true, it will automatically load a comma separated list under the settingPrefix and merge with
 * the numbered format.
 *
 * @param settingPrefix The setting prefix to load the array by
 * @return The setting array values
 */
public String[] getAsArray(String settingPrefix, String[] defaultArray) throws SettingsException {
  return getAsArray(settingPrefix, defaultArray, true);
}

代码示例来源:origin: com.floragunn/search-guard

public RestActionFilter(final SearchGuardService service, final String filterType, final String filterName,
    final AuditListener auditListener) {
  super(service, filterType, filterName, auditListener);
  allowedActions = Arrays.asList(settings.getAsArray("searchguard." + filterType + "." + filterName + ".allowed_actions",
      new String[0]));
  forbiddenActions = Arrays.asList(settings.getAsArray("searchguard." + filterType + "." + filterName + ".forbidden_actions",
      new String[0]));
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public KeepTypesFilterFactory(IndexSettings indexSettings,
               Environment env, String name, Settings settings) {
  super(indexSettings, name, settings);
  final String[] arrayKeepTypes = settings.getAsArray(KEEP_TYPES_KEY, null);
  if ((arrayKeepTypes == null)) {
    throw new IllegalArgumentException("keep_types requires `" + KEEP_TYPES_KEY + "` to be configured");
  }
  this.keepTypes = new HashSet<>(Arrays.asList(arrayKeepTypes));
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public PatternCaptureGroupTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
  super(indexSettings, name, settings);
  String[] regexes = settings.getAsArray(PATTERNS_KEY, null, false);
  if (regexes == null) {
    throw new IllegalArgumentException("required setting '" + PATTERNS_KEY + "' is missing for token filter [" + name + "]");
  }
  patterns = new Pattern[regexes.length];
  for (int i = 0; i < regexes.length; i++) {
    patterns[i] = Pattern.compile(regexes[i]);
  }
  preserveOriginal = settings.getAsBoolean(PRESERVE_ORIG_KEY, true);
}

代码示例来源:origin: harbby/presto-connectors

public PatternCaptureGroupTokenFilterFactory(Index index, Settings indexSettings, String name, Settings settings) {
  super(index, indexSettings, name, settings);
  String[] regexes = settings.getAsArray(PATTERNS_KEY, null, false);
  if (regexes == null) {
    throw new IllegalArgumentException("required setting '" + PATTERNS_KEY + "' is missing for token filter [" + name + "]");
  }
  patterns = new Pattern[regexes.length];
  for (int i = 0; i < regexes.length; i++) {
    patterns[i] = Pattern.compile(regexes[i]);
  }
  preserveOriginal = settings.getAsBoolean(PRESERVE_ORIG_KEY, true);
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

private void setForcedAwarenessAttributes(Settings forceSettings) {
  Map<String, String[]> forcedAwarenessAttributes = new HashMap<>();
  Map<String, Settings> forceGroups = forceSettings.getAsGroups();
  for (Map.Entry<String, Settings> entry : forceGroups.entrySet()) {
    String[] aValues = entry.getValue().getAsArray("values");
    if (aValues.length > 0) {
      forcedAwarenessAttributes.put(entry.getKey(), aValues);
    }
  }
  this.forcedAwarenessAttributes = forcedAwarenessAttributes;
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public HtmlStripCharFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
  super(indexSettings, name);
  String[] escapedTags = settings.getAsArray("escaped_tags");
  if (escapedTags.length > 0) {
    this.escapedTags = unmodifiableSet(newHashSet(escapedTags));
  } else {
    this.escapedTags = null;
  }
}

代码示例来源:origin: elasticfence/elasticsearch-http-user-auth

private String[] getSettingArray(String key, String[] defaultValue) throws Exception {
  Settings s = settings.getByPrefix(ElasticfenceSettings.SETTINGS_PREFIX);
  String[] value = s.getAsArray(key, defaultValue);
  if (value == null || value.length == 0) {
    EFLogger.warn(key + " is not defined in settings, setting default value of " +  Arrays.toString(defaultValue));
    return defaultValue;
  }
  //EFLogger.info(key + ": " + Arrays.toString(value));
  return value;
}

代码示例来源:origin: harbby/presto-connectors

@Inject
public TransportService(Settings settings, Transport transport, ThreadPool threadPool) {
  super(settings);
  this.transport = transport;
  this.threadPool = threadPool;
  this.tracerLogInclude = settings.getAsArray(SETTING_TRACE_LOG_INCLUDE, Strings.EMPTY_ARRAY, true);
  this.tracelLogExclude = settings.getAsArray(SETTING_TRACE_LOG_EXCLUDE, new String[]{"internal:discovery/zen/fd*", TransportLivenessAction.NAME}, true);
  tracerLog = Loggers.getLogger(logger, ".tracer");
  adapter = createAdapter();
  taskManager = createTaskManager();
}

代码示例来源:origin: harbby/presto-connectors

@Inject
public KeepTypesFilterFactory(Index index, IndexSettingsService indexSettingsService,
               Environment env, @Assisted String name, @Assisted Settings settings) {
  super(index, indexSettingsService.getSettings(), name, settings);
  final String[] arrayKeepTypes = settings.getAsArray(KEEP_TYPES_KEY, null);
  if ((arrayKeepTypes == null)) {
    throw new IllegalArgumentException("keep_types requires `" + KEEP_TYPES_KEY + "` to be configured");
  }
  this.keepTypes = new HashSet<>(Arrays.asList(arrayKeepTypes));
}

代码示例来源:origin: com.floragunn/search-guard

@Override
  public void fillRoles(final User user, final AuthCredentials optionalAuthCreds) throws AuthException {

    final String[] roles = settings.getAsArray(ConfigConstants.SEARCHGUARD_AUTHENTICATION_AUTHORIZATION_SETTINGSDB_ROLES
        + user.getName());

    if (optionalAuthCreds != null) {
      optionalAuthCreds.clear();
    }

    if (roles != null) {
      user.addRoles(Arrays.asList(roles));
    }
  }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public EdgeNGramTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
  super(indexSettings, name, settings);
  this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
  this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
  this.matcher = parseTokenChars(settings.getAsArray("token_chars"));
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public NGramTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
  super(indexSettings, name, settings);
  this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
  this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
  this.matcher = parseTokenChars(settings.getAsArray("token_chars"));
}

代码示例来源:origin: io.fabric8.insight/insight-elasticsearch-auth-plugin

@Inject
public HttpBasicServer(Settings settings, Environment environment, HttpServerTransport transport,
    RestController restController,
    NodeService nodeService) {
  super(settings, environment, transport, restController, nodeService);
  this.realm = settings.get("http.basic.realm", "karaf");
  this.roles = settings.getAsArray("http.basic.roles", new String[]{"admin", "manager", "viewer", "Monitor", "Operator", "Maintainer", "Deployer", "Auditor", "Administrator", "SuperUser"});
  this.log = settings.getAsBoolean("http.basic.log", false);
  Loggers.getLogger(getClass()).info("using realm: [{}] and authorized roles: [{}]",
      realm, roles);
}

代码示例来源:origin: jboss-fuse/fabric8

@Inject
public HttpBasicServer(Settings settings, Environment environment, HttpServerTransport transport,
    RestController restController,
    NodeService nodeService) {
  super(settings, environment, transport, restController, nodeService);
  this.realm = settings.get("http.basic.realm", "karaf");
  this.roles = settings.getAsArray("http.basic.roles", new String[]{"admin", "manager", "viewer", "Monitor", "Operator", "Maintainer", "Deployer", "Auditor", "Administrator", "SuperUser"});
  this.log = settings.getAsBoolean("http.basic.log", false);
  Loggers.getLogger(getClass()).info("using realm: [{}] and authorized roles: [{}]",
      realm, roles);
}

代码示例来源:origin: harbby/presto-connectors

NGramTokenizerFactory(Index index, Settings indexSettings, String name, Settings settings) {
  super(index, indexSettings, name, settings);
  this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
  this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
  this.matcher = parseTokenChars(settings.getAsArray("token_chars"));
  this.esVersion = org.elasticsearch.Version.indexCreated(indexSettings);
}

代码示例来源:origin: harbby/presto-connectors

@Inject
public HtmlStripCharFilterFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {
  super(index, indexSettingsService.getSettings(), name);
  String[] escapedTags = settings.getAsArray("escaped_tags");
  if (escapedTags.length > 0) {
    this.escapedTags = ImmutableSet.copyOf(escapedTags);
  } else {
    this.escapedTags = null;
  }
}

代码示例来源:origin: harbby/presto-connectors

public EdgeNGramTokenizerFactory(Index index, Settings indexSettings, String name, Settings settings) {
  super(index, indexSettings, name, settings);
  this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
  this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
  this.side = Lucene43EdgeNGramTokenizer.Side.getSide(settings.get("side", Lucene43EdgeNGramTokenizer.DEFAULT_SIDE.getLabel()));
  this.matcher = parseTokenChars(settings.getAsArray("token_chars"));
  this.esVersion = org.elasticsearch.Version.indexCreated(indexSettings);
}

相关文章