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 emptyIOExceptionpublic 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()
DatabaseConnectioncheckConnection in interface DatabaseConnectionpublic String getInfo()
DatabaseConnectiongetInfo in interface DatabaseConnectionpublic 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 - DatabaseExceptionpublic final void switchIndex(String aliasName, String indexNameToSwitchWith) throws DatabaseException
aliasName - indexNameToSwitchWith - DatabaseExceptionpublic org.elasticsearch.common.settings.Settings.Builder settings()
throws IOException
IOExceptionCopyright © 2018 Vitam. All rights reserved.