Search in sources :

Example 1 with ConstantClassLoaderProvider

use of io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider in project cdap by caskdata.

the class InMemoryDatasetOpExecutor method create.

@Override
public DatasetSpecification create(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetProperties props) throws Exception {
    DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider());
    if (type == null) {
        throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta);
    }
    DatasetSpecification spec = type.configure(datasetInstanceId.getEntityName(), props);
    DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec);
    admin.create();
    return spec;
}
Also used : ConstantClassLoaderProvider(co.cask.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider) DatasetSpecification(co.cask.cdap.api.dataset.DatasetSpecification) DatasetAdmin(co.cask.cdap.api.dataset.DatasetAdmin) DatasetType(co.cask.cdap.data2.datafabric.dataset.DatasetType)

Example 2 with ConstantClassLoaderProvider

use of io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider in project cdap by caskdata.

the class InMemoryDatasetOpExecutor method drop.

@Override
public void drop(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetSpecification spec) throws Exception {
    DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider());
    if (type == null) {
        throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta);
    }
    DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec);
    admin.drop();
}
Also used : ConstantClassLoaderProvider(io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider) DatasetAdmin(io.cdap.cdap.api.dataset.DatasetAdmin) DatasetType(io.cdap.cdap.data2.datafabric.dataset.DatasetType)

Example 3 with ConstantClassLoaderProvider

use of io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider in project cdap by caskdata.

the class InMemoryDatasetOpExecutor method create.

@Override
public DatasetCreationResponse create(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetProperties props) throws Exception {
    DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider());
    if (type == null) {
        throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta);
    }
    DatasetSpecification spec = type.configure(datasetInstanceId.getEntityName(), props);
    DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec);
    admin.create();
    return new DatasetCreationResponse(spec, null);
}
Also used : ConstantClassLoaderProvider(io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider) DatasetSpecification(io.cdap.cdap.api.dataset.DatasetSpecification) DatasetAdmin(io.cdap.cdap.api.dataset.DatasetAdmin) DatasetType(io.cdap.cdap.data2.datafabric.dataset.DatasetType)

Example 4 with ConstantClassLoaderProvider

use of io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider in project cdap by caskdata.

the class InMemoryDatasetOpExecutor method update.

@Override
public DatasetCreationResponse update(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetProperties props, DatasetSpecification existing) throws Exception {
    DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider());
    if (type == null) {
        throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta);
    }
    try {
        DatasetSpecification spec = type.reconfigure(datasetInstanceId.getEntityName(), props, existing);
        DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec);
        if (admin instanceof Updatable) {
            ((Updatable) admin).update(existing);
        } else {
            admin.create();
        }
        if (spec.getDescription() == null && existing.getDescription() != null) {
            spec.setDescription(existing.getDescription());
        }
        return new DatasetCreationResponse(spec, null);
    } catch (IncompatibleUpdateException e) {
        throw new ConflictException(e.getMessage());
    }
}
Also used : ConflictException(io.cdap.cdap.common.ConflictException) Updatable(io.cdap.cdap.api.dataset.Updatable) ConstantClassLoaderProvider(io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider) DatasetSpecification(io.cdap.cdap.api.dataset.DatasetSpecification) DatasetAdmin(io.cdap.cdap.api.dataset.DatasetAdmin) DatasetType(io.cdap.cdap.data2.datafabric.dataset.DatasetType) IncompatibleUpdateException(io.cdap.cdap.api.dataset.IncompatibleUpdateException)

Example 5 with ConstantClassLoaderProvider

use of io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider in project cdap by caskdata.

the class InMemoryDatasetOpExecutor method drop.

@Override
public void drop(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetSpecification spec) throws Exception {
    DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider());
    if (type == null) {
        throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta);
    }
    DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec);
    admin.drop();
}
Also used : ConstantClassLoaderProvider(co.cask.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider) DatasetAdmin(co.cask.cdap.api.dataset.DatasetAdmin) DatasetType(co.cask.cdap.data2.datafabric.dataset.DatasetType)

Aggregations

DatasetAdmin (co.cask.cdap.api.dataset.DatasetAdmin)3 DatasetType (co.cask.cdap.data2.datafabric.dataset.DatasetType)3 ConstantClassLoaderProvider (co.cask.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider)3 DatasetAdmin (io.cdap.cdap.api.dataset.DatasetAdmin)3 DatasetType (io.cdap.cdap.data2.datafabric.dataset.DatasetType)3 ConstantClassLoaderProvider (io.cdap.cdap.data2.datafabric.dataset.type.ConstantClassLoaderProvider)3 DatasetSpecification (co.cask.cdap.api.dataset.DatasetSpecification)2 DatasetSpecification (io.cdap.cdap.api.dataset.DatasetSpecification)2 IncompatibleUpdateException (co.cask.cdap.api.dataset.IncompatibleUpdateException)1 Updatable (co.cask.cdap.api.dataset.Updatable)1 ConflictException (co.cask.cdap.common.ConflictException)1 IncompatibleUpdateException (io.cdap.cdap.api.dataset.IncompatibleUpdateException)1 Updatable (io.cdap.cdap.api.dataset.Updatable)1 ConflictException (io.cdap.cdap.common.ConflictException)1