Package org.apache.hadoop.chukwa

Examples of org.apache.hadoop.chukwa.Chunk


  public void doTest(Date date, String recordData) {
    ChunkBuilder cb = new ChunkBuilder();
    cb.addRecord(recordData.getBytes());

    Chunk chunk = cb.getChunk();
    chunk.setDataType(DATA_TYPE);
    chunk.setSource(DATA_SOURCE);

    ChukwaTestOutputCollector<ChukwaRecordKey, ChukwaRecord> output =
            new ChukwaTestOutputCollector<ChukwaRecordKey, ChukwaRecord>();

    TsProcessor p = new TsProcessor();
View Full Code Here


    ChukwaAgent agent = new ChukwaAgent(conf);
    ChunkCatcherConnector chunks = new ChunkCatcherConnector();
    chunks.start();
    String psAgentID = agent.processAddCommand(
        "add exec= org.apache.hadoop.chukwa.datacollection.adaptor.ExecAdaptor ps 500 ps aux 0");
    Chunk c = chunks.waitForAChunk();
    System.out.println(new String(c.getData()));
    assertNotNull(psAgentID);
    agent.shutdown();
  }
View Full Code Here

    assertEquals(name, ADAPTORID);
    Thread.sleep(500);
    send.send(p);
   
    for(int i=0; i< 5; ++i) {
      Chunk c = chunks.waitForAChunk(5000);
      System.out.println("received " + i);
      assertNotNull(c);
      String dat = new String(c.getData());
      assertTrue(dat.equals(STR));
      assertTrue(c.getDataType().equals("raw"));
      assertEquals(c.getSeqID(), STR.length());
     
      agent.stopAdaptor(name, AdaptorShutdownPolicy.RESTARTING);
      Thread.sleep(500); //for socket to deregister
      name =agent.processAddCommand("add "+ADAPTORID + " = "+adaptor+" UDPAdaptor raw "+PORTNO + " 0");
      assertEquals(name, ADAPTORID);
    }
    Chunk c = chunks.waitForAChunk(5000);

    Thread.sleep(500);
   
    buf = "different data".getBytes();
    p = new DatagramPacket(buf, buf.length);  
    p.setSocketAddress(new InetSocketAddress("127.0.0.1",PORTNO));
    send.send(p);
    c = chunks.waitForAChunk(5000);
    assertNotNull(c);
    assertEquals(buf.length + STR.length(), c.getSeqID());
   
    agent.stopAdaptor(name, true);
    assertEquals(0, agent.adaptorCount());
    Thread.sleep(500);//before re-binding
    agent.shutdown();
View Full Code Here

    int LINES = 50000;
    long bytes = 0;
    long ts_start = System.currentTimeMillis();
    for (int i = 0; i < LINES; ++i) {
      Chunk c = getNewChunk();
      bytes += c.getData().length;
      hlp.process(null, c, nullcollector, Reporter.NULL);
      // hlp.parse(line, nullcollector, Reporter.NULL);
    }
    long time = (System.currentTimeMillis() - ts_start);
    System.out.println("parse took " + time + " milliseconds");
View Full Code Here

        .getBytes());
    cb.addRecord(RecordConstants.escapeAllButLastRecordSeparator("\n", data[1])
        .getBytes());
    cb.addRecord(RecordConstants.escapeAllButLastRecordSeparator("\n", data[2])
        .getBytes());
    Chunk chunk = cb.getChunk();
    OutputCollector<ChukwaRecordKey, ChukwaRecord> output = new ChukwaTestOutputCollector<ChukwaRecordKey, ChukwaRecord>();
    TProcessor p = new TProcessor();
    p.data = data;
    p.process(null, chunk, output, null);
  }
View Full Code Here

   
    assertEquals(0, agent.adaptorCount());

    agent.processAddCommand("add test = FileAdaptor raw " +testFile.getCanonicalPath() + " 0");
    assertEquals(1, agent.adaptorCount());
    Chunk c = chunks.waitForAChunk(5000);
    assertNotNull(c);
    String dat = new String(c.getData());
    assertTrue(dat.startsWith("0 abcdefghijklmnopqrstuvwxyz"));
    assertTrue(dat.endsWith("9 abcdefghijklmnopqrstuvwxyz\n"));
    assertTrue(c.getDataType().equals("raw"));
    agent.shutdown();
  }
View Full Code Here

        System.out.println("buzzed " + i + " times");
     
      assertEquals(0, agent.adaptorCount());
      agent.processAddCommand("add test = FileAdaptor raw " +testFile.getCanonicalPath() + " 0");
      assertEquals(1, agent.adaptorCount());
      Chunk c = chunks.waitForAChunk(5000);
      assertNotNull(c);
      String dat = new String(c.getData());
      assertTrue(dat.startsWith("0 abcdefghijklmnopqrstuvwxyz"));
      assertTrue(dat.endsWith("9 abcdefghijklmnopqrstuvwxyz\n"));
      assertTrue(c.getDataType().equals("raw"));
      if(agent.adaptorCount() > 0)
        agent.stopAdaptor("test", false);
    }
    agent.shutdown();
  }
View Full Code Here

    ChunkCatcherConnector chunks = new ChunkCatcherConnector();
    chunks.start();
    String psAgentID = agent.processAddCommand(
        "add org.apache.hadoop.chukwa.datacollection.adaptor.ExecAdaptor ps ps aux 0");
    assertNotNull(psAgentID);
    Chunk c = chunks.waitForAChunk();
    System.out.println(new String(c.getData()));
    agent.shutdown();
  }
View Full Code Here

    String adaptorId = agent
        .processAddCommand("add test = org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8"
            + " lines " + testFile + " 0");
    assertTrue(adaptorId.equals("test"));
    System.out.println("getting a chunk...");
    Chunk c = chunks.waitForAChunk();
    assertTrue(c.getSeqID() == testFile.length());

    assertTrue(c.getRecordOffsets().length == 80);
    int recStart = 0;
    for (int rec = 0; rec < c.getRecordOffsets().length; ++rec) {
      String record = new String(c.getData(), recStart,
          c.getRecordOffsets()[rec] - recStart + 1);
      assertTrue(record.equals(rec + " abcdefghijklmnopqrstuvwxyz\n"));
      recStart = c.getRecordOffsets()[rec] + 1;
    }
    assertTrue(c.getDataType().equals("lines"));
    agent.stopAdaptor(adaptorId, false);
    agent.shutdown();
    Thread.sleep(2000);
  }
View Full Code Here

    String adaptorId = agent
        .processAddCommand("add lr =org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8"
            + " lines " + testFile + " 0");
    assertTrue(adaptorId.equals("lr"));
    System.out.println("getting a chunk...");
    Chunk c = chunks.waitForAChunk();
    System.out.println("got chunk");
    while (!c.getDataType().equals("lines")) {
      c = chunks.waitForAChunk();
    }
    assertTrue(c.getSeqID() == testFile.length());
    assertTrue(c.getRecordOffsets().length == 80);
    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 + " abcdefghijklmnopqrstuvwxyz\n"));
      recStart = c.getRecordOffsets()[rec] + 1;
    }
    assertTrue(c.getDataType().equals("lines"));
    testFile = makeTestFile("chukwaLogRotateTest", 40);
    c = chunks.waitForAChunk();
    System.out.println("got chunk");
    while (!c.getDataType().equals("lines")) {
      c = chunks.waitForAChunk();
    }
    // assertTrue(c.getSeqID() == testFile.length());
    assertTrue(c.getRecordOffsets().length == 40);
    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 + " abcdefghijklmnopqrstuvwxyz\n"));
      recStart = c.getRecordOffsets()[rec] + 1;
    }
    assertTrue(c.getDataType().equals("lines"));
    agent.stopAdaptor(adaptorId, false);
    agent.shutdown();
    Thread.sleep(2000);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.Chunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.