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());
}
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);
}
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);
}
Aggregations