Search in sources :

Example 1 with TDExportJobRequest

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

the class TestTDClient method submitExportJob.

@Test
public void submitExportJob() throws Exception {
    TDExportJobRequest jobRequest = new TDExportJobRequest(SAMPLE_DB, "sample_output", new Date(0L), new Date(1456522300L * 1000), TDExportFileFormatType.JSONL_GZ, "access key id", "secret access key", "bucket", "prefix/", Optional.<String>absent());
    client.createDatabaseIfNotExists(SAMPLE_DB);
    client.createTableIfNotExists(SAMPLE_DB, "sample_output");
    String jobId = client.submitExportJob(jobRequest);
    TDJobSummary tdJob = waitJobCompletion(jobId);
// this job will do nothing because sample_output table is empty
}
Also used : TDExportJobRequest(com.treasuredata.client.model.TDExportJobRequest) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) TDJobSummary(com.treasuredata.client.model.TDJobSummary) Date(java.util.Date) Test(org.junit.Test)

Example 2 with TDExportJobRequest

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

the class TestTDClient method submitExportJobWithDomainKey.

@Test
public void submitExportJobWithDomainKey() throws Exception {
    String domainKey = randomDomainKey();
    TDExportJobRequest jobRequest = TDExportJobRequest.builder().database(SAMPLE_DB).table("sample_output").from(new Date(0L)).to(new Date(1456522300L * 1000)).fileFormat(TDExportFileFormatType.JSONL_GZ).accessKeyId("access key id").secretAccessKey("secret access key").bucketName("bucket").filePrefix("prefix/").domainKey(domainKey).build();
    client.createDatabaseIfNotExists(SAMPLE_DB);
    client.createTableIfNotExists(SAMPLE_DB, "sample_output");
    String jobId = client.submitExportJob(jobRequest);
    // Attempt to submit the job again and verify that we get a domain key conflict
    try {
        client.submitExportJob(jobRequest);
        fail("Expected " + TDClientHttpConflictException.class.getName());
    } catch (TDClientHttpConflictException e) {
        assertThat(e.getConflictsWith(), is(Optional.of(jobId)));
    }
}
Also used : Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) TDExportJobRequest(com.treasuredata.client.model.TDExportJobRequest) Date(java.util.Date) Test(org.junit.Test)

Aggregations

TDExportJobRequest (com.treasuredata.client.model.TDExportJobRequest)2 Date (java.util.Date)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)2 Test (org.junit.Test)2 TDJobSummary (com.treasuredata.client.model.TDJobSummary)1