Search in sources :

Example 1 with ObjectStore

use of co.cask.cdap.api.dataset.lib.ObjectStore in project cdap by caskdata.

the class CoreDatasetsModule method register.

@Override
public void register(DatasetDefinitionRegistry registry) {
    DatasetDefinition<Table, DatasetAdmin> tableDef = registry.get("table");
    DatasetDefinition<KeyValueTable, DatasetAdmin> kvTableDef = new KeyValueTableDefinition("keyValueTable", tableDef);
    registry.add(kvTableDef);
    registry.add(new KeyValueTableDefinition(KeyValueTable.class.getName(), tableDef));
    DatasetDefinition<ObjectStore, DatasetAdmin> objectStoreDef = new ObjectStoreDefinition("objectStore", kvTableDef);
    registry.add(new ObjectStoreDefinition("objectStore", kvTableDef));
    registry.add(new ObjectStoreDefinition(ObjectStore.class.getName(), kvTableDef));
    registry.add(new IndexedObjectStoreDefinition("indexedObjectStore", tableDef, objectStoreDef));
    registry.add(new IndexedObjectStoreDefinition(IndexedObjectStore.class.getName(), tableDef, objectStoreDef));
    registry.add(new IndexedTableDefinition("indexedTable", tableDef));
    registry.add(new IndexedTableDefinition(IndexedTable.class.getName(), tableDef));
    registry.add(new TimeseriesTableDefinition("timeseriesTable", tableDef));
    registry.add(new TimeseriesTableDefinition(TimeseriesTable.class.getName(), tableDef));
    registry.add(new CounterTimeseriesTableDefinition("counterTimeseriesTable", tableDef));
    registry.add(new CounterTimeseriesTableDefinition(CounterTimeseriesTable.class.getName(), tableDef));
    // in-memory table
    registry.add(new InMemoryTableDefinition("memoryTable"));
}
Also used : ObjectStore(co.cask.cdap.api.dataset.lib.ObjectStore) IndexedObjectStore(co.cask.cdap.api.dataset.lib.IndexedObjectStore) CounterTimeseriesTable(co.cask.cdap.api.dataset.lib.CounterTimeseriesTable) TimeseriesTable(co.cask.cdap.api.dataset.lib.TimeseriesTable) IndexedTable(co.cask.cdap.api.dataset.lib.IndexedTable) Table(co.cask.cdap.api.dataset.table.Table) KeyValueTable(co.cask.cdap.api.dataset.lib.KeyValueTable) DatasetAdmin(co.cask.cdap.api.dataset.DatasetAdmin) InMemoryTableDefinition(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryTableDefinition) CounterTimeseriesTableDefinition(co.cask.cdap.api.dataset.lib.CounterTimeseriesTableDefinition) IndexedTableDefinition(co.cask.cdap.api.dataset.lib.IndexedTableDefinition) KeyValueTable(co.cask.cdap.api.dataset.lib.KeyValueTable) IndexedObjectStoreDefinition(co.cask.cdap.api.dataset.lib.IndexedObjectStoreDefinition) KeyValueTableDefinition(co.cask.cdap.api.dataset.lib.KeyValueTableDefinition) IndexedObjectStoreDefinition(co.cask.cdap.api.dataset.lib.IndexedObjectStoreDefinition) TimeseriesTableDefinition(co.cask.cdap.api.dataset.lib.TimeseriesTableDefinition) CounterTimeseriesTableDefinition(co.cask.cdap.api.dataset.lib.CounterTimeseriesTableDefinition)

Example 2 with ObjectStore

use of co.cask.cdap.api.dataset.lib.ObjectStore in project cdap by caskdata.

the class SparkTestRun method testScalaSparkCrossNSDataset.

@Test
public void testScalaSparkCrossNSDataset() throws Exception {
    // Deploy and create a dataset in namespace datasetSpaceForSpark
    NamespaceMeta inputDSNSMeta = new NamespaceMeta.Builder().setName("datasetSpaceForSpark").build();
    getNamespaceAdmin().create(inputDSNSMeta);
    deploy(inputDSNSMeta.getNamespaceId(), SparkAppUsingObjectStore.class);
    DataSetManager<ObjectStore<String>> keysManager = getDataset(inputDSNSMeta.getNamespaceId().dataset("keys"));
    prepareInputData(keysManager);
    Map<String, String> args = ImmutableMap.of(ScalaCharCountProgram.INPUT_DATASET_NAMESPACE(), inputDSNSMeta.getNamespaceId().getNamespace(), ScalaCharCountProgram.INPUT_DATASET_NAME(), "keys");
    ApplicationManager applicationManager = deploy(SparkAppUsingObjectStore.class);
    SparkManager sparkManager = applicationManager.getSparkManager(ScalaCharCountProgram.class.getSimpleName()).start(args);
    sparkManager.waitForRun(ProgramRunStatus.COMPLETED, 1, TimeUnit.MINUTES);
    DataSetManager<KeyValueTable> countManager = getDataset("count");
    checkOutputData(countManager);
}
Also used : ObjectStore(co.cask.cdap.api.dataset.lib.ObjectStore) SparkAppUsingObjectStore(co.cask.cdap.spark.app.SparkAppUsingObjectStore) ApplicationManager(co.cask.cdap.test.ApplicationManager) SparkManager(co.cask.cdap.test.SparkManager) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) KeyValueTable(co.cask.cdap.api.dataset.lib.KeyValueTable) Test(org.junit.Test)

Example 3 with ObjectStore

use of co.cask.cdap.api.dataset.lib.ObjectStore in project cdap by caskdata.

the class SparkTestRun method testScalaSparkWithObjectStore.

@Test
public void testScalaSparkWithObjectStore() throws Exception {
    ApplicationManager applicationManager = deploy(SparkAppUsingObjectStore.class);
    DataSetManager<ObjectStore<String>> keysManager = getDataset("keys");
    prepareInputData(keysManager);
    SparkManager sparkManager = applicationManager.getSparkManager(ScalaCharCountProgram.class.getSimpleName()).start();
    sparkManager.waitForRun(ProgramRunStatus.COMPLETED, 1, TimeUnit.MINUTES);
    DataSetManager<KeyValueTable> countManager = getDataset("count");
    checkOutputData(countManager);
}
Also used : ApplicationManager(co.cask.cdap.test.ApplicationManager) ObjectStore(co.cask.cdap.api.dataset.lib.ObjectStore) SparkAppUsingObjectStore(co.cask.cdap.spark.app.SparkAppUsingObjectStore) SparkManager(co.cask.cdap.test.SparkManager) KeyValueTable(co.cask.cdap.api.dataset.lib.KeyValueTable) Test(org.junit.Test)

Example 4 with ObjectStore

use of co.cask.cdap.api.dataset.lib.ObjectStore in project cdap by caskdata.

the class SparkTestRun method testSparkWithObjectStore.

@Test
public void testSparkWithObjectStore() throws Exception {
    ApplicationManager applicationManager = deploy(SparkAppUsingObjectStore.class);
    DataSetManager<ObjectStore<String>> keysManager = getDataset("keys");
    prepareInputData(keysManager);
    SparkManager sparkManager = applicationManager.getSparkManager(CharCountProgram.class.getSimpleName()).start();
    sparkManager.waitForRun(ProgramRunStatus.COMPLETED, 1, TimeUnit.MINUTES);
    DataSetManager<KeyValueTable> countManager = getDataset("count");
    checkOutputData(countManager);
    // validate that the table emitted metrics
    // one read + one write in beforeSubmit(), increment (= read + write) in main -> 4
    Tasks.waitFor(4L, new Callable<Long>() {

        @Override
        public Long call() throws Exception {
            Collection<MetricTimeSeries> metrics = getMetricsManager().query(new MetricDataQuery(0, System.currentTimeMillis() / 1000L, Integer.MAX_VALUE, "system." + Constants.Metrics.Name.Dataset.OP_COUNT, AggregationFunction.SUM, ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE, DefaultId.NAMESPACE.getNamespace(), Constants.Metrics.Tag.APP, SparkAppUsingObjectStore.class.getSimpleName(), Constants.Metrics.Tag.SPARK, CharCountProgram.class.getSimpleName(), Constants.Metrics.Tag.DATASET, "totals"), Collections.<String>emptyList()));
            if (metrics.isEmpty()) {
                return 0L;
            }
            Assert.assertEquals(1, metrics.size());
            MetricTimeSeries ts = metrics.iterator().next();
            Assert.assertEquals(1, ts.getTimeValues().size());
            return ts.getTimeValues().get(0).getValue();
        }
    }, 10L, TimeUnit.SECONDS, 50L, TimeUnit.MILLISECONDS);
}
Also used : ApplicationManager(co.cask.cdap.test.ApplicationManager) ObjectStore(co.cask.cdap.api.dataset.lib.ObjectStore) SparkAppUsingObjectStore(co.cask.cdap.spark.app.SparkAppUsingObjectStore) SparkManager(co.cask.cdap.test.SparkManager) MetricTimeSeries(co.cask.cdap.api.metrics.MetricTimeSeries) IOException(java.io.IOException) KeyValueTable(co.cask.cdap.api.dataset.lib.KeyValueTable) Collection(java.util.Collection) MetricDataQuery(co.cask.cdap.api.metrics.MetricDataQuery) Test(org.junit.Test)

Aggregations

KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)4 ObjectStore (co.cask.cdap.api.dataset.lib.ObjectStore)4 SparkAppUsingObjectStore (co.cask.cdap.spark.app.SparkAppUsingObjectStore)3 ApplicationManager (co.cask.cdap.test.ApplicationManager)3 SparkManager (co.cask.cdap.test.SparkManager)3 Test (org.junit.Test)3 DatasetAdmin (co.cask.cdap.api.dataset.DatasetAdmin)1 CounterTimeseriesTable (co.cask.cdap.api.dataset.lib.CounterTimeseriesTable)1 CounterTimeseriesTableDefinition (co.cask.cdap.api.dataset.lib.CounterTimeseriesTableDefinition)1 IndexedObjectStore (co.cask.cdap.api.dataset.lib.IndexedObjectStore)1 IndexedObjectStoreDefinition (co.cask.cdap.api.dataset.lib.IndexedObjectStoreDefinition)1 IndexedTable (co.cask.cdap.api.dataset.lib.IndexedTable)1 IndexedTableDefinition (co.cask.cdap.api.dataset.lib.IndexedTableDefinition)1 KeyValueTableDefinition (co.cask.cdap.api.dataset.lib.KeyValueTableDefinition)1 TimeseriesTable (co.cask.cdap.api.dataset.lib.TimeseriesTable)1 TimeseriesTableDefinition (co.cask.cdap.api.dataset.lib.TimeseriesTableDefinition)1 Table (co.cask.cdap.api.dataset.table.Table)1 MetricDataQuery (co.cask.cdap.api.metrics.MetricDataQuery)1 MetricTimeSeries (co.cask.cdap.api.metrics.MetricTimeSeries)1 InMemoryTableDefinition (co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryTableDefinition)1