[ 
https://issues.apache.org/jira/browse/METRON-1834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666128#comment-16666128
 ] 

ASF GitHub Bot commented on METRON-1834:
----------------------------------------

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

    https://github.com/apache/metron/pull/1242#discussion_r228716676
  
    --- Diff: 
metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/utils/ElasticsearchUtils.java
 ---
    @@ -124,102 +129,146 @@ public static String getBaseIndexName(String 
indexName) {
       }
     
       /**
    -   * Instantiates an Elasticsearch client based on es.client.class, if 
set. Defaults to
    -   * org.elasticsearch.transport.client.PreBuiltTransportClient.
    +   * Instantiates an Elasticsearch client
        *
        * @param globalConfiguration Metron global config
    -   * @return
    +   * @return new es client
        */
    -  public static TransportClient getClient(Map<String, Object> 
globalConfiguration) {
    -    Set<String> customESSettings = new HashSet<>();
    -    customESSettings.addAll(Arrays.asList("es.client.class", 
USERNAME_CONFIG_KEY, PWD_FILE_CONFIG_KEY));
    -    Settings.Builder settingsBuilder = Settings.builder();
    -    Map<String, String> esSettings = getEsSettings(globalConfiguration);
    -    for (Map.Entry<String, String> entry : esSettings.entrySet()) {
    -      String key = entry.getKey();
    -      String value = entry.getValue();
    -      if (!customESSettings.contains(key)) {
    -        settingsBuilder.put(key, value);
    -      }
    -    }
    -    settingsBuilder.put("cluster.name", 
globalConfiguration.get("es.clustername"));
    -    settingsBuilder.put("client.transport.ping_timeout", 
esSettings.getOrDefault("client.transport.ping_timeout","500s"));
    -    setXPackSecurityOrNone(settingsBuilder, esSettings);
    -
    -    try {
    -      LOG.info("Number of available processors in Netty: {}", 
NettyRuntimeWrapper.availableProcessors());
    -      // Netty sets available processors statically and if an attempt is 
made to set it more than
    -      // once an IllegalStateException is thrown by 
NettyRuntime.setAvailableProcessors(NettyRuntime.java:87)
    -      // 
https://discuss.elastic.co/t/getting-availableprocessors-is-already-set-to-1-rejecting-1-illegalstateexception-exception/103082
    -      // 
https://discuss.elastic.co/t/elasticsearch-5-4-1-availableprocessors-is-already-set/88036
    -      System.setProperty("es.set.netty.runtime.available.processors", 
"false");
    -      TransportClient client = 
createTransportClient(settingsBuilder.build(), esSettings);
    -      for (HostnamePort hp : getIps(globalConfiguration)) {
    -        client.addTransportAddress(
    -                new 
InetSocketTransportAddress(InetAddress.getByName(hp.hostname), hp.port)
    -        );
    -      }
    -      return client;
    -    } catch (UnknownHostException exception) {
    -      throw new RuntimeException(exception);
    -    }
    +  public static ElasticsearchClient getClient(Map<String, Object> 
globalConfiguration) {
    --- End diff --
    
    Maybe this should be a builder pattern


> Migrate Elasticsearch from TransportClient to new Java REST API
> ---------------------------------------------------------------
>
>                 Key: METRON-1834
>                 URL: https://issues.apache.org/jira/browse/METRON-1834
>             Project: Metron
>          Issue Type: Improvement
>            Reporter: Michael Miklavcic
>            Assignee: Michael Miklavcic
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to