Search in sources :

Example 1 with Datasource

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

the class ExecuteSparkJob method getDatasources.

private Map<String, String> getDatasources(ProcessSession session, FlowFile flowFile, String PROVENANCE_JOB_STATUS_KEY, String datasourceIds, MetadataProviderService metadataService, List<String> extraJarPaths) throws JsonProcessingException {
    final Map<String, String> env = new HashMap<>();
    if (StringUtils.isNotBlank(datasourceIds)) {
        final StringBuilder datasources = new StringBuilder(10240);
        final ObjectMapper objectMapper = new ObjectMapper();
        final MetadataProvider provider = metadataService.getProvider();
        for (final String id : datasourceIds.split(",")) {
            datasources.append((datasources.length() == 0) ? '[' : ',');
            final Optional<Datasource> datasource = provider.getDatasource(id);
            if (datasource.isPresent()) {
                if (datasource.get() instanceof JdbcDatasource && StringUtils.isNotBlank(((JdbcDatasource) datasource.get()).getDatabaseDriverLocation())) {
                    final String[] databaseDriverLocations = ((JdbcDatasource) datasource.get()).getDatabaseDriverLocation().split(",");
                    extraJarPaths.addAll(Arrays.asList(databaseDriverLocations));
                }
                datasources.append(objectMapper.writeValueAsString(datasource.get()));
            } else {
                getLog().error("Required datasource {} is missing for Spark job: {}", new Object[] { id, flowFile });
                flowFile = session.putAttribute(flowFile, PROVENANCE_JOB_STATUS_KEY, "Invalid data source: " + id);
                session.transfer(flowFile, REL_FAILURE);
                return null;
            }
        }
        datasources.append(']');
        env.put("DATASOURCES", datasources.toString());
    }
    return env;
}
Also used : JdbcDatasource(com.thinkbiganalytics.metadata.rest.model.data.JdbcDatasource) Datasource(com.thinkbiganalytics.metadata.rest.model.data.Datasource) JdbcDatasource(com.thinkbiganalytics.metadata.rest.model.data.JdbcDatasource) HashMap(java.util.HashMap) MetadataProvider(com.thinkbiganalytics.nifi.core.api.metadata.MetadataProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with Datasource

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

the class BeginFeed method setupSource.

protected void setupSource(ProcessContext context, Feed feed, String datasourceName) {
    MetadataProvider provider = getProviderService(context).getProvider();
    Datasource datasource = getSourceDatasource(context, datasourceName);
    if (datasource != null) {
        getLog().debug("ensuring feed source - feed: {} datasource: {}", new Object[] { feed.getId(), datasource.getId() });
        provider.ensureFeedSource(feed.getId(), datasource.getId());
    // this.sourceDatasources.add(datasource);
    } else {
        throw new ProcessException("Source datasource does not exist: " + datasourceName);
    }
}
Also used : Datasource(com.thinkbiganalytics.metadata.rest.model.data.Datasource) ProcessException(org.apache.nifi.processor.exception.ProcessException) MetadataProvider(com.thinkbiganalytics.nifi.core.api.metadata.MetadataProvider)

Example 3 with Datasource

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

the class AbstractTerminateFeed method ensureDestinationDatasource.

protected Datasource ensureDestinationDatasource(ProcessContext context) {
    String datasetName = context.getProperty(DEST_DATASET_NAME).getValue();
    Datasource dataset = findDatasource(context, datasetName);
    if (dataset != null) {
        return dataset;
    } else {
        getLog().info("No destinationDatasource exists with the givn name, creating: " + datasetName);
        return createDestinationDatasource(context, datasetName, "");
    }
}
Also used : Datasource(com.thinkbiganalytics.metadata.rest.model.data.Datasource)

Example 4 with Datasource

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

the class MetadataClientProvider method getDatasourceByName.

/* (non-Javadoc)
     * @see com.thinkbiganalytics.controller.metadata.MetadataProvider#getDatasourceByName(java.lang.String)
     */
@Override
public Datasource getDatasourceByName(String dsName) {
    DatasourceCriteria criteria = this.client.datasourceCriteria().name(dsName);
    List<Datasource> list = this.client.getDatasources(criteria);
    if (list.isEmpty()) {
        return null;
    } else {
        return list.get(0);
    }
}
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) DatasourceCriteria(com.thinkbiganalytics.metadata.rest.model.data.DatasourceCriteria)

Example 5 with Datasource

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

the class MetadataClientProviderTest method testBeginOperation.

@Test
public void testBeginOperation() {
    Feed feed = this.provider.ensureFeed("category", "test9", "");
    Datasource ds = this.provider.ensureDirectoryDatasource("test9", "", 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());
    assertThat(op).isNotNull();
    assertThat(op.getState()).isEqualTo(State.IN_PROGRESS);
}
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) DataOperation(com.thinkbiganalytics.metadata.rest.model.op.DataOperation) FeedDestination(com.thinkbiganalytics.metadata.rest.model.feed.FeedDestination) DateTime(org.joda.time.DateTime) Feed(com.thinkbiganalytics.metadata.rest.model.feed.Feed) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) Test(org.junit.Test)

Aggregations

Datasource (com.thinkbiganalytics.metadata.rest.model.data.Datasource)27 JdbcDatasource (com.thinkbiganalytics.metadata.rest.model.data.JdbcDatasource)13 DatasourceModelTransform (com.thinkbiganalytics.feedmgr.service.datasource.DatasourceModelTransform)10 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)10 DatasourceProvider (com.thinkbiganalytics.metadata.api.datasource.DatasourceProvider)10 HashMap (java.util.HashMap)10 QueryResult (com.thinkbiganalytics.discovery.schema.QueryResult)9 TableSchema (com.thinkbiganalytics.discovery.schema.TableSchema)9 DatabaseType (com.thinkbiganalytics.jdbc.util.DatabaseType)9 NotFoundException (javax.ws.rs.NotFoundException)9 FeedServicesAccessControl (com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl)8 DataSet (com.thinkbiganalytics.metadata.api.catalog.DataSet)8 DataSetProvider (com.thinkbiganalytics.metadata.api.catalog.DataSetProvider)8 DatasourceCriteria (com.thinkbiganalytics.metadata.rest.model.data.DatasourceCriteria)8 UserDatasource (com.thinkbiganalytics.metadata.rest.model.data.UserDatasource)8 AccessControlled (com.thinkbiganalytics.security.AccessControlled)8 AccessController (com.thinkbiganalytics.security.AccessController)8 Collections2 (com.google.common.collect.Collections2)7 Formatters (com.thinkbiganalytics.Formatters)7 DefaultDatabaseMetadata (com.thinkbiganalytics.discovery.model.DefaultDatabaseMetadata)7