Skip to content

Commit

Permalink
[CYB-139][CYB-151][CYB-164] Transferring the configuration in a zip a…
Browse files Browse the repository at this point in the history
…rchive between clusters. New rest api with UI. (#61)
  • Loading branch information
vpavlenko-cv authored Apr 14, 2024
1 parent a57f6a0 commit 97aaef0
Show file tree
Hide file tree
Showing 111 changed files with 11,446 additions and 5,979 deletions.
5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/cybersec.iml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

53 changes: 0 additions & 53 deletions .idea/workspace.xml

This file was deleted.

3 changes: 0 additions & 3 deletions flink-cyber/.vscode/settings.json

This file was deleted.

46 changes: 46 additions & 0 deletions flink-cyber/cyber-services/cyber-service-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.cloudera.cyber</groupId>
<artifactId>cyber-services</artifactId>
<version>2.3.1</version>
</parent>
<artifactId>cyber-service-common</artifactId>
<name>Archetype - cyber-service-common</name>
<url>http://maven.apache.org</url>
<properties>
<commons-compress.version>1.24.0</commons-compress.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons-compress.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
<version>${assertj.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.cloudera.service.common;

import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.function.Function;

@UtilityClass
public class Utils {

/**
* Retrieves an enum constant of the specified enum type based on a case-insensitive search of a string representation,
* using a custom mapping function to extract the string representation from the enum constant.
*
* @param <T> the enum type
* @param name the string representation to search for
* @param enumClass the Class object representing the enum type
* @param nameFunction a function that extracts the string representation from an enum constant
* @return the enum constant matching the provided string representation, or null if not found
* @throws NullPointerException if {@code name}, {@code enumClass}, or {@code nameFunction} is null
*/
public static <T extends Enum<T>> T getEnumFromString(String name, Class<T> enumClass, Function<T, String> nameFunction) {
return Arrays.stream(enumClass.getEnumConstants())
.filter(type -> StringUtils.equalsIgnoreCase(name, nameFunction.apply(type)))
.findFirst()
.orElse(null);
}

public static <T extends Enum<T>> T getEnumFromStringContains(String name, Class<T> enumClass, Function<T, String> nameFunction) {
return Arrays.stream(enumClass.getEnumConstants())
.filter(type -> StringUtils.containsIgnoreCase(name, nameFunction.apply(type)))
.findFirst()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.cloudera.service.common.config.kafka;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Getter
@Setter
public class ClouderaKafkaProperties extends KafkaProperties {
private String replyTopic;
private String requestTopic;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.cloudera.service.common.config.kafka;

public class ClouderaManagementKafkaProperties extends ClouderaKafkaProperties{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.cloudera.service.common.config.kafka;

public class ClouderaWorkerKafkaProperties extends ClouderaKafkaProperties {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.cloudera.service.common.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RequestBody {
private String clusterServiceId;
private String jobIdHex;
private String pipelineDir;
private String branch;
private byte[] payload;
}
Original file line number Diff line number Diff line change
@@ -0,0 +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
}
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 ClusterMeta {
private String name;
private String clusterId;
private String clusterStatus;
private String version;
private String flinkVersion;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.cloudera.service.common.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobStatus;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Job {
private JobID jobId;

private String jobIdString;

private String jobFullName;

private String jobName;

private JobStatus jobState;

private String jobBranch;

private String jobPipeline;

private String startTime;

private JobType jobType;

@AllArgsConstructor
@Getter
public enum JobType {
GENERATOR("generate", "cs-restart-generator", "."),
PARSER("parse", "cs-restart-parser", "."),
TRIAGE("triage", "cs-restart-triage", "."),
PROFILE("profile", "cs-restart-profile", "."),
INDEX("index", "cs-restart-index", ".");

private final String name;
private final String scriptName;
private final String nameDelimiter;

public String[] getScript(Job job) {
switch (this) {
case GENERATOR:
case PROFILE:
case PARSER:
return new String[]{scriptName, job.getJobBranch(), job.getJobPipeline(), job.getJobName()};
case INDEX:
case TRIAGE:
return new String[]{scriptName, job.getJobBranch(), job.getJobPipeline()};
}
return new String[]{};
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.cloudera.service.common.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResponseBody {
private Map<String, String> jobConfigs;
private List<Job> jobs;
private Map<String, String> errorMessage;
private ClusterMeta clusterMeta;
}
Original file line number Diff line number Diff line change
@@ -0,0 +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
}
Loading

0 comments on commit 97aaef0

Please sign in to comment.