Here are the examples of the java api class org.apache.hadoop.chukwa.datacollection.connector.ChunkCatcherConnector taken from open source projects.
1. TestCmd#testStopAll()
Project: HiTune
File: TestCmd.java
File: TestCmd.java
public void testStopAll() throws Exception { Configuration conf = new Configuration(); conf.set("chukwaAgent.control.port", "0"); ChukwaAgent agent = new ChukwaAgent(conf); ChunkCatcherConnector chunks = new ChunkCatcherConnector(); chunks.start(); agent.processAddCommand("ADD adaptor1 = org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor" + " chukwaTestAdaptorType 0"); agent.processAddCommand("ADD adaptor2 = org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor" + " chukwaTestAdaptorType 0"); assertEquals(2, agent.adaptorCount()); Socket s = new Socket("localhost", agent.getControllerPort()); PrintWriter bw = new PrintWriter(new OutputStreamWriter(s.getOutputStream())); bw.println("stopAll"); bw.flush(); InputStreamReader in = new InputStreamReader(s.getInputStream()); in.read(); assertEquals(0, agent.adaptorCount()); agent.shutdown(); }
2. TestDelayedAcks#testAdaptorTimeout()
Project: HiTune
File: TestDelayedAcks.java
File: TestDelayedAcks.java
//start an adaptor -- chunks should appear in the connector //wait for timeout. More chunks should appear. public void testAdaptorTimeout() throws Exception { Configuration conf = new Configuration(); conf.set("chukwaAgent.control.port", "0"); conf.setBoolean("chukwaAgent.checkpoint.enabled", false); conf.setInt("chukwaAgent.adaptor.context.switch.time", 500); conf.setInt(AdaptorResetThread.TIMEOUT_OPT, ACK_TIMEOUT); ChukwaAgent agent = new ChukwaAgent(conf); ChunkCatcherConnector chunks = new ChunkCatcherConnector(); chunks.start(); assertEquals(0, agent.adaptorCount()); File testFile = makeTestFile("testDA", 50, new File(System.getProperty("test.build.data", "/tmp"))); long len = testFile.length(); System.out.println("wrote data to " + testFile); AdaptorResetThread restart = new AdaptorResetThread(conf, agent); //start timeout thread agent.processAddCommand("add fta = " + FileTailingAdaptor.class.getCanonicalName() + " testdata " + testFile.getCanonicalPath() + " 0"); assertEquals(1, agent.adaptorCount()); Chunk c1 = chunks.waitForAChunk(); assertNotNull(c1); List<CommitListEntry> pendingAcks = new ArrayList<CommitListEntry>(); pendingAcks.add(new DelayedCommit(c1.getInitiator(), c1.getSeqID(), c1.getData().length, "foo", c1.getSeqID(), agent.getAdaptorName(c1.getInitiator()))); restart.reportPending(pendingAcks); assertEquals(len, c1.getData().length); Thread.sleep(ACK_TIMEOUT * 2); int resetCount = restart.resetTimedOutAdaptors(ACK_TIMEOUT); Chunk c2 = chunks.waitForAChunk(1000); assertNotNull(c2); assertEquals(len, c2.getData().length); assertTrue(resetCount > 0); agent.shutdown(); testFile.delete(); }
3. TestXtrAdaptor#testXtrAdaptor()
Project: HiTune
File: TestXtrAdaptor.java
File: TestXtrAdaptor.java
public void testXtrAdaptor() throws IOException, ChukwaAgent.AlreadyRunningException, InterruptedException { Configuration conf = new Configuration(); File baseDir = new File(System.getProperty("test.build.data", "/tmp")); conf.set("chukwaAgent.checkpoint.dir", baseDir.getCanonicalPath()); conf.setBoolean("chukwaAgent.checkpoint.enabled", false); conf.set("chukwaAgent.control.port", "0"); ChukwaAgent agent = new ChukwaAgent(conf); ChunkCatcherConnector chunks = new ChunkCatcherConnector(); chunks.start(); System.setProperty("xtrace.reporter", "edu.berkeley.xtrace.reporting.TcpReporter"); System.setProperty("xtrace.tcpdest", "localhost:7831"); assertEquals(0, agent.adaptorCount()); agent.processAddCommand("add edu.berkeley.chukwa_xtrace.XtrAdaptor XTrace TcpReportSource 0"); assertEquals(1, agent.adaptorCount()); XTraceContext.startTrace("test", "testtrace", "atag"); XTraceContext.logEvent("test", "label"); Chunk c = chunks.waitForAChunk(); String report = new String(c.getData()); assertTrue(report.contains("Agent: test")); assertTrue(report.contains("Tag: atag")); System.out.println(report); System.out.println("-- next chunk --- "); c = chunks.waitForAChunk(); report = new String(c.getData()); assertTrue(report.contains("Agent: test")); assertTrue(report.contains("Label: label")); System.out.println(report); System.out.println("OK"); agent.shutdown(); }
4. TestAgentClient#setUp()
Project: HiTune
File: TestAgentClient.java
File: TestAgentClient.java
// consoleConnector = new ConsoleOutConnector(agent); protected void setUp() throws ChukwaAgent.AlreadyRunningException { config = new Configuration(); agent = new ChukwaAgent(config); c = new ChukwaAgentController(); connector = new ChunkCatcherConnector(); connector.start(); }