Package org.apache.hadoop.chukwa

Examples of org.apache.hadoop.chukwa.ChunkImpl


   * @return the number of bytes processed
   * @throws InterruptedException
   */
  protected int extractRecords(final ChunkReceiver eq, long buffOffsetInFile,
      byte[] buf, long fileTime) throws InterruptedException {
    final ChunkImpl chunk = new ChunkImpl(type, toWatch.getAbsolutePath(),
        buffOffsetInFile + buf.length, buf, this);
    chunk.addTag("time=\"" + fileTime + "\"");
    log.info("Adding " + toWatch.getAbsolutePath() + " to the queue");
    eq.add(chunk);
    log.info( toWatch.getAbsolutePath() + " added to the queue");
    return buf.length;
  }
View Full Code Here


          String stdout = (String) o.get("stdout");
          data = stdout.getBytes();
        }

        sendOffset += data.length;
        ChunkImpl c = new ChunkImpl(ExecAdaptor.this.type, "results from "
            + cmd, sendOffset, data, ExecAdaptor.this);

        if (SPLIT_LINES) {
          ArrayList<Integer> carriageReturns = new ArrayList<Integer>();
          for (int i = 0; i < data.length; ++i)
            if (data[i] == '\n')
              carriageReturns.add(i);

          c.setRecordOffsets(carriageReturns);
        } // else we get default one record


        //We can't replay exec data, so we might as well commit to it now.
        control.reportCommit(ExecAdaptor.this, sendOffset);
View Full Code Here

     // for each line, create a chunk and an arckive key, pass it to the
     // processor, then write it to the sequence file. 
     while ((line = reader.readLine()) != null) {

       ChunkImpl chunk = new ChunkImpl(dataType, streamName,
         line.length()  + lastSeqID, line.getBytes(), null);
       lastSeqID += line.length();
       chunk.addTag("cluster=\"" + clusterName + "\"");

       ChukwaArchiveKey archiveKey = new ChukwaArchiveKey();
       archiveKey.setTimePartition(System.currentTimeMillis());
       archiveKey.setDataType(chunk.getDataType());
       archiveKey.setStreamName(chunk.getStreamName());
       archiveKey.setSeqId(chunk.getSeqID());

       processor.process(archiveKey, chunk, collector, Reporter.NULL);
       seqFileWriter.append(collector.getChukwaRecordKey(),
                            collector.getChukwaRecord());
     }
View Full Code Here

        if (log.isDebugEnabled()) {
          log.debug("Adding Chunk from JMS message: " + new String(bytes));
        }

        Chunk c = new ChunkImpl(type, source, bytesReceived, bytes, JMSAdaptor.this);
        dest.add(c);

      } catch (JMSException e) {
        log.error("can't read JMS messages in " + adaptorID, e);
      }
View Full Code Here

    Configuration conf = new Configuration();
    Path path = new Path(tempFile.getAbsolutePath());
    List<ChunkImpl> chunks = new ArrayList<ChunkImpl>();
    byte[] dat = "test".getBytes();
   
    ChunkImpl c = new ChunkImpl("Data", "aname", dat.length, dat, null);
    chunks.add(c);
   
    dat = "ing".getBytes();
    c = new ChunkImpl("Data", "aname", dat.length+4, dat, null);
    chunks.add(c);
   
    //Utilize the writeSeqFile method to create a valid .chukwa sequence file
   
    writeSeqFile(conf, FileSystem.getLocal(conf), path, chunks);
View Full Code Here

  public void testBasicPatternMatching()  {
   try {
     Filter rules = new Filter("host=foo.*&cluster=bar&datatype=Data");
     assertEquals(3, rules.size());
     byte[] dat = "someText".getBytes();
     ChunkImpl chunkNone = new ChunkImpl("badData","aname", dat.length, dat, null);
     assertFalse(rules.matches(chunkNone));
     assertTrue(Filter.ALL.matches(chunkNone));


       //do the right thing on a non-match
     ChunkImpl chunkSome = new ChunkImpl("badData", "aname", dat.length, dat, null);
     chunkSome.setSource("fooly");
     chunkSome.addTag("cluster=\"bar\"");
     assertFalse(rules.matches( chunkSome));
     assertTrue(Filter.ALL.matches(chunkSome));

     ChunkImpl chunkAll = new ChunkImpl("Data", "aname", dat.length, dat, null);
     chunkAll.setSource("fooly");
     chunkAll.addTag("cluster=\"bar\"");

     assertTrue(rules.matches(chunkAll));
     assertTrue(Filter.ALL.matches(chunkAll));

    
View Full Code Here

    collectors.add("http://somehost.invalid/chukwa");
    send.setCollectors(new RetryListOfCollectors(collectors, conf));
   
    byte[] data = "sometestdata".getBytes();
    Adaptor a = new FileTailingAdaptor();
    ChunkImpl ci = new ChunkImpl("testtype", "sname", data.length, data, a);
    ArrayList<Chunk> toSend = new ArrayList<Chunk>();
    toSend.add(ci);
    try {
      List<CommitListEntry> resp = send.send(toSend);
      assertTrue(resp.size() == 0);
View Full Code Here

   }
  }
 
  public void testClusterPatterns() {
    byte[] dat = "someText".getBytes();
    ChunkImpl chunk1 = new ChunkImpl("Data", "aname", dat.length, dat, null);
    chunk1.setSource("asource");
    assertTrue(Filter.ALL.matches(chunk1));
    Filter rule = new Filter("tags.foo=bar");
   
    assertFalse(rule.matches(chunk1));
    chunk1.addTag("foo=\"bar\"");
    assertTrue(rule.matches(chunk1));
    chunk1.addTag("baz=\"quux\"");
    assertTrue(rule.matches(chunk1));
    assertTrue(Filter.ALL.matches(chunk1));
  }
View Full Code Here

    String doneFileName=originalFileName.substring(0, extensionIndex)+".done";
    String doneDir= originalFileDir + doneFileName;
    Path donePath= new Path(doneDir);
   
    ChukwaArchiveKey key = new ChukwaArchiveKey();
      ChunkImpl evt = ChunkImpl.getBlankChunk();

    newOutputStr = localFs.create(recoverPath);
      seqFileWriter = SequenceFile.createWriter(conf, newOutputStr,
                                                ChukwaArchiveKey.class, ChunkImpl.class,
                                                SequenceFile.CompressionType.NONE, null);
View Full Code Here

  private static void dumpFile(Path p, Configuration conf,
      FileSystem fs) throws IOException {
    SequenceFile.Reader r = new SequenceFile.Reader(fs, p, conf);

    ChukwaArchiveKey key = new ChukwaArchiveKey();
    ChunkImpl chunk = ChunkImpl.getBlankChunk();
    try {
      while (r.next(key, chunk)) {
       
        String entryKey = chunk.getSource() +":"+chunk.getDataType() +":" +
        chunk.getStreamName();
       
        Integer oldC = counts.get(entryKey);
        if(oldC != null)
          counts.put(entryKey, oldC + 1);
        else
          counts.put(entryKey, new Integer(1));
       
        if(!summarize) {
          System.out.println("\nTimePartition: " + key.getTimePartition());
          System.out.println("DataType: " + key.getDataType());
          System.out.println("StreamName: " + key.getStreamName());
          System.out.println("SeqId: " + key.getSeqId());
          System.out.println("\t\t =============== ");
 
          System.out.println("Cluster : " + chunk.getTags());
          System.out.println("DataType : " + chunk.getDataType());
          System.out.println("Source : " + chunk.getSource());
          System.out.println("Application : " + chunk.getStreamName());
          System.out.println("SeqID : " + chunk.getSeqID());
          System.out.println("Data : " + new String(chunk.getData()));
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

TOP

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

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.