w.write("line3,3\n");
} finally {
w.close();
}
MemoryOutputElement output1 = getOutput("select-out");
assertNotNull(output1);
SelectableList<GenericData.Record> outRecords1 = output1.getRecords();
synchronized (outRecords1) {
while (outRecords1.size() < 3) {
outRecords1.wait();
}
for(GenericData.Record r : outRecords1) {
LOG.debug("query 1 got " + r.get("x"));
}
this.assertRecordExists(outRecords1, "x", new Utf8("line1"));
this.assertRecordExists(outRecords1, "x", new Utf8("line2"));
this.assertRecordExists(outRecords1, "x", new Utf8("line3"));
}
LOG.debug("first query SUCCESS");
if (killFirstQuery) {
LOG.debug("Canceling first query");
env.cancelFlow(queryId1);
joinFlow(queryId1);
LOG.debug("First query canceled.");
}
// Test the second query.
LOG.debug("Running second query");
getConf().set(SelectStmt.CLIENT_SELECT_TARGET_KEY, "select-out2");
QuerySubmitResponse selectResponse2 = env.submitQuery(
"SELECT * FROM inputstream WHERE y = 6",
getQueryOpts());
assertNotNull(selectResponse2);
FlowId queryId2 = selectResponse2.getFlowId();
assertNotNull(queryId2);
// Add more data to the stream.
w = new BufferedWriter(new FileWriter(sourceFile, true));
try {
w.write("line4,4\n");
w.write("line5,5\n");
w.write("line6,6\n");
} finally {
w.close();
}
MemoryOutputElement output2 = getOutput("select-out2");
assertNotNull(output2);
SelectableList<GenericData.Record> outRecords2 = output2.getRecords();
synchronized (outRecords2) {
while (outRecords2.size() < 1) {
outRecords2.wait();
}