Class 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean isStarted  
      private org.elasticsearch.node.Node node  
    • 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 settings
      org.elasticsearch.common.transport.TransportAddress httpAddress()
      Returns current address to connect to with HTTP client.
      void start()
      Starts current node
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • node

        private final org.elasticsearch.node.Node node
      • isStarted

        private volatile boolean isStarted
    • Constructor Detail

      • EmbeddedElasticsearchNode

        private EmbeddedElasticsearchNode​(org.elasticsearch.node.Node 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 unless start() 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 interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception