Package org.apache.hadoop.chukwa.extraction.engine

Examples of org.apache.hadoop.chukwa.extraction.engine.ChukwaRecordKey


        rec = values.next();
        bytes += Long.valueOf(rec.getValue("bytes"));
       
        /* output raw values to different data type for uses which
         * require detailed per-operation data */
        ChukwaRecordKey detailed_key = new ChukwaRecordKey();
        String [] k = key.getKey().split("/");
        String full_timestamp = null;
        full_timestamp = rec.getValue("actual_time");
        detailed_key.setReduceType("ClientTraceDetailed");
        detailed_key.setKey(k[0]+"/"+k[1]+"_"+k[2]+"/"+full_timestamp);
        output.collect(detailed_key, rec);
      }
      if (null == rec) {
        return;
      }
View Full Code Here


        return;
      }
      line.setLogType("JobData");
    }
   
    key = new ChukwaRecordKey();
    ChukwaRecord record = new ChukwaRecord();
    this.buildGenericRecord(record, null, -1l, line.getLogType());
   
    for (Entry<String, String> entry : line.entrySet()) {
      record.add(entry.getKey(), entry.getValue());
View Full Code Here

        ChukwaRecord record = null;
        String jobID = null;
        String attemptID = null;
        while (values.hasNext()) {
            ChukwaRecordKey newkey = new ChukwaRecordKey();
            newkey.setKey(key.getKey());

            record = values.next();
            attemptID = record.getValue("TaskID");
            log.debug("attemptID: " + attemptID);
            if(attemptID == null || attemptID.equals(Util.EMPTY)){
                newkey.setReduceType(getDataType());
            }
            else {
                matcher = p.matcher(attemptID);
                if (matcher.find()) {
                    jobID= "job_" + matcher.group(1).trim();
                    String subType = jobID;
                    if(matcher.group(2).equals("m")){
                        subType += "/" + "MAP";
                    }
                    else if(matcher.group(2).equals("r")){
                        subType += "/" + "REDUCE";
                    }
                    newkey.setReduceType(getDataType()+"/" + subType + "/" + attemptID);
                }
                else {
                    newkey.setReduceType(getDataType() + "/" + attemptID);
                }
            }
            try {
                log.debug("emit key: "+ newkey.toString() + " record: " + record.toString());
                output.collect(newkey, record);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
               
View Full Code Here

                        }
                        if(splits.containsKey("FINISH_TIME")){
                            timestamp = Long.parseLong(splits.get("FINISH_TIME"));
                        }
                        if(timestamp != 0){
                            key = new ChukwaRecordKey();
                            record = new ChukwaRecord();
                            buildGenericRecord(record, null, timestamp, reduceType);
                            key.setKey("Job/" + splits.get("JOBID"));
                            addFields(splits, record);
                        }
                        unknowChunk=false;
                    }

                    //MapTask.csv & ReduceTask.csv
                    else if(recordType.equals("Task")){
                        if(splits.containsKey("TASK_TYPE")){
                            long timestamp = 0;
                            if(splits.containsKey("START_TIME")){
                                timestamp = Long.parseLong(splits.get("START_TIME"));
                            }
                            if(splits.containsKey("FINISH_TIME")){
                                timestamp = Long.parseLong(splits.get("FINISH_TIME"));
                            }
                            if(timestamp != 0){
                                key = new ChukwaRecordKey();
                                record = new ChukwaRecord();
                                buildGenericRecord(record, null, timestamp, reduceType);
                                if(splits.get("TASK_TYPE").equalsIgnoreCase("REDUCE")){
                                    key.setKey("ReduceTask/" + splits.get("TASKID"));
                                }
                                else {
                                    key.setKey("MapTask/" + splits.get("TASKID"));
                                }
                                addFields(splits, record);
                            }

                        }
                        unknowChunk=false;
                    }

                    //MapAttempt.csv
                    else if(recordType.equals("MapAttempt")){
                        long timestamp = 0;
                        if(splits.containsKey("START_TIME")){
                            timestamp = Long.parseLong(splits.get("START_TIME"));
                        }
                        if(splits.containsKey("FINISH_TIME")){
                            timestamp = Long.parseLong(splits.get("FINISH_TIME"));
                        }
                        if(timestamp != 0){
                            key = new ChukwaRecordKey();
                            record = new ChukwaRecord();
                            buildGenericRecord(record, null, timestamp, reduceType);
                            key.setKey("MapAttempt/" + splits.get("TASK_ATTEMPT_ID"));
                            addFields(splits, record);
                        }
                        unknowChunk=false;
                    }

                    //ReduceAttempt.csv
                    else if(recordType.equals("ReduceAttempt")){
                        long timestamp = 0;
                        if(splits.containsKey("START_TIME")){
                            timestamp = Long.parseLong(splits.get("START_TIME"));
                        }
                        if(splits.containsKey("FINISH_TIME")){
                            timestamp = Long.parseLong(splits.get("FINISH_TIME"));
                        }
                        if(timestamp != 0){
                            key = new ChukwaRecordKey();
                            record = new ChukwaRecord();
                            buildGenericRecord(record, null, timestamp, reduceType);
                            key.setKey("ReduceAttempt/" + splits.get("TASK_ATTEMPT_ID"));
                            addFields(splits, record);
                        }
View Full Code Here

                else {
                    fields = Util.parseRecordLine(line,Util.SPACE);
                    if(fields!=null &&  fields.length == headers.length){
                        timestamp = Long.parseLong(fields[0]) * 1000; //Timestamp in milliseconds
                        record = new ChukwaRecord();
                        key = new ChukwaRecordKey();
                        buildGenericRecord(record, null, timestamp, chunk.getDataType());

                        unknowChunk=false;
                        for (int j = 0; j < fields.length; j++){
                            log.debug("data schema: " + headers[j] + " data fields: " + fields[j]);
View Full Code Here

                else {
                    fields = Util.parseRecordLine(line,Util.COMMA);
                    if(fields != null && fields.length == headers.length){
                        timestamp = Long.parseLong(fields[0]); //Timestamp in milliseconds
                        record = new ChukwaRecord();
                        key = new ChukwaRecordKey();
                        buildGenericRecord(record, null, timestamp, reduceType);
                       
                        unknowChunk =false;
                        for (int j = 0; j < fields.length; j++){
                            log.debug("data schema: " + headers[j] + " data fields: " + fields[j]);
View Full Code Here

        JobConf jobconf = null;

        String jobID = null;
        String taskID = null;
        String attemptID = null;
        ChukwaRecordKey newkey = null;
        while (values.hasNext()) {
            newkey = null;
            record = values.next();
            String keyValue = key.getKey();
            log.debug("key:"+ keyValue);
            int index = -1;
            if((index = keyValue.indexOf("Job/"))!= -1){
                jobID = keyValue.substring(keyValue.indexOf("/")+1);
                if(jobconf==null){
                    jobconf=new JobConf(jobID.substring(4));
                }
                jobconf.update(record.getTime()/1000);
                newkey = new ChukwaRecordKey();
                newkey.setReduceType("HiTune.JobHistoryLog" + "/" + jobID + "/" + "Job");
            }
            else if((index = keyValue.indexOf("MapTask/"))!= -1){
                taskID = keyValue.substring(keyValue.indexOf("/")+1);
                matcher = p.matcher(taskID);
                if (matcher.find()) {
                    jobID = "job_" + matcher.group(1).trim();
//                    if(jobconf==null){
//                        jobconf=new JobConf(jobID.substring(4));
//                    }
//                    jobconf.update(record.getTime()/1000);
                    newkey = new ChukwaRecordKey();
                    newkey.setReduceType("HiTune.JobHistoryLog" + "/" + jobID + "/" + "MapTask");
                }

            }
            else if((index = keyValue.indexOf("ReduceTask/"))!= -1){
                taskID = keyValue.substring(keyValue.indexOf("/")+1);
                matcher = p.matcher(taskID);
                if (matcher.find()) {
                    jobID = "job_" + matcher.group(1).trim();
//                    if(jobconf==null){
//                        jobconf=new JobConf(jobID.substring(4));
//                    }
//                    jobconf.update(record.getTime()/1000);
                    newkey = new ChukwaRecordKey();
                    newkey.setReduceType("HiTune.JobHistoryLog" + "/" + jobID + "/" + "ReduceTask");
                }

            }
            else if((index = keyValue.indexOf("MapAttempt/"))!= -1){
                attemptID = keyValue.substring(keyValue.indexOf("/")+1);
                matcher = p.matcher(attemptID);
                if (matcher.find()) {
                    jobID = "job_" + matcher.group(1).trim();
//                    if(jobconf==null){
//                        jobconf=new JobConf(jobID.substring(4));
//                    }
//                    jobconf.update(record.getTime()/1000);
                    newkey = new ChukwaRecordKey();
                    newkey.setReduceType("HiTune.JobHistoryLog" + "/" + jobID + "/" + "MapAttempt");
                }

            }
            else if((index = keyValue.indexOf("ReduceAttempt/"))!= -1){
                attemptID = keyValue.substring(keyValue.indexOf("/")+1);
                matcher = p.matcher(attemptID);
                if (matcher.find()) {
                    jobID = "job_" + matcher.group(1).trim();
//                    if(jobconf==null){
//                        jobconf=new JobConf(jobID.substring(4));
//                    }
//                    jobconf.update(record.getTime()/1000);
                    newkey = new ChukwaRecordKey();
                    newkey.setReduceType("HiTune.JobHistoryLog" + "/" + jobID + "/" + "ReduceAttempt");
                }

            }

            if(newkey!=null && record!=null){
                newkey.setKey(keyValue + "/" + record.getTime());
                log.debug("newkey:" + newkey.getKey());
                log.debug("newkeyType:" + newkey.getReduceType());
                try {
                    log.debug("emit key: "+ newkey.toString() + " record: " + record.toString());
                    output.collect(newkey,record);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
View Full Code Here

    String fsName = conf.get("writer.hdfs.filesystem");
    FileSystem fs = FileSystem.get(new URI(fsName), conf);

    SequenceFile.Reader r = new SequenceFile.Reader(fs, new Path(args[0]), conf);

    ChukwaRecordKey key = new ChukwaRecordKey();
    ChukwaRecord record = new ChukwaRecord();
    try {
      while (r.next(key, record)) {
        System.out.println("\t ===== KEY   ===== ");

        System.out.println("DataType: " + key.getReduceType());
        System.out.println("\nKey: " + key.getKey());
        System.out.println("\t ===== Value =====");

        String[] fields = record.getFields();
        System.out.println("Timestamp : " + record.getTime());
        for (String field : fields) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.extraction.engine.ChukwaRecordKey

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.