Java Code Examples for org.springframework.cloud.deployer.spi.scheduler.ScheduleInfo#setScheduleName()

The following examples show how to use org.springframework.cloud.deployer.spi.scheduler.ScheduleInfo#setScheduleName() . 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: 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 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: AbstractSchedulerIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
@Test
public void testDuplicateSchedule() {
	ScheduleRequest request = createScheduleRequest();
	taskScheduler().schedule(request);
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName(request.getScheduleName());

	this.expectedException.expect(CreateScheduleException.class);
	this.expectedException.expectMessage(String.format("Failed to create schedule %s", request.getScheduleName()));

	verifySchedule(scheduleInfo);
	taskScheduler().schedule(request);
}
 
Example 4
Source File: AbstractSchedulerIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
private ScheduleInfo createAndVerifySchedule() {
	ScheduleRequest request = createScheduleRequest();
	taskScheduler().schedule(request);
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName(request.getScheduleName());
	verifySchedule(scheduleInfo);
	return scheduleInfo;
}
 
Example 5
Source File: AbstractSchedulerIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
private void unscheduleTestSchedule(String scheduleName) {
	log.info("unscheduling {}...", scheduleName);

	taskScheduler().unschedule(scheduleName);

	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName(scheduleName);
	assertThat(scheduleInfo, eventually(specifiedScheduleNotPresent(
			taskScheduler().list(), scheduleName),
			this.unScheduleTimeout.maxAttempts, this.unScheduleTimeout.pause));

}
 
Example 6
Source File: TaskScheduleCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public void list() {
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName("schedName");
	scheduleInfo.setTaskDefinitionName("testDefinition");
	scheduleInfo.setScheduleProperties(Collections.EMPTY_MAP);

	when(schedule.listForPlatform(null)).thenReturn(Arrays.asList(scheduleInfo));

	String wholeCommand = "task schedule list";
	CommandResult cr = dataFlowShell.executeCommand(wholeCommand);

	Table table = (Table) cr.getResult();
	assertEquals("schedName", table.getModel().getValue(1, 0));
}
 
Example 7
Source File: TaskScheduleCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public void listByTaskDefinition(String definitionName) {
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName("schedName");
	scheduleInfo.setTaskDefinitionName("testDefinition");
	scheduleInfo.setScheduleProperties(Collections.EMPTY_MAP);

	when(schedule.list(definitionName, null)).thenReturn(Arrays.asList(scheduleInfo));

	String wholeCommand = String.format("task schedule list --definitionName %s", definitionName);
	CommandResult cr = dataFlowShell.executeCommand(wholeCommand);

	Table table = (Table) cr.getResult();
	assertEquals("schedName", table.getModel().getValue(1, 0));
}
 
Example 8
Source File: BaseDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private List<ScheduleInfo> getSampleList() {
	List<ScheduleInfo> result = new ArrayList<>();
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName("FOO");
	scheduleInfo.setTaskDefinitionName("BAR");
	Map<String, String> props = new HashMap<>(1);
	props.put("scheduler.AAA.spring.cloud.scheduler.cron.expression", "00 41 17 ? * *");
	scheduleInfo.setScheduleProperties(props);
	result.add(scheduleInfo);
	return result;
}
 
Example 9
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 10
Source File: DefaultSchedulerServiceTests.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;
}