Search in sources :

Example 21 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class ConfigTestApp method configure.

@Override
public void configure() {
    setName(NAME);
    ConfigClass configObj = getConfig();
    addStream(new Stream(configObj.streamName));
    createDataset(configObj.tableName, KeyValueTable.class);
    addWorker(new DefaultWorker(configObj.streamName));
    addFlow(new SimpleFlow(configObj.streamName, configObj.tableName));
}
Also used : Stream(co.cask.cdap.api.data.stream.Stream)

Example 22 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class FakeApp method configure.

@Override
public void configure() {
    setName(NAME);
    addStream(new Stream(STREAM_NAME));
    addDatasetModule(FakeDatasetModule.NAME, FakeDatasetModule.class);
    createDataset(DS_NAME, FakeDataset.class.getName());
    addFlow(new FakeFlow());
    addSpark(new FakeSpark());
    addWorkflow(new FakeWorkflow());
    AppConfig config = getConfig();
    if (config.addTimeSchedule) {
        scheduleWorkflow(Schedules.builder(config.timeScheduleName).createTimeSchedule(config.timeScheduleCron), FakeWorkflow.NAME);
    }
    if (config.addSizeSchedule) {
        scheduleWorkflow(Schedules.builder(config.sizeScheduleName).createDataSchedule(Schedules.Source.STREAM, STREAM_NAME, STREAM_TRIGGER_MB), FakeWorkflow.NAME);
    }
    addService(PingService.NAME, new PingService());
    addService(PrefixedEchoHandler.NAME, new PrefixedEchoHandler());
}
Also used : Stream(co.cask.cdap.api.data.stream.Stream)

Example 23 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class SpamClassifier method configure.

@Override
public void configure() {
    setName("SpamClassifier");
    setDescription("A Spark Streaming Example for Kafka Message Classification");
    addStream(new Stream(STREAM));
    addSpark(new SpamClassifierProgram());
    addService(SERVICE_HANDLER, new SpamClassifierServiceHandler());
    // Store for message classification status
    try {
        ObjectStores.createObjectStore(getConfigurer(), DATASET, Double.class, DatasetProperties.builder().setDescription("Kafka Message Spam " + "Classification").build());
    } catch (UnsupportedTypeException e) {
        // because Double is an actual class.
        throw new RuntimeException(e);
    }
}
Also used : UnsupportedTypeException(co.cask.cdap.api.data.schema.UnsupportedTypeException) Stream(co.cask.cdap.api.data.stream.Stream)

Example 24 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class HelloWorld method configure.

@Override
public void configure() {
    setName("HelloWorld");
    setDescription("A Hello World program for the Cask Data Application Platform");
    addStream(new Stream("who"));
    createDataset("whom", KeyValueTable.class, DatasetProperties.builder().setDescription("Store names").build());
    addFlow(new WhoFlow());
    addService(new Greeting());
}
Also used : Stream(co.cask.cdap.api.data.stream.Stream)

Example 25 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class LogAnalysisApp method configure.

@Override
public void configure() {
    setDescription("CDAP Log Analysis App");
    // A stream to ingest log data
    addStream(new Stream(LOG_STREAM));
    // A Spark and MapReduce for processing log data
    addSpark(new ResponseCounterSpark());
    addMapReduce(new HitCounterProgram());
    addWorkflow(new LogAnalysisWorkflow());
    // Services to query for result
    addService(HIT_COUNTER_SERVICE, new HitCounterServiceHandler());
    addService(RESPONSE_COUNTER_SERVICE, new ResponseCounterHandler());
    addService(REQUEST_COUNTER_SERVICE, new RequestCounterHandler());
    // Datasets to store output after processing
    createDataset(RESPONSE_COUNT_STORE, KeyValueTable.class, DatasetProperties.builder().setDescription("Store response counts").build());
    createDataset(HIT_COUNT_STORE, KeyValueTable.class, DatasetProperties.builder().setDescription("Store hit counts").build());
    createDataset(REQ_COUNT_STORE, TimePartitionedFileSet.class, FileSetProperties.builder().setOutputFormat(TextOutputFormat.class).setOutputProperty(TextOutputFormat.SEPERATOR, ":").setDescription("Store request counts").build());
}
Also used : Stream(co.cask.cdap.api.data.stream.Stream)

Aggregations

Stream (co.cask.cdap.api.data.stream.Stream)48 UnsupportedTypeException (co.cask.cdap.api.data.schema.UnsupportedTypeException)10 BasicService (co.cask.cdap.api.service.BasicService)6 InputStream (java.io.InputStream)2 Schema (co.cask.cdap.api.data.schema.Schema)1 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)1 Table (co.cask.cdap.api.dataset.table.Table)1 AvroKeyOutputFormat (org.apache.avro.mapreduce.AvroKeyOutputFormat)1 TextOutputFormat (org.apache.hadoop.mapreduce.lib.output.TextOutputFormat)1