Search in sources :

Example 1 with Dataset

use of com.thinkbiganalytics.metadata.rest.model.op.Dataset in project kylo by Teradata.

the class TerminateHiveTableFeed method completeOperation.

@Override
protected DataOperation completeOperation(ProcessContext context, FlowFile flowFile, Datasource dataset, DataOperation op, DataOperation.State state) {
    MetadataProvider provider = getProviderService(context).getProvider();
    if (state == State.SUCCESS) {
        HiveTableDatasource hds = (HiveTableDatasource) dataset;
        Dataset changeSet = provider.createDataset(hds, null);
        return provider.completeOperation(op.getId(), "", changeSet);
    } else {
        return provider.completeOperation(op.getId(), "", state);
    }
}
Also used : MetadataProvider(com.thinkbiganalytics.nifi.core.api.metadata.MetadataProvider) Dataset(com.thinkbiganalytics.metadata.rest.model.op.Dataset) HiveTableDatasource(com.thinkbiganalytics.metadata.rest.model.data.HiveTableDatasource)

Example 2 with Dataset

use of com.thinkbiganalytics.metadata.rest.model.op.Dataset in project kylo by Teradata.

the class MetadataClientTest method testCompleteOperation.

// @Test
public void testCompleteOperation() throws ParseException {
    Feed feedA = buildFeed("category", "feedA").post();
    HiveTableDatasource dsA = buildHiveTableDatasource("test-table").post();
    feedA = client.addDestination(feedA.getId(), dsA.getId());
    Feed feedB = buildFeed("category", "feedB", "category", "feedA").post();
    feedB = client.addSource(feedB.getId(), dsA.getId());
    String destA = feedA.getDestinations().iterator().next().getId();
    DataOperation op = client.beginOperation(destA, "");
    op.setState(State.SUCCESS);
    HiveTablePartitions changeSet = new HiveTablePartitions();
    changeSet.setPartitions(Arrays.asList(new HiveTablePartition("month", null, "Jan", "Feb"), new HiveTablePartition("year", null, "2015", "2016")));
    Dataset dataset = new Dataset(new DateTime(), dsA, ChangeType.UPDATE, ContentType.PARTITIONS, changeSet);
    op.setDataset(dataset);
    op = client.updateDataOperation(op);
    assertThat(op).isNotNull();
}
Also used : DataOperation(com.thinkbiganalytics.metadata.rest.model.op.DataOperation) HiveTablePartition(com.thinkbiganalytics.metadata.rest.model.data.HiveTablePartition) HiveTablePartitions(com.thinkbiganalytics.metadata.rest.model.op.HiveTablePartitions) Dataset(com.thinkbiganalytics.metadata.rest.model.op.Dataset) DateTime(org.joda.time.DateTime) Feed(com.thinkbiganalytics.metadata.rest.model.feed.Feed) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) HiveTableDatasource(com.thinkbiganalytics.metadata.rest.model.data.HiveTableDatasource)

Example 3 with Dataset

use of com.thinkbiganalytics.metadata.rest.model.op.Dataset 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)

Example 4 with Dataset

use of com.thinkbiganalytics.metadata.rest.model.op.Dataset 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 5 with Dataset

use of com.thinkbiganalytics.metadata.rest.model.op.Dataset in project kylo by Teradata.

the class MetadataClientTest method testCheckPrecondition.

// @Test
public void testCheckPrecondition() throws ParseException {
    Feed feedA = buildFeed("category", "feedA").post();
    Feed feedB = buildFeed("category", "feedB", "category", "feedA").post();
    HiveTableDatasource dsA = buildHiveTableDatasource("test-table").post();
    feedA = client.addDestination(feedA.getId(), dsA.getId());
    String destIdA = feedA.getDestinations().iterator().next().getId();
    DataOperation op = client.beginOperation(destIdA, "");
    op.setState(State.SUCCESS);
    op.setDataset(new Dataset(new DateTime(), dsA, ChangeType.UPDATE, ContentType.PARTITIONS));
    op = client.updateDataOperation(op);
    ServiceLevelAssessment assmt = client.assessPrecondition(feedB.getId());
    assertThat(assmt).isNotNull();
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAssessment) DataOperation(com.thinkbiganalytics.metadata.rest.model.op.DataOperation) Dataset(com.thinkbiganalytics.metadata.rest.model.op.Dataset) DateTime(org.joda.time.DateTime) Feed(com.thinkbiganalytics.metadata.rest.model.feed.Feed) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) HiveTableDatasource(com.thinkbiganalytics.metadata.rest.model.data.HiveTableDatasource)

Aggregations

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