Package org.apache.ambari.eventdb.db

Examples of org.apache.ambari.eventdb.db.PostgresConnector


    if (StringUtils.contains(DEFAULT_DRIVER, "oracle")) {
      return new OracleConnector(DEFAULT_URL, DEFAULT_DRIVER, DEFAULT_USERNAME, DEFAULT_PASSWORD);
    }else if (StringUtils.contains(DEFAULT_DRIVER, "mysql")) {
      return new MySQLConnector(DEFAULT_URL, DEFAULT_DRIVER, DEFAULT_USERNAME, DEFAULT_PASSWORD);
    } else {
      return new PostgresConnector(DEFAULT_URL, DEFAULT_DRIVER, DEFAULT_USERNAME, DEFAULT_PASSWORD);
    }
  }
View Full Code Here


  @Produces(MediaType.APPLICATION_JSON)
  @Path("/workflow")
  public Workflows getWorkflows(@QueryParam("orderBy") String field, @DefaultValue(PostgresConnector.SORT_ASC) @QueryParam("sortDir") String sortDir,
      @DefaultValue("0") @QueryParam("offset") int offset, @DefaultValue("-1") @QueryParam("limit") int limit) {
    Workflows workflows = EMPTY_WORKFLOWS;
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      if (field == null)
        workflows = conn.fetchWorkflows();
      else {
        field = field.toUpperCase();
        if ("ELAPSEDTIME".equals(field))
          field = "DURATION";
        workflows = conn.fetchWorkflows(WorkflowFields.valueOf(field), sortDir.toUpperCase().equals(PostgresConnector.SORT_ASC), offset, limit);
      }
    } catch (IOException e) {
      LOG.error("Error interacting with RCA database ", e);
      workflows = EMPTY_WORKFLOWS;
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return workflows;
  }
View Full Code Here

      default:
        field = WorkflowFields.WORKFLOWID;
    }
   
    DataTable table = null;
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      table = conn.fetchWorkflows(start, amount, searchTerm, echo, field, sortAscending, workflowId, workflowName, workflowType, userName, minJobs, maxJobs,
          minInputBytes, maxInputBytes, minOutputBytes, maxOutputBytes, minDuration, maxDuration, minStartTime, maxStartTime, minFinishTime, maxFinishTime);
    } catch (IOException e) {
      LOG.error("Error interacting with RCA database ", e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return table;
  }
View Full Code Here

  @Produces(MediaType.APPLICATION_JSON)
  @Path("/job")
  public Jobs getJobs(@QueryParam("workflowId") String workflowId, @DefaultValue("-1") @QueryParam("startTime") long minFinishTime,
      @DefaultValue("-1") @QueryParam("endTime") long maxStartTime) {
    Jobs jobs = new Jobs();
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      if (workflowId != null)
        jobs.setJobs(conn.fetchJobDetails(workflowId));
      else if (maxStartTime >= minFinishTime)
        jobs.setJobs(conn.fetchJobDetails(minFinishTime, maxStartTime));
    } catch (IOException e) {
      LOG.error("Error interacting with RCA database ", e);
      jobs.setJobs(EMPTY_JOBS);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return jobs;
  }
View Full Code Here

  @Produces(MediaType.APPLICATION_JSON)
  @Path("/task")
  public TaskData getTaskSummary(@QueryParam("jobId") String jobId, @QueryParam("width") int steps, @QueryParam("workflowId") String workflowId,
      @DefaultValue("-1") @QueryParam("startTime") long minFinishTime, @DefaultValue("-1") @QueryParam("endTime") long maxStartTime) {
    TaskData points = new TaskData();
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      List<TaskAttempt> taskAttempts = null;
      long startTime = -1;
      long endTime = -1;
      if (jobId != null) {
        long[] times = conn.fetchJobStartStopTimes(jobId);
        if (times != null) {
          startTime = times[0];
          endTime = times[1];
          taskAttempts = conn.fetchJobTaskAttempts(jobId);
        }
      } else {
        startTime = minFinishTime;
        endTime = maxStartTime;
        if (workflowId != null)
          taskAttempts = conn.fetchWorkflowTaskAttempts(workflowId);
        else
          taskAttempts = conn.fetchTaskAttempts(minFinishTime, maxStartTime);
      }
      if (startTime > 0 && endTime > 0 && endTime >= startTime) {
        double submitTimeSecs = startTime / 1000.0;
        double finishTimeSecs = endTime / 1000.0;
        double step = (finishTimeSecs - submitTimeSecs) / steps;
        if (step < 1)
          step = 1;
        if (taskAttempts != null)
          getTaskDetails(taskAttempts, points, submitTimeSecs, finishTimeSecs, step);
      }
    } catch (IOException e) {
      LOG.error("Error interacting with RCA database ", e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return points;
  }
View Full Code Here

  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("/taskdetails")
  public List<TaskAttempt> getTaskDetails(@QueryParam("jobId") String jobId, @QueryParam("workflowId") String workflowId) {
    List<TaskAttempt> taskAttempts = new ArrayList<TaskAttempt>();
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      if (jobId != null) {
        taskAttempts = conn.fetchJobTaskAttempts(jobId);
      } else if (workflowId != null) {
        taskAttempts = conn.fetchWorkflowTaskAttempts(workflowId);
      }
    } catch (IOException e) {
      LOG.error("Error interacting with RCA database ", e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return taskAttempts;
  }
View Full Code Here

  public TaskLocalityData getTaskLocalitySummary(@QueryParam("jobId") String jobId, @DefaultValue("4") @QueryParam("minr") int minr,
      @DefaultValue("24") @QueryParam("maxr") int maxr, @QueryParam("workflowId") String workflowId) {
    if (maxr < minr)
      maxr = minr;
    TaskLocalityData data = new TaskLocalityData();
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      if (jobId != null) {
        long[] times = conn.fetchJobStartStopTimes(jobId);
        if (times != null) {
          getApproxTaskAttemptsByLocality(conn.fetchJobTaskAttempts(jobId), times[0], times[1], data, minr, maxr);
        }
      } else if (workflowId != null) {
        getExactTaskAttemptsByLocality(conn.fetchWorkflowTaskAttempts(workflowId), data, minr, maxr);
      }
    } catch (IOException e) {
      LOG.error("Error interacting with RCA database ", e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return data;
  }
View Full Code Here

    List<WorkflowDBEntry> emptyWorkflows = Collections.emptyList();
    EMPTY_WORKFLOWS.setWorkflows(emptyWorkflows);
  }
 
  PostgresConnector getConnector() throws IOException {
    return new PostgresConnector(DEFAULT_HOSTNAME, DEFAULT_DBNAME, DEFAULT_USERNAME, DEFAULT_PASSWORD);
  }
View Full Code Here

  @Produces(MediaType.APPLICATION_JSON)
  @Path("/workflow")
  public Workflows getWorkflows(@QueryParam("orderBy") String field, @DefaultValue(PostgresConnector.SORT_ASC) @QueryParam("sortDir") String sortDir,
      @DefaultValue("0") @QueryParam("offset") int offset, @DefaultValue("-1") @QueryParam("limit") int limit) {
    Workflows workflows = EMPTY_WORKFLOWS;
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      if (field == null)
        workflows = conn.fetchWorkflows();
      else {
        field = field.toUpperCase();
        if ("ELAPSEDTIME".equals(field))
          field = "DURATION";
        workflows = conn.fetchWorkflows(WorkflowFields.valueOf(field), sortDir.toUpperCase().equals(PostgresConnector.SORT_ASC), offset, limit);
      }
    } catch (IOException e) {
      e.printStackTrace();
      workflows = EMPTY_WORKFLOWS;
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return workflows;
  }
View Full Code Here

      default:
        field = WorkflowFields.WORKFLOWID;
    }
   
    DataTable table = null;
    PostgresConnector conn = null;
    try {
      conn = getConnector();
      table = conn.fetchWorkflows(start, amount, searchTerm, echo, field, sortAscending, workflowId, workflowName, workflowType, userName, minJobs, maxJobs,
          minInputBytes, maxInputBytes, minOutputBytes, maxOutputBytes, minDuration, maxDuration, minStartTime, maxStartTime);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
    return table;
  }
View Full Code Here

TOP

Related Classes of org.apache.ambari.eventdb.db.PostgresConnector

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.