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

x33g5p2x  于2022-01-18 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(253)

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

Client.close介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Override
 public void close() {
  nativeClient.close();
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

private void disposeClient() {
 if ( client != null ) {
  client.close();
 }
}

代码示例来源:origin: apache/flume

@Override
public void close() {
 if (client != null) {
  client.close();
 }
 client = null;
}

代码示例来源:origin: apache/usergrid

/**
 * Reset the client instance
 */
public synchronized void releaseClient() {
  //reset our static variables
  if ( client != null ) {
    try {
      client.close();
    }
    //if we fail for any reason, null it so the next request creates a new client
    finally {
      client = null;
    }
  }
}

代码示例来源:origin: brianfrankcooper/YCSB

@Override
public void cleanup() throws DBException {
 if (!remoteMode) {
  if (!node.isClosed()) {
   client.close();
   node.close();
  }
 } else {
  client.close();
 }
}

代码示例来源:origin: loklak/loklak_server

/**
 * Close the connection to the remote elasticsearch client. This should only be called when the application is
 * terminated.
 * Please avoid to open and close the ElasticsearchClient for the same cluster and index more than once.
 * To avoid that this method is called more than once, the elasticsearch_client object is set to null
 * as soon this was called the first time. This is needed because the finalize method calls this
 * method as well.
 */
public void close() {
  if (this.elasticsearchClient != null) {
    this.elasticsearchClient.close();
    this.elasticsearchClient = null;
  }
  if (this.elasticsearchNode != null) {
    this.elasticsearchNode.close();
    this.elasticsearchNode = null;
  }
}

代码示例来源:origin: thinkaurelius/titan

@Override
public void close() throws BackendException {
  if (node != null && !node.isClosed()) {
    node.close();
  }
  client.close();
}

代码示例来源:origin: apache/nifi

/**
 * Dispose of ElasticSearch client
 */
public void closeClient() {
  if (esClient.get() != null) {
    getLogger().info("Closing ElasticSearch Client");
    esClient.get().close();
    esClient.set(null);
  }
}

代码示例来源:origin: apache/nifi

/**
 * Dispose of ElasticSearch client
 */
public void closeClient() {
  Client client = esClient.get();
  if (client != null) {
    getLogger().info("Closing ElasticSearch Client");
    esClient.set(null);
    client.close();
  }
}

代码示例来源:origin: apache/flume

private void openLocalDiscoveryClient() {
 logger.info("Using ElasticSearch AutoDiscovery mode");
 Node node = NodeBuilder.nodeBuilder().client(true).local(true).node();
 if (client != null) {
  client.close();
 }
 client = node.client();
}

代码示例来源:origin: apache/flume

/**
 * Open client to elaticsearch cluster
 * 
 * @param clusterName
 */
private void openClient(String clusterName) {
 logger.info("Using ElasticSearch hostnames: {} ",
   Arrays.toString(serverAddresses));
 Settings settings = ImmutableSettings.settingsBuilder()
   .put("cluster.name", clusterName).build();
 TransportClient transportClient = new TransportClient(settings);
 for (InetSocketTransportAddress host : serverAddresses) {
  transportClient.addTransportAddress(host);
 }
 if (client != null) {
  client.close();
 }
 client = transportClient;
}

代码示例来源:origin: Netflix/conductor

@AfterClass
public static void closeClient() throws Exception {
  if (elasticSearchClient != null) {
    elasticSearchClient.close();
  }
  embeddedElasticSearch.stop();
}

代码示例来源:origin: NLPchina/elasticsearch-sql

this.client.close();

代码示例来源:origin: Impetus/Kundera

@Override
public void close()
{
  if (client != null)
  {
    client.close();
  }
}

代码示例来源:origin: yacy/yacy_grid_mcp

/**
 * Close the connection to the remote elasticsearch client. This should only be called when the application is
 * terminated.
 * Please avoid to open and close the ElasticsearchClient for the same cluster and index more than once.
 * To avoid that this method is called more than once, the elasticsearch_client object is set to null
 * as soon this was called the first time. This is needed because the finalize method calls this
 * method as well.
 */
public void close() {
  if (this.elasticsearchClient != null) {
    this.elasticsearchClient.close();
    this.elasticsearchClient = null;
  }
}

代码示例来源:origin: apache/flink

/**
 * Tests that the Elasticsearch sink works properly.
 */
public void runElasticsearchSinkTest() throws Exception {
  final String index = "elasticsearch-sink-test-index";
  final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction());
  source.addSink(createElasticsearchSinkForEmbeddedNode(
      1,
      CLUSTER_NAME,
      new SourceSinkDataTestKit.TestElasticsearchSinkFunction(index)));
  env.execute("Elasticsearch Sink Test");
  // verify the results
  Client client = embeddedNodeEnv.getClient();
  SourceSinkDataTestKit.verifyProducedSinkData(client, index);
  client.close();
}

代码示例来源:origin: komoot/photon

/**
 * stops the elasticsearch node
 */
public void shutdown() {
  try {
    if (esNode != null)
      esNode.close();
    esClient.close();
  } catch (IOException e) {
    throw new RuntimeException("Error during elasticsearch server shutdown", e);
  }
}

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

@Override
public void close() {
  in().close();
}

代码示例来源:origin: larsga/Duke

@Override
public void close() {
  if (this.client != null) {
    this.client.close();
    this.client = null;
  }
  if (this.node != null && !this.node.isClosed()) {
    this.node.close();
    this.node = null;
  }
}

代码示例来源:origin: apache/samza

@Override
public void stop() {
 for (Map.Entry<String, BulkProcessor> e : sourceBulkProcessor.entrySet()) {
  flush(e.getKey());
  e.getValue().close();
 }
 client.close();
}

相关文章