use of com.datatorrent.bufferserver.packet.MessageType in project apex-core by apache.
the class InputNodeTest method emitTestHelper.
private void emitTestHelper(boolean trueEmitTuplesFalseHandleIdleTime) throws Exception {
TestInputOperator tio = new TestInputOperator();
tio.trueEmitTuplesFalseHandleIdleTime = trueEmitTuplesFalseHandleIdleTime;
DefaultAttributeMap dam = new DefaultAttributeMap();
dam.put(OperatorContext.APPLICATION_WINDOW_COUNT, 10);
dam.put(OperatorContext.CHECKPOINT_WINDOW_COUNT, 10);
final InputNode in = new InputNode(tio, new OperatorContext(0, "operator", dam, null));
TestSink testSink = new TestSink();
in.connectInputPort(Node.INPUT, new TestWindowGenerator());
in.connectOutputPort("output", testSink);
Thread t = new Thread() {
@Override
public void run() {
in.activate();
in.run();
in.deactivate();
}
};
t.start();
Thread.sleep(3000);
in.shutdown();
t.join();
Assert.assertTrue("Should have emitted some tuples", testSink.collectedTuples.size() > 0);
boolean insideWindow = false;
for (Object tuple : testSink.collectedTuples) {
if (tuple instanceof Tuple) {
Tuple controlTuple = (Tuple) tuple;
MessageType tupleType = controlTuple.getType();
if (tupleType == MessageType.RESET_WINDOW) {
Assert.assertFalse(insideWindow);
} else if (tupleType == MessageType.BEGIN_WINDOW) {
Assert.assertFalse(insideWindow);
insideWindow = true;
} else if (tupleType == MessageType.END_WINDOW) {
Assert.assertTrue(insideWindow);
insideWindow = false;
}
} else {
Assert.assertTrue(insideWindow);
}
}
}
Aggregations