Skip to content

Commit cf4e581

Browse files
committed
Remove schedule. prefix from rest client and shell
Signed-off-by: Glenn Renfro <[email protected]>
1 parent 3cf889d commit cf4e581

File tree

11 files changed

+44
-40
lines changed

11 files changed

+44
-40
lines changed

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/BaseDocumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ private List<ScheduleInfo> getSampleList() {
328328
scheduleInfo.setScheduleName("FOO");
329329
scheduleInfo.setTaskDefinitionName("BAR");
330330
Map<String, String> props = new HashMap<>(1);
331-
props.put("scheduler.AAA.spring.cloud.scheduler.cron.expression", "00 41 17 ? * *");
331+
props.put("deployer.AAA.spring.cloud.scheduler.cron.expression", "00 41 17 ? * *");
332332
scheduleInfo.setScheduleProperties(props);
333333
result.add(scheduleInfo);
334334
return result;

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/TaskSchedulerDocumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void createSchedule() throws Exception {
6464
.queryParam("scheduleName", "myschedule")
6565
.queryParam("taskDefinitionName", "mytaskname")
6666
.queryParam("platform", "default")
67-
.queryParam("properties", "scheduler.cron.expression=00 22 17 ? *")
67+
.queryParam("properties", "deployer.cron.expression=00 22 17 ? *")
6868
.queryParam("arguments", "--foo=bar"))
6969
.andExpect(status().isCreated())
7070
.andDo(this.documentationHandler.document(

spring-cloud-dataflow-docs/src/main/asciidoc/tasks.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ dataflow:>task schedule list
13461346
╔══════════════════════════╤════════════════════╤════════════════════════════════════════════════════╗
13471347
║ Schedule Name │Task Definition Name│ Properties ║
13481348
╠══════════════════════════╪════════════════════╪════════════════════════════════════════════════════╣
1349-
║mytaskschedule │mytask │spring.cloud.scheduler.cron.expression = */1 * * * *║
1349+
║mytaskschedule │mytask │spring.cloud.deployer.cron.expression = */1 * * * *
13501350
╚══════════════════════════╧════════════════════╧════════════════════════════════════════════════════╝
13511351
----
13521352
====

spring-cloud-dataflow-rest-client/src/main/java/org/springframework/cloud/dataflow/rest/client/dsl/task/TaskSchedule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
*/
4848
public class TaskSchedule implements AutoCloseable {
4949

50-
public static final String CRON_EXPRESSION_KEY = "scheduler.cron.expression";
50+
public static final String CRON_EXPRESSION_KEY = "deployer.cron.expression";
5151

5252
private final String scheduleName;
5353

spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/util/DeploymentPropertiesUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public final class DeploymentPropertiesUtils {
6161
.compile("(\\s(?=" + "([^\\\"']*[\\\"'][^\\\"']*[\\\"'])*[^\\\"']*$))");
6262

6363

64-
private static final String[] DEPLOYMENT_PROPERTIES_PREFIX ={"deployer", "app", "version", "scheduler", "spring.cloud.dataflow.task"};
64+
private static final String[] DEPLOYMENT_PROPERTIES_PREFIX ={"deployer", "app", "version", "spring.cloud.dataflow.task"};
6565

6666
private DeploymentPropertiesUtils() {
6767
// prevent instantiation
@@ -127,7 +127,7 @@ public static List<String> parseParamList(String s, String delimiter) {
127127
// we have a key/value pair having '=', or malformed first pair
128128
if (!startsWithDeploymentPropertyPrefix(candidate)) {
129129
throw new IllegalArgumentException(
130-
"Only deployment property keys starting with 'app.' or 'scheduler' or 'deployer.' or 'version.'" +
130+
"Only deployment property keys starting with 'app.' or 'deployer.' or 'version.'" +
131131
" allowed. Not " + candidate);
132132
}
133133
pairs.add(candidate);
@@ -286,9 +286,9 @@ public static void validateDeploymentProperties(Map<String, String> properties)
286286
for (Entry<String, String> property : properties.entrySet()) {
287287
String key = property.getKey();
288288
if (!key.startsWith("app.") && !key.startsWith("deployer.")
289-
&& !key.startsWith("scheduler.") && !key.startsWith("version.")) {
289+
&& !key.startsWith("version.")) {
290290
throw new IllegalArgumentException(
291-
"Only deployment property keys starting with 'app.', 'deployer.' or, 'scheduler.' allowed, got '" + key + "'");
291+
"Only deployment property keys starting with 'app.' or 'deployer.' allowed, got '" + key + "'");
292292
}
293293
}
294294
}

spring-cloud-dataflow-rest-resource/src/test/java/org/springframework/cloud/dataflow/rest/util/DeploymentPropertiesUtilsTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ private static void assertArrays(String[] left, String[] right) {
5252
@Test
5353
void deploymentPropertiesParsing() {
5454
Map<String, String> props = DeploymentPropertiesUtils.parse("app.foo.bar=v, app.foo.wizz=v2 , deployer.foo"
55-
+ ".pot=fern, app.other.key = value , deployer.other.cow = meww, scheduler.other.key = baz");
55+
+ ".pot=fern, app.other.key = value , deployer.other.cow = meww, deployer.other.key = baz");
5656
assertThat(props.entrySet()).contains(entry("app.foo.bar", "v"));
5757
assertThat(props.entrySet()).contains(entry("app.other.key", "value"));
5858
assertThat(props.entrySet()).contains(entry("app.foo.wizz", "v2"));
5959
assertThat(props.entrySet()).contains(entry("deployer.foo.pot", "fern"));
6060
assertThat(props.entrySet()).contains(entry("deployer.other.cow", "meww"));
61-
assertThat(props.entrySet()).contains(entry("scheduler.other.key", "baz"));
61+
assertThat(props.entrySet()).contains(entry("deployer.other.key", "baz"));
6262

6363
props = DeploymentPropertiesUtils.parse("app.f=v");
6464
assertThat(props.entrySet()).contains(entry("app.f", "v"));
@@ -87,7 +87,7 @@ void deploymentPropertiesParsing() {
8787
fail("Illegal Argument Exception expected.");
8888
}
8989
catch (Exception e) {
90-
assertThat(e.getMessage()).isEqualTo("Only deployment property keys starting with 'app.' or 'scheduler' or 'deployer.' or 'version.' allowed. Not invalidkeyvalue");
90+
assertThat(e.getMessage()).isEqualTo("Only deployment property keys starting with 'app.' or 'deployer.' or 'version.' allowed. Not invalidkeyvalue");
9191
}
9292

9393
props = DeploymentPropertiesUtils.parse("deployer.foo=bar,invalidkeyvalue2");
@@ -125,7 +125,7 @@ void deploymentPropertiesParsing2() {
125125
fail("Illegal Argument Exception expected.");
126126
}
127127
catch (Exception e) {
128-
assertThat(e.getMessage()).isEqualTo("Only deployment property keys starting with 'app.' or 'scheduler' or 'deployer.' or 'version.' allowed. Not a=b");
128+
assertThat(e.getMessage()).isEqualTo("Only deployment property keys starting with 'app.' or 'deployer.' or 'version.' allowed. Not a=b");
129129
}
130130

131131
props = DeploymentPropertiesUtils.parseArgumentList("a=b c=d", " ");

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/service/impl/DefaultSchedulerService.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void schedule(
283283
AppDefinition revisedDefinition = TaskServiceUtils.mergeAndExpandAppProperties(taskDefinition, metadataResource,
284284
appDeploymentProperties, visibleProperties);
285285
DeploymentPropertiesUtils.validateDeploymentProperties(taskDeploymentProperties);
286-
taskDeploymentProperties = extractAndQualifySchedulerProperties(taskDeploymentProperties);
286+
taskDeploymentProperties = filterPrefixedProperties(taskDeploymentProperties);
287287
deployerDeploymentProperties.putAll(taskDeploymentProperties);
288288
scheduleName = validateScheduleNameForPlatform(launcher.getType(), scheduleName);
289289
ScheduleRequest scheduleRequest = new ScheduleRequest(revisedDefinition,
@@ -501,22 +501,15 @@ private List<ScheduleInfo> limitScheduleInfoResultSize(
501501
}
502502

503503
/**
504-
* Retain only properties that are meant for the <em>scheduler</em> of a given task(those
505-
* that start with {@code scheduler.}and qualify all
506-
* property values with the {@code spring.cloud.scheduler.} prefix.
504+
* Provided a filtered Map that removes entries prefixed with "app." or "deployer.".
507505
*
508-
* @param input the scheduler properties
509-
* @return scheduler properties for the task
506+
* @param input the properties
507+
* @return deployer properties for the schedule
510508
*/
511-
@Deprecated
512-
private static Map<String, String> extractAndQualifySchedulerProperties(Map<String, String> input) {
513-
final String prefix = "scheduler.";
514-
final int prefixLength = prefix.length();
515-
509+
private static Map<String, String> filterPrefixedProperties(Map<String, String> input) {
516510
return new TreeMap<>(input).entrySet().stream()
517-
.filter(kv -> kv.getKey().startsWith(prefix))
518-
.collect(Collectors.toMap(kv -> "spring.cloud.deployer." + kv.getKey().substring(prefixLength), Map.Entry::getValue,
519-
(fromWildcard, fromApp) -> fromApp));
511+
.filter(kv -> (!kv.getKey().startsWith("deployer.") && !kv.getKey().startsWith("app.")))
512+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
520513
}
521514

522515
protected Resource getTaskResource(String taskDefinitionName, String version) {

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/TaskSchedulerControllerTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void createAndVerifySchedule(String scheduleName, String createdSchedule
189189

190190
repository.save(new TaskDefinition("testDefinition", "testApp"));
191191
mockMvc.perform(post("/tasks/schedules").param("taskDefinitionName", "testDefinition")
192-
.param("scheduleName", scheduleName).param("properties", "scheduler.cron.expression=* * * * *")
192+
.param("scheduleName", scheduleName).param("properties", "deployer.testApp.cron.expression=* * * * *")
193193
.accept(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated());
194194
assertThat(simpleTestScheduler.list()).hasSize(1);
195195
ScheduleInfo scheduleInfo = simpleTestScheduler.list().get(0);
@@ -253,7 +253,7 @@ private String createScheduleWithArguments(String arguments) throws Exception {
253253
mockMvc.perform(post("/tasks/schedules").param("taskDefinitionName", "testDefinition")
254254
.param("scheduleName", "mySchedule")
255255
.param("properties",
256-
"scheduler.cron.expression=* * * * *,app.testApp.prop1=foo,app.testApp.prop2.secret=kenny,deployer.*.prop1.secret=cartman,deployer.*.prop2.password=kyle")
256+
"deployer.testApp.cron.expression=* * * * *,app.testApp.prop1=foo,app.testApp.prop2.secret=kenny,deployer.*.prop1.secret=cartman,deployer.*.prop2.password=kyle")
257257
.param("arguments", arguments)
258258
.accept(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated());
259259
assertThat(simpleTestScheduler.list()).hasSize(1);
@@ -283,7 +283,7 @@ void createScheduleBadCron() throws Exception {
283283
mockMvc.perform(post("/tasks/schedules").param("taskDefinitionName", "testDefinition")
284284
.param("scheduleName", "myScheduleBadCron")
285285
.param("properties",
286-
"scheduler.cron.expression=" + SimpleTestScheduler.INVALID_CRON_EXPRESSION)
286+
"deployer.testApp.cron.expression=" + SimpleTestScheduler.INVALID_CRON_EXPRESSION)
287287
.accept(MediaType.APPLICATION_JSON)).andExpect(status().isBadRequest());
288288
}
289289

@@ -339,7 +339,7 @@ private void createSampleSchedule(String scheduleName) {
339339

340340
private void createSampleSchedule(String taskDefinitionName, String scheduleName) {
341341
Map<String, String> properties = new HashMap<>();
342-
properties.put("scheduler.testApp." + SchedulerPropertyKeys.CRON_EXPRESSION, "* * * * *");
342+
properties.put("deployer.testApp." + SchedulerPropertyKeys.CRON_EXPRESSION, "* * * * *");
343343
schedulerService.schedule(scheduleName, taskDefinitionName, properties, new ArrayList<>(), null);
344344
}
345345

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/service/impl/DefaultSchedulerServiceMultiplatformTests.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
@AutoConfigureTestDatabase(replace = Replace.ANY)
9494
public class DefaultSchedulerServiceMultiplatformTests {
9595

96-
private static final String DATA_FLOW_SCHEDULER_PREFIX = "scheduler.";
96+
private static final String DATA_FLOW_DEPLOYER_PREFIX = "deployer.demo.";
9797

9898
private static final String DEPLOYER_PREFIX = "spring.cloud.deployer.";
9999

@@ -166,8 +166,8 @@ void setup() throws Exception {
166166
initializeSuccessfulRegistry();
167167

168168
this.testProperties = new HashMap<>();
169-
this.testProperties.put(DATA_FLOW_SCHEDULER_PREFIX + "AAAA", "* * * * *");
170-
this.testProperties.put(DATA_FLOW_SCHEDULER_PREFIX + "EXPRESSION", "* * * * *");
169+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "AAAA", "* * * * *");
170+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "EXPRESSION", "* * * * *");
171171
this.testProperties.put("version." + BASE_DEFINITION_NAME, "1.0.0");
172172
this.resolvedProperties = new HashMap<>();
173173
this.resolvedProperties.put(DEPLOYER_PREFIX + "AAAA", "* * * * *");
@@ -243,6 +243,11 @@ public void testScheduleWithLongName() {
243243

244244
@Test
245245
void scheduleCTR() {
246+
this.testProperties = new HashMap<>();
247+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "AAAA", "* * * * *");
248+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "EXPRESSION", "* * * * *");
249+
this.testProperties.put("deployer.composed-task-runner." + "AAAA", "* * * * *");
250+
this.testProperties.put("deployer.composed-task-runner." + "EXPRESSION", "* * * * *");
246251
schedulerService.schedule(BASE_SCHEDULE_NAME, CTR_DEFINITION_NAME, this.testProperties, this.commandLineArgs, KUBERNETES_PLATFORM);
247252
verifyScheduleExistsInScheduler(createScheduleInfo(BASE_SCHEDULE_NAME, CTR_DEFINITION_NAME));
248253
}

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/service/impl/DefaultSchedulerServiceTests.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@
9494
@AutoConfigureTestDatabase(replace = Replace.ANY)
9595
public class DefaultSchedulerServiceTests {
9696

97-
private static final String DATA_FLOW_SCHEDULER_PREFIX = "scheduler.";
97+
private static final String DATA_FLOW_DEPLOYER_PREFIX = "deployer.demo.";
9898

99-
private static final String SCHEDULER_PREFIX = "spring.cloud.deployer.";
99+
private static final String DEPLOYER_PREFIX = "spring.cloud.deployer.";
100100

101101
private static final String BASE_SCHEDULE_NAME = "myTaskSchedule";
102102

@@ -161,11 +161,11 @@ void setup() throws Exception{
161161
initializeSuccessfulRegistry();
162162

163163
this.testProperties = new HashMap<>();
164-
this.testProperties.put(DATA_FLOW_SCHEDULER_PREFIX + "AAAA", "* * * * *");
165-
this.testProperties.put(DATA_FLOW_SCHEDULER_PREFIX + "EXPRESSION", "* * * * *");
164+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "AAAA", "* * * * *");
165+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "EXPRESSION", "* * * * *");
166166
this.resolvedProperties = new HashMap<>();
167-
this.resolvedProperties.put(SCHEDULER_PREFIX + "AAAA", "* * * * *");
168-
this.resolvedProperties.put(SCHEDULER_PREFIX + "EXPRESSION", "* * * * *");
167+
this.resolvedProperties.put(DEPLOYER_PREFIX + "AAAA", "* * * * *");
168+
this.resolvedProperties.put(DEPLOYER_PREFIX + "EXPRESSION", "* * * * *");
169169
this.commandLineArgs = new ArrayList<>();
170170
}
171171

@@ -241,6 +241,11 @@ public void testScheduleWithLongName(){
241241

242242
@Test
243243
void scheduleCTR(){
244+
this.testProperties = new HashMap<>();
245+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "AAAA", "* * * * *");
246+
this.testProperties.put(DATA_FLOW_DEPLOYER_PREFIX + "EXPRESSION", "* * * * *");
247+
this.testProperties.put("deployer.composed-task-runner." + "AAAA", "* * * * *");
248+
this.testProperties.put("deployer.composed-task-runner." + "EXPRESSION", "* * * * *");
244249
schedulerService.schedule(BASE_SCHEDULE_NAME, CTR_DEFINITION_NAME, this.testProperties, Collections.singletonList("app.demo.0=foo=bar"));
245250
verifyScheduleExistsInScheduler(createScheduleInfo(BASE_SCHEDULE_NAME, CTR_DEFINITION_NAME));
246251
AuditActionType[] createActions = {AuditActionType.CREATE};

0 commit comments

Comments
 (0)