org.apache.hadoop.chukwa.ChukwaArchiveKey

Here are the examples of the java api class org.apache.hadoop.chukwa.ChukwaArchiveKey taken from open source projects.

1. DataOperations#extractRawLogFromdataSink()

Project: HiTune
File: DataOperations.java
public static void extractRawLogFromdataSink(String directory, String fileName) throws Exception {
    ChukwaConfiguration conf = new ChukwaConfiguration();
    String fsName = conf.get("writer.hdfs.filesystem");
    FileSystem fs = FileSystem.get(new URI(fsName), conf);
    SequenceFile.Reader r = new SequenceFile.Reader(fs, new Path(directory + fileName + ".done"), conf);
    File outputFile = new File(directory + fileName + ".raw");
    ChukwaArchiveKey key = new ChukwaArchiveKey();
    ChunkImpl chunk = ChunkImpl.getBlankChunk();
    FileWriter out = new FileWriter(outputFile);
    try {
        while (r.next(key, chunk)) {
            out.write(new String(chunk.getData()));
        }
    } finally {
        out.close();
        r.close();
    }
}

2. DumpArchive#dumpFile()

Project: HiTune
File: DumpArchive.java
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();
    }
}