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("testAdaptor"));
assertTrue(agent.getAdaptor("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; but after reboot
// we should
// still only be looking at foo.
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(1, agent.adaptorCount());// check that we processed initial
// adaptors
assertNotNull(agent.getAdaptor("testAdaptor"));
assertTrue(agent.getAdaptor("testAdaptor").getCurrentStatus().contains("foo"));
agent.shutdown();