Skip to content
Snippets Groups Projects
Commit 78d49c32 authored by Escalante Martinez, Marisa's avatar Escalante Martinez, Marisa
Browse files

APPController for ADAPT VH

parent 53dd4905
Branches
Tags
No related merge requests found
Showing
with 227 additions and 338 deletions
......@@ -122,6 +122,3 @@ local.properties
.cache-main
.scala_dependencies
.worksheet
#Windows specific
*~
# DECIDE Application Controller Library
# DECIDE Application Controller
The Application Controller Library provides a consistent way for handling the AppDescription and History json files to every project that has to operate on these files.
......@@ -6,7 +6,6 @@ The Application Controller Library provides a consistent way for handling the Ap
1. [Features](#features)
1. [Installation](#installation)
1. [Getting started](#getting-started)
1. [Validation Exception Handling](#validation-exception-handling)
1. [The Model](#the-model)
1. [The Interface](#the-interface)
1. [License](#license)
......@@ -21,14 +20,14 @@ The Application Controller Library provides a consistent way for handling the Ap
The project is available via Git repository. If you have access, do the following steps:
```bash
```shell
$> git clone https://gitlab.fokus.fraunhofer.de/DECIDE/app-controller.git
$> cd app-controller
```
The project uses Maven as build tool. After build you will find the jar and a fat jar in the target directory. To build use the follwoing command:
```bash
```shell
$> mvn clean package
```
......@@ -61,8 +60,8 @@ AppManager appManager = AppManager.open(String gitRef, String username, String p
AppDescription appDescription = appManager.getAppDescription();
//do something with the AppDescription
//then save
appManager.writeAndSync(appDescription, "Added new Microservices");
//close the AppManager
......@@ -78,33 +77,12 @@ try (AppManager appManager = AppManager.open("https://git.ref/", "username", "pa
AppDescription appDescription = appManager.getAppDescription();
//work on the AppDescription & save it with AppManager
appManager.writeAndSync(appDescription, "Added NFRs");
} catch (AppManagerException | IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
```
For further examples please take a look at the test cases.
## Validation Exception Handling
A `DECIDEValidationException` is usually a wrapper for the underlying validation library validation errors. The AppController utilizes the JSON Schema Validator from everit-org. You can easily access the original `ValidationException` if you need more details beyond the main message.
```java
try {
AppDescription appDescription = appManager.getAppDescription();
} catch (DECIDEValidationException e) {
ValidationException original = (ValidationException)e.getCause();
// get a list of all sub messages
List<String> messages = original.getAllMessages();
// get all sub exceptions. Each one is again a ValidationException
List<ValidationException> original.getCausingExceptions();
// getting a fancy pretty printed json structure containing all sub errors
String json = original.getJSON().toString(4);
} catch (IOEXception e) {
}
```
Please note that `DECIDEValidationException` is also a subclass of `AppManagerException`.
## The Model
......
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.DECIDEh2020</groupId>
<artifactId>app-controller</artifactId>
<version>0.0.15-SNAPSHOT</version>
<distributionManagement>
<repository>
<id>paca-releases</id>
<name>Paca Releases Repo</name>
<url>https://paca.fokus.fraunhofer.de/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>paca-snaptshots</id>
<url>https://paca.fokus.fraunhofer.de/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<scm>
<connection>scm:git:https://${GITLAB_USER_LDAP}:${GITLAB_USER_PASSWORD}@gitlab.fokus.fraunhofer.de/${CI_PROJECT_PATH}</connection>
<url>https://${GITLAB_USER_LDAP}:${GITLAB_USER_PASSWORD}@gitlab.fokus.fraunhofer.de/${CI_PROJECT_PATH}</url>
<developerConnection>scm:git:https://${GITLAB_USER_LDAP}:${GITLAB_USER_PASSWORD}@gitlab.fokus.fraunhofer.de/${CI_PROJECT_PATH}</developerConnection>
<tag>HEAD</tag>
</scm>
<version>0.0.12</version>
<repositories>
<repository>
<id>jgit-repository</id>
......@@ -35,12 +17,11 @@
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.1.1.201809181055-r</version>
<version>4.11.0.201803080745-r</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
......@@ -77,14 +58,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
......@@ -104,8 +77,6 @@
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<shadedArtifactAttached>true</shadedArtifactAttached>
<filters>
<filter>
<artifact>*:*</artifact>
......@@ -116,10 +87,12 @@
</excludes>
</filter>
</filters>
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
......@@ -3,6 +3,7 @@ package eu.DECIDEh2020.appManager;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Collections;
import java.util.UUID;
import com.fasterxml.jackson.core.JsonParseException;
......@@ -54,7 +55,7 @@ public class AppDescriptionFactory {
appDescription.setVersion("0.2.2-alpha");
appDescription.setHighTechnologicalRisk(false);
appDescription.getMicroservices().add(createMicroservice("Default"));
appDescription.setMicroservices(Collections.singletonList(createMicroservice("Default")));
return appDescription;
}
......@@ -64,7 +65,7 @@ public class AppDescriptionFactory {
microservice.setId(UUID.randomUUID().toString());
microservice.setName(name);
microservice.getEndpoints().add("http://mircroservice1.com/service");
microservice.setEndpoints(Collections.singletonList("http://mircroservice1.com/service"));
return microservice;
}
......
......@@ -72,9 +72,4 @@ public class AppDescriptionHelper {
}
public String getMicroserviceName(String id) {
Microservice microservice = appDescription.getMicroservices().stream().filter(m -> m.getId().equalsIgnoreCase(id)).findFirst().orElse(null);
return microservice != null ? microservice.getName() : null;
}
}
......@@ -166,10 +166,6 @@ public class AppManager implements Closeable {
}
}
public void reset() {
gitHandler.resetAll();
}
@Override
public void close() throws IOException {
try {
......
......@@ -52,7 +52,7 @@ public class AppDescription {
private Monitoring monitoring;
private String applicationInstanceId;
private String appInstanceId;
private Map<String, JsonNode> additionalProperties = new HashMap<>();
......@@ -176,12 +176,12 @@ public class AppDescription {
this.recommendedPatterns = recommendedPatterns;
}
public String getApplicationInstanceId() {
return applicationInstanceId;
public String getAppInstanceId() {
return appInstanceId;
}
public void setApplicationInstanceId(String applicationInstanceId) {
this.applicationInstanceId = applicationInstanceId;
public void setAppInstanceId(String appInstanceId) {
this.appInstanceId = appInstanceId;
}
@JsonAnyGetter
......
......@@ -12,26 +12,16 @@ import java.util.Map;
@JsonInclude(Include.NON_EMPTY)
public class AvailabilityNfr extends Nfr {
private String abstractValue;
private Double value;
private double quantitativeAvailability;
private String unit;
public String getAbstractValue() {
return abstractValue;
}
public void setAbstractValue(String abstractValue) {
this.abstractValue = abstractValue;
}
public Double getValue() {
return value;
public double getQuantitativeAvailability() {
return quantitativeAvailability;
}
public void setValue(double value) {
this.value = value;
public void setQuantitativeAvailability(double quantitativeAvailability) {
this.quantitativeAvailability = quantitativeAvailability;
}
public String getUnit() {
......
......@@ -13,12 +13,13 @@ import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Container {
private String id;
private String name;
private String imageName;
private String imageTag;
private String dockerPrivateRegistryIp;
private Integer dockerPrivateRegistryPort;
private int dockerPrivateRegistryPort;
private String hostname;
private String restart;
......@@ -30,23 +31,31 @@ public class Container {
private List<String> networks = new ArrayList<>();
private List<VolumeMapping> volumeMapping = new ArrayList<>();
private Map<String, String> volumeMapping = new HashMap<>();
private List<String> environment = new ArrayList<>();
private String consulKvProviderNodeName;
private Integer addConsulService;
private boolean addConsulService;
private Integer consulServicePort;
private int consulServicePort;
private Integer addConsulTraefikRules;
private boolean addConsulTraefikRules;
private List<PortMapping> portMapping = new ArrayList<>();
private Map<Integer, Integer> portMapping = new HashMap<>();
private List<Endpoint> endpoints = new ArrayList<>();
private Endpoint endpoints;
private Map<String, JsonNode> additionalProperties = new HashMap<>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
......@@ -79,11 +88,11 @@ public class Container {
this.dockerPrivateRegistryIp = dockerPrivateRegistryIp;
}
public Integer getDockerPrivateRegistryPort() {
public int getDockerPrivateRegistryPort() {
return dockerPrivateRegistryPort;
}
public void setDockerPrivateRegistryPort(Integer dockerPrivateRegistryPort) {
public void setDockerPrivateRegistryPort(int dockerPrivateRegistryPort) {
this.dockerPrivateRegistryPort = dockerPrivateRegistryPort;
}
......@@ -135,11 +144,11 @@ public class Container {
this.networks = networks;
}
public List<VolumeMapping> getVolumeMapping() {
public Map<String, String> getVolumeMapping() {
return volumeMapping;
}
public void setVolumeMapping(List<VolumeMapping> volumeMapping) {
public void setVolumeMapping(Map<String, String> volumeMapping) {
this.volumeMapping = volumeMapping;
}
......@@ -159,44 +168,36 @@ public class Container {
this.consulKvProviderNodeName = consulKvProviderNodeName;
}
public Integer getAddConsulService() {
public boolean isAddConsulService() {
return addConsulService;
}
public void setAddConsulService(Integer addConsulService) {
public void setAddConsulService(boolean addConsulService) {
this.addConsulService = addConsulService;
}
public List<PortMapping> getPortMapping() {
return portMapping;
}
public void setPortMapping(List<PortMapping> portMapping) {
this.portMapping = portMapping;
}
public List<Endpoint> getEndpoints() {
return endpoints;
public boolean isAddConsulTraefikRules() {
return addConsulTraefikRules;
}
public void setEndpoints(List<Endpoint> endpoints) {
this.endpoints = endpoints;
public void setAddConsulTraefikRules(boolean addConsulTraefikRules) {
this.addConsulTraefikRules = addConsulTraefikRules;
}
public Integer getConsulServicePort() {
return consulServicePort;
public Map<Integer, Integer> getPortMapping() {
return portMapping;
}
public void setConsulServicePort(Integer consulServicePort) {
this.consulServicePort = consulServicePort;
public void setPortMapping(Map<Integer, Integer> portMapping) {
this.portMapping = portMapping;
}
public void setAddConsulTraefikRules(Integer addConsulTraefikRules) {
this.addConsulTraefikRules = addConsulTraefikRules;
public Endpoint getEndpoints() {
return endpoints;
}
public Integer getAddConsulTraefikRules() {
return addConsulTraefikRules;
public void setEndpoints(Endpoint endpoints) {
this.endpoints = endpoints;
}
@JsonAnyGetter
......
......@@ -6,26 +6,16 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@JsonInclude(Include.NON_EMPTY)
public class CostNfr extends Nfr {
private String abstractValue;
private Double value;
private double quantitativeCost;
private String unit;
public String getAbstractValue() {
return abstractValue;
}
public void setAbstractValue(String abstractValue) {
this.abstractValue = abstractValue;
public double getQuantitativeCost() {
return quantitativeCost;
}
public Double getValue() {
return value;
}
public void setValue(Double value) {
this.value = value;
public void setQuantitativeCost(double quantitativeCost) {
this.quantitativeCost = quantitativeCost;
}
public String getUnit() {
......@@ -35,5 +25,4 @@ public class CostNfr extends Nfr {
public void setUnit(String unit) {
this.unit = unit;
}
}
......@@ -9,8 +9,8 @@ public class DetachableResource {
private String id;
private String name;
private Boolean db;
private Boolean sql;
private boolean db;
private boolean sql;
private String specificDb;
private String size;
private String classification;
......@@ -28,11 +28,11 @@ public class DetachableResource {
this.id = id;
}
public Boolean isDb() {
public boolean isDb() {
return db;
}
public void setDb(Boolean db) {
public void setDb(boolean db) {
this.db = db;
}
......@@ -48,11 +48,11 @@ public class DetachableResource {
this.name = name;
}
public Boolean isSql() {
public boolean isSql() {
return sql;
}
public void setSql(Boolean sql) {
public void setSql(boolean sql) {
this.sql = sql;
}
......
......@@ -8,9 +8,9 @@ import com.fasterxml.jackson.annotation.JsonInclude;
public class Endpoint {
private String protocol;
private Integer port;
private Integer skipRule;
private String containerNameOverride;
private int port;
private boolean skipRule;
private boolean containerNameOverride;
public String getProtocol() {
return protocol;
......@@ -20,27 +20,27 @@ public class Endpoint {
this.protocol = protocol;
}
public Integer getPort() {
public int getPort() {
return port;
}
public void setPort(Integer port) {
public void setPort(int port) {
this.port = port;
}
public Integer getSkipRule() {
public boolean isSkipRule() {
return skipRule;
}
public void setSkipRule(Integer skipRule) {
public void setSkipRule(boolean skipRule) {
this.skipRule = skipRule;
}
public String getContainerNameOverride() {
public boolean isContainerNameOverride() {
return containerNameOverride;
}
public void setContainerNameOverride(String containerNameOverride) {
public void setContainerNameOverride(boolean containerNameOverride) {
this.containerNameOverride = containerNameOverride;
}
......
......@@ -8,24 +8,34 @@ import java.util.List;
@JsonInclude(Include.NON_EMPTY)
public class LocationNfr extends Nfr {
private String abstractValue;
private List<String> qualitativeRegions;
private List<String> value;
private List<String> qualitativeCountries;
public String getAbstractValue() {
return abstractValue;
private String qualitativePolicy;
public List<String> getQualitativeRegions() {
return qualitativeRegions;
}
public void setQualitativeRegions(List<String> qualitativeRegions) {
this.qualitativeRegions = qualitativeRegions;
}
public List<String> getQualitativeCountries() {
return qualitativeCountries;
}
public void setAbstractValue(String abstractValue) {
this.abstractValue = abstractValue;
public void setQualitativeCountries(List<String> qualitativeCountries) {
this.qualitativeCountries = qualitativeCountries;
}
public List<String> getValue() {
return value;
public String getQualitativePolicy() {
return qualitativePolicy;
}
public void setValue(List<String> value) {
this.value = value;
public void setQualitativePolicy(String qualitativePolicy) {
this.qualitativePolicy = qualitativePolicy;
}
}
......@@ -35,7 +35,7 @@ public class Metric {
private List<Parameter> parameters = new ArrayList<>();
private List<Metric> underlyingMetrics = new ArrayList<>();
private List<String> underlyingMetrics = new ArrayList<>();
public String getId() {
return id;
......@@ -101,11 +101,11 @@ public class Metric {
this.parameters = parameters;
}
public List<Metric> getUnderlyingMetrics() {
public List<String> getUnderlyingMetrics() {
return underlyingMetrics;
}
public void setUnderlyingMetrics(List<Metric> underlyingMetrics) {
public void setUnderlyingMetrics(List<String> underlyingMetrics) {
this.underlyingMetrics = underlyingMetrics;
}
......
......@@ -26,15 +26,15 @@ public class Microservice {
private String id;
private String name;
private String classification;
private Boolean stateful = false;
private boolean stateful = false;
private String programmingLanguage;
private String sourceRepository;
private List<String> tags = new ArrayList<>();
private Boolean publicIP = false;
private boolean publicIP = false;
private List<String> endpoints = new ArrayList<>();
private String containerId;
private String containerRef;
private Integer deploymentOrder;
private int deploymentOrder;
private List<String> dependencies = new ArrayList<>();
private List<String> safeMethods = new ArrayList<>();
private List<DetachableResource> detachableResources = new ArrayList<>();
......@@ -64,11 +64,11 @@ public class Microservice {
this.classification = classification;
}
public Boolean isStateful() {
public boolean isStateful() {
return stateful;
}
public void setStateful(Boolean stateful) {
public void setStateful(boolean stateful) {
this.stateful = stateful;
}
......@@ -100,11 +100,11 @@ public class Microservice {
this.tags = tags;
}
public Boolean isPublicIP() {
public boolean isPublicIP() {
return publicIP;
}
public void setPublicIP(Boolean publicIP) {
public void setPublicIP(boolean publicIP) {
this.publicIP = publicIP;
}
......@@ -132,11 +132,11 @@ public class Microservice {
this.containerRef = containerRef;
}
public Integer getDeploymentOrder() {
public int getDeploymentOrder() {
return deploymentOrder;
}
public void setDeploymentOrder(Integer deploymentOrder) {
public void setDeploymentOrder(int deploymentOrder) {
this.deploymentOrder = deploymentOrder;
}
......
......@@ -9,14 +9,14 @@ import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Monitoring {
private Boolean status;
private boolean status;
private List<String> urls = new ArrayList<>();
public Boolean getStatus() {
public boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
public void setStatus(boolean status) {
this.status = status;
}
......
......@@ -12,30 +12,30 @@ import java.util.Map;
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type",
property = "kind",
visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = AvailabilityNfr.class, name = "Availability"),
@JsonSubTypes.Type(value = PerformanceNfr.class, name = "Performance"),
@JsonSubTypes.Type(value = ScalabilityNfr.class, name = "Scalability"),
@JsonSubTypes.Type(value = LocationNfr.class, name = "Location"),
@JsonSubTypes.Type(value = CostNfr.class, name = "Cost")})
@JsonSubTypes.Type(value = AvailabilityNfr.class, name = "availability"),
@JsonSubTypes.Type(value = PerformanceNfr.class, name = "performance"),
@JsonSubTypes.Type(value = ScalabilityNfr.class, name = "scalability"),
@JsonSubTypes.Type(value = LocationNfr.class, name = "location"),
@JsonSubTypes.Type(value = CostNfr.class, name = "cost")})
@JsonInclude(Include.NON_EMPTY)
public class Nfr {
@JsonTypeId
private String type;
private String kind;
private List<String> tags = new ArrayList<>();
private Map<String, JsonNode> additionalProperties = new HashMap<>();
public String getType() {
return type;
public String getKind() {
return kind;
}
public void setType(String type) {
this.type = type;
public void setKind(String kind) {
this.kind = kind;
}
public List<String> getTags() {
......
......@@ -19,12 +19,6 @@ public class Pattern {
private List<String> tags = new ArrayList<>();
private List<String> positiveImpacts = new ArrayList<>();
private List<String> categories = new ArrayList<>();
private Boolean selected = false;
private Map<String, JsonNode> additionalProperties = new HashMap<>();
public String getTitle() {
......@@ -51,30 +45,6 @@ public class Pattern {
this.tags = tags;
}
public List<String> getPositiveImpacts() {
return positiveImpacts;
}
public void setPositiveImpacts(List<String> positiveImpacts) {
this.positiveImpacts = positiveImpacts;
}
public List<String> getCategories() {
return categories;
}
public void setCategories(List<String> categories) {
this.categories = categories;
}
public Boolean isSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
@JsonAnyGetter
public Map<String, JsonNode> getAdditionalProperties() {
return additionalProperties;
......
......@@ -6,26 +6,16 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
@JsonInclude(Include.NON_EMPTY)
public class PerformanceNfr extends Nfr {
private String abstractValue;
private Double value;
private double quantitativeResponseTime;
private String unit;
public String getAbstractValue() {
return abstractValue;
}
public void setAbstractValue(String abstractValue) {
this.abstractValue = abstractValue;
public double getQuantitativeResponseTime() {
return quantitativeResponseTime;
}
public Double getValue() {
return value;
}
public void setValue(Double value) {
this.value = value;
public void setQuantitativeResponseTime(double quantitativeResponseTime) {
this.quantitativeResponseTime = quantitativeResponseTime;
}
public String getUnit() {
......@@ -35,5 +25,4 @@ public class PerformanceNfr extends Nfr {
public void setUnit(String unit) {
this.unit = unit;
}
}
......@@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
public class Remedy {
private String type;
private Integer value;
private int value;
private String unit;
private String validity;
......@@ -38,7 +38,7 @@ public class Remedy {
return validity;
}
public Integer getValue() {
public int getValue() {
return value;
}
......@@ -54,7 +54,7 @@ public class Remedy {
this.validity = validity;
}
public void setValue(Integer value) {
public void setValue(int value) {
this.value = value;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment