Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Licensed to STRATIO (C) under one or more contributor license agreements.
   * See the NOTICE file distributed with this work for additional information
   * regarding copyright ownership.  The STRATIO (C) 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
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
 package com.stratio.connector.elasticsearch.core.connection;
 import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
This class represents a logic connection. Created by jmgomez on 28/08/14.
 public class NodeConnection extends Connection<Client> {

The Log.
     private final Logger logger = LoggerFactory.getLogger(this.getClass());

The Elasticsearch client.
     private Client elasticClient = null;

The elasticsearch node connection.
     private Node node = null;
Store the connection status.
     private boolean isConnect = false;

Store the connection name.
     private String connectionName;


credentials the credentials.
config The cluster configuration.
     public NodeConnection(ICredentials credentialsConnectorClusterConfig config) {
         NodeBuilder nodeBuilder = nodeBuilder();
          = nodeBuilder.settings(ElasticsearchClientConfiguration.getSettings(config)).node();
          = .client();
          = true;
          = config.getName().getName();
         .info("Elasticsearch Node connection established ");

Close the connection.
     public void close() {
         if ( != null) {
              = false;
              = null;
              = null;
             .info("ElasticSearch  connection [" +  + "] close");

Retun the connection status.

true if the connection is open. False in other case.
    public boolean isConnect() {
        return ;

Return the native connection.

the native connection.
    public Client getNativeConnection() {
        return ;
New to GrepCode? Check out our FAQ X