-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CYB-193][UI] Landing page for pipelines. (#81)
- Loading branch information
1 parent
dcf2ea3
commit 71cf8d1
Showing
119 changed files
with
2,995 additions
and
2,284 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
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
2 changes: 1 addition & 1 deletion
2
...s/cyber-service-common/src/main/java/com/cloudera/service/common/request/RequestType.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.cloudera.service.common.request; | ||
|
||
public enum RequestType { | ||
GET_ALL_CLUSTERS_SERVICE_REQUEST, GET_CLUSTER_SERVICE_REQUEST, START_JOB_REQUEST, RESTART_JOB_REQUEST, STOP_JOB_REQUEST, GET_JOB_CONFIG_REQUEST, UPDATE_JOB_CONFIG_REQUEST | ||
GET_ALL_CLUSTERS_SERVICE_REQUEST, GET_CLUSTER_SERVICE_REQUEST, START_JOB_REQUEST, RESTART_JOB_REQUEST, STOP_JOB_REQUEST, GET_JOB_CONFIG_REQUEST, CREATE_EMPTY_PIPELINE, START_ARCHIVE_PIPELINE, UPDATE_JOB_CONFIG_REQUEST | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...ces/cyber-service-common/src/main/java/com/cloudera/service/common/response/Pipeline.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,18 @@ | ||
package com.cloudera.service.common.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Pipeline { | ||
String id; | ||
String name; | ||
String clusterName; | ||
String date; | ||
String userName; | ||
} |
2 changes: 1 addition & 1 deletion
2
...cyber-service-common/src/main/java/com/cloudera/service/common/response/ResponseType.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.cloudera.service.common.response; | ||
|
||
public enum ResponseType { | ||
GET_ALL_CLUSTERS_SERVICE_RESPONSE, GET_CLUSTER_SERVICE_RESPONSE, START_JOB_RESPONSE, RESTART_JOB_RESPONSE, STOP_JOB_RESPONSE, GET_JOB_CONFIG_RESPONSE, UPDATE_JOB_CONFIG_RESPONSE, ERROR_RESPONSE | ||
GET_ALL_CLUSTERS_SERVICE_RESPONSE, GET_CLUSTER_SERVICE_RESPONSE, START_JOB_RESPONSE, RESTART_JOB_RESPONSE, STOP_JOB_RESPONSE, GET_JOB_CONFIG_RESPONSE, UPDATE_JOB_CONFIG_RESPONSE, CREATE_EMPTY_PIPELINE_RESPONSE, START_ARCHIVE_PIPELINE_RESPONSE, ERROR_RESPONSE | ||
} |
18 changes: 18 additions & 0 deletions
18
...orker-service/src/main/java/com/cloudera/cyber/restcli/configuration/AppWorkerConfig.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,18 @@ | ||
package com.cloudera.cyber.restcli.configuration; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConfigurationProperties(prefix = "cluster") | ||
@Getter | ||
@Setter | ||
public class AppWorkerConfig { | ||
private String name; | ||
private String id; | ||
private String status; | ||
private String version; | ||
private String pipelineDir; | ||
} |
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
78 changes: 78 additions & 0 deletions
78
...-worker-service/src/main/java/com/cloudera/cyber/restcli/service/FilePipelineService.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,78 @@ | ||
package com.cloudera.cyber.restcli.service; | ||
|
||
import com.cloudera.cyber.restcli.configuration.AppWorkerConfig; | ||
import com.cloudera.service.common.Utils; | ||
import com.cloudera.service.common.response.Job; | ||
import com.cloudera.service.common.utils.ArchiveUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class FilePipelineService { | ||
private final AppWorkerConfig config; | ||
|
||
|
||
public void createEmptyPipeline(String pipelineName, String branchName) { | ||
String fullPath = this.config.getPipelineDir().endsWith("/") ? this.config.getPipelineDir() + pipelineName + "/" + branchName | ||
: this.config.getPipelineDir() + "/" + pipelineName + "/" + branchName; | ||
File directory = new File(fullPath); | ||
if (directory.mkdirs()) { | ||
log.info("Create full path {}", fullPath); | ||
} | ||
try { | ||
ProcessBuilder processBuilder = new ProcessBuilder("cs-create-pipeline", pipelineName); | ||
processBuilder.directory(directory); | ||
Process process = processBuilder.start(); | ||
process.waitFor(); | ||
} catch (IOException ioe) { | ||
log.error("Caught get IOException {} ", ioe.getMessage()); | ||
} catch (InterruptedException e) { | ||
log.error("Caught Interrupt Exception with message {} ", e.getMessage()); | ||
} | ||
} | ||
|
||
public void extractPipeline(byte[] payload, String pipelineName, String branch) throws IOException { | ||
String fullPipelinePath = pipelineName.endsWith("/") ? this.config.getPipelineDir() + pipelineName + "/" + branch : this.config.getPipelineDir() + "/" + pipelineName + "/" + branch; | ||
ArchiveUtil.decompressFromTarGzInMemory(payload, fullPipelinePath, true); | ||
} | ||
|
||
public void startPipelineJob(String pipelineName, String branch, String profileName, List<String> jobsNames) throws IOException { | ||
String fullPipelinePath = pipelineName.endsWith("/") ?this.config.getPipelineDir() + pipelineName + "/" + branch | ||
: this.config.getPipelineDir() + "/" + pipelineName + "/" + branch; | ||
|
||
List<Job> jobs = jobsNames.stream().map(jobName -> Job.builder() | ||
.jobPipeline(pipelineName) | ||
.jobType(Utils.getEnumFromString(jobName, Job.JobType.class, Job.JobType::getName)) | ||
.jobBranch(branch) | ||
.jobName(StringUtils.defaultString(profileName, "main")) | ||
.build()).collect(Collectors.toList()); | ||
for (Job job : jobs) { | ||
job.getJobType().getScript(job); | ||
ProcessBuilder processBuilder = new ProcessBuilder(job.getJobType().getScript(job)); | ||
processBuilder.directory(new File(fullPipelinePath)); | ||
Process process = processBuilder.start(); | ||
Thread clt = new Thread(() -> { | ||
try { | ||
log.info(IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8)); | ||
log.error(IOUtils.toString(process.getErrorStream(), StandardCharsets.UTF_8)); | ||
} catch (IOException e) { | ||
log.error("Error happens on stream reading from bash {}", e.getMessage()); | ||
} | ||
}); | ||
clt.setDaemon(true); | ||
clt.start(); | ||
} | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.