Package org.platformlayer.jobs.model

Examples of org.platformlayer.jobs.model.JobExecutionData


  @Override
  public void visit(CliContext context, JobLog o, OutputSink sink) throws IOException {
    LinkedHashMap<String, Object> values = Maps.newLinkedHashMap();

    JobExecutionData execution = o.getExecution();
    if (execution != null) {
      values.put("jobId", execution.getJobKey().getItemIdString());
      values.put("executionId", execution.getExecutionId());

      values.put("start", o.getExecution().getStartedAt());
      values.put("end", o.getExecution().getEndedAt());

      values.put("state", execution.getState());
    }

    List<JobLogLine> lines = o.getLines();
    values.put("lines", lines.size());
View Full Code Here


    JobLogPrinter jobLogPrinter = new JobLogPrinter(new PrintWriter(System.out));

    if (Strings.isNullOrEmpty(executionId)) {
      JobExecutionList jobExecutions = client.listJobExecutions(jobId);

      JobExecutionData last = null;

      for (JobExecutionData execution : jobExecutions.getRuns()) {
        if (execution.getState() == JobState.PRESTART) {
          continue;
        }

        if (last == null) {
          last = execution;
          continue;
        }

        if (last.getStartedAt().before(execution.getStartedAt())) {
          last = execution;
          continue;
        }
      }

      if (last != null) {
        executionId = last.getExecutionId();
      }
    }

    // TODO: What if executionId == null? Also retries..
    JobLog previousJobLog = null;
View Full Code Here

    values.put("id", o.key.getItemIdString());
    values.put("target", o.targetId);
    values.put("action", o.action.getType());
    // values.put("state", o.state);

    JobExecutionData lastRun = o.getLastRun();
    values.put("lastrun:id", lastRun != null ? lastRun.getExecutionId() : null);
    values.put("lastrun:state", lastRun != null ? lastRun.getState() : null);
    values.put("lastrun:end", lastRun != null ? lastRun.getEndedAt() : null);

    sink.outputRow(values);
  }
View Full Code Here

  // return jobData;
  // }

  @Override
  public JobLog getJobLog(PlatformLayerKey jobKey, String executionId, int logSkip) throws OpsException {
    JobExecutionData execution = findExecution(jobKey, executionId);

    Date startedAt = execution.getStartedAt();
    if (execution.getEndedAt() == null) {
      JobLog log = operationQueue.getActiveJobLog(jobKey, executionId);
      if (log != null) {
        JobLog ret = new JobLog();
        ret.lines = Lists.newArrayList(Iterables.skip(log.lines, logSkip));
        ret.execution = log.execution;
View Full Code Here

      executionId = jobRepository.insertExecution(jobData.key, startedAt);
    } catch (RepositoryException e) {
      throw new OpsException("Error inserting job execution into repository", e);
    }

    JobExecutionData execution = new JobExecutionData();
    execution.job = jobData;
    execution.jobKey = jobData.getJobKey();
    execution.startedAt = startedAt;
    execution.executionId = executionId;
    execution.state = JobState.PRESTART;
View Full Code Here

        }
        return null;
      }

      try {
        JobExecutionData execution = createExecution(jobData);

        PersistentActiveJob activeJob = new PersistentActiveJob(SimpleOperationQueue.this, auth, execution);
        activeJobs.put(execution.jobKey, activeJob);

        OperationWorker operationWorker = new OperationWorker(opsSystem, activeJob);
View Full Code Here

      db.close();
    }
  }

  private JobExecutionData mapFromEntity(JobExecutionEntity execution, PlatformLayerKey jobKey) {
    JobExecutionData data = new JobExecutionData();
    data.executionId = execution.executionId;
    data.endedAt = execution.endedAt;
    data.startedAt = execution.startedAt;
    data.state = execution.state;
    data.executionId = execution.executionId;
View Full Code Here

    data.action = actionFromXml(entity.actionXml);
    data.key = jobKey;
    data.targetId = PlatformLayerKey.parse(entity.target);

    if (entity.lastrunId != null) {
      JobExecutionData execution = new JobExecutionData();
      execution.endedAt = entity.lastrunEndedAt;
      execution.executionId = entity.lastrunId;
      execution.state = entity.lastrunState;
      data.lastRun = execution;
    }
View Full Code Here

      return;
    }

    Collections.sort(runs, new Comparator<JobData>() {
      Date getLastRun(JobData d) {
        JobExecutionData lastRun = d.getLastRun();
        if (lastRun == null) {
          return null;
        }
        return lastRun.getEndedAt();
      }

      @Override
      public int compare(JobData o1, JobData o2) {
        Date v1 = getLastRun(o1);
View Full Code Here

        // Assume completed?
        throw new IllegalStateException("Job not found in job list");
      }

      JobExecutionList executions = client.listJobExecutions(job.getJobKey().getItemIdString());
      JobExecutionData foundExecution = null;
      for (JobExecutionData candidate : executions) {
        if (jobKey.equals(candidate.getJobKey())) {
          foundExecution = candidate;
        }
      }

      if (foundExecution == null) {
        throw new IllegalStateException("Execution not found in execution list");
      }

      JobState state = foundExecution.getState();
      switch (state) {
      case FAILED:
      case SUCCESS:
        System.out.println("Job completed; state=" + state);
        return found;
View Full Code Here

TOP

Related Classes of org.platformlayer.jobs.model.JobExecutionData

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.