org.elasticsearch.client.IndicesAdminClient.resizeIndex()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(107)

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

IndicesAdminClient.resizeIndex介绍

[英]Resize an index using an explicit request allowing to specify the settings, mappings and aliases of the target index of the index.
[中]使用显式请求调整索引大小,允许指定索引的目标索引的设置、映射和别名。

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public final RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
  final ResizeRequest resizeRequest = new ResizeRequest(request.param("target"), request.param("index"));
  resizeRequest.setResizeType(getResizeType());
  final String rawCopySettings = request.param("copy_settings");
  final Boolean copySettings;
  if (rawCopySettings == null) {
    copySettings = resizeRequest.getCopySettings();
  } else if (rawCopySettings.isEmpty()) {
    copySettings = true;
  } else {
    copySettings = Booleans.parseBoolean(rawCopySettings);
    if (copySettings == false) {
      throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]");
    }
  }
  if (copySettings == null) {
    deprecationLogger.deprecated(
        "resize operations without copying settings is deprecated; "
            + "set parameter [copy_settings] to [true] for future default behavior");
  }
  resizeRequest.setCopySettings(copySettings);
  request.applyContentParser(resizeRequest::fromXContent);
  resizeRequest.timeout(request.paramAsTime("timeout", resizeRequest.timeout()));
  resizeRequest.masterNodeTimeout(request.paramAsTime("master_timeout", resizeRequest.masterNodeTimeout()));
  resizeRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
  return channel -> client.admin().indices().resizeIndex(resizeRequest, new RestToXContentListener<>(channel));
}

代码示例来源:origin: apache/servicemix-bundles

@Override
  public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    if (request.param("target") == null) {
      throw new IllegalArgumentException("no target index");
    }
    if (request.param("index") == null) {
      throw new IllegalArgumentException("no source index");
    }
    ResizeRequest shrinkIndexRequest = new ResizeRequest(request.param("target"), request.param("index"));
    shrinkIndexRequest.setResizeType(ResizeType.SHRINK);
    request.applyContentParser(parser -> ResizeRequest.PARSER.parse(parser, shrinkIndexRequest, null));
    shrinkIndexRequest.timeout(request.paramAsTime("timeout", shrinkIndexRequest.timeout()));
    shrinkIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", shrinkIndexRequest.masterNodeTimeout()));
    shrinkIndexRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
    return channel -> client.admin().indices().resizeIndex(shrinkIndexRequest, new AcknowledgedRestListener<ResizeResponse>(channel) {
      @Override
      public void addCustomFields(XContentBuilder builder, ResizeResponse response) throws IOException {
        response.addCustomFields(builder);
      }
    });
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
  public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    if (request.param("target") == null) {
      throw new IllegalArgumentException("no target index");
    }
    if (request.param("index") == null) {
      throw new IllegalArgumentException("no source index");
    }
    ResizeRequest shrinkIndexRequest = new ResizeRequest(request.param("target"), request.param("index"));
    shrinkIndexRequest.setResizeType(ResizeType.SPLIT);
    request.applyContentParser(parser -> ResizeRequest.PARSER.parse(parser, shrinkIndexRequest, null));
    shrinkIndexRequest.timeout(request.paramAsTime("timeout", shrinkIndexRequest.timeout()));
    shrinkIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", shrinkIndexRequest.masterNodeTimeout()));
    shrinkIndexRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
    return channel -> client.admin().indices().resizeIndex(shrinkIndexRequest, new AcknowledgedRestListener<ResizeResponse>(channel) {
      @Override
      public void addCustomFields(XContentBuilder builder, ResizeResponse response) throws IOException {
        response.addCustomFields(builder);
      }
    });
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public final RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
  final ResizeRequest resizeRequest = new ResizeRequest(request.param("target"), request.param("index"));
  resizeRequest.setResizeType(getResizeType());
  final String rawCopySettings = request.param("copy_settings");
  final Boolean copySettings;
  if (rawCopySettings == null) {
    copySettings = resizeRequest.getCopySettings();
  } else if (rawCopySettings.isEmpty()) {
    copySettings = true;
  } else {
    copySettings = Booleans.parseBoolean(rawCopySettings);
    if (copySettings == false) {
      throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]");
    }
  }
  if (copySettings == null) {
    deprecationLogger.deprecated(
        "resize operations without copying settings is deprecated; "
            + "set parameter [copy_settings] to [true] for future default behavior");
  }
  resizeRequest.setCopySettings(copySettings);
  request.applyContentParser(resizeRequest::fromXContent);
  resizeRequest.timeout(request.paramAsTime("timeout", resizeRequest.timeout()));
  resizeRequest.masterNodeTimeout(request.paramAsTime("master_timeout", resizeRequest.masterNodeTimeout()));
  resizeRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
  return channel -> client.admin().indices().resizeIndex(resizeRequest, new RestToXContentListener<>(channel));
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public final RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
  final ResizeRequest resizeRequest = new ResizeRequest(request.param("target"), request.param("index"));
  resizeRequest.setResizeType(getResizeType());
  final String rawCopySettings = request.param("copy_settings");
  final Boolean copySettings;
  if (rawCopySettings == null) {
    copySettings = resizeRequest.getCopySettings();
  } else if (rawCopySettings.isEmpty()) {
    copySettings = true;
  } else {
    copySettings = Booleans.parseBoolean(rawCopySettings);
    if (copySettings == false) {
      throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]");
    }
  }
  if (copySettings == null) {
    deprecationLogger.deprecated(
        "resize operations without copying settings is deprecated; "
            + "set parameter [copy_settings] to [true] for future default behavior");
  }
  resizeRequest.setCopySettings(copySettings);
  request.applyContentParser(resizeRequest::fromXContent);
  resizeRequest.timeout(request.paramAsTime("timeout", resizeRequest.timeout()));
  resizeRequest.masterNodeTimeout(request.paramAsTime("master_timeout", resizeRequest.masterNodeTimeout()));
  resizeRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
  return channel -> client.admin().indices().resizeIndex(resizeRequest, new RestToXContentListener<>(channel));
}

相关文章

微信公众号

最新文章

更多

IndicesAdminClient类方法