forked from apache/streampipes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve structure of pipeline execution management (apache#1096)
- Loading branch information
1 parent
2a2d06f
commit 7be2b88
Showing
35 changed files
with
1,269 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
streampipes-model/src/main/java/org/apache/streampipes/model/api/EndpointSelectable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.model.api; | ||
|
||
public interface EndpointSelectable { | ||
|
||
String getName(); | ||
|
||
String getSelectedEndpointUrl(); | ||
void setSelectedEndpointUrl(String selectedEndpointUrl); | ||
|
||
String getCorrespondingPipeline(); | ||
|
||
void setCorrespondingPipeline(String pipelineId); | ||
|
||
String getDetachPath(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...agement/src/main/java/org/apache/streampipes/manager/execution/PipelineExecutionInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.manager.execution; | ||
|
||
import org.apache.streampipes.model.SpDataSet; | ||
import org.apache.streampipes.model.base.InvocableStreamPipesEntity; | ||
import org.apache.streampipes.model.base.NamedStreamPipesEntity; | ||
import org.apache.streampipes.model.pipeline.Pipeline; | ||
import org.apache.streampipes.model.pipeline.PipelineOperationStatus; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class PipelineExecutionInfo { | ||
|
||
private final List<NamedStreamPipesEntity> failedServices; | ||
private final List<InvocableStreamPipesEntity> processorsAndSinks; | ||
private final List<SpDataSet> dataSets; | ||
|
||
private PipelineOperationStatus pipelineOperationStatus; | ||
|
||
private final String pipelineId; | ||
|
||
public static PipelineExecutionInfo create(Pipeline pipeline) { | ||
return new PipelineExecutionInfo(pipeline); | ||
} | ||
|
||
private PipelineExecutionInfo(Pipeline pipeline) { | ||
this.failedServices = new ArrayList<>(); | ||
this.processorsAndSinks = findProcessorsAndSinks(pipeline); | ||
this.dataSets = findDataSets(pipeline); | ||
this.pipelineOperationStatus = new PipelineOperationStatus(); | ||
this.pipelineId = pipeline.getPipelineId(); | ||
} | ||
|
||
private List<InvocableStreamPipesEntity> findProcessorsAndSinks(Pipeline pipeline) { | ||
return Stream | ||
.concat( | ||
pipeline.getSepas().stream(), | ||
pipeline.getActions().stream() | ||
).collect(Collectors.toList()); | ||
} | ||
|
||
private List<SpDataSet> findDataSets(Pipeline pipeline) { | ||
return pipeline | ||
.getStreams() | ||
.stream() | ||
.filter(s -> s instanceof SpDataSet) | ||
.map(s -> new SpDataSet((SpDataSet) s)) | ||
.toList(); | ||
} | ||
|
||
public void addFailedPipelineElement(NamedStreamPipesEntity failedElement) { | ||
this.failedServices.add(failedElement); | ||
} | ||
|
||
public void addDataSets(List<SpDataSet> dataSets) { | ||
this.dataSets.addAll(dataSets); | ||
} | ||
|
||
public List<SpDataSet> getDataSets() { | ||
return dataSets; | ||
} | ||
|
||
public List<NamedStreamPipesEntity> getFailedServices() { | ||
return failedServices; | ||
} | ||
|
||
public List<InvocableStreamPipesEntity> getProcessorsAndSinks() { | ||
return processorsAndSinks; | ||
} | ||
|
||
public void applyPipelineOperationStatus(PipelineOperationStatus status) { | ||
this.pipelineOperationStatus = status; | ||
} | ||
|
||
public PipelineOperationStatus getPipelineOperationStatus() { | ||
return this.pipelineOperationStatus; | ||
} | ||
|
||
public String getPipelineId() { | ||
return pipelineId; | ||
} | ||
|
||
public boolean isOperationSuccessful() { | ||
return failedServices.size() == 0 && pipelineOperationStatus.isSuccess(); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
.../src/main/java/org/apache/streampipes/manager/execution/PipelineExecutionTaskFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.streampipes.manager.execution; | ||
|
||
import org.apache.streampipes.manager.execution.http.DetachPipelineElementSubmitter; | ||
import org.apache.streampipes.manager.execution.http.InvokePipelineElementSubmitter; | ||
import org.apache.streampipes.manager.execution.provider.CurrentPipelineElementProvider; | ||
import org.apache.streampipes.manager.execution.provider.StoredPipelineElementProvider; | ||
import org.apache.streampipes.manager.execution.task.AfterInvocationTask; | ||
import org.apache.streampipes.manager.execution.task.DiscoverEndpointsTask; | ||
import org.apache.streampipes.manager.execution.task.SubmitRequestTask; | ||
import org.apache.streampipes.manager.execution.task.PipelineExecutionTask; | ||
import org.apache.streampipes.manager.execution.task.SecretEncryptionTask; | ||
import org.apache.streampipes.manager.execution.task.StorePipelineStatusTask; | ||
import org.apache.streampipes.manager.execution.task.UpdateGroupIdTask; | ||
import org.apache.streampipes.model.message.PipelineStatusMessageType; | ||
import org.apache.streampipes.model.pipeline.Pipeline; | ||
import org.apache.streampipes.resource.management.secret.SecretProvider; | ||
|
||
import java.util.List; | ||
|
||
public class PipelineExecutionTaskFactory { | ||
|
||
public static List<PipelineExecutionTask> makeStartPipelineTasks(Pipeline pipeline) { | ||
return List.of( | ||
new UpdateGroupIdTask(), | ||
new SecretEncryptionTask(SecretProvider.getDecryptionService()), | ||
new DiscoverEndpointsTask(), | ||
new SubmitRequestTask(new InvokePipelineElementSubmitter(pipeline), new CurrentPipelineElementProvider()), | ||
new SecretEncryptionTask(SecretProvider.getEncryptionService()), | ||
new AfterInvocationTask(PipelineStatusMessageType.PIPELINE_STARTED), | ||
new StorePipelineStatusTask(true, false) | ||
); | ||
} | ||
|
||
public static List<PipelineExecutionTask> makeStopPipelineTasks(Pipeline pipeline, | ||
boolean forceStop) { | ||
return List.of( | ||
new SubmitRequestTask(new DetachPipelineElementSubmitter(pipeline), new StoredPipelineElementProvider()), | ||
new AfterInvocationTask(PipelineStatusMessageType.PIPELINE_STOPPED), | ||
new StorePipelineStatusTask(false, forceStop) | ||
); | ||
} | ||
} |
Oops, something went wrong.