Start a print.

@param jobId the job ID
@param specJson the client json request.
@param out the stream to write to.
354228
public final Processor.ExecutionContext print(
            final String jobId, final PJsonObject specJson, final OutputStream out)
            throws Exception {
        final OutputFormat format = getOutputFormat(specJson);
        final File taskDirectory = this.workingDirectories.getTaskDirectory();

        try {
            return format.print(jobId, specJson, getConfiguration(), this.configFile.getParentFile(),
                                taskDirectory, out);
        } finally {
            this.workingDirectories.removeDirectory(taskDirectory);
        }
    }
1013952
public boolean startJob(final Long jobId) {

		final ScheduledJob job = removeFromQueueInternal(jobId);

		if (job != null) {
			activeJobs.put(jobId, job);
			job.startJob();
			return true;
		} else {
			return false;
		}
	}
919456
private void startScript(String line, DispatchCallback callback) {
    OutputFile outFile = sqlLine.getScriptOutputFile();
    if (outFile != null) {
      callback.setToFailure();
      sqlLine.error(sqlLine.loc("script-already-running", outFile));
      return;
    }

    String filename;
    if (line.length() == "script".length()
        || (filename =
            sqlLine.dequote(line.substring("script".length() + 1))) == null) {
      sqlLine.error("Usage: script <file name>");
      callback.setToFailure();
      return;
    }

    try {
      outFile = new OutputFile(expand(filename));
      sqlLine.setScriptOutputFile(outFile);
      sqlLine.output(sqlLine.loc("script-started", outFile));
      callback.setToSuccess();
    } catch (Exception e) {
      callback.setToFailure();
      sqlLine.error(e);
    }
  }
632697
@Override
    public int enqueue(JobRequest jd)
    {
        try
        {
            return target.path("ji").request().post(Entity.entity(jd, MediaType.APPLICATION_XML), JobInstance.class).getId();
        }
        catch (BadRequestException e)
        {
            throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e);
        }
        catch (Exception e)
        {
            throw new JqmClientException(e);
        }
    }
1315197
private void writeJsonForArchivedJob(PrintWriter wrt, RecentJobEvent jobEvent) {
		
		try {
		
			wrt.write("[");
		
			ManagementGraph jobManagementGraph = jobmanager.getManagementGraph(jobEvent.getJobID());
			
			//Serialize job to json
			wrt.write("{");
			wrt.write("\"jobid\": \"" + jobEvent.getJobID() + "\",");
			wrt.write("\"jobname\": \"" + jobEvent.getJobName()+"\",");
			wrt.write("\"status\": \""+ jobEvent.getJobStatus() + "\",");
			wrt.write("\"SCHEDULED\": "+ jobmanager.getArchive().getJobTime(jobEvent.getJobID(), JobStatus.SCHEDULED) + ",");
			wrt.write("\"RUNNING\": "+ jobmanager.getArchive().getJobTime(jobEvent.getJobID(), JobStatus.RUNNING) + ",");
			wrt.write("\"FINISHED\": "+ jobmanager.getArchive().getJobTime(jobEvent.getJobID(), JobStatus.FINISHED) + ",");
			wrt.write("\"FAILED\": "+ jobmanager.getArchive().getJobTime(jobEvent.getJobID(), JobStatus.FAILED) + ",");
			wrt.write("\"CANCELED\": "+ jobmanager.getArchive().getJobTime(jobEvent.getJobID(), JobStatus.CANCELED) + ",");
			wrt.write("\"CREATED\": " + jobmanager.getArchive().getJobTime(jobEvent.getJobID(), JobStatus.CREATED)+",");

			if (jobEvent.getJobStatus() == JobStatus.FAILED) {
			ManagementGraphIterator managementGraphIterator =  new ManagementGraphIterator(jobManagementGraph,true);
			wrt.write("\"failednodes\": [");
			HashSet<String> map = new HashSet<String>();
			boolean first = true;
			while (managementGraphIterator.hasNext()) {
				ManagementVertex managementVertex = managementGraphIterator.next();
				String instanceName = managementVertex.getInstanceName();
				if (managementVertex.getExecutionState() == ExecutionState.FAILED && !map.contains(instanceName)) {
					if (first) {
						first = false;
					} else {
						wrt.write(",");
					}
					wrt.write("{");
					wrt.write("\"node\": \"" + instanceName + "\",");
					wrt.write("\"message\": \"" + StringUtils.escapeHtml(managementVertex.getOptMessage()) + "\"");
					wrt.write("}");
					map.add(instanceName);
				}
			}
			wrt.write("],");
			}

			// Serialize ManagementGraph to json
			wrt.write("\"groupvertices\": [");
			boolean first = true;
			for(ManagementGroupVertex groupVertex : jobManagementGraph.getGroupVerticesInTopologicalOrder()) {
				//Write seperator between json objects
				if(first) {
					first = false;
				} else {
					wrt.write(","); }
				
				wrt.write(groupVertex.toJson());
				
			}
			wrt.write("],");
			
			// write accumulators
			AccumulatorEvent accumulators = jobmanager.getAccumulatorResults(jobEvent.getJobID());
			Map<String, Object> accMap = AccumulatorHelper.toResultMap(accumulators.getAccumulators());
			
			wrt.write("\n\"accumulators\": [");
			int i = 0;
			for( Entry<String, Object> accumulator : accMap.entrySet()) {
				wrt.write("{ \"name\": \""+accumulator.getKey()+" (" + accumulator.getValue().getClass().getName()+")\","
						+ " \"value\": \""+accumulator.getValue().toString()+"\"}\n");
				if(++i < accMap.size()) {
					wrt.write(",");
				}
			}
			wrt.write("],\n");
			
			wrt.write("\"groupverticetimes\": {");
			first = true;
			for(ManagementGroupVertex groupVertex : jobManagementGraph.getGroupVerticesInTopologicalOrder()) {
				
				if(first) {
					first = false;
				} else {
					wrt.write(","); }
				
				// Calculate start and end time for groupvertex
				long started = Long.MAX_VALUE;
				long ended = 0;
				
				// Take earliest running state and latest endstate of groupmembers
				for(int j = 0; j < groupVertex.getNumberOfGroupMembers(); j++) {
					ManagementVertex vertex = groupVertex.getGroupMember(j);
					
					long running = jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.RUNNING);
					if(running != 0 && running < started) {
						started = running;
					}
					
					long finished = jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.FINISHED);
					long canceled = jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.CANCELED);
					long failed = jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.FAILED);
					
					if(finished != 0 && finished > ended) {
						ended = finished;
					}
					
					if(canceled != 0 && canceled > ended) {
						ended = canceled;
					}
					
					if(failed != 0 && failed > ended) {
						ended = failed;
					}

				}
				
				wrt.write("\""+groupVertex.getID()+"\": {");
				wrt.write("\"groupvertexid\": \"" + groupVertex.getID() + "\",");
				wrt.write("\"groupvertexname\": \"" + groupVertex + "\",");
				wrt.write("\"STARTED\": "+ started + ",");
				wrt.write("\"ENDED\": "+ ended);
				wrt.write("}");
				
			}

			wrt.write("}");
			
			wrt.write("}");
			
			
		wrt.write("]");
		
		} catch (EofException eof) { // Connection closed by client
			LOG.info("Info server for jobmanager: Connection closed by client, EofException");
		} catch (IOException ioe) { // Connection closed by client	
			LOG.info("Info server for jobmanager: Connection closed by client, IOException");
		} 
		
	}
553377
public void output(PrintWriter out)
    {
        Map<String, Entry> entries = config.getSortedEntries();
        
        if ( entries.isEmpty() )
        {
            return;
        }

        ColumnPrinter printer = build(entries);

        out.println("Configuration Details");
        printer.print(out);
    }
630750
public static void copyThread(InputStream in, OutputStream out)
    {
        try{
            instance().run(new Job(in,out));
        }
        catch(InterruptedException e)
        {
            log.warn(LogSupport.EXCEPTION,e);
        }
    }
1251974
public static void print(Object self, PrintWriter out) {
        if (out == null) {
            out = new PrintWriter(System.out);
        }
        out.print(InvokerHelper.toString(self));
    }
505258
public void write(String jobname, FsJob job) throws IOException {
        writeFile(jobname, FILENAME, FsJobParser.toJson(job));
    }
1269765
public static void doPublish(final Jedis jedis, final String namespace, final String channel, final String jobJson) {
        jedis.publish(JesqueUtils.createKey(namespace, CHANNEL, channel), jobJson);
    }
591034
@Override
	public void start() throws Exception {
		synchronized (lock) {
			if (jobExecutorService == null) {
				// create the embedded runtime
				jobExecutorServiceConfiguration = createConfiguration();

				// start it up
				jobExecutorService = createJobExecutorService(jobExecutorServiceConfiguration);
			} else {
				throw new IllegalStateException("The local executor was already started.");
			}
		}
	}
711936
public static void printJsonCodePoint(Appendable out, int codePoint)
        throws IOException
    {
        // JSON only allows double-quote strings.
        printCodePoint(out, codePoint, EscapeMode.JSON);
    }
133632
@Override
    public final void writeStartArray() throws IOException, JsonGenerationException
    {
        _verifyValueWrite("start an array");
        _writeContext = _writeContext.createChildArrayContext();
        if (_cfgPrettyPrinter != null) {
            _cfgPrettyPrinter.writeStartArray(this);
        } else {
            if (_outputTail >= _outputEnd) {
                _flushBuffer();
            }
            _outputBuffer[_outputTail++] = '[';
        }
    }
232849
public int printStartGridScreenData(PrintWriter out, int iPrintOptions)
    {
        out.println(Utility.startTag(XMLTags.DATA));
        return iPrintOptions;
    }
208091
public static void printWorkspaceAsJson(Workspace workspace) {
        if (workspace == null) {
            throw new IllegalArgumentException("A workspace must be provided.");
        }

        try {
            System.out.println(toJson(workspace, true));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
650995
protected void printResults(PrintStream out) {
        log.debug("printResults()");
        StringBuilder line = new StringBuilder();
        out.println(line);
        out.println();
    }
1332623
public void doJson(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        if (req.getParameter("jsonp") == null || permit(req)) {
            setHeaders(rsp);
            rsp.serveExposedBean(req,bean, req.getParameter("jsonp") == null ? Flavor.JSON : Flavor.JSONP);
        } else {
            rsp.sendError(HttpURLConnection.HTTP_FORBIDDEN, "jsonp forbidden; implement jenkins.security.SecureRequester");
        }
    }