Package org.apache.hadoop.chukwa

Examples of org.apache.hadoop.chukwa.Chunk


    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();
  }
View Full Code Here


   
    File testFile = makeTestFile("/tmp/chukwaTest");
    agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.FileTailingAdaptor" +
        " raw " + testFile + " 0");
    assertTrue(agent.adaptorCount() == 1);
    Chunk c = chunks.waitForAChunk();
    assertTrue(c.getDataType().equals("raw"));
    assertTrue(c.getRecordOffsets().length == 1);
    assertTrue(c.getSeqID() == testFile.length());    
    agent.shutdown();
  }
View Full Code Here

    File testFile = makeTestFile("/tmp/chukwaTest");
    agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8" +
        " lines " + testFile + " 0");
    assertTrue(agent.adaptorCount() == 1);
    System.out.println("getting a chunk...");
    Chunk c = chunks.waitForAChunk();
    System.out.println("got chunk");
    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"));   
    agent.shutdown();
  }
View Full Code Here

    }
    return false;
  }
  public void run() {
    List<Chunk> chunks = new LinkedList<Chunk>();
    Chunk chunk = null;
    long now = 0;
    while ( (isRunning || !chunks.isEmpty()) && (System.currentTimeMillis() < timeOut)) {
      try {
        now = System.currentTimeMillis();
        // Don't rotate if we are not running
View Full Code Here

   
    for(String logEvent :logEvents) {
      cb.addRecord(logEvent.getBytes());
    }
   
    Chunk c = cb.getChunk();
    c.setApplication(tChunk.getApplication());
    c.setDataType(tChunk.getDataType());
    c.setSeqID(tChunk.getSeqId());
    c.setSource(tChunk.getSource());
    c.setTags(tChunk.getTags());
   
    if (isDebug) {
      System.out.println("\n\t ===============");
      System.out.println("tChunk.getApplication() :" + tChunk.getApplication());
      System.out.println("tChunk.getDataType() :" + tChunk.getDataType());
      System.out.println("tChunk.getSeqId() :" + tChunk.getSeqId());
      System.out.println("tChunk.getSource() :" + tChunk.getSource());
      System.out.println("tChunk.getStreamName() :" + tChunk.getStreamName());
      System.out.println("tChunk.getTags() :" + tChunk.getTags());
     
     
      System.out.println("c.getApplication() :" + c.getApplication());
      System.out.println("c.getDataType() :" + c.getDataType());
      System.out.println("c.getSeqID() :" + c.getSeqID());
      System.out.println("c.getSource() :" + c.getSource());
      System.out.println("c.getTags() :" + c.getTags());
      System.out.println("c.getData()" + new String( c.getData()));
     
    }
 
   
   
View Full Code Here

    archiveKey.setSeqId(chunk.getSeqID());
    seqFileWriter.append(archiveKey, chunk);
  }
 
  public static Chunk getChunk(ChunkBuilder cb,String dataType) {
    Chunk c = cb.getChunk();
    c.setApplication("CmdLineConverter");
    c.setDataType(dataType);
    c.setSeqID(System.currentTimeMillis());
    c.setSource(localHostAddr);
    return c;
  }
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

    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

            + " lines " + testFile + " 0");
    assertNotNull(adaptorId);
    assertEquals(1, agent.adaptorCount());

    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);
      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.