当前位置: 首页>>代码示例>>Java>>正文


Java JobOperator.getJobNames方法代码示例

本文整理汇总了Java中javax.batch.operations.JobOperator.getJobNames方法的典型用法代码示例。如果您正苦于以下问题:Java JobOperator.getJobNames方法的具体用法?Java JobOperator.getJobNames怎么用?Java JobOperator.getJobNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.batch.operations.JobOperator的用法示例。


在下文中一共展示了JobOperator.getJobNames方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRun

import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void doRun() {
    final JobOperator operator = operator();
    final Set<String> names = operator.getJobNames();
    if (names == null || names.isEmpty()) {
        info("No job");
    } else {
        info("     Name   \t|\texecution id\t|\tbatch status\t|\texit status\t|\tstart time\t|\tend time");
        for (final String name : names) {
            try {
                final JobExecution exec = new LinkedList<JobExecution>(
                        operator.getJobExecutions(
                            new LinkedList<JobInstance>(
                                operator.getJobInstances(name, operator.getJobInstanceCount(name) - 1, 2)).getLast())).getLast();
                info(String.format("%s\t|\t%12d\t|\t%s\t|\t%s\t|\t%tc\t|\t%tc",
                        StringUtils.leftPad(name, 12),
                        exec.getExecutionId(),
                        StringUtils.leftPad(exec.getBatchStatus() != null ? exec.getBatchStatus().toString() : "null", 12),
                        StringUtils.leftPad(exec.getExitStatus(), 11), exec.getStartTime(), exec.getEndTime()));
            } catch (final NoSuchJobException nsje) {
                // no-op
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:26,代码来源:Status.java

示例2: startProcess

import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void startProcess() throws Exception {
	logger.info("starting process test");
	CountDownLatch latch = new CountDownLatch(1);
	JobOperator jobOperator = getJobOperator();
	Properties props = new Properties();
	props.setProperty(INPUT_DATA_FILE_NAME, INPUT_PROPERTIES);
	long executionId = jobOperator.start(JOB_NAME, props);
	latch.await(10, SECONDS);
	List<Long> runningExecutions = jobOperator.getRunningExecutions(JOB_NAME);
	assertEquals("running executions. The process is end", 0, runningExecutions.size());
	Set<String> jobNames = jobOperator.getJobNames();
	assertTrue("one or three jobs", jobNames.size() >= 1 && jobNames.size() <= 3);
	String strJobNames = "";
	for (String jobName : jobNames)
		strJobNames += jobName;
	assertTrue("one only job called", strJobNames.contains(JOB_NAME));
	List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
	assertEquals("no step executions", 1, stepExecutions.size());
	stepExecutions(stepExecutions.get(0));
	Properties properties = jobOperator.getParameters(executionId);
	assertEquals("one property found", 1, properties.size());
	assertEquals("MY_NEW_PROPERTY found", INPUT_PROPERTIES, properties.get(INPUT_DATA_FILE_NAME));
	JobInstance jobInstance = jobInstance(jobOperator.getJobInstance(executionId), JOB_NAME);
	jobExecutions(jobOperator.getJobExecutions(jobInstance));
	assertNotNull("executionId not empty", executionId);
	assertTrue("Created file from writer 1", new File(PAYROLL_TEMP_FILE + "1.tmp").exists());
	assertTrue("Created file from writer 2", new File(PAYROLL_TEMP_FILE + "2.tmp").exists());
	assertTrue("Created file from writer 3", new File(PAYROLL_TEMP_FILE + "3.tmp").exists());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:31,代码来源:SimpleJobTestCase.java

示例3: startProcess

import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void startProcess() throws Exception {
	logger.info("starting mail process test");
	CountDownLatch latch = new CountDownLatch(1);
	long executionId = 0;
	JobOperator jobOperator = getJobOperator();

	Properties p = new Properties();
	p.setProperty("source", INPUT_PROPERTIES);
	p.setProperty("destination", "target/output.properties");
	p.setProperty("filesystem", "target");
	executionId = jobOperator.start(JOB_NAME, p);
	latch.await(2, SECONDS);
	List<Long> runningExecutions = jobOperator.getRunningExecutions(JOB_NAME);
	assertEquals("running executions. The process is end", 0, runningExecutions.size());
	Set<String> jobNames = jobOperator.getJobNames();
	assertTrue("one or two job", jobNames.size() >= 1 && jobNames.size() <= 3);
	String strJobNames = "";
	for (String jobName : jobNames)
		strJobNames += jobName;
	assertTrue("one only job called", strJobNames.contains(JOB_NAME));
	List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
	assertEquals("no step executions", 2, stepExecutions.size());
	stepExecutions(stepExecutions.get(0), false);
	stepExecutions(stepExecutions.get(1), true);
	Properties properties = jobOperator.getParameters(executionId);
	assertEquals("one property found", 3, properties.size());
	assertEquals("MY_NEW_PROPERTY found", INPUT_PROPERTIES, properties.get("source"));
	JobInstance jobInstance = jobInstance(jobOperator.getJobInstance(executionId));
	jobExecutions(jobOperator.getJobExecutions(jobInstance));
	assertNotNull("executionId not empty", executionId);
	assertTrue("the destination file is created", new File(properties.get("destination") + "").exists());
	assertTrue("message received",
			myFactory.getBody().contains("Job Execution id " + executionId + " warned disk space getting low!"));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:36,代码来源:MailJobTestCase.java

示例4: startBatchJob

import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
public void startBatchJob()
{
    try
    {
        JobOperator jobOperator = BatchRuntime.getJobOperator();

        for (String job : jobOperator.getJobNames())
        {
            System.out.println("EXISTING JOB: " + job);
        }

        Properties props = new Properties();
        props.setProperty("basedate", "11-02-2014|11:11:11");

        System.out.println("Starting batch via servlet");
        long executionID = jobOperator.start(JOBNAME, props);

        Thread.sleep(300);

        System.out.println("Job with ID " + executionID + " started");
        JobExecution jobExec = jobOperator.getJobExecution(executionID);
        String status = jobExec.getBatchStatus().toString();
        System.out.println("Job status: " + status);
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:tijs14tijs,项目名称:ROAD,代码行数:30,代码来源:MapBean.java

示例5: clearPersistence

import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
private static void clearPersistence(final JobOperator jobOperator) {
    final PersistenceManagerService service = ServicesManager.find().service(PersistenceManagerService.class);
    for (final String name : jobOperator.getJobNames()) {
        for (final JobInstance id : jobOperator.getJobInstances(name, 0, Integer.MAX_VALUE)) {
            service.cleanUp(id.getInstanceId());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:9,代码来源:JMXTest.java

示例6: processRequest

import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 * 
 * @param request
 *            servlet request
 * @param response
 *            servlet response
 * @throws ServletException
 *             if a servlet-specific error occurs
 * @throws IOException
 *             if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request,
		HttpServletResponse response) throws ServletException, IOException {
	response.setContentType("text/html;charset=UTF-8");
	try (PrintWriter out = response.getWriter()) {
		out.println("<html>");
		out.println("<head>");
		out.println("<title>Servlet Execute Job</title>");
		out.println("</head>");
		out.println("<body>");
		out.println("<h1>Servlet TestServlet at "
				+ request.getContextPath() + "</h1>");
		out.println("About to start the job<br>");
		JobOperator jo = BatchRuntime.getJobOperator();
		out.println("Got the job operator: " + jo + "<br>");

		Properties props = new Properties();
		props.put("csvDatasFileName",
				request.getParameter("tt"));

		long jid = jo.start("loadHistoryJob", props);
		out.println("Job submitted: " + jid + "<br>");
		out.println(jo.getJobInstanceCount("loadHistoryJob")
				+ " job instance found<br/>");
		JobExecution je = jo.getJobExecution(jid);

		// jo.abandon(jid);
		out.println("Job created on: " + je.getCreateTime() + "<br>");
		out.println("Job started on: " + je.getStartTime() + "<br>");
		out.println("Found: " + jo.getJobNames().size() + " jobs<br>");
		for (String j : jo.getJobNames()) {
			out.println("--> " + j + "<br>");
		}

		out.println("<br><br><a href=\"/\">Home</a>  - <a href=\"./list\">All players.</a>");
		out.println("</body>");
		out.println("</html>");
	} catch (JobStartException | JobSecurityException ex) {
		Logger.getLogger(ExecuteJobServlet.class.getName()).log(Level.SEVERE,
				"erreur jobs", ex);
	}
}
 
开发者ID:mgreau,项目名称:docker4dev-tennistour-app,代码行数:55,代码来源:ExecuteJobServlet.java


注:本文中的javax.batch.operations.JobOperator.getJobNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。