Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 2ea34a6

Browse files
oodamienilayaperumalg
authored andcommitted
Stream Deploy: avoid resubmitting apps form values
* Use Stream update REST endpoint
1 parent 765fa0b commit 2ea34a6

File tree

3 files changed

+74
-23
lines changed

3 files changed

+74
-23
lines changed

ui/src/app/streams/stream-deploy/builder/builder.component.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,21 @@ export class StreamDeployBuilderComponent implements OnInit, OnDestroy {
503503
return [];
504504
}
505505
return appProperties.map((property: Properties.Property) => {
506-
return (property.value !== undefined && property.value.toString() !== '' && property.value !== property.defaultValue) ? ({
507-
key: `${property.id}`,
508-
value: property.value
509-
}) : null;
506+
if (property.value && property.value !== undefined && property.value.toString() !== ''
507+
&& property.value !== property.defaultValue) {
508+
if (property.id.startsWith(`${appId}.`)) {
509+
return {
510+
key: `${property.name}`,
511+
value: property.value
512+
};
513+
} else {
514+
return {
515+
key: `${property.id}`,
516+
value: property.value
517+
};
518+
}
519+
}
520+
return null;
510521
}).filter((app) => app !== null);
511522
}
512523

ui/src/app/streams/stream-deploy/stream-deploy.component.ts

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
5858
*/
5959
properties: Array<string> = [];
6060

61+
/**
62+
* Original properties Array
63+
*/
64+
ignoreProperties: Array<string> = [];
65+
6166
/**
6267
* Constructor
6368
*
@@ -96,6 +101,7 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
96101
val => this.streamsService.getDeploymentInfo(val.id),
97102
(config: any, deploymentInfo: StreamDefinition) => {
98103
const properties = [];
104+
const ignoreProperties = [];
99105

100106
// Deployer properties
101107
Object.keys(deploymentInfo.deploymentProperties).map(app => {
@@ -128,11 +134,14 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
128134
keyShort = key.substring(`${appType}.`.length, key.length);
129135
}
130136
properties.push(`app.${app}.${keyShort}=${value}`);
137+
ignoreProperties.push(`app.${app}.${keyShort}=${value}`);
131138
});
132139
}
133140
});
134-
135141
this.properties = properties;
142+
if (!config.skipper) {
143+
this.ignoreProperties = ignoreProperties;
144+
}
136145
config.streamDefinition = deploymentInfo;
137146
return config;
138147
}
@@ -181,35 +190,55 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
181190
this.update(value);
182191
const propertiesMap = {};
183192
value.forEach((val) => {
184-
const arr = val.split(/=(.*)/);
185-
if (arr.length !== 3) {
186-
console.error('Split line property', val);
187-
} else {
188-
// Workaround sensitive property: ignored property
189-
if (arr[1] === `'******'`) {
190-
console.log(`Sensitive property ${arr[0]} is ignored`);
193+
if (this.ignoreProperties.indexOf(val) === -1) {
194+
const arr = val.split(/=(.*)/);
195+
if (arr.length !== 3) {
196+
console.error('Split line property', val);
191197
} else {
192-
propertiesMap[arr[0]] = arr[1];
198+
// Workaround sensitive property: ignored property
199+
if (arr[1] === `'******'`) {
200+
console.log(`Sensitive property ${arr[0]} is ignored`);
201+
} else {
202+
propertiesMap[arr[0]] = arr[1];
203+
}
193204
}
194205
}
195206
});
196207

197208
let obs = Observable.of({});
198-
if (['deployed', 'deploying'].indexOf(this.refConfig.streamDefinition.status) > -1) {
199-
obs = this.streamsService.undeployDefinition(this.refConfig.streamDefinition);
200-
}
201-
const busy = obs.pipe(mergeMap(
209+
const isDeployed = (['deployed', 'deploying'].indexOf(this.refConfig.streamDefinition.status) > -1);
210+
const update = this.refConfig.skipper && isDeployed;
211+
212+
if (update) {
213+
obs = obs.pipe(mergeMap(
214+
val => this.streamsService.updateDefinition(this.refConfig.id, propertiesMap),
215+
(val1, val2) => val2
216+
));
217+
} else {
218+
if (isDeployed) {
219+
obs = obs.pipe(mergeMap(
220+
val => this.streamsService.undeployDefinition(this.refConfig.streamDefinition),
221+
(val1, val2) => val2
222+
));
223+
}
224+
obs = obs.pipe(mergeMap(
202225
val => this.streamsService.deployDefinition(this.refConfig.id, propertiesMap),
203226
(val1, val2) => val2
204-
))
205-
.pipe(takeUntil(this.ngUnsubscribe$))
206-
.subscribe(
207-
data => {
208-
this.toastyService.success(`Successfully deployed stream definition "${this.refConfig.id}"`);
227+
));
228+
}
229+
230+
const busy = obs.pipe(takeUntil(this.ngUnsubscribe$))
231+
.subscribe(data => {
232+
if (update) {
233+
this.toastyService.success(`Successfully update stream definition "${this.refConfig.id}"`);
234+
} else {
235+
this.toastyService.success(`Successfully deployed stream definition "${this.refConfig.id}"`);
236+
}
209237
this.router.navigate(['streams']);
210238
},
211239
error => {
212-
this.toastyService.error(`${error.message ? error.message : error.toString()}`);
240+
const err = error.message ? error.message : error.toString();
241+
this.toastyService.error(err ? err : 'An error occurred during the stream deployment update.');
213242
}
214243
);
215244

ui/src/app/streams/streams.service.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ export class StreamsService {
168168
return Observable.forkJoin(observables);
169169
}
170170

171+
updateDefinition(streamDefinitionName: String, propertiesAsMap: any = {}): Observable<Response> {
172+
console.log('Updating...', streamDefinitionName, propertiesAsMap);
173+
const options = HttpUtils.getDefaultRequestOptions();
174+
return this.http.post(`/streams/deployments/update/${streamDefinitionName}`, {
175+
releaseName: streamDefinitionName,
176+
packageIdentifier: { packageName: streamDefinitionName, packageVersion: null },
177+
updateProperties: propertiesAsMap
178+
}, options)
179+
.catch(this.errorHandler.handleError);
180+
}
181+
171182
getDeploymentInfo(streamDefinitionName: string): Observable<StreamDefinition> {
172183
const options = HttpUtils.getDefaultRequestOptions();
173184
return this.http.get(`/streams/deployments/${streamDefinitionName}`, options).map(res => {

0 commit comments

Comments
 (0)