/* (non-Javadoc)
@see com.ibm.jbatch.container.services.IPersistenceManagerService#createJobStatus(long)
167995
@Override
	public JobStatus createJobStatus(long jobInstanceId) {
		logger.entering(CLASSNAME, "createJobStatus", jobInstanceId);
		Connection conn = null;
		PreparedStatement statement = null;
		JobStatus jobStatus = new JobStatus(jobInstanceId);
		try {
			conn = getConnection();
			statement = conn.prepareStatement("INSERT INTO jobstatus (id, obj) VALUES(?, ?)");
			statement.setLong(1, jobInstanceId);
			statement.setBytes(2, serializeObject(jobStatus));
			statement.executeUpdate();

		} catch (SQLException e) {
			throw new PersistenceException(e);
		} catch (IOException e) {
			throw new PersistenceException(e);
		} finally {
			cleanupConnection(conn, null, statement);
		}
		logger.exiting(CLASSNAME, "createJobStatus");
		return jobStatus;
	}
671737
private Job createJob() {
    Job job = new Job();
    JobConfiguration jobConfig = new JobConfiguration();
    JobConfigurationLoad loadConfig = new JobConfigurationLoad();
    jobConfig.setLoad(loadConfig);
    job.setConfiguration(jobConfig);

    loadConfig.setAllowQuotedNewlines(false);
    loadConfig.setSourceFormat("NEWLINE_DELIMITED_JSON");

    List<String> sources = new ArrayList<String>();
    for (GcsFilename file : fileSet) {
      sources.add(getFileUri(file));
    }

    loadConfig.setSourceUris(sources);

    TableReference tableRef = new TableReference();
    tableRef.setDatasetId(dataset);
    tableRef.setTableId(tableName);
    tableRef.setProjectId(projectId);
    loadConfig.setDestinationTable(tableRef);
    loadConfig.setSchema(schema.getValue());
    return job;
  }
1155231
@Override
    public WSJobInstance updateJobInstanceAndExecutionWithInstanceStateAndBatchStatus(long instanceId, long executionId,
                                                                                      final InstanceState state, final BatchStatus batchStatus) {

        JobInstanceEntity retMe = null;

        //Update the JobInstance
        retMe = (JobInstanceEntity) persistenceManagerService.updateJobInstanceWithInstanceStateAndBatchStatus(instanceId, state, batchStatus, new Date());

        //Update the Job Execution Instance
        persistenceManagerService.updateJobExecutionAndInstanceOnStatusChange(executionId, batchStatus, new Date());

        return retMe;
    }
1373590
public static COSFileStatus createFileStatus(Path keyPath,
      S3ObjectSummary summary,
      long blockSize) {
    long size = summary.getSize();
    return createFileStatus(keyPath,
        objectRepresentsDirectory(summary.getKey(), size),
        size, summary.getLastModified(), blockSize);
  }
1221101
protected Job postJobWithDescription(JSONObject jobDescription, long notBeforeRealtimeElapsed) {
        String jobId = UUID.randomUUID().toString();
        InternalJob job = new InternalJob(jobId, jobDescription, notBeforeRealtimeElapsed);
        return post(job);
    }
861011
static TaskStatus createTaskStatus(DataInput in, TaskAttemptID taskId, 
                                     float progress, int numSlots,
                                     State runState, String diagnosticInfo,
                                     String stateString, String taskTracker,
                                     Phase phase, Counters counters) 
  throws IOException {
    boolean isMap = in.readBoolean();
    return createTaskStatus(isMap, taskId, progress, numSlots, runState, 
                            diagnosticInfo, stateString, taskTracker, phase, 
                            counters);
  }
1274533
public void updateStatus(JobStatus newStatus) {
    JobMonitor monitor = getJobMonitor(newStatus);
    monitor.updateStatus(newStatus);
  }
1075480
public static HealthStatus create(int status, String message, Throwable exception) {
    return new AutoValue_HealthStatus(message, status, Optional.ofNullable(exception));
  }
306650
public static void localRunnerNotification(JobConf conf, JobStatus status) {
    JobEndStatusInfo notification = createNotification(conf, status);
    if (notification != null) {
      while (notification.configureForRetry()) {
        try {
          int code = httpNotification(notification.getUri());
          if (code != 200) {
            throw new IOException("Invalid response status code: " + code);
          }
          else {
            break;
          }
        }
        catch (IOException ioex) {
          LOG.error("Notification error [" + notification.getUri() + "]", ioex);
        }
        catch (Exception ex) {
          LOG.error("Notification error [" + notification.getUri() + "]", ex);
        }
        try {
          synchronized (Thread.currentThread()) {
            Thread.currentThread().sleep(notification.getRetryInterval());
          }
        }
        catch (InterruptedException iex) {
          LOG.error("Notification retry error [" + notification + "]", iex);
        }
      }
    }
  }
1036896
protected Job createJob() throws IOException {
    Job job = Job.getInstance(new Configuration());
    for (Map.Entry<Object, Object> entry : this.taskContext.getTaskState().getProperties().entrySet()) {
      if (entry.getKey() instanceof String && ((String) entry.getKey()).startsWith(JOB_CONFIGURATION_PREFIX)) {
        String actualKey = ((String) entry.getKey()).substring(JOB_CONFIGURATION_PREFIX.length());
        job.getConfiguration().set(actualKey, (String) entry.getValue());
      }
    }
    return job;
  }
450322
@SuppressWarnings("rawtypes")
  @Override
  public EntityManagerFactory createContainerEntityManagerFactory(
      PersistenceUnitInfo info, Map properties) {
    EntityManagerFactory factory = wrappedPersistenceProvider.createContainerEntityManagerFactory(info, properties);
    return factory;
  }
681506
public JobFile track(FileStatus jobFileStatus) {

    String jobfileName = jobFileStatus.getPath().getName();
    JobFile jobFile = new JobFile(jobfileName);

    // Extra check, caller should already have taken care of this.
    if (jobFile.isJobConfFile() || jobFile.isJobHistoryFile()) {
      track(jobFile.getJobid());

      long modificationTimeMillis = jobFileStatus.getModificationTime();
      if (modificationTimeMillis < minModificationTimeMillis) {
        minModificationTimeMillis = modificationTimeMillis;
      }
      if (modificationTimeMillis > maxModificationTimeMillis) {
        maxModificationTimeMillis = modificationTimeMillis;
      }
    }
    return jobFile;
  }
443340
@Override
  public SimpleOrderedMap<Object> create(ComponentStatus status, Boolean encode)
      throws IOException {
    SimpleOrderedMap<Object> mtasStatusResponse = new SimpleOrderedMap<>();
    if (status.getMtasHandler) {
      mtasStatusResponse.add(NAME_MTAS_STATUS_MTASHANDLER, status.handler);
    }
    if (status.getNumberOfDocuments) {
      mtasStatusResponse.add(NAME_MTAS_STATUS_NUMBEROFDOCUMENTS,
          status.numberOfDocuments);
    }
    if (status.getNumberOfSegments) {
      mtasStatusResponse.add(NAME_MTAS_STATUS_NUMBEROFSEGMENTS,
          status.numberOfSegments);
    }
    if(mtasStatusResponse.size()>0) {
      mtasStatusResponse.add(ShardInformation.NAME_NAME, status.name);
      if (status.key != null) {
        mtasStatusResponse.add(NAME_MTAS_STATUS_KEY, status.key); 
      }
      return mtasStatusResponse;
    } else {
      return null;
    }  
  }
865245
@Override
	public CheckpointStorage createCheckpointStorage(JobID jobId) throws IOException {
		return new MemoryBackendCheckpointStorage(jobId, getCheckpointPath(), getSavepointPath(), maxStateSize);
	}
358429
public EngineResult createNewJob(String jobname) {
        HttpPost postRequest = new HttpPost(baseUrl);
        List<NameValuePair> nvp = new LinkedList<NameValuePair>();
        nvp.add(new BasicNameValuePair("action", "create"));
        nvp.add(new BasicNameValuePair("createpath", jobname));
        StringEntity postEntity = null;
        try {
            postEntity = new UrlEncodedFormEntity(nvp);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        postEntity.setContentType("application/x-www-form-urlencoded");
        postRequest.addHeader("Accept", "application/xml");
        postRequest.setEntity(postEntity);
        return engineResult(postRequest);
    }
788115
@POST
  @Produces(APPLICATION_JSON)
  @Timed
  @ExceptionMetered
  public CreateJobResponse post(@Valid final Job job,
                                @RequestUser final String username) {
    final Job.Builder clone = job.toBuilder()
        .setCreatingUser(username)
        .setCreated(clock.now().getMillis())
        // If the job had a hash coming in, preserve it
        .setHash(job.getId().getHash());
    final Job actualJob = clone.build();
    final Collection<String> errors = jobValidator.validate(actualJob);
    final String jobIdString = actualJob.getId().toString();
    if (!errors.isEmpty()) {
      throw badRequest(new CreateJobResponse(INVALID_JOB_DEFINITION, ImmutableList.copyOf(errors),
          jobIdString));
    }
    try {
      model.addJob(actualJob);
    } catch (JobExistsException e) {
      throw badRequest(new CreateJobResponse(JOB_ALREADY_EXISTS, ImmutableList.<String>of(),
          jobIdString));
    }
    log.info("created job: {}", actualJob);
    return new CreateJobResponse(CreateJobResponse.Status.OK, ImmutableList.<String>of(),
        jobIdString);
  }
1343014
private static void createInternal(
      @Nullable Credentials credentials,
      String projectId,
      Duration exportInterval,
      MonitoredResource monitoredResource,
      @Nullable String metricNamePrefix,
      Map<LabelKey, LabelValue> constantLabels)
      throws IOException {
    synchronized (monitor) {
      checkState(instance == null, "Stackdriver stats exporter is already created.");
      instance =
          new StackdriverStatsExporter(
              projectId,
              createMetricServiceClient(credentials),
              exportInterval,
              monitoredResource,
              metricNamePrefix,
              constantLabels);
    }
  }