Examples of ErStreamHandler


Examples of org.apache.hadoop.chukwa.inputtools.mdl.ErStreamHandler

    TorqueTimerTask torqueTimerTask = new TorqueTimerTask(p, command);
    timeout.schedule(torqueTimerTask, TorqueTimerTask.timeoutInterval * 1000);

    BufferedReader result = new BufferedReader(new InputStreamReader(p
        .getInputStream()));
    ErStreamHandler errorHandler = new ErStreamHandler(p.getErrorStream(),
        command, true);
    errorHandler.start();

    String line = null;
    boolean start = false;
    TreeSet<String> jobsInTorque = new TreeSet<String>();
    while ((line = result.readLine()) != null) {
      if (line.startsWith("---")) {
        start = true;
        continue;
      }

      if (start) {
        String[] items = line.split("\\s+");
        if (items.length >= 10) {
          String hodIdLong = items[0];
          String hodId = hodIdLong.split("[.]")[0];
          String userId = items[1];
          String numOfMachine = items[5];
          String status = items[9];
          jobsInTorque.add(hodId);
          if (!currentHodJobs.containsKey(hodId)) {
            TreeMap<String, String> aJobData = new TreeMap<String, String>();

            aJobData.put("userId", userId);
            aJobData.put("numOfMachine", numOfMachine);
            aJobData.put("traceCheckCount", "0");
            aJobData.put("process", "0");
            aJobData.put("status", status);
            currentHodJobs.put(hodId, aJobData);
          } else {
            TreeMap<String, String> aJobData = currentHodJobs.get(hodId);
            aJobData.put("status", status);
            currentHodJobs.put(hodId, aJobData);
          }// if..else
        }
      }
    }// while

    try {
      errorHandler.join();
    } catch (InterruptedException ie) {
      log.error(ie.getMessage());
    }
    timeout.cancel();

View Full Code Here

Examples of org.apache.hadoop.chukwa.inputtools.mdl.ErStreamHandler

    TorqueTimerTask torqueTimerTask = new TorqueTimerTask(p, command);
    timeout.schedule(torqueTimerTask, TorqueTimerTask.timeoutInterval * 1000);

    BufferedReader result = new BufferedReader(new InputStreamReader(p
        .getInputStream()));
    ErStreamHandler errorHandler = new ErStreamHandler(p.getErrorStream(),
        command, false);
    errorHandler.start();
    String line = null;
    String hosts = null;
    long startTimeValue = -1;
    long endTimeValue = Calendar.getInstance().getTimeInMillis();
    long executeTimeValue = Calendar.getInstance().getTimeInMillis();
    boolean qstatfinished;

    while ((line = result.readLine()) != null) {
      if (line.indexOf("ctime") >= 0) {
        String startTime = line.split("=")[1].trim();
        // Tue Sep 9 23:44:29 2008
        SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
        Date startTimeDate;
        try {
          startTimeDate = sdf.parse(startTime);
          startTimeValue = startTimeDate.getTime();
        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

      }
      if (line.indexOf("mtime") >= 0) {
        String endTime = line.split("=")[1].trim();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
        Date endTimeDate;
        try {
          endTimeDate = sdf.parse(endTime);
          endTimeValue = endTimeDate.getTime();
        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

      }
      if (line.indexOf("etime") >= 0) {
        String executeTime = line.split("=")[1].trim();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
        Date executeTimeDate;
        try {
          executeTimeDate = sdf.parse(executeTime);
          executeTimeValue = executeTimeDate.getTime();
        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

      }
      if (line.indexOf("exec_host") >= 0) {
        hosts = line.split("=")[1].trim();
      }
    }

    if (hosts != null && startTimeValue >= 0) {
      String[] items2 = hosts.split("[+]");
      int num = 0;
      for (int i = 0; i < items2.length; i++) {
        String machinetmp = items2[i];
        if (machinetmp.length() > 3) {
          String machine = items2[i].substring(0, items2[i].length() - 2);
          StringBuffer data = new StringBuffer();
          data.append("HodId=").append(hodId);
          data.append(", Machine=").append(machine);
          if (domain != null) {
            data.append(".").append(domain);
          }
          log.info(data);
          num++;
        }
      }
      Timestamp startTimedb = new Timestamp(startTimeValue);
      Timestamp endTimedb = new Timestamp(endTimeValue);
      StringBuffer data = new StringBuffer();
      long timeQueued = executeTimeValue - startTimeValue;
      data.append("HodID=").append(hodId);
      data.append(", UserId=").append(userId);
      data.append(", StartTime=").append(startTimedb);
      data.append(", TimeQueued=").append(timeQueued);
      data.append(", NumOfMachines=").append(num);
      data.append(", EndTime=").append(endTimedb);
      log.info(data);
      qstatfinished = true;

    } else {

      qstatfinished = false;
    }

    try {
      errorHandler.join();
    } catch (InterruptedException ie) {
      log.error(ie.getMessage());
    }
    result.close();
    timeout.cancel();
View Full Code Here

Examples of org.apache.hadoop.chukwa.inputtools.mdl.ErStreamHandler

    TorqueTimerTask torqueTimerTask = new TorqueTimerTask(p, command);
    timeout.schedule(torqueTimerTask, TorqueTimerTask.timeoutInterval * 1000);

    BufferedReader result = new BufferedReader(new InputStreamReader(p
        .getInputStream()));
    ErStreamHandler errorHandler = new ErStreamHandler(p.getErrorStream(),
        command, false);
    errorHandler.start();
    String line = null;
    String exit_status = null;
    String hosts = null;
    long timeQueued = -1;
    long startTimeValue = -1;
    long endTimeValue = -1;
    boolean findResult = false;

    while ((line = result.readLine()) != null && !findResult) {
      if (line.indexOf("end") >= 0 && line.indexOf("Exit_status") >= 0
          && line.indexOf("qtime") >= 0) {
        TreeMap<String, String> jobData = new TreeMap<String, String>();
        String[] items = line.split("\\s+");
        for (int i = 0; i < items.length; i++) {
          String[] items2 = items[i].split("=");
          if (items2.length >= 2) {
            jobData.put(items2[0], items2[1]);
          }

        }
        String startTime = jobData.get("ctime");
        startTimeValue = Long.valueOf(startTime);
        startTimeValue = startTimeValue - startTimeValue % (60);
        Timestamp startTimedb = new Timestamp(startTimeValue * 1000);

        String queueTime = jobData.get("qtime");
        long queueTimeValue = Long.valueOf(queueTime);

        String sTime = jobData.get("start");
        long sTimeValue = Long.valueOf(sTime);

        timeQueued = sTimeValue - queueTimeValue;

        String endTime = jobData.get("end");
        endTimeValue = Long.valueOf(endTime);
        endTimeValue = endTimeValue - endTimeValue % (60);
        Timestamp endTimedb = new Timestamp(endTimeValue * 1000);

        exit_status = jobData.get("Exit_status");
        hosts = jobData.get("exec_host");
        String[] items2 = hosts.split("[+]");
        int num = 0;
        for (int i = 0; i < items2.length; i++) {
          String machinetemp = items2[i];
          if (machinetemp.length() >= 3) {
            String machine = items2[i].substring(0, items2[i].length() - 2);
            StringBuffer data = new StringBuffer();
            data.append("HodId=").append(hodId);
            data.append(", Machine=").append(machine);
            if (domain != null) {
              data.append(".").append(domain);
            }
            log.info(data.toString());
            num++;
          }
        }

        StringBuffer data = new StringBuffer();
        data.append("HodID=").append(hodId);
        data.append(", UserId=").append(userId);
        data.append(", Status=").append(exit_status);
        data.append(", TimeQueued=").append(timeQueued);
        data.append(", StartTime=").append(startTimedb);
        data.append(", EndTime=").append(endTimedb);
        data.append(", NumOfMachines=").append(num);
        log.info(data.toString());
        findResult = true;
        log.debug(" hod info for job " + hodId + " has been loaded ");
      }// if

    }// while

    try {
      errorHandler.join();
    } catch (InterruptedException ie) {
      log.error(ie.getMessage());
    }

    timeout.cancel();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.