Package com.google.appengine.tools.pipeline.impl.model

Examples of com.google.appengine.tools.pipeline.impl.model.JobRecord


   *         may be passed in to further invocations of {@code futureCall()} in
   *         order to specify a data dependency.
   */
  public <T> FutureValue<T> futureCallUnchecked(JobSetting[] settings, Job<?> jobInstance,
      Object... params) {
    JobRecord childJobRecord = PipelineManager.registerNewJobRecord(
        updateSpec, settings, thisJobRecord, currentRunGUID, jobInstance, params);
    thisJobRecord.appendChildKey(childJobRecord.getKey());
    return new FutureValueImpl<>(childJobRecord.getOutputSlotInflated());
  }
View Full Code Here


    // Get all of the Pipeline objects so we can confirm the orphaned jobs are
    // really there
    PipelineObjects allObjects = PipelineManager.queryFullPipeline(pipelineHandle);
    Key rootJobKey = KeyFactory.createKey(JobRecord.DATA_STORE_KIND, pipelineHandle);
    JobRecord rootJob = allObjects.jobs.get(rootJobKey);
    assertNotNull(rootJob);
    String graphGuid = rootJob.getChildGraphGuid();
    assertNotNull(graphGuid);
    int numJobs = allObjects.jobs.size();
    assertEquals(2, numJobs);
    int numOrphanedJobs = 0;
    int numNonOrphanedJobs = 0;
View Full Code Here

  public void testGetJobDisplayName() throws Exception {
    PipelineService service = PipelineServiceFactory.newPipelineService();
    ConcreteJob job = new ConcreteJob();
    String pipelineId = service.startNewPipeline(job);
    JobRecord jobRecord = PipelineManager.getJob(pipelineId);
    assertEquals(job.getJobDisplayName(), jobRecord.getRootJobDisplayName());
    JobInfo jobInfo = waitUntilJobComplete(pipelineId);
    assertEquals("Shalom", jobInfo.getOutput());
    jobRecord = PipelineManager.getJob(pipelineId);
    assertEquals(job.getJobDisplayName(), jobRecord.getRootJobDisplayName());
    PipelineObjects pobjects = PipelineManager.queryFullPipeline(pipelineId);
    assertEquals(job.getJobDisplayName(), pobjects.rootJob.getRootJobDisplayName());
  }
View Full Code Here

      params = new Object[0];
    }
    // Create the root Job and its associated Barriers and Slots
    // Passing null for parent JobRecord and graphGUID
    // Create HandleSlotFilledTasks for the input parameters.
    JobRecord jobRecord = registerNewJobRecord(
        updateSpec, settings, null, null, rootJobInstance, params);
    updateSpec.setRootJobKey(jobRecord.getRootJobKey());
    // Save the Pipeline model objects and enqueue the tasks that start the Pipeline executing.
    backEnd.save(updateSpec, jobRecord.getQueueSettings());
    return jobRecord.getKey().getName();
  }
View Full Code Here

   *        with the given Object as its value.
   * @return The newly constructed JobRecord.
   */
  public static JobRecord registerNewJobRecord(UpdateSpec updateSpec, JobSetting[] settings,
      JobRecord generatorJob, String graphGUID, Job<?> jobInstance, Object[] params) {
    JobRecord jobRecord;
    if (generatorJob == null) {
      // Root Job
      if (graphGUID != null) {
        throw new IllegalArgumentException("graphGUID must be null for root jobs");
      }
      jobRecord = JobRecord.createRootJobRecord(jobInstance, settings);
    } else {
      jobRecord = new JobRecord(generatorJob, graphGUID, jobInstance, false, settings);
    }
    return registerNewJobRecord(updateSpec, jobRecord, params);
  }
View Full Code Here

   *         be found in the data store.
   */
  public static void stopJob(String jobHandle) throws NoSuchObjectException {
    checkNonEmpty(jobHandle, "jobHandle");
    Key key = KeyFactory.createKey(JobRecord.DATA_STORE_KIND, jobHandle);
    JobRecord jobRecord = backEnd.queryJob(key, JobRecord.InflationType.NONE);
    jobRecord.setState(State.STOPPED);
    UpdateSpec updateSpec = new UpdateSpec(jobRecord.getRootJobKey());
    updateSpec.getOrCreateTransaction("stopJob").includeJob(jobRecord);
    backEnd.save(updateSpec, jobRecord.getQueueSettings());
  }
View Full Code Here

   *         be found in the data store.
   */
  public static void cancelJob(String jobHandle) throws NoSuchObjectException {
    checkNonEmpty(jobHandle, "jobHandle");
    Key key = KeyFactory.createKey(JobRecord.DATA_STORE_KIND, jobHandle);
    JobRecord jobRecord = backEnd.queryJob(key, InflationType.NONE);
    CancelJobTask cancelJobTask = new CancelJobTask(key, jobRecord.getQueueSettings());
    try {
      backEnd.enqueue(cancelJobTask);
    } catch (TaskAlreadyExistsException e) {
      // OK. Some other thread has already enqueued this task.
    }
View Full Code Here

    Key generatorJobKey = slot.getGeneratorJobKey();
    if (null == generatorJobKey) {
      throw new RuntimeException(
          "Pipeline is fatally corrupted. Slot for promised value has no generatorJobKey: " + slot);
    }
    JobRecord generatorJob = backEnd.queryJob(generatorJobKey, JobRecord.InflationType.NONE);
    if (null == generatorJob) {
      throw new RuntimeException("Pipeline is fatally corrupted. "
          + "The generator job for a promised value slot was not found: " + generatorJobKey);
    }
    String childGraphGuid = generatorJob.getChildGraphGuid();
    if (null == childGraphGuid) {
      // The generator job has not been saved with a childGraphGuid yet. This can happen if the
      // promise handle leaked out to an external thread before the job that generated it
      // had finished.
      throw new NoSuchObjectException(
          "The framework is not ready to accept the promised value yet. "
          + "Please try again after the job that generated the promis handle has completed.");
    }
    if (!childGraphGuid.equals(slot.getGraphGuid())) {
      // The slot has been orphaned
      throw new OrphanedObjectException(promiseHandle);
    }
    UpdateSpec updateSpec = new UpdateSpec(slot.getRootJobKey());
    registerSlotFilled(updateSpec, generatorJob.getQueueSettings(), slot, value);
    backEnd.save(updateSpec, generatorJob.getQueueSettings());
  }
View Full Code Here

   *
   * @see "http://goto/java-pipeline-model"
   */
  private static void runJob(RunJobTask task) {
    Key jobKey = task.getJobKey();
    JobRecord jobRecord = queryJobOrAbandonTask(jobKey, JobRecord.InflationType.FOR_RUN);
    jobRecord.getQueueSettings().merge(task.getQueueSettings());
    Key rootJobKey = jobRecord.getRootJobKey();
    logger.info("Running pipeline job " + jobKey.getName() + "; UI at "
        + PipelineServlet.makeViewerUrl(rootJobKey, jobKey));
    JobRecord rootJobRecord;
    if (rootJobKey.equals(jobKey)) {
      rootJobRecord = jobRecord;
    } else {
      rootJobRecord = queryJobOrAbandonTask(rootJobKey, JobRecord.InflationType.NONE);
    }
    if (rootJobRecord.getState() == State.STOPPED) {
      logger.warning("The pipeline has been stopped: " + rootJobRecord);
      throw new AbandonTaskException();
    }

    // TODO(user): b/12301978, check if its a previous run and if so AbandonTaskException
View Full Code Here

        updateSpec, jobRecord.getQueueSettings(), jobKey, State.WAITING_TO_RUN, State.RETRY);
  }

  private static void cancelJob(CancelJobTask cancelJobTask) {
    Key jobKey = cancelJobTask.getJobKey();
    JobRecord jobRecord = queryJobOrAbandonTask(jobKey, JobRecord.InflationType.FOR_RUN);
    jobRecord.getQueueSettings().merge(cancelJobTask.getQueueSettings());
    Key rootJobKey = jobRecord.getRootJobKey();
    logger.info("Cancelling pipeline job " + jobKey.getName());
    JobRecord rootJobRecord;
    if (rootJobKey.equals(jobKey)) {
      rootJobRecord = jobRecord;
    } else {
      rootJobRecord = queryJobOrAbandonTask(rootJobKey, JobRecord.InflationType.NONE);
    }
    if (rootJobRecord.getState() == State.STOPPED) {
      logger.warning("The pipeline has been stopped: " + rootJobRecord);
      throw new AbandonTaskException();
    }

    switch (jobRecord.getState()) {
View Full Code Here

TOP

Related Classes of com.google.appengine.tools.pipeline.impl.model.JobRecord

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.