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

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


  public void process(ChukwaRecordKey key, Iterator<ChukwaRecord> values,
      OutputCollector<ChukwaRecordKey, ChukwaRecord> output, Reporter reporter) {
    try {
      HashMap<String, String> data = new HashMap<String, String>();

      ChukwaRecord record = null;
      String[] fields = null;
      while (values.hasNext()) {
        record = values.next();
        fields = record.getFields();
        for (String field : fields) {
          data.put(field, record.getValue(field));
        }
      }

      // Extract initial time: SUBMIT_TIME
      long initTime = Long.parseLong(data.get("SUBMIT_TIME"));

      // Extract HodId
      // maybe use a regex to extract this and load it from configuration
      // JOBCONF=
      // "/user/xxx/mapredsystem/563976.xxx.yyy.com/job_200809062051_0001/job.xml"
      String jobConf = data.get("JOBCONF");
      int idx = jobConf.indexOf("mapredsystem/");
      idx += 13;
      int idx2 = jobConf.indexOf(".", idx);
      data.put("HodId", jobConf.substring(idx, idx2));

      ChukwaRecordKey newKey = new ChukwaRecordKey();
      newKey.setKey("" + initTime);
      newKey.setReduceType("MRJob");

      ChukwaRecord newRecord = new ChukwaRecord();
      newRecord.add(Record.tagsField, record.getValue(Record.tagsField));
      newRecord.setTime(initTime);
      newRecord.add(Record.tagsField, record.getValue(Record.tagsField));
      Iterator<String> it = data.keySet().iterator();
      while (it.hasNext()) {
        String field = it.next();
        newRecord.add(field, data.get(field));
      }

      output.collect(newKey, newRecord);
    } catch (IOException e) {
      log.warn("Unable to collect output in JobLogHistoryReduceProcessor ["
View Full Code Here


  protected void parse(String recordEntry,
                       OutputCollector<ChukwaRecordKey, ChukwaRecord> output,
                       Reporter reporter) throws Throwable {
    ChukwaRecordKey key = new ChukwaRecordKey("someReduceType", recordEntry);
    ChukwaRecord record = new ChukwaRecord();

    output.collect(key, record);
  }
View Full Code Here

    try {

      Pattern task_id_pat = Pattern.compile("attempt_[0-9]*_[0-9]*_[mr]_([0-9]*)_[0-9]*");

      ChukwaRecordKey key = new ChukwaRecordKey();
      ChukwaRecord record = new ChukwaRecord();

      // initialize data structures for checking FSM
      // should see 10 maps, 8 reduces
      boolean mapSeen[] = new boolean[10];
      boolean reduceSeen[] = new boolean[8];
      boolean reduceShuffleSeen[] = new boolean[8];
      boolean reduceSortSeen[] = new boolean[8];
      boolean reduceReducerSeen[] = new boolean[8];
      for (int i = 0; i < 10; i++) mapSeen[i] = false;
      for (int i = 0; i < 8; i++) {
        reduceSeen[i] = false;
        reduceShuffleSeen[i] = false;
        reduceSortSeen[i] = false;
        reduceReducerSeen[i] = false;
      }

      Path fsm_outputs = new Path(FSM_OUTPUT_PATH.toString()+File.separator+
        "/*/MAPREDUCE_FSM/MAPREDUCE_FSM*.evt");
      FileStatus [] files;
      files = fileSys.globStatus(fsm_outputs);
      int count = 0;

      for (int i = 0; i < files.length; i++) {
        SequenceFile.Reader r = new SequenceFile.Reader(fileSys, files[i].getPath(), conf);
        System.out.println("Processing files " + files[i].getPath().toString());
        while (r.next(key, record)) {
          String state_name = record.getValue("STATE_NAME");
          String task_id = record.getValue("TASK_ID");
         
          Matcher m = task_id_pat.matcher(task_id);
          if (!m.matches()) {
            continue;
          }
View Full Code Here

      FileStatus [] files;
      files = fileSys.globStatus(fsm_outputs);
      int count = 0;
      int numHDFSRead = 0, numHDFSWrite = 0, numShuffles = 0;
      ChukwaRecordKey key = new ChukwaRecordKey();
      ChukwaRecord record = new ChukwaRecord();

      for (int i = 0; i < files.length; i++) {
        SequenceFile.Reader r = new SequenceFile.Reader(fileSys, files[i].getPath(), conf);
        System.out.println("Processing files " + files[i].getPath().toString());
        while (r.next(key, record)) {
          String state_name = record.getValue("STATE_NAME");
 
          if (state_name.equals("READ_LOCAL") || state_name.equals("READ_REMOTE"))
          {
            numHDFSRead++;
          } else if (state_name.equals("WRITE_LOCAL") || state_name.equals("WRITE_REMOTE")
View Full Code Here

      String body = recordEntry.substring(idx + 1);
      body = body.replaceAll("\n", "");
      // log.info("record [" + recordEntry + "] body [" + body +"]");
      Date d = sdf.parse(dStr);

      ChukwaRecord record = new ChukwaRecord();

      String[] list = body.split(",");
      for(String pair : list) {
        String[] kv = pair.split("=");
        record.add(kv[0], kv[1]);
      }
      record.add("cluster", chunk.getTag("cluster"));
      buildGenericRecord(record, d.getTime(), "summary");
      output.collect(key, record);
    } catch (ParseException e) {
      log.warn("Wrong format in JobSummary [" + recordEntry + "]",
          e);
View Full Code Here

      }
      kvMatcher.reset(recordEntry);
      if (!kvMatcher.find()) {
        throw new IOException("Failed to find record");
      }
      ChukwaRecord rec = new ChukwaRecord();
      do {
        rec.add(kvMatcher.group(1), kvMatcher.group(2));
      } while (kvMatcher.find());
      Locality loc = getLocality(rec.getValue("src"), rec.getValue("dest"));
      rec.add("locality", loc.getLabel());

      calendar.setTimeInMillis(ms);
      calendar.set(Calendar.SECOND, 0);
      calendar.set(Calendar.MILLISECOND, 0);
      ms = calendar.getTimeInMillis();
      calendar.set(Calendar.MINUTE, 0);
      key.setKey(calendar.getTimeInMillis() + "/" + loc.getLabel() + "/" +
                 rec.getValue("op").toLowerCase() + "/" + ms);
      key.setReduceType("ClientTrace");
      rec.setTime(ms);

      rec.add(Record.tagsField, chunk.getTags());
      rec.add(Record.sourceField, chunk.getSource());
      rec.add(Record.applicationField, chunk.getStreamName());
      rec.add("actual_time",(new Long(ms_fullresolution)).toString());
      output.collect(key, rec);

    } catch (ParseException e) {
      log.warn("Unable to parse the date in DefaultProcessor ["
          + recordEntry + "]", e);
View Full Code Here

          long ts = Long.parseLong(jsonTs);

          String jsonValue = null;
          Iterator<String> it = jsonData.keys();

          ChukwaRecord record = null;

          while (it.hasNext()) {
            jsonTs = it.next();
            jsonValue = jsonData.getString(jsonTs);

            record = new ChukwaRecord();
            key = new ChukwaRecordKey();
            this.buildGenericRecord(record, null, ts, "Ywatch");
            record.add("poller", poller);
            record.add("host", host);
            record.add("metricName", metricName);
            record.add("value", jsonValue);
            output.collect(key, record);
            log.info("YWatchProcessor output 1 metric");
          }

        } catch (IOException e) {
View Full Code Here

      log.debug("Parser Open [" + fileName + "]");

      long timestamp = 0;
      int listSize = 0;
      ChukwaRecordKey key = new ChukwaRecordKey();
      ChukwaRecord record = new ChukwaRecord();

      r = new SequenceFile.Reader(fs, new Path(fileName), conf);

      log.debug("readData Open2 [" + fileName + "]");
      if ((fileName.equals(res.fileName)) && (res.position != -1)) {
        r.seek(res.position);
      }
      res.fileName = fileName;

      while (r.next(key, record)) {
        if (record != null) {
          res.position = r.getPosition();

          timestamp = record.getTime();
          res.currentTs = timestamp;
          log.debug("\nSearch for startDate: " + new Date(t0) + " is :"
              + new Date(timestamp));

          if (timestamp < t0) {
            // log.debug("Line not in range. Skipping: " +record);
            continue;
          } else if (timestamp < t1) {
            log.debug("In Range: " + record.toString());
            boolean valid = false;

            if ((filter == null || filter.equals(""))) {
              valid = true;
            } else if (isValid(record, filter)) {
              valid = true;
            }

            if (valid) {
              records.add(record);
              record = new ChukwaRecord();
              listSize = records.size();
              if (listSize >= maxRows) {
                // maxRow so stop here
                // Update token
                token.key = key.getKey();
View Full Code Here

      OutputCollector<ChukwaRecordKey, ChukwaRecord> output, Reporter reporter)
      throws Throwable {
    try {
      String dStr = recordEntry.substring(0, 23);
      Date d = sdf.parse(dStr);
      ChukwaRecord record = new ChukwaRecord();

      if (this.chunk.getStreamName().indexOf("datanode") > 0) {
        buildGenericRecord(record, recordEntry, d.getTime(), dataNodeType);
      } else if (this.chunk.getStreamName().indexOf("namenode") > 0) {
        buildGenericRecord(record, recordEntry, d.getTime(), nameNodeType);
View Full Code Here

              valid = true;
            }

            if (valid) {
              // System.out.println("In Range In Filter: " + line);
              ChukwaRecord record = new ChukwaRecord();
              record.setTime(timestamp);
              record.add("offset", "" + offset);
              record.add(Record.bodyField, data[1]);
              record.add(Record.sourceField, dataSource);

              records.add(record);
              listSize = records.size();
              if (listSize > maxRows) {
                records.remove(0);
View Full Code Here

TOP

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

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.