当前位置: 首页>>代码示例>>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;未经允许,请勿转载。