Search in sources :

Example 1 with ElasticsearchDatastoreProperties

use of org.talend.components.elasticsearch.ElasticsearchDatastoreProperties in project components by Talend.

the class ElasticsearchDatastoreTestIT method createDatastoreProperties.

/**
 * @return the properties for this datastore, fully initialized with the default values and credentials
 * from the System environment.
 */
public static ElasticsearchDatastoreProperties createDatastoreProperties() {
    // Configure the dataset.
    ElasticsearchDatastoreProperties datastoreProps = new ElasticsearchDatastoreProperties(null);
    datastoreProps.init();
    datastoreProps.nodes.setValue(System.getProperty("es.hosts"));
    return datastoreProps;
}
Also used : ElasticsearchDatastoreProperties(org.talend.components.elasticsearch.ElasticsearchDatastoreProperties)

Example 2 with ElasticsearchDatastoreProperties

use of org.talend.components.elasticsearch.ElasticsearchDatastoreProperties in project components by Talend.

the class ElasticsearchDatastoreRuntimeTestIT method createDatastoreProp.

public static ElasticsearchDatastoreProperties createDatastoreProp() {
    ElasticsearchDatastoreProperties datastore = new ElasticsearchDatastoreProperties("datastore");
    datastore.nodes.setValue(ElasticsearchTestConstants.HOSTS);
    return datastore;
}
Also used : ElasticsearchDatastoreProperties(org.talend.components.elasticsearch.ElasticsearchDatastoreProperties)

Example 3 with ElasticsearchDatastoreProperties

use of org.talend.components.elasticsearch.ElasticsearchDatastoreProperties in project components by Talend.

the class ElasticsearchDatastoreTestIT method testBasic.

@Test
public void testBasic() throws Exception {
    ElasticsearchDatastoreProperties props = createDatastoreProperties();
    RuntimeInfo ri = def.getRuntimeInfo(props);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        DatastoreRuntime runtime = (DatastoreRuntime) si.getInstance();
        runtime.initialize(null, props);
        assertThat(runtime, not(nullValue()));
        Iterator iterator = runtime.doHealthChecks(null).iterator();
        assertTrue(iterator.hasNext());
        assertEquals(ValidationResult.OK, iterator.next());
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) DatastoreRuntime(org.talend.components.common.datastore.runtime.DatastoreRuntime) Iterator(java.util.Iterator) ElasticsearchDatastoreProperties(org.talend.components.elasticsearch.ElasticsearchDatastoreProperties) Test(org.junit.Test)

Example 4 with ElasticsearchDatastoreProperties

use of org.talend.components.elasticsearch.ElasticsearchDatastoreProperties in project components by Talend.

the class ElasticsearchBeamRuntimeTestIT method init.

@Before
public void init() throws IOException, ExecutionException, InterruptedException {
    client = ElasticsearchTestUtils.createClient(ElasticsearchTestConstants.HOSTS.split(":")[0], ElasticsearchTestConstants.TRANSPORT_PORT, ElasticsearchTestConstants.CLUSTER_NAME);
    datastoreProperties = new ElasticsearchDatastoreProperties("datastore");
    datastoreProperties.init();
    datastoreProperties.nodes.setValue(ElasticsearchTestConstants.HOSTS);
    RestClient restClient = ElasticsearchConnection.createClient(datastoreProperties);
    BasicHeader emptyHeader = new BasicHeader("", "");
    Map<String, String> emptyParams = new HashMap<>();
    ElasticsearchTestUtils.deleteIndex(INDEX_NAME, client);
    Response checkExistsResponse = restClient.performRequest("HEAD", "/" + INDEX_NAME, emptyParams);
    ElasticsearchResponse checkExists = new ElasticsearchResponse(checkExistsResponse);
    if (!checkExists.isOk()) {
        // create index for test, name is 'beam'
        restClient.performRequest("PUT", "/" + INDEX_NAME, emptyHeader);
    }
}
Also used : Response(org.elasticsearch.client.Response) HashMap(java.util.HashMap) RestClient(org.elasticsearch.client.RestClient) BasicHeader(org.apache.http.message.BasicHeader) ElasticsearchDatastoreProperties(org.talend.components.elasticsearch.ElasticsearchDatastoreProperties) Before(org.junit.Before)

Aggregations

ElasticsearchDatastoreProperties (org.talend.components.elasticsearch.ElasticsearchDatastoreProperties)4 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 BasicHeader (org.apache.http.message.BasicHeader)1 Response (org.elasticsearch.client.Response)1 RestClient (org.elasticsearch.client.RestClient)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DatastoreRuntime (org.talend.components.common.datastore.runtime.DatastoreRuntime)1 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)1 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)1