public class ElasticsearchAccess extends Object implements DatabaseConnection
Modifier and Type | Field and Description |
---|---|
protected org.elasticsearch.client.transport.TransportClient |
client |
protected String |
clusterName |
org.elasticsearch.common.settings.Settings.Builder |
default_builder
The ES Builder
|
protected List<ElasticsearchNode> |
nodes |
Constructor and Description |
---|
ElasticsearchAccess(String clusterName,
List<ElasticsearchNode> nodes)
Create an ElasticSearch access
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkConnection()
Check the connection of the database
|
void |
close()
Close the ElasticSearch connection
|
boolean |
createIndexAndAliasIfAliasNotExists(String collectionName,
String mapping,
String type,
Integer tenantId)
Create an index and alias for a collection (if the alias does not exist)
|
String |
createIndexWithoutAlias(String collectionName,
String mapping,
String type,
Integer tenantId)
Create an index without a linked alias
|
org.elasticsearch.client.Client |
getClient() |
String |
getClusterName() |
String |
getInfo()
Get information on a Database
|
List<ElasticsearchNode> |
getNodes() |
static org.elasticsearch.common.settings.Settings |
getSettings(String clusterName)
Production settings, see Elasticsearch production settings
https://www.elastic.co/guide/en/elasticsearch/guide/current/deploy.html.
Additionnal on server side:
in sysctl "vm.swappiness = 1", "vm.max_map_count=262144"
in elasticsearch.yml "bootstrap.mlockall: true"
|
org.elasticsearch.common.settings.Settings.Builder |
settings()
Settings method
|
void |
switchIndex(String aliasName,
String indexNameToSwitchWith)
Switch index
|
public org.elasticsearch.common.settings.Settings.Builder default_builder
protected final org.elasticsearch.client.transport.TransportClient client
protected final String clusterName
protected final List<ElasticsearchNode> nodes
public ElasticsearchAccess(String clusterName, List<ElasticsearchNode> nodes) throws VitamException, IOException
clusterName
- the name of the Clusternodes
- the elasticsearch nodesVitamException
- when elasticseach node list is emptyIOException
public static org.elasticsearch.common.settings.Settings getSettings(String clusterName)
public void close()
public String getClusterName()
public org.elasticsearch.client.Client getClient()
public List<ElasticsearchNode> getNodes()
public boolean checkConnection()
DatabaseConnection
checkConnection
in interface DatabaseConnection
public String getInfo()
DatabaseConnection
getInfo
in interface DatabaseConnection
public final boolean createIndexAndAliasIfAliasNotExists(String collectionName, String mapping, String type, Integer tenantId)
collectionName
- the name of the collectionmapping
- the mapping as a stringtype
- the type of the collectiontenantId
- the tenant on which to create the indexpublic final String createIndexWithoutAlias(String collectionName, String mapping, String type, Integer tenantId) throws DatabaseException
collectionName
- mapping
- type
- tenantId
- DatabaseException
public final void switchIndex(String aliasName, String indexNameToSwitchWith) throws DatabaseException
aliasName
- indexNameToSwitchWith
- DatabaseException
public org.elasticsearch.common.settings.Settings.Builder settings() throws IOException
IOException
Copyright © 2018 Vitam. All rights reserved.