當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.close方法代碼示例

本文整理匯總了Java中org.elasticsearch.node.Node.close方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.close方法的具體用法?Java Node.close怎麽用?Java Node.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.node.Node的用法示例。


在下文中一共展示了Node.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startNodes

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
public void startNodes() {
    for (Node node : nodes) {
        try {
            getClusterService(node).addListener(new TribeClusterStateListener(node));
            node.start();
        } catch (Exception e) {
            // calling close is safe for non started nodes, we can just iterate over all
            for (Node otherNode : nodes) {
                try {
                    otherNode.close();
                } catch (Exception inner) {
                    inner.addSuppressed(e);
                    logger.warn((Supplier<?>) () -> new ParameterizedMessage("failed to close node {} on failed start", otherNode), inner);
                }
            }
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
            throw new ElasticsearchException(e);
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:23,代碼來源:TribeService.java

示例2: doStart

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
@Override
protected void doStart() {
    for (Node node : nodes) {
        try {
            node.start();
        } catch (Throwable e) {
            // calling close is safe for non started nodes, we can just iterate over all
            for (Node otherNode : nodes) {
                try {
                    otherNode.close();
                } catch (Throwable t) {
                    logger.warn("failed to close node {} on failed start", t, otherNode);
                }
            }
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
            throw new ElasticsearchException(e.getMessage(), e);
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:22,代碼來源:TribeService.java

示例3: main

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
public static void main(String[] args)
{
	Node node = nodeBuilder().node();
	Client client = node.client();

	AdminClient ac = client.admin();

	client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
	ElasticTest t = new ElasticTest();
	t.initRiver(client);
	// t.initRiver(client);
	// t.getContributionsByCandName(client, "aaew_corpus_aaew_full", 0);
	t.search(client);
	// // on shutdown
	// // Configuration
	// ClientConfig clientConfig = new
	// ClientConfig.Builder("http://localhost:9200").multiThreaded(true).build();
	//
	// // Construct a new Jest client according to configuration via factory
	// JestClientFactory factory = new JestClientFactory();
	// factory.setClientConfig(clientConfig);
	// JestClient clientj = factory.getObject();
	// clientj.
	node.close();

}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:27,代碼來源:ElasticTest.java

示例4: setup

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
@Override
public ClientWrapper setup() throws Exception {
    final Settings settings = Settings
        .builder()
        .put("node.name", InetAddress.getLocalHost().getHostName())
        .putArray("discovery.zen.ping.unicast.hosts", seeds)
        .put("cluster.name", clusterName)
        .put("node.data", false)
        .build();

    final Node node = new Node(settings);

    return new ClientWrapper(node.client(), new Runnable() {
        @Override
        public void run() {
            try {
                node.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });
}
 
開發者ID:spotify,項目名稱:heroic,代碼行數:24,代碼來源:NodeClientSetup.java

示例5: doClose

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
@Override
protected void doClose() {
    for (Node node : nodes) {
        try {
            node.close();
        } catch (Exception e) {
            logger.warn((Supplier<?>) () -> new ParameterizedMessage("failed to close node {}", node), e);
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:TribeService.java

示例6: doClose

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
@Override
protected void doClose() {
    for (Node node : nodes) {
        try {
            node.close();
        } catch (Throwable t) {
            logger.warn("failed to close node {}", t, node);
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:11,代碼來源:TribeService.java

示例7: close

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
/**
 * Shuts down the embedded cluster.
 */
@Override
public void close() throws IOException {
  if(pool != null){
    pool.close();
  }
  if(client != null){
    client.close();
  }
  if(!USE_EXTERNAL_ES5){
    logger.info("--> tearing down elasticsearch cluster");
    if (nodes != null) {
      for (Node node : nodes) {
        node.close();
      }
    }
    if (sslEnabled) {
      try {
        proxy.stop();
      } catch (Exception e) {
        throw new RuntimeException("Could not shutdown ssl proxy", e);
      }
    }
    logger.info("--> elasticsearch cluster is shut down");

  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:30,代碼來源:ElasticsearchCluster.java

示例8: testNullTransportClient

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
@Test(expected = IllegalArgumentException.class)
public void testNullTransportClient() throws Exception {

File dataDir = tempFolder.newFolder();

Node node = NodeBuilder.nodeBuilder()
	.settings(Settings.settingsBuilder()
		.put("path.home", dataDir.getParent())
		.put("http.enabled", false)
		.put("path.data", dataDir.getAbsolutePath()))
	// set a custom cluster name to verify that user config works correctly
	.clusterName("my-transport-client-cluster")
	.node();

final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new TestSourceFunction());

Map<String, String> config = new HashMap<>();
// This instructs the sink to emit after every element, otherwise they would be buffered
config.put(ElasticsearchSink.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1");
config.put("cluster.name", "my-transport-client-cluster");

source.addSink(new ElasticsearchSink<>(config, null, new TestElasticsearchSinkFunction()));

env.execute("Elasticsearch TransportClient Test");

// verify the results
Client client = node.client();
for (int i = 0; i < NUM_ELEMENTS; i++) {
 GetResponse response = client.get(new GetRequest("my-index",
	 "my-type", Integer.toString(i))).actionGet();
 Assert.assertEquals("message #" + i, response.getSource().get("data"));
}

node.close();
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:38,代碼來源:ElasticsearchSinkITCase.java

示例9: testEmptyTransportClient

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
@Test(expected = IllegalArgumentException.class)
public void testEmptyTransportClient() throws Exception {

File dataDir = tempFolder.newFolder();

Node node = NodeBuilder.nodeBuilder()
	.settings(Settings.settingsBuilder()
		.put("path.home", dataDir.getParent())
		.put("http.enabled", false)
		.put("path.data", dataDir.getAbsolutePath()))
	// set a custom cluster name to verify that user config works correctly
	.clusterName("my-transport-client-cluster")
	.node();

final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new TestSourceFunction());

Map<String, String> config = new HashMap<>();
// This instructs the sink to emit after every element, otherwise they would be buffered
config.put(ElasticsearchSink.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1");
config.put("cluster.name", "my-transport-client-cluster");

source.addSink(new ElasticsearchSink<>(config, new ArrayList<InetSocketAddress>(), new TestElasticsearchSinkFunction()));

env.execute("Elasticsearch TransportClient Test");

// verify the results
Client client = node.client();
for (int i = 0; i < NUM_ELEMENTS; i++) {
 GetResponse response = client.get(new GetRequest("my-index",
	 "my-type", Integer.toString(i))).actionGet();
 Assert.assertEquals("message #" + i, response.getSource().get("data"));
}

node.close();
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:38,代碼來源:ElasticsearchSinkITCase.java

示例10: stopCluster

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
public final void stopCluster() throws Exception {
	for (Node node : esNodes) {
		try {
               node.close();
               LoggerContext context = (LoggerContext) LogManager.getContext(false);
               Configurator.shutdown(context);
               Thread.sleep(150);
           } catch (Throwable e) {
               e.printStackTrace();
           }
	}
	esNodes.clear();
}
 
開發者ID:floragunncom,項目名稱:search-guard,代碼行數:14,代碼來源:ClusterHelper.java

示例11: setup

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
@Override
public ClientWrapper setup() throws Exception {
    final Settings settings = Settings
        .builder()
        .put("path.home", root)
        .put("node.name", InetAddress.getLocalHost().getHostName())
        .put("script.inline", "on")
        // .put("script.disable_dynamic", false)
        // .put("script.groovy.sandbox.enabled",
        // true)
        .put("cluster.name", clusterName)
        .put("transport.type", "local")
        .put("http.enabled", false)
        .build();
    final Node node = new Node(settings).start();

    return new ClientWrapper(node.client(), new Runnable() {
        @Override
        public void run() {
            try {
                node.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });
}
 
開發者ID:spotify,項目名稱:heroic,代碼行數:28,代碼來源:StandaloneClientSetup.java

示例12: closeNodes

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
private void closeNodes() throws IOException {
    logger.info("closing all clients");
    for (AbstractClient client : clients.values()) {
        client.close();
    }
    clients.clear();
    logger.info("closing all nodes");
    for (Node node : nodes.values()) {
        if (node != null) {
            node.close();
        }
    }
    nodes.clear();
    logger.info("all nodes closed");
}
 
開發者ID:jprante,項目名稱:elasticsearch-xml,代碼行數:16,代碼來源:NodeTestUtils.java

示例13: closeNode

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
public void closeNode(String id) {
    Client client = clients.remove(id);
    if (client != null) {
        client.close();
    }
    Node node = nodes.remove(id);
    if (node != null) {
        node.close();
    }
}
 
開發者ID:jaibeermalik,項目名稱:elasticsearch-tutorial,代碼行數:11,代碼來源:SearchClientServiceMockImpl.java

示例14: closeAllNodes

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
public void closeAllNodes() {
    for (Client client : clients.values()) {
        client.close();
    }
    clients.clear();
    for (Node node : nodes.values()) {
        node.close();
    }
    nodes.clear();
}
 
開發者ID:jaibeermalik,項目名稱:elasticsearch-tutorial,代碼行數:11,代碼來源:SearchClientServiceMockImpl.java

示例15: closeNode

import org.elasticsearch.node.Node; //導入方法依賴的package包/類
public void closeNode(final String id)
{
    final Client client = clients.remove(id);
    if (client != null)
    {
        client.close();
    }
    final Node node = nodes.remove(id);
    if (node != null)
    {
        node.close();
    }
}
 
開發者ID:jaibeermalik,項目名稱:elasticsearch-akka,代碼行數:14,代碼來源:SearchClientServiceMockImpl.java


注:本文中的org.elasticsearch.node.Node.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。