public class ElasticsearchResourceManager extends TestContainerResourceManager<GenericContainer<?>> implements org.apache.beam.it.common.ResourceManager
The class supports many indices per resource manager object.
The index name is formed using testId. The index name will be "{prefix}-{testId}-{ISO8601 time, microsecond precision}".
The class is thread-safe.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
ElasticsearchResourceManager.Builder
Builder for  
ElasticsearchResourceManager. | 
HOST_IP, port| Modifier and Type | Method and Description | 
|---|---|
static ElasticsearchResourceManager.Builder | 
builder(java.lang.String testId)  | 
void | 
cleanupAll()
Deletes all created resources and cleans up the Elasticsearch client, making the manager object
 unusable. 
 | 
long | 
count(java.lang.String indexName)
Gets the count of documents in an index. 
 | 
boolean | 
createIndex(java.lang.String indexName)
Creates an index on Elasticsearch. 
 | 
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> | 
fetchAll(java.lang.String indexName)
Reads all the documents in an index. 
 | 
java.lang.String | 
getUri()
Returns the URI connection string to the Elasticsearch service. 
 | 
boolean | 
insertDocuments(java.lang.String indexName,
               java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> documents)
Inserts the given Documents into a collection. 
 | 
getDockerImageName, getHost, getPortpublic static ElasticsearchResourceManager.Builder builder(java.lang.String testId)
public java.lang.String getUri()
public boolean createIndex(java.lang.String indexName)
                    throws ElasticsearchResourceManagerException
indexName - Name of the index to create.ElasticsearchResourceManagerException - if there is an error creating the collection in
     Elasticsearch.public boolean insertDocuments(java.lang.String indexName,
                               java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> documents)
                        throws ElasticsearchResourceManagerException
Note: Implementations may do collection creation here, if one does not already exist.
indexName - The name of the index to insert the documents into.documents - A map of (id, document) to insert into the collection.ElasticsearchResourceManagerException - if there is an error inserting the documents.public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> fetchAll(java.lang.String indexName)
                                                                          throws ElasticsearchResourceManagerException
indexName - The name of the index to read from.ElasticsearchResourceManagerException - if there is an error reading the data.public long count(java.lang.String indexName)
           throws ElasticsearchResourceManagerException
indexName - The name of the index to read from.ElasticsearchResourceManagerException - if there is an error reading the data.public void cleanupAll()
                throws ElasticsearchResourceManagerException
cleanupAll in interface org.apache.beam.it.common.ResourceManagercleanupAll in class TestContainerResourceManager<GenericContainer<?>>ElasticsearchResourceManagerException - if there is an error deleting the Elasticsearch
     resources.