assertTrue(c.getDataType().equals("lines"));
agent.shutdown();
}
public void testStartAfterOffset() throws IOException, InterruptedException, ChukwaAgent.AlreadyRunningException {
ChukwaAgent agent = new ChukwaAgent();
File testFile = makeTestFile();
int startOffset = 50;
agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8 " +
"lines "+ startOffset+ " " + testFile + " " + (startOffset + 29) );
assertTrue(agent.adaptorCount() == 1);
System.out.println("getting a chunk...");
Chunk c = chunks.waitForAChunk();
System.out.println("got chunk");
assertTrue(c.getSeqID() == testFile.length() + startOffset);
assertTrue(c.getRecordOffsets().length == 79);//80 lines in test file, minus the one we skipped
int recStart = 0;
for(int rec = 0 ; rec < c.getRecordOffsets().length; ++rec) {
String record = new String(c.getData(), recStart, c.getRecordOffsets()[rec] - recStart+1);
System.out.println("record "+ rec+ " was: " + record);
assertTrue(record.equals((rec+1) + " abcdefghijklmnopqrstuvwxyz\n"));
recStart = c.getRecordOffsets()[rec] +1;
}
assertTrue(c.getDataType().equals("lines"));
agent.shutdown();
}