當前位置: 首頁>>代碼示例>>Java>>正文


Java JobMetadata類代碼示例

本文整理匯總了Java中io.bootique.job.JobMetadata的典型用法代碼示例。如果您正苦於以下問題:Java JobMetadata類的具體用法?Java JobMetadata怎麽用?Java JobMetadata使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JobMetadata類屬於io.bootique.job包,在下文中一共展示了JobMetadata類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lockingJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
@Override
public RunnableJob lockingJob(RunnableJob executable, JobMetadata metadata) {

	return () -> {
		String lockName = getLockName(metadata);

		LOGGER.info("Attempting to lock '{}'", lockName);

		ZkMutex lock = ZkMutex.acquire(injector, lockName);
		if (lock == null) {
			LOGGER.info("** Another job instance owns the lock. Skipping execution of '{}'", lockName);
			return new JobResult(metadata, JobOutcome.SKIPPED, null,
					"Another job instance owns the lock. Skipping execution");
		}

		try {
			return executable.run();
		} finally {
			lock.release();
		}
	};
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:23,代碼來源:ZkClusterLockHandler.java

示例2: lockingJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
@Override
public RunnableJob lockingJob(RunnableJob executable, JobMetadata metadata) {

	return () -> {
		String lockName = toLockName(metadata);
		Lock lock = getLock(lockName);

		LOGGER.info("Attempting to lock '{}'", lockName);

		if (!lock.tryLock()) {
			LOGGER.info("== Another job instance owns the lock. Skipping execution of '{}'", lockName);
			return new JobResult(metadata, JobOutcome.SKIPPED, null,
					"Another job instance owns the lock. Skipping execution");
		}

		try {
			return executable.run();
		} finally {
			lock.unlock();
		}
	};
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:23,代碼來源:LocalLockHandler.java

示例3: testBuild_Params

import io.bootique.job.JobMetadata; //導入依賴的package包/類
@Test
public void testBuild_Params() {

	JobMetadata j = JobMetadata.builder("nn").dateParam("dd", "2015-02-04").stringParam("ss", "ssv")
			.longParam("ll", "34556775").build();
	assertEquals(3, j.getParameters().size());

	List<JobParameterMetadata<?>> params = new ArrayList<>(j.getParameters());
	assertEquals("dd", params.get(0).getName());
	assertEquals(LocalDate.of(2015, 2, 4), params.get(0).fromString(null));

	assertEquals("ss", params.get(1).getName());
	assertEquals("ssv", params.get(1).fromString(null));

	assertEquals("ll", params.get(2).getName());
	assertEquals(new Long(34556775), params.get(2).fromString(null));

}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:19,代碼來源:JobMetadataBuilderTest.java

示例4: invalidJobNameResult

import io.bootique.job.JobMetadata; //導入依賴的package包/類
private JobFuture invalidJobNameResult(String jobName, Map<String, Object> parameters) {
    return JobFuture.forJob(jobName)
            .future(new ExpiredFuture())
            .runnable(() -> JobResult.unknown(JobMetadata.build(jobName)))
            .resultSupplier(() -> JobResult.failure(JobMetadata.build(jobName), "Invalid job name: " + jobName))
            .build();
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:8,代碼來源:DefaultScheduler.java

示例5: buildDelegate

import io.bootique.job.JobMetadata; //導入依賴的package包/類
private Job buildDelegate() {
    Map<String, Job> jobMap = mapJobs(jobs);
    JobMetadata.Builder builder = JobMetadata.builder(name);
    for (Job job : jobMap.values()) {
        job.getMetadata().getParameters().forEach(builder::param);
    }
    JobMetadata metadata = builder.build();

    return new Job() {
        @Override
        public JobMetadata getMetadata() {
            return metadata;
        }

        @Override
        public JobResult run(Map<String, Object> parameters) {
            traverseExecution(jobExecutions -> {
                Set<JobResult> results = execute(jobExecutions, jobMap);
                results.forEach(result -> {
                    if (result.getOutcome() != JobOutcome.SUCCESS) {
                        String message = "Failed to execute job: " + result.getMetadata().getName();
                        if (result.getMessage() != null) {
                            message += ". Reason: " + result.getMessage();
                        }
                        throw new RuntimeException(message, result.getThrowable());
                    }
                });
            });
            return JobResult.success(getMetadata());
        }
    };
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:33,代碼來源:JobGroup.java

示例6: convertParams

import io.bootique.job.JobMetadata; //導入依賴的package包/類
private Map<String, Object> convertParams(JobMetadata jobMD, Map<String, String> params) {
    // clone params map in order to preserve parameters that were not specified in metadata
    Map<String, Object> convertedParams = new HashMap<>(params);
    for (JobParameterMetadata<?> param : jobMD.getParameters()) {
        String valueString = params.get(param.getName());
        Object value = param.fromString(valueString);
        convertedParams.put(param.getName(), value);
    }
    return convertedParams;
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:11,代碼來源:DependencyGraph.java

示例7: getJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
@Override
public Job getJob(String jobName) {
    Job execution = executions.get(jobName);
    if (execution == null) {
        DependencyGraph graph = new DependencyGraph(jobName, jobDefinitions, jobs);
        Collection<Job> executionJobs = collectJobs(graph);
        if (executionJobs.size() == 1) {
            // do not create a full-fledged execution for standalone jobs
            Job job = executionJobs.iterator().next();
            JobMetadata jobMetadata = cloneMetadata(jobName, job.getMetadata());
            Job delegate = new Job() {
                @Override
                public JobMetadata getMetadata() {
                    return jobMetadata;
                }

                @Override
                public JobResult run(Map<String, Object> parameters) {
                    return job.run(parameters);
                }
            };
            execution = new SingleJob(delegate, graph.topSort().get(0).iterator().next(), listeners);
        } else {
            execution = new JobGroup(jobName, executionJobs, graph, scheduler, listeners);
        }

        Job existing = executions.putIfAbsent(jobName, execution);
        if (existing != null) {
            execution = existing;
        }
    }
    return execution;
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:34,代碼來源:DefaultJobRegistry.java

示例8: testBuild_static

import io.bootique.job.JobMetadata; //導入依賴的package包/類
@Test
public void testBuild_static() {

	JobMetadata j = JobMetadata.build("nn");
	assertNotNull(j);
	assertEquals("nn", j.getName());
	assertTrue(j.getParameters().isEmpty());
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:9,代碼來源:JobMetadataBuilderTest.java

示例9: testBuild_Name

import io.bootique.job.JobMetadata; //導入依賴的package包/類
@Test
public void testBuild_Name() {

	JobMetadata j = JobMetadata.builder("nn").build();
	assertNotNull(j);
	assertEquals("nn", j.getName());
	assertTrue(j.getParameters().isEmpty());
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:9,代碼來源:JobMetadataBuilderTest.java

示例10: BomParameterizedJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
public BomParameterizedJob() {
	super(JobMetadata.builder(BomParameterizedJob.class).longParam(LONG_PARAMETER).dateParam(DATE_PARAMETER).build());
}
 
開發者ID:bootique,項目名稱:bootique-bom,代碼行數:4,代碼來源:BomParameterizedJob.java

示例11: BomJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
public BomJob() {
	super(JobMetadata.build(BomJob.class));
}
 
開發者ID:bootique,項目名稱:bootique-bom,代碼行數:4,代碼來源:BomJob.java

示例12: ParameterizedJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
public ParameterizedJob() {
    // pass a metadata object to the super constructor that defines supported parameter names and types
    super(JobMetadata.builder(ParameterizedJob.class).dateParam(DATE_PARAM).longParam(LONG_PARAM).build());
}
 
開發者ID:bootique-examples,項目名稱:bootique-jobs-demo,代碼行數:5,代碼來源:ParameterizedJob.java

示例13: InjectionJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
public InjectionJob() {
    super(JobMetadata.build(InjectionJob.class));
}
 
開發者ID:bootique-examples,項目名稱:bootique-jobs-demo,代碼行數:4,代碼來源:InjectionJob.java

示例14: SimpleJob

import io.bootique.job.JobMetadata; //導入依賴的package包/類
public SimpleJob() {
    // Pass default metadata object to super constructor. Job will be named based on the
    // class name (sans "Job" suffix).
    super(JobMetadata.build(SimpleJob.class));
}
 
開發者ID:bootique-examples,項目名稱:bootique-jobs-demo,代碼行數:6,代碼來源:SimpleJob.java

示例15: SimpleJob1

import io.bootique.job.JobMetadata; //導入依賴的package包/類
public SimpleJob1() {
    // Pass metadata object to the super constructor. Configure metadata to use a custom job name.
    super(JobMetadata.build("job1"));
}
 
開發者ID:bootique-examples,項目名稱:bootique-jobs-demo,代碼行數:5,代碼來源:SimpleJob1.java


注:本文中的io.bootique.job.JobMetadata類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。