Search in sources :

Example 1 with DirectoryDatasource

use of com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource in project kylo by Teradata.

the class MetadataClientTest method testBuildDirectoryDatasource.

// @Test
public void testBuildDirectoryDatasource() {
    DirectoryDatasource ds = buildDirectoryDatasource("test-dir").post();
    assertThat(ds).isNotNull();
}
Also used : DirectoryDatasource(com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource)

Example 2 with DirectoryDatasource

use of com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource in project kylo by Teradata.

the class MetadataClientProviderTest method testEnsureDirectoryDatasource.

@Test
public void testEnsureDirectoryDatasource() {
    this.provider.ensureDirectoryDatasource("test6", "", Paths.get("aaa", "bbb"));
    Datasource ds = this.provider.getDatasourceByName("test6");
    assertThat(ds).isNotNull();
    assertThat(ds).isInstanceOf(DirectoryDatasource.class);
    String dsId = ds.getId();
    DirectoryDatasource dds = (DirectoryDatasource) ds;
    assertThat(dds.getPath()).contains("aaa/bbb");
    ds = this.provider.ensureDirectoryDatasource("test6", "", Paths.get("aaa", "bbb"));
    assertThat(ds).isNotNull();
    assertThat(ds.getId()).isEqualTo(dsId);
}
Also used : DirectoryDatasource(com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource) Datasource(com.thinkbiganalytics.metadata.rest.model.data.Datasource) HiveTableDatasource(com.thinkbiganalytics.metadata.rest.model.data.HiveTableDatasource) DirectoryDatasource(com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource) Test(org.junit.Test)

Example 3 with DirectoryDatasource

use of com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource in project kylo by Teradata.

the class MetadataClientProviderTest method testCompleteOperation.

@Test
public void testCompleteOperation() {
    Feed feed = this.provider.ensureFeed("category", "test10", "");
    DirectoryDatasource ds = this.provider.ensureDirectoryDatasource("test10", "", Paths.get("aaa", "bbb"));
    feed = this.provider.ensureFeedDestination(feed.getId(), ds.getId());
    FeedDestination dest = feed.getDestination(ds.getId());
    DataOperation op = this.provider.beginOperation(dest, new DateTime());
    Dataset set = this.provider.createDataset(ds, Paths.get("a.txt"), Paths.get("b.txt"));
    op = this.provider.completeOperation(op.getId(), "", set);
    assertThat(op).isNotNull();
    assertThat(op.getState()).isEqualTo(State.SUCCESS);
}
Also used : DataOperation(com.thinkbiganalytics.metadata.rest.model.op.DataOperation) FeedDestination(com.thinkbiganalytics.metadata.rest.model.feed.FeedDestination) Dataset(com.thinkbiganalytics.metadata.rest.model.op.Dataset) DirectoryDatasource(com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource) DateTime(org.joda.time.DateTime) Feed(com.thinkbiganalytics.metadata.rest.model.feed.Feed) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) Test(org.junit.Test)

Example 4 with DirectoryDatasource

use of com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource in project kylo by Teradata.

the class TerminateDirectoryFeed method completeOperation.

@Override
protected DataOperation completeOperation(ProcessContext context, FlowFile flowFile, Datasource datasource, DataOperation op, DataOperation.State state) {
    MetadataProvider provider = getProviderService(context).getProvider();
    DirectoryDatasource dds = (DirectoryDatasource) datasource;
    if (state == State.SUCCESS) {
        ArrayList<Path> paths = new ArrayList<>();
        // TODO Extract file paths from flow file
        Dataset dataset = provider.createDataset(dds, paths);
        return provider.completeOperation(op.getId(), "", dataset);
    } else {
        return provider.completeOperation(op.getId(), "", state);
    }
}
Also used : Path(java.nio.file.Path) MetadataProvider(com.thinkbiganalytics.nifi.core.api.metadata.MetadataProvider) Dataset(com.thinkbiganalytics.metadata.rest.model.op.Dataset) ArrayList(java.util.ArrayList) DirectoryDatasource(com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource)

Aggregations

DirectoryDatasource (com.thinkbiganalytics.metadata.rest.model.data.DirectoryDatasource)4 Dataset (com.thinkbiganalytics.metadata.rest.model.op.Dataset)2 Test (org.junit.Test)2 FeedExecutedSinceFeed (com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed)1 Datasource (com.thinkbiganalytics.metadata.rest.model.data.Datasource)1 HiveTableDatasource (com.thinkbiganalytics.metadata.rest.model.data.HiveTableDatasource)1 Feed (com.thinkbiganalytics.metadata.rest.model.feed.Feed)1 FeedDestination (com.thinkbiganalytics.metadata.rest.model.feed.FeedDestination)1 DataOperation (com.thinkbiganalytics.metadata.rest.model.op.DataOperation)1 MetadataProvider (com.thinkbiganalytics.nifi.core.api.metadata.MetadataProvider)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1