org.springframework.cloud.task.configuration.TaskProperties Java Examples

The following examples show how to use org.springframework.cloud.task.configuration.TaskProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskLauncherTasklet.java    From composed-task-runner with Apache License 2.0 6 votes vote down vote up
public TaskLauncherTasklet(
		TaskOperations taskOperations, TaskExplorer taskExplorer,
		ComposedTaskProperties composedTaskProperties, String taskName,
		TaskProperties taskProperties) {
	Assert.hasText(taskName, "taskName must not be empty nor null.");
	Assert.notNull(taskOperations, "taskOperations must not be null.");
	Assert.notNull(taskExplorer, "taskExplorer must not be null.");
	Assert.notNull(composedTaskProperties,
			"composedTaskProperties must not be null");

	this.taskName = taskName;
	this.taskOperations = taskOperations;
	this.taskExplorer = taskExplorer;
	this.composedTaskProperties = composedTaskProperties;
	this.taskProperties = taskProperties;
}
 
Example #2
Source File: TaskLifecycleListener.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
/**
 * @param taskRepository {@link TaskRepository} to record executions.
 * @param taskNameResolver {@link TaskNameResolver} used to determine task name for
 * task execution.
 * @param applicationArguments {@link ApplicationArguments} to be used for task
 * execution.
 * @param taskExplorer {@link TaskExplorer} to be used for task execution.
 * @param taskProperties {@link TaskProperties} to be used for the task execution.
 * @param taskListenerExecutorObjectFactory {@link TaskListenerExecutorObjectFactory}
 * to initialize TaskListenerExecutor for a task
 */
public TaskLifecycleListener(TaskRepository taskRepository,
		TaskNameResolver taskNameResolver, ApplicationArguments applicationArguments,
		TaskExplorer taskExplorer, TaskProperties taskProperties,
		TaskListenerExecutorObjectFactory taskListenerExecutorObjectFactory) {
	Assert.notNull(taskRepository, "A taskRepository is required");
	Assert.notNull(taskNameResolver, "A taskNameResolver is required");
	Assert.notNull(taskExplorer, "A taskExplorer is required");
	Assert.notNull(taskProperties, "TaskProperties is required");
	Assert.notNull(taskListenerExecutorObjectFactory,
			"A TaskListenerExecutorObjectFactory is required");

	this.taskRepository = taskRepository;
	this.taskNameResolver = taskNameResolver;
	this.applicationArguments = applicationArguments;
	this.taskExplorer = taskExplorer;
	this.taskProperties = taskProperties;
	this.taskListenerExecutorObjectFactory = taskListenerExecutorObjectFactory;
	this.taskMetrics = new TaskMetrics();
}
 
Example #3
Source File: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void testTaskLauncherTaskletWithTaskExecutionIdWithPreviousParentID() throws Exception{

	TaskLauncherTasklet taskLauncherTasklet = prepTaskLauncherTests();
	TaskProperties taskProperties = new TaskProperties();
	taskProperties.setExecutionid(88L);
	mockReturnValForTaskExecution(2L);
	ChunkContext chunkContext = chunkContext();
	createCompleteTaskExecution(0);
	chunkContext.getStepContext()
			.getStepExecution().getExecutionContext().put("task-arguments", new ArrayList<String>());
	((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).add("--spring.cloud.task.parent-execution-id=84");
	taskLauncherTasklet = getTaskExecutionTasklet(taskProperties);
	taskLauncherTasklet.setArguments(null);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(2L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertEquals("--spring.cloud.task.parent-execution-id=88", ((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).get(0));
}
 
Example #4
Source File: TaskLauncherTasklet.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
public TaskLauncherTasklet(
		TaskOperations taskOperations, TaskExplorer taskExplorer,
		ComposedTaskProperties composedTaskProperties, String taskName,
		TaskProperties taskProperties) {
	Assert.hasText(taskName, "taskName must not be empty nor null.");
	Assert.notNull(taskOperations, "taskOperations must not be null.");
	Assert.notNull(taskExplorer, "taskExplorer must not be null.");
	Assert.notNull(composedTaskProperties,
			"composedTaskProperties must not be null");

	this.taskName = taskName;
	this.taskOperations = taskOperations;
	this.taskExplorer = taskExplorer;
	this.composedTaskProperties = composedTaskProperties;
	this.taskProperties = taskProperties;
}
 
Example #5
Source File: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void testTaskLauncherTaskletWithTaskExecutionId() throws Exception{
	TaskLauncherTasklet taskLauncherTasklet = prepTaskLauncherTests();

	TaskProperties taskProperties = new TaskProperties();
	taskProperties.setExecutionid(88L);
	mockReturnValForTaskExecution(2L);
	ChunkContext chunkContext = chunkContext();
	createCompleteTaskExecution(0);
	taskLauncherTasklet = getTaskExecutionTasklet(taskProperties);
	taskLauncherTasklet.setArguments(null);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(2L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertEquals("--spring.cloud.task.parent-execution-id=88", ((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).get(0));
}
 
Example #6
Source File: TaskLauncherTaskletTests.java    From composed-task-runner with Apache License 2.0 5 votes vote down vote up
@Test
@DirtiesContext
public void testTaskLauncherTaskletWithTaskExecutionId() throws Exception{
	createCompleteTaskExecution(0);
	TaskLauncherTasklet taskLauncherTasklet =
			getTaskExecutionTasklet();
	ChunkContext chunkContext = chunkContext();
	mockReturnValForTaskExecution(1L);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(1L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertNull(chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments"));

	TaskProperties taskProperties = new TaskProperties();
	taskProperties.setExecutionid(88l);
	mockReturnValForTaskExecution(2L);
	chunkContext = chunkContext();
	createCompleteTaskExecution(0);
	taskLauncherTasklet = getTaskExecutionTasklet(taskProperties);
	taskLauncherTasklet.setArguments(null);
	execute(taskLauncherTasklet, null, chunkContext);
	assertEquals(2L, chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-execution-id"));
	assertEquals("--spring.cloud.task.parent-execution-id=88", ((List)chunkContext.getStepContext()
			.getStepExecution().getExecutionContext()
			.get("task-arguments")).get(0));
}
 
Example #7
Source File: TaskRepositoryInitializer.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	boolean isInitializeEnabled = (this.taskProperties.isInitializeEnabled() != null)
			? this.taskProperties.isInitializeEnabled()
			: this.taskInitializationEnabled;
	if (this.dataSource != null && isInitializeEnabled && this.taskProperties
			.getTablePrefix().equals(TaskProperties.DEFAULT_TABLE_PREFIX)) {
		String platform = getDatabaseType(this.dataSource);
		if ("hsql".equals(platform)) {
			platform = "hsqldb";
		}
		if ("postgres".equals(platform)) {
			platform = "postgresql";
		}
		if ("oracle".equals(platform)) {
			platform = "oracle10g";
		}
		if ("mysql".equals(platform)) {
			platform = "mysql";
		}
		if ("sqlserver".equals(platform)) {
			platform = "sqlserver";
		}
		ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
		String schemaLocation = schema;
		schemaLocation = schemaLocation.replace("@@platform@@", platform);
		populator.addScript(this.resourceLoader.getResource(schemaLocation));
		populator.setContinueOnError(true);
		logger.debug(
				String.format("Initializing task schema for %s database", platform));
		DatabasePopulatorUtils.execute(populator, this.dataSource);
	}
}
 
Example #8
Source File: JdbcDataflowTaskExecutionDao.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * @param dataSource  used by the dao to execute queries and updates the tables.
 * @param taskProperties the {@link TaskProperties} to use for this dao.
 */
public JdbcDataflowTaskExecutionDao(DataSource dataSource, TaskProperties taskProperties) {
	Assert.notNull(dataSource, "The dataSource must not be null.");
	Assert.notNull(taskProperties, "taskProperties must not be null");
	this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
	this.taskProperties = taskProperties;
}
 
Example #9
Source File: DataFlowServerConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
DataflowTaskExecutionDao dataflowTaskExecutionDao(DataSource dataSource, TaskProperties taskProperties) {
	return new JdbcDataflowTaskExecutionDao(dataSource, taskProperties);
}
 
Example #10
Source File: TaskLauncherTaskletTests.java    From composed-task-runner with Apache License 2.0 4 votes vote down vote up
private TaskLauncherTasklet getTaskExecutionTasklet() {
	return getTaskExecutionTasklet(new TaskProperties());
}
 
Example #11
Source File: TaskRepositoryInitializer.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
public TaskRepositoryInitializer(TaskProperties taskProperties) {
	this.taskProperties = taskProperties;
}
 
Example #12
Source File: TaskLauncherTaskletTests.java    From composed-task-runner with Apache License 2.0 4 votes vote down vote up
private TaskLauncherTasklet getTaskExecutionTasklet(TaskProperties taskProperties) {
	return new TaskLauncherTasklet(this.taskOperations,
			this.taskExplorer, this.composedTaskProperties,
			TASK_NAME, taskProperties);
}
 
Example #13
Source File: JobDependencies.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public DataflowTaskExecutionDao dataflowTaskExecutionDao(DataSource dataSource) {
	return new JdbcDataflowTaskExecutionDao(dataSource, new TaskProperties());
}
 
Example #14
Source File: TaskServiceDependencies.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public DataflowTaskExecutionDao dataflowTaskExecutionDao(DataSource dataSource) {
	return new JdbcDataflowTaskExecutionDao(dataSource, new TaskProperties());
}
 
Example #15
Source File: TaskServiceDependencies.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public DataflowTaskExecutionDao dataflowTaskExecutionDao(DataSource dataSource, TaskProperties taskProperties) {
	return new JdbcDataflowTaskExecutionDao(dataSource, taskProperties);
}
 
Example #16
Source File: TestDependencies.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public DataflowTaskExecutionDao dataflowTaskExecutionDao(DataSource dataSource) {
	return new JdbcDataflowTaskExecutionDao(dataSource, new TaskProperties());
}
 
Example #17
Source File: TestDependencies.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public DataflowTaskExecutionDao dataflowTaskExecutionDao(DataSource dataSource, TaskProperties taskProperties) {
	return new JdbcDataflowTaskExecutionDao(dataSource, taskProperties);
}
 
Example #18
Source File: ComposedTaskRunnerStepFactoryTests.java    From composed-task-runner with Apache License 2.0 4 votes vote down vote up
@Bean
public ComposedTaskRunnerStepFactory stepFactory(TaskProperties taskProperties) {
	return new ComposedTaskRunnerStepFactory(new ComposedTaskProperties(), "FOOBAR");
}
 
Example #19
Source File: DataFlowServerConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public TaskProperties taskProperties() {
	return new TaskProperties();
}
 
Example #20
Source File: ComposedTaskRunnerStepFactoryTests.java    From composed-task-runner with Apache License 2.0 4 votes vote down vote up
@Bean
public TaskProperties taskProperties() {
	return new TaskProperties();
}
 
Example #21
Source File: ComposedTaskRunnerStepFactoryTests.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public ComposedTaskRunnerStepFactory stepFactory(TaskProperties taskProperties) {
	return new ComposedTaskRunnerStepFactory(new ComposedTaskProperties(), "FOOBAR");
}
 
Example #22
Source File: ComposedTaskRunnerStepFactoryTests.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public TaskProperties taskProperties() {
	return new TaskProperties();
}
 
Example #23
Source File: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
TaskRepositoryInitializer taskRepositoryInitializer() {
	return new TaskRepositoryInitializer(new TaskProperties());
}
 
Example #24
Source File: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
private TaskLauncherTasklet getTaskExecutionTasklet(TaskProperties taskProperties) {
	return new TaskLauncherTasklet(this.taskOperations,
			this.taskExplorer, this.composedTaskProperties,
			TASK_NAME, taskProperties);
}
 
Example #25
Source File: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
private TaskLauncherTasklet getTaskExecutionTasklet() {
	return getTaskExecutionTasklet(new TaskProperties());
}