本文整理匯總了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);
}
}
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
});
}
示例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);
}
}
}
示例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);
}
}
}
示例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");
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
});
}
示例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");
}
示例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();
}
}
示例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();
}
示例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();
}
}