org.springframework.cloud.deployer.spi.scheduler.ScheduleInfo Java Examples

The following examples show how to use org.springframework.cloud.deployer.spi.scheduler.ScheduleInfo. 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: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
private void verifyScheduleExistsInScheduler(ScheduleInfo scheduleInfo) {
	List<ScheduleInfo> scheduleInfos = schedulerService.listForPlatform(KUBERNETES_PLATFORM);
	scheduleInfos = scheduleInfos.stream().filter(s -> s.getScheduleName().
			equals(scheduleInfo.getScheduleName())).
			collect(Collectors.toList());

	assertThat(scheduleInfos.size()).isEqualTo(1);
	assertThat(scheduleInfos.get(0).getTaskDefinitionName()).isEqualTo(
			scheduleInfo.getTaskDefinitionName());

	for(String key: scheduleInfo.getScheduleProperties().keySet()) {
		assertThat(scheduleInfos.get(0).getScheduleProperties().
				get(key)).
				isEqualTo(scheduleInfo.getScheduleProperties().get(key));
	}
}
 
Example #2
Source File: AbstractSchedulerIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
@Test
public void testListFilter() {
	String definitionName = randomName();
	String scheduleName = scheduleName() + definitionName;
	for (int i = 0; i < 4; i++) {
		ScheduleRequest request = createScheduleRequest(scheduleName + i, definitionName + i%2);
		taskScheduler().schedule(request);
	}
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName(scheduleName+0);
	scheduleInfo.setTaskDefinitionName(definitionName+0);
	assertThat(scheduleInfo, eventually(
			hasSpecifiedSchedulesByTaskDefinitionName(taskScheduler().list(definitionName+0),
					scheduleInfo.getTaskDefinitionName(), 2),
			this.scheduleTimeout.maxAttempts, this.scheduleTimeout.pause));
}
 
Example #3
Source File: KubernetesSchedulerTests.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 6 votes vote down vote up
@AfterClass
public static void cleanup() {
	KubernetesSchedulerProperties kubernetesSchedulerProperties = new KubernetesSchedulerProperties();
	kubernetesSchedulerProperties.setNamespace("default");

	KubernetesClient kubernetesClient = new DefaultKubernetesClient()
			.inNamespace(kubernetesSchedulerProperties.getNamespace());

	KubernetesScheduler kubernetesScheduler = new KubernetesScheduler(kubernetesClient,
			kubernetesSchedulerProperties);

	List<ScheduleInfo> scheduleInfos = kubernetesScheduler.list();

	for (ScheduleInfo scheduleInfo : scheduleInfos) {
		kubernetesScheduler.unschedule(scheduleInfo.getScheduleName());
	}
	// Cleanup the schedules that aren't part of the list() - created from listScheduleWithExternalCronJobs test
	kubernetesScheduler.unschedule("job2");
	kubernetesScheduler.unschedule("job3");
}
 
Example #4
Source File: KubernetesScheduler.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 6 votes vote down vote up
@Override
public List<ScheduleInfo> list() {
	CronJobList cronJobList = this.client.batch().cronjobs().list();

	List<CronJob> cronJobs = cronJobList.getItems();
	List<ScheduleInfo> scheduleInfos = new ArrayList<>();

	for (CronJob cronJob : cronJobs) {
		if (cronJob.getMetadata() != null && cronJob.getMetadata().getLabels() != null &&
				StringUtils.hasText(cronJob.getMetadata().getLabels().get(SPRING_CRONJOB_ID_KEY))) {
			Map<String, String> properties = new HashMap<>();
			properties.put(SchedulerPropertyKeys.CRON_EXPRESSION, cronJob.getSpec().getSchedule());

			ScheduleInfo scheduleInfo = new ScheduleInfo();
			scheduleInfo.setScheduleName(cronJob.getMetadata().getName());
			scheduleInfo.setTaskDefinitionName(cronJob.getMetadata().getLabels().get(SPRING_CRONJOB_ID_KEY));
			scheduleInfo.setScheduleProperties(properties);

			scheduleInfos.add(scheduleInfo);
		}
	}

	return scheduleInfos;
}
 
Example #5
Source File: DefaultSchedulerServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
private void verifyScheduleExistsInScheduler(ScheduleInfo scheduleInfo) {
	List<ScheduleInfo> scheduleInfos = schedulerService.list();
	scheduleInfos = scheduleInfos.stream().filter(s -> s.getScheduleName().
			equals(scheduleInfo.getScheduleName())).
			collect(Collectors.toList());

	assertThat(scheduleInfos.size()).isEqualTo(1);
	assertThat(scheduleInfos.get(0).getTaskDefinitionName()).isEqualTo(
			scheduleInfo.getTaskDefinitionName());

	for(String key: scheduleInfo.getScheduleProperties().keySet()) {
		assertThat(scheduleInfos.get(0).getScheduleProperties().
				get(key)).
				isEqualTo(scheduleInfo.getScheduleProperties().get(key));
	}
}
 
Example #6
Source File: TestConfig.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Bean
public Scheduler localScheduler() {
	// This is in auto-config package and we can depend on that, use same
	// dummy no-op impl here.
	return new Scheduler() {
		@Override
		public void schedule(ScheduleRequest scheduleRequest) {
			throw new UnsupportedOperationException("Scheduling is not implemented for local platform.");
		}

		@Override
		public void unschedule(String scheduleName) {
			throw new UnsupportedOperationException("Scheduling is not implemented for local platform.");
		}

		@Override
		public List<ScheduleInfo> list(String taskDefinitionName) {
			return Collections.emptyList();
		}

		@Override
		public List<ScheduleInfo> list() {
			return Collections.emptyList();
		}
	};
}
 
Example #7
Source File: LocalDataflowResource.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Scheduler localScheduler() {
	return new Scheduler() {
		@Override
		public void schedule(ScheduleRequest scheduleRequest) {
			throw new UnsupportedOperationException("Interface is not implemented for schedule method.");
		}

		@Override
		public void unschedule(String scheduleName) {
			throw new UnsupportedOperationException("Interface is not implemented for unschedule method.");
		}

		@Override
		public List<ScheduleInfo> list(String taskDefinitionName) {
			throw new UnsupportedOperationException("Interface is not implemented for list method.");
		}

		@Override
		public List<ScheduleInfo> list() {
			throw new UnsupportedOperationException("Interface is not implemented for list method.");
		}
	};
}
 
Example #8
Source File: BaseDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
public Scheduler localTestScheduler() {
	return new Scheduler() {
		@Override
		public void schedule(ScheduleRequest scheduleRequest) {
			throw new UnsupportedOperationException("Interface is not implemented for schedule method.");
		}

		@Override
		public void unschedule(String scheduleName) {
			throw new UnsupportedOperationException("Interface is not implemented for unschedule method.");
		}

		@Override
		public List<ScheduleInfo> list(String taskDefinitionName) {
			throw new UnsupportedOperationException("Interface is not implemented for list method.");
		}

		@Override
		public List<ScheduleInfo> list() {
			return getSampleList();
		}
	};
}
 
Example #9
Source File: LocalSchedulerAutoConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Scheduler localScheduler() {
	return new Scheduler() {
		@Override
		public void schedule(ScheduleRequest scheduleRequest) {
			throw new UnsupportedOperationException("Scheduling is not implemented for local platform.");
		}

		@Override
		public void unschedule(String scheduleName) {
			throw new UnsupportedOperationException("Scheduling is not implemented for local platform.");
		}

		@Override
		public List<ScheduleInfo> list(String taskDefinitionName) {
			return Collections.emptyList();
		}

		@Override
		public List<ScheduleInfo> list() {
			return Collections.emptyList();
		}
	};
}
 
Example #10
Source File: CloudFoundryAppSchedulerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Test
public void testListWithJobsNoAssociatedSchedule() {
	setupMockResultsNoScheduleForJobs();
	List<ScheduleInfo> result = this.cloudFoundryAppScheduler.list();
	assertThat(result.size()).isEqualTo(2);
	verifyScheduleInfo(result.get(0), "test-application-1", "test-job-name-1", null);
	verifyScheduleInfo(result.get(1), "test-application-2", "test-job-name-2", null);
}
 
Example #11
Source File: TaskSchedulerController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Return a {@link ScheduleInfo} for a specific Schedule.
 *
 * @param scheduleName assembler for the {@link ScheduleInfo}
 * @param platform the name of the platform from which the schedule will be retrieved.
 * @return a {@link ScheduleInfoResource} instance for the scheduleName specified.
 */
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public ScheduleInfoResource getSchedule(@PathVariable("name") String scheduleName,
		@RequestParam(value = "platform", required = false) String platform) {
	ScheduleInfo schedule = this.schedulerService.getSchedule(scheduleName, platform);
	if (schedule == null) {
		throw new NoSuchScheduleException(String.format("Schedule [%s] doesn't exist" , scheduleName));
	}
	return taskAssembler.toModel(schedule);
}
 
Example #12
Source File: TaskSchedulerController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Return a page-able list of {@link ScheduleInfo}s for a specific
 * {@link org.springframework.cloud.dataflow.core.TaskDefinition} name.
 *
 * @param taskDefinitionName name of the taskDefinition to search.
 * @param platform name of the platform from which the list is retrieved.
 * @param assembler assembler for the {@link ScheduleInfo}.
 * @return a list of Schedules.
 */
@RequestMapping("/instances/{taskDefinitionName}")
public PagedModel<ScheduleInfoResource> filteredList(@PathVariable String taskDefinitionName,
		@RequestParam(value = "platform", required = false) String platform,
		PagedResourcesAssembler<ScheduleInfo> assembler) {
	List<ScheduleInfo> result = this.schedulerService.list(taskDefinitionName, platform);
	int resultSize = result.size();
	Pageable pageable = PageRequest.of(0,
			(resultSize == 0) ? resultSize = 1 : resultSize); //handle empty result set
	Page<ScheduleInfo> page = new PageImpl<>(result, pageable,
			result.size());
	return assembler.toModel(page, taskAssembler);
}
 
Example #13
Source File: DefaultSchedulerServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testEmptyList() {
	taskDefinitionRepository.save(new TaskDefinition(BASE_DEFINITION_NAME + 1, "demo"));
	List<ScheduleInfo> schedules = schedulerService.list(BASE_DEFINITION_NAME + 1, "testTaskPlatform");
	assertThat(schedules.size()).isEqualTo(0);
	schedules = schedulerService.list();
	assertThat(schedules.size()).isEqualTo(0);
}
 
Example #14
Source File: DefaultSchedulerServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testListWithParams() {
	taskDefinitionRepository.save(new TaskDefinition(BASE_DEFINITION_NAME + 1, "demo"));
	schedulerService.schedule(BASE_SCHEDULE_NAME + 1,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 2,
			BASE_DEFINITION_NAME + 1, this.testProperties, this.commandLineArgs);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 3,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs);

	List<ScheduleInfo> schedules = schedulerService.list(BASE_DEFINITION_NAME + 1);
	assertThat(schedules.size()).isEqualTo(1);
	verifyScheduleExistsInScheduler(schedules.get(0));
}
 
Example #15
Source File: DefaultSchedulerServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testListMaxEntry() {
	final int MAX_COUNT = 500;
	schedulerServiceProperties.setMaxSchedulesReturned(MAX_COUNT);
	for (int i = 0; i < MAX_COUNT + 1; i++) {
		schedulerService.schedule(BASE_SCHEDULE_NAME + i,
				BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs);
	}
	List<ScheduleInfo> schedules = schedulerService.list();
	assertThat(schedules.size()).isEqualTo(MAX_COUNT);
}
 
Example #16
Source File: DefaultSchedulerServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testList(){
	schedulerService.schedule(BASE_SCHEDULE_NAME + 1,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 2,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 3,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs);

	List<ScheduleInfo> schedules = schedulerService.list();
	assertThat(schedules.size()).isEqualTo(3);
	verifyScheduleExistsInScheduler(schedules.get(0));
	verifyScheduleExistsInScheduler(schedules.get(1));
	verifyScheduleExistsInScheduler(schedules.get(2));
}
 
Example #17
Source File: DefaultSchedulerServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testScheduleWithCapitalizeNameOnKuberenetesPlatform() {
	SchedulerService testSchedulerService = getMockedKubernetesSchedulerService();
	testSchedulerService.schedule(BASE_SCHEDULE_NAME + "AB", BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs);
	List<ScheduleInfo> scheduleInfos = testSchedulerService.list();
	assertThat(scheduleInfos.size()).isEqualTo(1);
	assertThat(scheduleInfos.get(0).getScheduleName()).isEqualTo("mytaskscheduleab");
}
 
Example #18
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private ScheduleInfo createScheduleInfo(String scheduleName, String taskDefinitionName) {
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName(scheduleName);
	scheduleInfo.setTaskDefinitionName(taskDefinitionName);
	scheduleInfo.setScheduleProperties(this.resolvedProperties);
	return scheduleInfo;
}
 
Example #19
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testEmptyList() {
	taskDefinitionRepository.save(new TaskDefinition(BASE_DEFINITION_NAME + 1, "demo"));
	List<ScheduleInfo> schedules = schedulerService.list(BASE_DEFINITION_NAME + 1, "testTaskPlatform");
	assertThat(schedules.size()).isEqualTo(0);
	schedules = schedulerService.listForPlatform(KUBERNETES_PLATFORM);
	assertThat(schedules.size()).isEqualTo(0);
}
 
Example #20
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testListWithParams() {
	taskDefinitionRepository.save(new TaskDefinition(BASE_DEFINITION_NAME + 1, "demo"));
	schedulerService.schedule(BASE_SCHEDULE_NAME + 1,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 2,
			BASE_DEFINITION_NAME + 1, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 3,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);

	List<ScheduleInfo> schedules = schedulerService.list(BASE_DEFINITION_NAME + 1, KUBERNETES_PLATFORM);
	assertThat(schedules.size()).isEqualTo(1);
	verifyScheduleExistsInScheduler(schedules.get(0));
}
 
Example #21
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testListMaxEntry() {
	final int MAX_COUNT = 500;
	schedulerServiceProperties.setMaxSchedulesReturned(MAX_COUNT);
	for (int i = 0; i < MAX_COUNT + 1; i++) {
		schedulerService.schedule(BASE_SCHEDULE_NAME + i,
				BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);
	}
	List<ScheduleInfo> schedules = schedulerService.listForPlatform(KUBERNETES_PLATFORM);
	assertThat(schedules.size()).isEqualTo(MAX_COUNT);
}
 
Example #22
Source File: DefaultSchedulerService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
public void unschedule(String scheduleName, String platformName) {
	final ScheduleInfo scheduleInfo = getSchedule(scheduleName, platformName);
	if (scheduleInfo != null) {
		Launcher launcher = getTaskLauncher(platformName);
		launcher.getScheduler().unschedule(scheduleInfo.getScheduleName());
		this.auditRecordService.populateAndSaveAuditRecord(
				AuditOperationType.SCHEDULE,
				AuditActionType.DELETE, scheduleInfo.getScheduleName(),
				scheduleInfo.getTaskDefinitionName(),
				platformName);
	}
}
 
Example #23
Source File: DefaultSchedulerService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
public void unscheduleForTaskDefinition(String taskDefinitionName) {
	for (Launcher launcher : getLaunchers()) {
		for(ScheduleInfo scheduleInfo : listForPlatform(launcher.getName())) {
			if(scheduleInfo.getTaskDefinitionName().equals(taskDefinitionName)) {
				unschedule(scheduleInfo.getScheduleName(), launcher.getName());
			}
		}
	}
}
 
Example #24
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testList(){
	schedulerService.schedule(BASE_SCHEDULE_NAME + 1,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 2,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);
	schedulerService.schedule(BASE_SCHEDULE_NAME + 3,
			BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);

	List<ScheduleInfo> schedules = schedulerService.listForPlatform(KUBERNETES_PLATFORM);
	assertThat(schedules.size()).isEqualTo(3);
	verifyScheduleExistsInScheduler(schedules.get(0));
	verifyScheduleExistsInScheduler(schedules.get(1));
	verifyScheduleExistsInScheduler(schedules.get(2));
}
 
Example #25
Source File: DefaultSchedulerServiceMultiplatformTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testScheduleWithCapitalizeNameOnKuberenetesPlatform() {
	SchedulerService testSchedulerService = getMockedKubernetesSchedulerService();
	testSchedulerService.schedule(BASE_SCHEDULE_NAME + "AB", BASE_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);
	List<ScheduleInfo> scheduleInfos = testSchedulerService.listForPlatform(KUBERNETES_PLATFORM);
	assertThat(scheduleInfos.size()).isEqualTo(1);
	assertThat(scheduleInfos.get(0).getScheduleName()).isEqualTo("mytaskscheduleab");
}
 
Example #26
Source File: TaskSchedulerControllerTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private String createScheduleWithArguments(String arguments) throws Exception {
	this.registry.save("testApp", ApplicationType.task, "1.0.0", new URI("file:src/test/resources/apps/foo-task"), null);

	repository.save(new TaskDefinition("testDefinition", "testApp"));
	mockMvc.perform(post("/tasks/schedules/").param("taskDefinitionName", "testDefinition")
			.param("scheduleName", "mySchedule")
			.param("properties",
					"scheduler.cron.expression=* * * * *,app.testApp.prop1=foo,app.testApp.prop2.secret=kenny,deployer.*.prop1.secret=cartman,deployer.*.prop2.password=kyle")
			.param("arguments", arguments)
			.accept(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated());
	assertEquals(1, simpleTestScheduler.list().size());
	ScheduleInfo scheduleInfo = simpleTestScheduler.list().get(0);
	assertEquals("mySchedule", scheduleInfo.getScheduleName());
	assertEquals(1, scheduleInfo.getScheduleProperties().size());
	assertEquals("* * * * *", scheduleInfo.getScheduleProperties().get("spring.cloud.scheduler.cron.expression"));

	final List<AuditRecord> auditRecords = auditRecordRepository.findAll();

	assertEquals(6, auditRecords.size());
	final AuditRecord auditRecord = auditRecords.get(5);

	assertEquals(AuditOperationType.SCHEDULE, auditRecord.getAuditOperation());
	assertEquals(AuditActionType.CREATE, auditRecord.getAuditAction());
	assertEquals("mySchedule", auditRecord.getCorrelationId());

	return auditRecord.getAuditData();
}
 
Example #27
Source File: TaskSchedulerControllerTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void createAndVerifySchedule(String scheduleName, String createdScheduleName) throws Exception{
	this.registry.save("testApp", ApplicationType.task,
			"1.0.0", new URI("file:src/test/resources/apps/foo-task"), null);

	repository.save(new TaskDefinition("testDefinition", "testApp"));
	mockMvc.perform(post("/tasks/schedules/").param("taskDefinitionName", "testDefinition")
			.param("scheduleName", scheduleName).param("properties", "scheduler.cron.expression=* * * * *")
			.accept(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated());
	assertEquals(1, simpleTestScheduler.list().size());
	ScheduleInfo scheduleInfo = simpleTestScheduler.list().get(0);
	assertEquals(createdScheduleName, scheduleInfo.getScheduleName());
	assertEquals(1, scheduleInfo.getScheduleProperties().size());
	assertEquals("* * * * *", scheduleInfo.getScheduleProperties().get("spring.cloud.scheduler.cron.expression"));

	final List<AuditRecord> auditRecords = auditRecordRepository.findAll();

	assertEquals(6, auditRecords.size());
	final AuditRecord auditRecord = auditRecords.get(5);

	assertEquals(AuditOperationType.SCHEDULE, auditRecord.getAuditOperation());
	assertEquals(AuditActionType.CREATE, auditRecord.getAuditAction());
	assertEquals("mySchedule", auditRecord.getCorrelationId());

	assertEquals("{\"commandlineArguments\":[],\"taskDefinitionName\":\"testDefinition\","
			+ "\"taskDefinitionProperties\":{\"spring.datasource.username\":null,\"spring.cloud.task.name\":\"testDefinition\",\"spring.datasource.url\":null,\"spring.datasource.driverClassName\":null},"
			+ "\"deploymentProperties\":{}}", auditRecord.getAuditData());
}
 
Example #28
Source File: DefaultSchedulerService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private List<ScheduleInfo> limitScheduleInfoResultSize(List<ScheduleInfo> resultSet,
		int schedulerLimitResultSize) {
	if(resultSet.size() > schedulerLimitResultSize) {
		resultSet = resultSet.subList(0, schedulerLimitResultSize);
	}
	return resultSet;
}
 
Example #29
Source File: DefaultSchedulerService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
public ScheduleInfo getSchedule(String scheduleName, String platformName) {
	List<ScheduleInfo> result = listForPlatform(platformName).stream()
			.filter(scheduleInfo -> scheduleInfo.getScheduleName().equals(scheduleName))
			.collect(Collectors.toList());
	Assert.isTrue(!(result.size() > 1), "more than one schedule was returned for scheduleName, should only be one");
	return result.size() > 0 ? result.get(0) : null;
}
 
Example #30
Source File: TaskSchedulerController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Return a page-able list of {@link ScheduleInfo}s.
 *
 * @param assembler assembler for the {@link ScheduleInfo}
 * @param platform the name of the platform from which schedules will be retrieved.
 * @param pageable {@link Pageable} to be used
 * @return a list of Schedules
 */
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public PagedModel<ScheduleInfoResource> list(Pageable pageable,
		@RequestParam(value = "platform", required = false) String platform,
		PagedResourcesAssembler<ScheduleInfo> assembler) {
	List<ScheduleInfo> result = this.schedulerService.listForPlatform(platform);
	return assembler.toModel(new PageImpl<>(result, pageable, result.size()), taskAssembler);
}