クラス ElasticsearchClusterRunner

  • すべての実装されたインタフェース:
    Closeable, AutoCloseable

    public class ElasticsearchClusterRunner
    extends Object
    implements Closeable
    ElasticsearchClusterRunner manages multiple Elasticsearch instances.
    作成者:
    shinsuke
    • フィールドの詳細

      • MODULE_TYPES

        public static String[] MODULE_TYPES
      • nodeList

        protected List<org.elasticsearch.node.Node> nodeList
      • envList

        protected List<org.elasticsearch.env.Environment> envList
      • pluginList

        protected Collection<Class<? extends org.elasticsearch.plugins.Plugin>> pluginList
      • maxHttpPort

        protected int maxHttpPort
      • maxTransportPort

        protected int maxTransportPort
      • basePath

        protected String basePath
      • confPath

        protected String confPath
      • dataPath

        protected String dataPath
      • logsPath

        protected String logsPath
      • numOfNode

        protected int numOfNode
      • baseTransportPort

        protected int baseTransportPort
      • baseHttpPort

        protected int baseHttpPort
      • clusterName

        protected String clusterName
      • indexStoreType

        protected String indexStoreType
      • useLogger

        protected boolean useLogger
      • disableESLogger

        protected boolean disableESLogger
      • printOnFailure

        protected boolean printOnFailure
      • moduleTypes

        protected String moduleTypes
      • pluginTypes

        protected String pluginTypes
    • コンストラクタの詳細

      • ElasticsearchClusterRunner

        public ElasticsearchClusterRunner()
    • メソッドの詳細

      • main

        public static void main​(String[] args)
      • isClosed

        public boolean isClosed()
        Check if a cluster runner is closed.
        戻り値:
        true if a runner is closed.
      • clean

        public void clean()
        Delete all configuration files and directories.
      • build

        public void build​(ElasticsearchClusterRunner.Configs configs)
        Create and start Elasticsearch cluster with Configs instance.
        パラメータ:
        configs - configuration
      • build

        public void build​(String... args)
        Create and start Elasticsearch cluster with arguments.
        パラメータ:
        args - artuments for starting a cluster
      • execute

        protected void execute​(int id)
      • getAvailableHttpPort

        protected int getAvailableHttpPort​(int number)
      • getAvailableTransportPort

        protected int getAvailableTransportPort​(int number)
      • putIfAbsent

        protected void putIfAbsent​(org.elasticsearch.common.settings.Settings.Builder settingsBuilder,
                                   String key,
                                   String value)
      • setMaxHttpPort

        public void setMaxHttpPort​(int maxHttpPort)
      • setMaxTransportPort

        public void setMaxTransportPort​(int maxTransportPort)
      • getNode

        public org.elasticsearch.node.Node getNode​(int i)
        Return a node by the node index.
        パラメータ:
        i - A node index
        戻り値:
        null if the node is not found
      • startNode

        public boolean startNode​(int i)
        Start a closed node.
        パラメータ:
        i - the number of nodes
        戻り値:
        true if the node is started.
      • getNode

        public org.elasticsearch.node.Node getNode​(String name)
        Return a node by the name.
        パラメータ:
        name - A node name
        戻り値:
        null if the node is not found by the name
      • getNodeIndex

        public int getNodeIndex​(org.elasticsearch.node.Node node)
        Return a node index.
        パラメータ:
        node - node to check an index
        戻り値:
        -1 if the node does not exist.
      • getNodeSize

        public int getNodeSize()
        Return the number of nodes.
        戻り値:
        the number of nodes
      • print

        public void print​(String line)
      • createDir

        protected void createDir​(Path path)
      • node

        public org.elasticsearch.node.Node node()
        Return an available node.
        戻り値:
        node
      • masterNode

        public org.elasticsearch.node.Node masterNode()
        Return a master node.
        戻り値:
        master node
      • nonMasterNode

        public org.elasticsearch.node.Node nonMasterNode()
        Return a non-master node.
        戻り値:
        non-master node
      • client

        public org.elasticsearch.client.Client client()
        Return an elasticsearch client.
        戻り値:
        client
      • admin

        public org.elasticsearch.client.AdminClient admin()
        Return an elasticsearch admin client.
        戻り値:
        admin client
      • ensureGreen

        public org.elasticsearch.cluster.health.ClusterHealthStatus ensureGreen​(String... indices)
        Wait for green state of a cluster.
        パラメータ:
        indices - indices to check status
        戻り値:
        cluster health status
      • ensureYellow

        public org.elasticsearch.cluster.health.ClusterHealthStatus ensureYellow​(String... indices)
        Wait for yellow state of a cluster.
        パラメータ:
        indices - indices to check status
        戻り値:
        cluster health status
      • waitForRelocation

        public org.elasticsearch.cluster.health.ClusterHealthStatus waitForRelocation()
      • flush

        public org.elasticsearch.action.admin.indices.flush.FlushResponse flush()
      • flush

        public org.elasticsearch.action.admin.indices.flush.FlushResponse flush​(boolean force)
      • refresh

        public org.elasticsearch.action.admin.indices.refresh.RefreshResponse refresh()
      • refresh

        public org.elasticsearch.action.admin.indices.refresh.RefreshResponse refresh​(ElasticsearchClusterRunner.BuilderCallback<org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder> builder)
      • upgrade

        public org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse upgrade()
      • upgrade

        public org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse upgrade​(boolean upgradeOnlyAncientSegments)
      • upgrade

        public org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse upgrade​(ElasticsearchClusterRunner.BuilderCallback<org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequestBuilder> builder)
      • forceMerge

        public org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse forceMerge()
      • forceMerge

        public org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse forceMerge​(int maxNumSegments,
                                                                                               boolean onlyExpungeDeletes,
                                                                                               boolean flush)
      • forceMerge

        public org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse forceMerge​(ElasticsearchClusterRunner.BuilderCallback<org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequestBuilder> builder)
      • openIndex

        public org.elasticsearch.action.admin.indices.open.OpenIndexResponse openIndex​(String index)
      • closeIndex

        public org.elasticsearch.action.support.master.AcknowledgedResponse closeIndex​(String index)
      • createIndex

        public org.elasticsearch.action.admin.indices.create.CreateIndexResponse createIndex​(String index,
                                                                                             org.elasticsearch.common.settings.Settings settings)
      • createIndex

        public org.elasticsearch.action.admin.indices.create.CreateIndexResponse createIndex​(String index,
                                                                                             ElasticsearchClusterRunner.BuilderCallback<org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder> builder)
      • indexExists

        public boolean indexExists​(String index)
      • deleteIndex

        public org.elasticsearch.action.support.master.AcknowledgedResponse deleteIndex​(String index)
      • createMapping

        public org.elasticsearch.action.support.master.AcknowledgedResponse createMapping​(String index,
                                                                                          String type,
                                                                                          String mappingSource)
      • createMapping

        public org.elasticsearch.action.support.master.AcknowledgedResponse createMapping​(String index,
                                                                                          String type,
                                                                                          org.elasticsearch.common.xcontent.XContentBuilder source)
      • createMapping

        public org.elasticsearch.action.support.master.AcknowledgedResponse createMapping​(String index,
                                                                                          ElasticsearchClusterRunner.BuilderCallback<org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder> builder)
      • insert

        public org.elasticsearch.action.index.IndexResponse insert​(String index,
                                                                   String type,
                                                                   String id,
                                                                   String source)
      • delete

        public org.elasticsearch.action.delete.DeleteResponse delete​(String index,
                                                                     String type,
                                                                     String id)
      • count

        @Deprecated
        public org.elasticsearch.action.search.SearchResponse count​(String index,
                                                                    String type)
        推奨されていません。
      • count

        public org.elasticsearch.action.search.SearchResponse count​(String index)
      • search

        @Deprecated
        public org.elasticsearch.action.search.SearchResponse search​(String index,
                                                                     String type,
                                                                     org.elasticsearch.index.query.QueryBuilder queryBuilder,
                                                                     org.elasticsearch.search.sort.SortBuilder<?> sort,
                                                                     int from,
                                                                     int size)
        推奨されていません。
      • search

        public org.elasticsearch.action.search.SearchResponse search​(String index,
                                                                     org.elasticsearch.index.query.QueryBuilder queryBuilder,
                                                                     org.elasticsearch.search.sort.SortBuilder<?> sort,
                                                                     int from,
                                                                     int size)
      • getAlias

        public org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse getAlias​(String alias)
      • getAlias

        public org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse getAlias​(String alias,
                                                                                            ElasticsearchClusterRunner.BuilderCallback<org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequestBuilder> builder)
      • updateAlias

        public org.elasticsearch.action.support.master.AcknowledgedResponse updateAlias​(String alias,
                                                                                        String[] addedIndices,
                                                                                        String[] deletedIndices)
      • updateAlias

        public org.elasticsearch.action.support.master.AcknowledgedResponse updateAlias​(ElasticsearchClusterRunner.BuilderCallback<org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder> builder)
      • clusterService

        public org.elasticsearch.cluster.service.ClusterService clusterService()
      • getInstance

        public <T> T getInstance​(Class<T> clazz)
      • getClusterName

        public String getClusterName()