Search in sources :

Example 11 with TDJobSummary

use of com.treasuredata.client.model.TDJobSummary in project td-client-java by treasure-data.

the class TestTDClient method submitBulkLoadJob.

@Test
public void submitBulkLoadJob() throws Exception {
    ObjectNode config = JsonNodeFactory.instance.objectNode();
    ObjectNode in = JsonNodeFactory.instance.objectNode();
    in.put("type", "s3");
    config.put("in", in);
    client.createDatabaseIfNotExists(SAMPLE_DB);
    client.createTableIfNotExists(SAMPLE_DB, "sample_output");
    String jobId = client.submit(TDJobRequest.newBulkLoad(SAMPLE_DB, "sample_output", config));
    TDJobSummary tdJob = waitJobCompletion(jobId);
// this job will fail because of lack of parameters for s3 input plugin
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) TDJobSummary(com.treasuredata.client.model.TDJobSummary) Test(org.junit.Test)

Example 12 with TDJobSummary

use of com.treasuredata.client.model.TDJobSummary in project td-client-java by treasure-data.

the class TestTDClient method submitJobWithDomainKey.

@Test
public void submitJobWithDomainKey() throws Exception {
    String domainKey = randomDomainKey();
    TDJobRequest request1 = new TDJobRequestBuilder().setType(TDJob.Type.PRESTO).setDatabase("sample_datasets").setQuery("select 1").setDomainKey(domainKey).createTDJobRequest();
    String jobId = client.submit(request1);
    waitJobCompletion(jobId);
    TDJobRequest request2 = new TDJobRequestBuilder().setType(TDJob.Type.PRESTO).setDatabase("sample_datasets").setQuery("select 1").setDomainKey(domainKey).createTDJobRequest();
    try {
        client.submit(request2);
        fail("Expected " + TDClientHttpConflictException.class.getName());
    } catch (TDClientHttpConflictException e) {
        assertThat(e.getConflictsWith(), is(Optional.of(jobId)));
    }
    TDJobSummary statusByDomainKey = client.jobStatusByDomainKey(domainKey);
    assertThat(statusByDomainKey.getJobId(), is(jobId));
}
Also used : TDJobRequestBuilder(com.treasuredata.client.model.TDJobRequestBuilder) TDJobRequest(com.treasuredata.client.model.TDJobRequest) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) TDJobSummary(com.treasuredata.client.model.TDJobSummary) Test(org.junit.Test)

Aggregations

TDJobSummary (com.treasuredata.client.model.TDJobSummary)12 Test (org.junit.Test)10 Matchers.containsString (org.hamcrest.Matchers.containsString)9 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)9 TDJob (com.treasuredata.client.model.TDJob)2 InputStream (java.io.InputStream)2 Date (java.util.Date)2 GZIPInputStream (java.util.zip.GZIPInputStream)2 MessageUnpacker (org.msgpack.core.MessageUnpacker)2 ArrayValue (org.msgpack.value.ArrayValue)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 TDDatabase (com.treasuredata.client.model.TDDatabase)1 TDExportJobRequest (com.treasuredata.client.model.TDExportJobRequest)1 TDJobRequest (com.treasuredata.client.model.TDJobRequest)1 TDJobRequestBuilder (com.treasuredata.client.model.TDJobRequestBuilder)1 TDTable (com.treasuredata.client.model.TDTable)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1