Github user cjolif commented on a diff in the pull request:

    https://github.com/apache/flink/pull/6391#discussion_r205051308
  
    --- Diff: 
flink-connectors/flink-connector-elasticsearch6/src/main/java/org/apache/flink/streaming/connectors/elasticsearch6/Elasticsearch6ApiCallBridge.java
 ---
    @@ -0,0 +1,109 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.streaming.connectors.elasticsearch6;
    +
    +import 
org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchApiCallBridge;
    +import 
org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchSinkBase;
    +import org.apache.flink.util.Preconditions;
    +
    +import org.apache.http.HttpHost;
    +import org.elasticsearch.action.bulk.BackoffPolicy;
    +import org.elasticsearch.action.bulk.BulkItemResponse;
    +import org.elasticsearch.action.bulk.BulkProcessor;
    +import org.elasticsearch.client.RestClient;
    +import org.elasticsearch.client.RestHighLevelClient;
    +import org.elasticsearch.common.unit.TimeValue;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import javax.annotation.Nullable;
    +
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * Implementation of {@link ElasticsearchApiCallBridge} for Elasticsearch 
6 and later versions.
    + */
    +public class Elasticsearch6ApiCallBridge implements 
ElasticsearchApiCallBridge<RestHighLevelClient> {
    +
    +   private static final long serialVersionUID = -5222683870097809633L;
    +
    +   private static final Logger LOG = 
LoggerFactory.getLogger(Elasticsearch6ApiCallBridge.class);
    +
    +   /**
    +    * User-provided HTTP Host.
    +    */
    +   private final List<HttpHost> httpHosts;
    +
    +   Elasticsearch6ApiCallBridge(List<HttpHost> httpHosts) {
    +           Preconditions.checkArgument(httpHosts != null && 
!httpHosts.isEmpty());
    +           this.httpHosts = httpHosts;
    +   }
    +
    +   @Override
    +   public RestHighLevelClient createClient(Map<String, String> 
clientConfig) {
    +           RestHighLevelClient rhlClient =
    --- End diff --
    
    might have been good to support:
    - context path / path prefix in addition to host
    - login/password for Elasticsearch instances protected
    
    that's ok to not do it as soon as the user can by subclassing. Maybe to 
make it easier to subclass there should be two methods.
    
    keep the public `createClient` one that returns the `RHLClient`. And add a 
protected method `createRestClientBuilder` which return the 
`RestClientBuilder`. This way one can just redefine the protected method and 
let the pubic one handle the actual `RHLClient` instanciation from the 
`RestClientBuilder` created by the protected method. 


---

Reply via email to