Search in sources :

Example 1 with MessageSerializerFactory

use of org.apache.apex.malhar.lib.appdata.query.serde.MessageSerializerFactory in project apex-malhar by apache.

the class QueryManagerAsynchronousTest method stressTest.

@Test
public void stressTest() throws Exception {
    final int totalTuples = 100000;
    final int batchSize = 100;
    final double waitMillisProb = .01;
    AppDataWindowEndQueueManager<MockQuery, Void> queueManager = new AppDataWindowEndQueueManager<MockQuery, Void>();
    DefaultOutputPort<String> outputPort = new DefaultOutputPort<String>();
    CollectorTestSink<MockResult> sink = new CollectorTestSink<MockResult>();
    TestUtils.setSink(outputPort, sink);
    MessageSerializerFactory msf = new MessageSerializerFactory(new ResultFormatter());
    QueryManagerAsynchronous<MockQuery, Void, MutableLong, MockResult> queryManagerAsynch = new QueryManagerAsynchronous<>(outputPort, queueManager, new NOPQueryExecutor(waitMillisProb), msf, Thread.currentThread());
    Thread producerThread = new Thread(new ProducerThread(queueManager, totalTuples, batchSize, waitMillisProb));
    producerThread.start();
    producerThread.setName("Producer Thread");
    long startTime = System.currentTimeMillis();
    queryManagerAsynch.setup(null);
    int numWindows = 0;
    for (; sink.collectedTuples.size() < totalTuples && ((System.currentTimeMillis() - startTime) < 60000); numWindows++) {
        queryManagerAsynch.beginWindow(numWindows);
        Thread.sleep(100);
        queryManagerAsynch.endWindow();
    }
    producerThread.stop();
    queryManagerAsynch.teardown();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
    // Do Nothing
    }
    Assert.assertEquals(totalTuples, sink.collectedTuples.size());
}
Also used : ResultFormatter(org.apache.apex.malhar.lib.appdata.schemas.ResultFormatter) MessageSerializerFactory(org.apache.apex.malhar.lib.appdata.query.serde.MessageSerializerFactory) MutableLong(org.apache.commons.lang3.mutable.MutableLong) DefaultOutputPort(com.datatorrent.api.DefaultOutputPort) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 2 with MessageSerializerFactory

use of org.apache.apex.malhar.lib.appdata.query.serde.MessageSerializerFactory in project apex-malhar by apache.

the class DimensionalSchemaTest method produceSchema.

private String produceSchema(String resourceName) throws Exception {
    String eventSchemaJSON = SchemaUtils.jarResourceFileToString(resourceName);
    MessageSerializerFactory dsf = new MessageSerializerFactory(new ResultFormatter());
    DimensionalSchema schemaDimensional = new DimensionalSchema(new DimensionalConfigurationSchema(eventSchemaJSON, AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
    SchemaQuery schemaQuery = new SchemaQuery("1");
    SchemaResult result = new SchemaResult(schemaQuery, schemaDimensional);
    return dsf.serialize(result);
}
Also used : MessageSerializerFactory(org.apache.apex.malhar.lib.appdata.query.serde.MessageSerializerFactory)

Example 3 with MessageSerializerFactory

use of org.apache.apex.malhar.lib.appdata.query.serde.MessageSerializerFactory in project apex-malhar by apache.

the class AbstractAppDataSnapshotServer method setup.

@SuppressWarnings("unchecked")
@Override
public void setup(OperatorContext context) {
    super.setup(context);
    setupSchema();
    schemaRegistry = new SchemaRegistrySingle(schema);
    // Setup for query processing
    setupQueryProcessor();
    queryDeserializerFactory = new MessageDeserializerFactory(SchemaQuery.class, DataQuerySnapshot.class);
    queryDeserializerFactory.setContext(DataQuerySnapshot.class, schemaRegistry);
    resultSerializerFactory = new MessageSerializerFactory(resultFormatter);
    queryProcessor.setup(context);
}
Also used : DataQuerySnapshot(org.apache.apex.malhar.lib.appdata.schemas.DataQuerySnapshot) SchemaRegistrySingle(org.apache.apex.malhar.lib.appdata.schemas.SchemaRegistrySingle) MessageSerializerFactory(org.apache.apex.malhar.lib.appdata.query.serde.MessageSerializerFactory) MessageDeserializerFactory(org.apache.apex.malhar.lib.appdata.query.serde.MessageDeserializerFactory) SchemaQuery(org.apache.apex.malhar.lib.appdata.schemas.SchemaQuery)

Aggregations

MessageSerializerFactory (org.apache.apex.malhar.lib.appdata.query.serde.MessageSerializerFactory)3 DefaultOutputPort (com.datatorrent.api.DefaultOutputPort)1 MessageDeserializerFactory (org.apache.apex.malhar.lib.appdata.query.serde.MessageDeserializerFactory)1 DataQuerySnapshot (org.apache.apex.malhar.lib.appdata.schemas.DataQuerySnapshot)1 ResultFormatter (org.apache.apex.malhar.lib.appdata.schemas.ResultFormatter)1 SchemaQuery (org.apache.apex.malhar.lib.appdata.schemas.SchemaQuery)1 SchemaRegistrySingle (org.apache.apex.malhar.lib.appdata.schemas.SchemaRegistrySingle)1 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)1 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 Test (org.junit.Test)1