Class EmbeddedElasticsearchNode
- java.lang.Object
-
- org.apache.calcite.adapter.elasticsearch.EmbeddedElasticsearchNode
-
- All Implemented Interfaces:
java.lang.AutoCloseable
class EmbeddedElasticsearchNode extends java.lang.Object implements java.lang.AutoCloseable
Represents a single elastic search node which can run embedded in a java application.Intended for unit and integration tests. Settings and plugins are crafted for Calcite.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
EmbeddedElasticsearchNode.LocalNode
Having separate class to expose (protected) constructor which allows to install different plugins.
-
Constructor Summary
Constructors Modifier Constructor Description private
EmbeddedElasticsearchNode(org.elasticsearch.node.Node node)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.elasticsearch.client.Client
client()
Exposes elastic transport client (use of HTTP client is preferred).void
close()
static EmbeddedElasticsearchNode
create()
Creates elastic node as single member of a cluster.private static EmbeddedElasticsearchNode
create(org.elasticsearch.common.settings.Settings settings)
Creates an instance with existing settingsorg.elasticsearch.common.transport.TransportAddress
httpAddress()
Returns current address to connect to with HTTP client.void
start()
Starts current node
-
-
-
Method Detail
-
create
private static EmbeddedElasticsearchNode create(org.elasticsearch.common.settings.Settings settings)
Creates an instance with existing settings- Parameters:
settings
- configuration parameters of ES instance- Returns:
- instance which needs to be explicitly started (using
start()
)
-
create
public static EmbeddedElasticsearchNode create()
Creates elastic node as single member of a cluster. Node will not be started unlessstart()
is explicitly called.Need
synchronized
because of static caches inside ES (which are not thread safe).- Returns:
- instance which needs to be explicitly started (using
start()
)
-
start
public void start()
Starts current node
-
httpAddress
public org.elasticsearch.common.transport.TransportAddress httpAddress()
Returns current address to connect to with HTTP client.- Returns:
- hostname/port for HTTP connection
-
client
public org.elasticsearch.client.Client client()
Exposes elastic transport client (use of HTTP client is preferred).- Returns:
- current elastic search client
-
close
public void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
-