checkpointDir.mkdir();
checkpointDir.deleteOnExit();
conf.set("chukwaAgent.checkpoint.dir", checkpointDir.getAbsolutePath());
ChukwaAgent agent = new ChukwaAgent(conf);
ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
conn.start();
assertEquals(1, agent.adaptorCount());// check that we processed initial
// adaptors
assertNotNull(agent.getAdaptor("adaptor_testAdaptor"));
assertTrue(agent.getAdaptor("adaptor_testAdaptor").getCurrentStatus().contains("foo"));
System.out
.println("---------------------done with first run, now stopping");
agent.shutdown();
Thread.sleep(2000);
assertEquals(0, agent.adaptorCount());
// at this point, there should be a checkpoint file with a tailer reading
// foo.
// we're going to rewrite initial adaptors to read bar; after reboot
// we should be looking at both foo andn bar.
ps = new PrintStream(new FileOutputStream(initialAdaptors, false));// overwrite
ps.println("add bar= org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8 raw 0 "
+ bar.getAbsolutePath() + " 0 ");
ps.close();
System.out.println("---------------------restarting");
agent = new ChukwaAgent(conf);
conn = new ConsoleOutConnector(agent, true);
conn.start();
assertEquals(2, agent.adaptorCount());// check that we processed initial
// adaptors
assertNotNull(agent.getAdaptor("adaptor_testAdaptor"));
assertTrue(agent.getAdaptor("adaptor_testAdaptor").getCurrentStatus().contains("foo"));
agent.shutdown();