diff --git a/AppController/.gitignore b/AppController/.gitignore index 071e0238aa051ff237df749efeda3fa4dc751186..0614962651baaa7de898a06cc388f3e071948668 100644 --- a/AppController/.gitignore +++ b/AppController/.gitignore @@ -122,6 +122,3 @@ local.properties .cache-main .scala_dependencies .worksheet - -#Windows specific -*~ diff --git a/AppController/README.md b/AppController/README.md index 698ada774d7c1afefe1853161653b1a694242514..0280169bbf6c931f60ca892f8209dd4391b0c6f4 100644 --- a/AppController/README.md +++ b/AppController/README.md @@ -1,4 +1,4 @@ -# 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 ``` @@ -57,15 +56,15 @@ A small example on getting the `AppDescription` and saving it using the `AppMana ```java AppManager appManager = AppManager.open(String gitRef, String username, String password, Path localPath); -// get the Appdescription +//get the Appdescription AppDescription appDescription = appManager.getAppDescription(); -// do something with the AppDescription +//do something with the AppDescription +//then save -// then save appManager.writeAndSync(appDescription, "Added new Microservices"); -// close the AppManager +//close the AppManager appManager.close(); ``` @@ -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 diff --git a/AppController/pom.xml b/AppController/pom.xml index 75e9de8fbf8d902277c520f7a781d8f5c40a8f04..5f1bf7a6ec820226582c5e68597502ec2399c0fa 100644 --- a/AppController/pom.xml +++ b/AppController/pom.xml @@ -1,125 +1,98 @@ -<?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"> - <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> - - <repositories> - <repository> - <id>jgit-repository</id> - <url>https://repo.eclipse.org/content/groups/releases/</url> - </repository> - <repository> - <id>jitpack.io</id> - <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> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - <version>2.9.5</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - <version>2.9.5</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - <version>2.9.5</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>1.2.3</version> - </dependency> - <dependency> - <groupId>com.github.everit-org.json-schema</groupId> - <artifactId>org.everit.json.schema</artifactId> - <version>1.9.1</version> - </dependency> - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <version>6.14.3</version> - <scope>test</scope> - </dependency> - </dependencies> - - <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> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <version>3.1.1</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - <configuration> - <minimizeJar>true</minimizeJar> - <shadedArtifactAttached>true</shadedArtifactAttached> - <filters> - <filter> - <artifact>*:*</artifact> - <excludes> - <exclude>META-INF/*.SF</exclude> - <exclude>META-INF/*.DSA</exclude> - <exclude>META-INF/*.RSA</exclude> - </excludes> - </filter> - </filters> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file +<?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"> + <modelVersion>4.0.0</modelVersion> + + <groupId>eu.DECIDEh2020</groupId> + <artifactId>app-controller</artifactId> + <version>0.0.12</version> + <repositories> + <repository> + <id>jgit-repository</id> + <url>https://repo.eclipse.org/content/groups/releases/</url> + </repository> + <repository> + <id>jitpack.io</id> + <url>https://jitpack.io</url> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>org.eclipse.jgit</groupId> + <artifactId>org.eclipse.jgit</artifactId> + <version>4.11.0.201803080745-r</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>2.9.5</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.9.5</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.9.5</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.3</version> + </dependency> + <dependency> + <groupId>com.github.everit-org.json-schema</groupId> + <artifactId>org.everit.json.schema</artifactId> + <version>1.9.1</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.14.3</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.7.0</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>3.1.1</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionFactory.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionFactory.java index b21e440a7f02ab2fd965c982f24e3b8524df33a5..34e4d5d1049c55b3c6a4ef83f65af1f7828a46b8 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionFactory.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionFactory.java @@ -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; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionHelper.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionHelper.java index d89083ce6c943a217f77636356a332ef97b1ffb3..8cc0720ed6ab39cee88d0c74dbbeb94874e1e783 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionHelper.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/AppDescriptionHelper.java @@ -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; - } - } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/AppManager.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/AppManager.java index c6101c5135fb2d92525f09b31946215b2aeff841..7cc97ee58a5cea55c142569fa03133aa9d84897b 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/AppManager.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/AppManager.java @@ -166,10 +166,6 @@ public class AppManager implements Closeable { } } - public void reset() { - gitHandler.resetAll(); - } - @Override public void close() throws IOException { try { diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AppDescription.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AppDescription.java index 2ba1ab8ee0e9a931db611212a1feb2a7ca91d879..f7692985429094f0e170cdf22ecccadc90961f40 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AppDescription.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AppDescription.java @@ -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 diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AvailabilityNfr.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AvailabilityNfr.java index 8f6b55331bcba9acc540a8a0087fa5eda9b02543..30eb10e30827a267eddc1fb7867b7a7823335491 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AvailabilityNfr.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/AvailabilityNfr.java @@ -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() { diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Container.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Container.java index a50317d62dab8e19cc3077b5619f60ce8ef210ed..13e1f19122d0bc11341fa4a5716321fc3be7b43f 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Container.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Container.java @@ -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 diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/CostNfr.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/CostNfr.java index f0c9f16f03fdfa6d718508dd00dae55964367fa1..65be78861fa7d82be2c45cad1cc539013fb5d72e 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/CostNfr.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/CostNfr.java @@ -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; } - } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/DetachableResource.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/DetachableResource.java index 454d11dd5580a0ba4b70cabfa904e6d53e83f9c7..5303f95276bf9c6042489c0ee2d8ac5c913685b4 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/DetachableResource.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/DetachableResource.java @@ -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; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Endpoint.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Endpoint.java index 3e4e9a7b24a5c63ba6160c67bf09809aebbe9c5e..1848e3dd79245fbb20afd23c3e3901ef8cc8275f 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Endpoint.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Endpoint.java @@ -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; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/LocationNfr.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/LocationNfr.java index ef259009067eb6b7b71abc46aa4c051bd23f6b43..27915cfe84b05f7ab021d3481172e7f3991b9f33 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/LocationNfr.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/LocationNfr.java @@ -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; } } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Metric.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Metric.java index 87ab2eb1fc9f441bee9a4a7976941255ce01490b..0d395d27dd1746176abb45984f16a6201e4bc1f1 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Metric.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Metric.java @@ -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; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Microservice.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Microservice.java index dccefd3a72f9fe17dd62358a65630cb3f079a56e..f4ae44763fc498d13b6731044f5359efe3869ea1 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Microservice.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Microservice.java @@ -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; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Monitoring.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Monitoring.java index 683d621a2b64ce3da44c25378b38b2c7b07bb243..9949e564fcba7d6161cde1a41c7b633c6c27277a 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Monitoring.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Monitoring.java @@ -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; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Nfr.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Nfr.java index 2fe82f17584da7bcfb38063c3f5b6e0378455914..a6c81d68155ebccf65c1a75f6358e86cc7e4f221 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Nfr.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Nfr.java @@ -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() { diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Pattern.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Pattern.java index 1e363a0144ac45f46d60fb51f1d819eab3b265b0..f15a5b81fb96b4bfca5ebe2b1165d7bed9e86edb 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Pattern.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Pattern.java @@ -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; diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/PerformanceNfr.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/PerformanceNfr.java index 630428962597e5d1c478f68e783bd58e7f819cfa..d3a68b5b6b83e77b12efc446f1524305382dfec7 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/PerformanceNfr.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/PerformanceNfr.java @@ -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; } - } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Remedy.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Remedy.java index c99ac1da25e4bf0741b1d44ce61addf7b44dac7b..934ebcfe6cc9d3e8d624b4bffae1b07e4acc586c 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Remedy.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Remedy.java @@ -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; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ScalabilityNfr.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ScalabilityNfr.java index 60b9481f982ca4fe59ad66982381d62145d9cf82..c03575fe82a1437add31dc47fc2d6c510c265278 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ScalabilityNfr.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ScalabilityNfr.java @@ -8,34 +8,14 @@ import java.util.List; @JsonInclude(Include.NON_EMPTY) public class ScalabilityNfr extends Nfr { - private String abstractValue; + private List<String> scaleBy; - private Double value; - - private String unit; - - public String getAbstractValue() { - return abstractValue; - } - - public void setAbstractValue(String abstractValue) { - this.abstractValue = abstractValue; - } - - public Double getValue() { - return value; - } - - public void setValue(Double value) { - this.value = value; - } - - public String getUnit() { - return unit; + public List<String> getScaleBy() { + return scaleBy; } - public void setUnit(String unit) { - this.unit = unit; + public void setScaleBy(List<String> scaleBy) { + this.scaleBy = scaleBy; } } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/SchemaElement.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/SchemaElement.java index 9f720dfd476fd03c2a2458afa80e0adb677612ac..b688d1cf192d368f58065dc5b1a67f2a17c0aa65 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/SchemaElement.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/SchemaElement.java @@ -13,7 +13,7 @@ public class SchemaElement { private String csId; - private Integer index; + private int index; public List<String> getMicroservices() { return microservices; @@ -31,11 +31,11 @@ public class SchemaElement { this.csId = csId; } - public Integer getIndex() { + public int getIndex() { return index; } - public void setIndex(Integer index) { + public void setIndex(int index) { this.index = index; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ServiceObjective.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ServiceObjective.java index e7ef72c81a02a3a6a6458b983dcee0ab8bae9d78..0731de7f082110cbdd92ed77112e79619c395e7e 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ServiceObjective.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ServiceObjective.java @@ -10,9 +10,7 @@ package eu.DECIDEh2020.appManager.models; * Contributors: * * Majid Salehi Ghamsari Fraunhofer FOKUS -* Simon Dutkowski Fraunhofer FOKUS -* -* *Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -27,12 +25,13 @@ public class ServiceObjective { private String comment; private String termName; + private String monitoringResult; private String type; - private String value; + private double value; private String unit; - private String conditionStatement; + private String calculationFormula; private List<ViolationTriggerRule> violationTriggerRules = new ArrayList<>(); private Remedy remedy; private List<Metric> metrics = new ArrayList<>(); @@ -61,11 +60,19 @@ public class ServiceObjective { this.type = type; } - public String getValue() { + public String getMonitoringResult() { + return monitoringResult; + } + + public void setMonitoringResult(String monitoringResult) { + this.monitoringResult = monitoringResult; + } + + public double getValue() { return value; } - public void setValue(String value) { + public void setValue(double value) { this.value = value; } @@ -77,12 +84,12 @@ public class ServiceObjective { this.unit = unit; } - public String getConditionStatement() { - return conditionStatement; + public String getCalculationFormula() { + return calculationFormula; } - public void setConditionStatement(String conditionStatement) { - this.conditionStatement = conditionStatement; + public void setCalculationFormula(String calculationFormula) { + this.calculationFormula = calculationFormula; } public List<ViolationTriggerRule> getViolationTriggerRules() { diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Sla.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Sla.java index eab6f6beab87fc6190898a42c8f771eefe84cea0..a265995b3bb4c680987c7ed19fcb858a26d7bc3f 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Sla.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/Sla.java @@ -28,7 +28,7 @@ public class Sla { private String visibility; - private Integer validityPeriod; + private int validityPeriod; private List<String> coveredServices = new ArrayList<>(); @@ -54,11 +54,11 @@ public class Sla { this.visibility = visibility; } - public Integer getValidityPeriod() { + public int getValidityPeriod() { return validityPeriod; } - public void setValidityPeriod(Integer validityPeriod) { + public void setValidityPeriod(int validityPeriod) { this.validityPeriod = validityPeriod; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ViolationTriggerRule.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ViolationTriggerRule.java index 1abe176ef627802188ddef4bfce9af6eddb81aa8..3244d15ffd1a9dc03e4c75a171432b8e0fca90c5 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ViolationTriggerRule.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/ViolationTriggerRule.java @@ -20,22 +20,22 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_EMPTY) public class ViolationTriggerRule { - private Integer breachesCount; - private Integer violationInterval; + private int breachesCount; + private int violationInterval; - public Integer getBreachesCount() { + public int getBreachesCount() { return breachesCount; } - public void setBreachesCount(Integer breachesCount) { - this.breachesCount = breachesCount; + public int getViolationInterval() { + return violationInterval; } - public Integer getViolationInterval() { - return violationInterval; + public void setBreachesCount(int breachesCount) { + this.breachesCount = breachesCount; } - public void setViolationInterval(Integer violationInterval) { + public void setViolationInterval(int violationInterval) { this.violationInterval = violationInterval; } diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/VirtualMachine.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/VirtualMachine.java index 21a014333f6dee10ba8a28efda139837d7aa9108..163c0c4b2891e6d6536fea21f26775618f5f537a 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/models/VirtualMachine.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/models/VirtualMachine.java @@ -18,9 +18,9 @@ public class VirtualMachine { private String cspId; private String cspName; - private Integer ram; - private Integer cores; - private Integer storage; + private int ram; + private int cores; + private int storage; private String image; private String cloudBrokerEndpoint; @@ -38,12 +38,13 @@ public class VirtualMachine { private String consulJoinIp; private String dockerPrivateRegistryIp; - private Integer dockerPrivateRegistryPPort; + private int dockerPrivateRegistryPPort; private String dockerHostNodeName; private String dockerHostPublicIp; private Map<String, JsonNode> additionalProperties = new HashMap<>(); + public String getId() { return id; } @@ -68,27 +69,27 @@ public class VirtualMachine { this.cspName = cspName; } - public Integer getRam() { + public int getRam() { return ram; } - public void setRam(Integer ram) { + public void setRam(int ram) { this.ram = ram; } - public Integer getCores() { + public int getCores() { return cores; } - public void setCores(Integer cores) { + public void setCores(int cores) { this.cores = cores; } - public Integer getStorage() { + public int getStorage() { return storage; } - public void setStorage(Integer storage) { + public void setStorage(int storage) { this.storage = storage; } @@ -100,118 +101,6 @@ public class VirtualMachine { this.image = image; } - public String getCloudBrokerEndpoint() { - return cloudBrokerEndpoint; - } - - public void setCloudBrokerEndpoint(String cloudBrokerEndpoint) { - this.cloudBrokerEndpoint = cloudBrokerEndpoint; - } - - public String getCloudBrokerUsername() { - return cloudBrokerUsername; - } - - public void setCloudBrokerUsername(String cloudBrokerUsername) { - this.cloudBrokerUsername = cloudBrokerUsername; - } - - public String getCloudBrokerPassword() { - return cloudBrokerPassword; - } - - public void setCloudBrokerPassword(String cloudBrokerPassword) { - this.cloudBrokerPassword = cloudBrokerPassword; - } - - public String getVmSoftwareId() { - return vmSoftwareId; - } - - public void setVmSoftwareId(String vmSoftwareId) { - this.vmSoftwareId = vmSoftwareId; - } - - public String getVmResourceId() { - return vmResourceId; - } - - public void setVmResourceId(String vmResourceId) { - this.vmResourceId = vmResourceId; - } - - public String getVmRegionId() { - return vmRegionId; - } - - public void setVmRegionId(String vmRegionId) { - this.vmRegionId = vmRegionId; - } - - public String getInstanceTypeId() { - return instanceTypeId; - } - - public void setInstanceTypeId(String instanceTypeId) { - this.instanceTypeId = instanceTypeId; - } - - public String getKeyPairId() { - return keyPairId; - } - - public void setKeyPairId(String keyPairId) { - this.keyPairId = keyPairId; - } - - public List<Integer> getOpenedPorts() { - return openedPorts; - } - - public void setOpenedPorts(List<Integer> openedPorts) { - this.openedPorts = openedPorts; - } - - public String getConsulJoinIp() { - return consulJoinIp; - } - - public void setConsulJoinIp(String consulJoinIp) { - this.consulJoinIp = consulJoinIp; - } - - public String getDockerPrivateRegistryIp() { - return dockerPrivateRegistryIp; - } - - public void setDockerPrivateRegistryIp(String dockerPrivateRegistryIp) { - this.dockerPrivateRegistryIp = dockerPrivateRegistryIp; - } - - public Integer getDockerPrivateRegistryPPort() { - return dockerPrivateRegistryPPort; - } - - public void setDockerPrivateRegistryPPort(Integer dockerPrivateRegistryPPort) { - this.dockerPrivateRegistryPPort = dockerPrivateRegistryPPort; - } - - public String getDockerHostNodeName() { - return dockerHostNodeName; - } - - public void setDockerHostNodeName(String dockerHostNodeName) { - this.dockerHostNodeName = dockerHostNodeName; - } - - public String getDockerHostPublicIp() { - return dockerHostPublicIp; - } - - public void setDockerHostPublicIp(String dockerHostPublicIp) { - this.dockerHostPublicIp = dockerHostPublicIp; - } - @JsonAnyGetter public Map<String, JsonNode> getAdditionalProperties() { return additionalProperties; diff --git a/AppController/src/main/java/eu/DECIDEh2020/appManager/persistence/GitHandler.java b/AppController/src/main/java/eu/DECIDEh2020/appManager/persistence/GitHandler.java index ef96d9dc0ce868c81c3f4dd92a5edd809edc9c4d..5c477db79901ce1fbc5adf1c692fb1ebd3918137 100644 --- a/AppController/src/main/java/eu/DECIDEh2020/appManager/persistence/GitHandler.java +++ b/AppController/src/main/java/eu/DECIDEh2020/appManager/persistence/GitHandler.java @@ -19,33 +19,36 @@ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; -import java.nio.file.Files; import java.nio.file.Path; import java.util.Iterator; import org.eclipse.jgit.api.*; +import org.eclipse.jgit.api.errors.CanceledException; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.DetachedHeadException; import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidConfigurationException; import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.api.errors.NoHeadException; +import org.eclipse.jgit.api.errors.NoMessageException; +import org.eclipse.jgit.api.errors.RefNotFoundException; +import org.eclipse.jgit.api.errors.TransportException; +import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.merge.MergeStrategy; import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import org.eclipse.jgit.transport.*; -import org.eclipse.jgit.util.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class GitHandler { - - private final Logger log = LoggerFactory.getLogger(getClass()); - public static class Repository { Path path; private String uri, host, user, password, name, port, protocol; - private boolean newRepo = true, localRepo = true; + private boolean secureStorage, newRepo = true, localRepo = true; private String token; - public Repository(String uri, Path path, String host, String user, String password, String port, String name, String protocol) { + public Repository(String uri, Path path, String host, String user, String password, String port, String name, String protocol, boolean secureStorage) { this.uri = uri; this.path = path; this.host = host; @@ -54,6 +57,7 @@ public class GitHandler { this.port = port; this.protocol = protocol; this.password = password; + this.secureStorage = secureStorage; } public Repository() { @@ -135,6 +139,22 @@ public class GitHandler { this.password = password; } + /** + * @return the secureStorage + */ + public boolean isSecureStorage() { + return secureStorage; + } + + /** + * @param secureStorage + * the secureStorage to set + */ + public void setSecureStorage(boolean secureStorage) { + this.secureStorage = secureStorage; + } + + /** * @return the name */ @@ -279,24 +299,18 @@ public class GitHandler { try { Iterator<PushResult> it = pc.call().iterator(); if (it.hasNext()) { - log.debug(it.next().toString()); + System.out.println(it.next().toString()); } } catch (InvalidRemoteException e) { - log.error("push to repo", e); + e.printStackTrace(); } } public void pullFromRepo() throws GitAPIException { - try { - PullResult result = git.pull().setCredentialsProvider(cp).setStrategy(MergeStrategy.RESOLVE).call(); - if (result.isSuccessful()) { - return; - } - } catch (GitAPIException e) { - log.error("standard pull", e); + PullResult result = git.pull().setCredentialsProvider(cp).call(); + if (!result.isSuccessful()) { + git.pull().setStrategy(MergeStrategy.THEIRS).setCredentialsProvider(cp).call(); } - resetMerging(); - git.pull().setStrategy(MergeStrategy.THEIRS).setCredentialsProvider(cp).call(); } public void setCredentials(String name,String password) { @@ -349,32 +363,9 @@ public class GitHandler { } } catch (MalformedURLException e) { - log.error("repo url parsing", e); - } catch (UnsupportedEncodingException e) { - log.error("token encoding", e); - } - } - private void resetMerging() throws GitAPIException { - try { - git.getRepository().writeMergeCommitMsg( null ); - git.getRepository().writeMergeHeads( null ); - } catch (IOException e) { - log.error("abort merging", e); - } - git.reset().setMode( ResetCommand.ResetType.HARD ).call(); - } + } catch (UnsupportedEncodingException e) { - public void resetAll() { - git.getRepository().close(); - close(); - try { - FileUtils.delete(repository.getPath().toFile(), FileUtils.RECURSIVE | FileUtils.IGNORE_ERRORS); - log.debug("directory deleted"); - log.debug("exists {}", Files.exists(repository.getPath())); - cloneRepo(); - } catch (GitAPIException | IOException e) { - log.error("reset cloned repo", e); } } diff --git a/AppController/src/main/resources/application_description.schema.json b/AppController/src/main/resources/application_description.schema.json index 6b8da68851621caa2eb40779a3fc50cff7201dd1..216e14fab9f81867a7e2df5f843d3d0418a85e64 100644 --- a/AppController/src/main/resources/application_description.schema.json +++ b/AppController/src/main/resources/application_description.schema.json @@ -93,7 +93,7 @@ "$ref": "#/definitions/Container" } }, - "applicationInstanceId": { + "appInstanceId": { "type": "string" } }, @@ -190,10 +190,10 @@ }, "Nfr": { "type": "object", - "required": [ "type" ], + "required": [ "kind" ], "properties": { - "type": { - "enum": [ "Availability", "Performance", "Scalability", "Location", "Cost" ] + "kind": { + "enum": [ "availability", "performance", "scalability", "location", "cost" ] }, "tags": { "type": "array", @@ -211,16 +211,12 @@ }, { "type": "object", - "required": [ "abstractValue", "value" ], + "required": [ "quantitativeAvailability", "unit" ], "properties": { - "type": { - "const": "Availability" - }, - "abstractValue": { - "type": "string", - "enum": [ "Low", "Medium", "High" ] + "kind": { + "const": "availability" }, - "value": { + "quantitativeAvailability": { "type": "number", "minimum": 0, "maximum": 100 @@ -239,16 +235,12 @@ }, { "type": "object", - "required": [ "abstractValue", "value" ], + "required": [ "quantitativeResponseTime", "unit" ], "properties": { - "type": { - "const": "Performance" - }, - "abstractValue": { - "type": "string", - "enum": [ "Low", "Medium", "High" ] + "kind": { + "const": "performance" }, - "value": { + "quantitativeResponseTime": { "type": "number", "exclusiveMinimum": 0 }, @@ -266,20 +258,20 @@ }, { "type": "object", - "required": [ "abstractValue", "value" ], + "required": [ "scaleBy" ], "properties": { - "type": { - "const": "Scalability" - }, - "abstractValue": { - "type": "string", - "enum": [ "Low", "Medium", "High" ] - }, - "value": { - "type": "number" + "kind": { + "const": "scalability" }, - "unit": { - "type": "string" + "scaleBy": { + "type": "array", + "items": { + "enum": [ + "messageCount", + "processorLoad" + ] + }, + "uniqueItems": true } } } @@ -292,21 +284,27 @@ }, { "type": "object", - "required": [ "abstractValue", "value" ], + "required": [ "qualitativeRegions", "qualitativeCountries" ], "properties": { - "type": { - "const": "Location" + "kind": { + "const": "location" }, - "abstractValue": { - "type": "string", - "enum": [ "Single Location", "Single Country", "Cross Border" ] + "qualitativeRegions": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true }, - "value": { + "qualitativeCountries": { "type": "array", "items": { "type": "string" }, "uniqueItems": true + }, + "qualitativePolicy": { + "enum": [ "sameUserCountry" ] } } } @@ -319,16 +317,12 @@ }, { "type": "object", - "required": [ "abstractValue", "value" ], + "required": [ "quantitativeCost", "unit" ], "properties": { - "type": { - "const": "Cost" - }, - "abstractValue": { - "type": "string", - "enum": [ "Low", "Medium", "High" ] + "kind": { + "const": "cost" }, - "value": { + "quantitativeCost": { "type": "number", "exclusiveMinimum": 0 }, @@ -341,6 +335,11 @@ }, "VirtualMachine": { "type": "object", + "required": [ + "id", + "cspName", + "cspId" + ], "properties": { "id": { "type": "string" @@ -378,13 +377,19 @@ "Container": { "type": "object", "required": [ + "id", + "name", "imageName", "imageTag", "hostname", "restart", - "dockerHostNodeName" + "dockerHostNodeName", + "consulKvProviderNodeName" ], "properties": { + "id": { + "type": "string" + }, "containerName": { "type": "string" }, @@ -407,7 +412,8 @@ ] }, "dockerPrivateRegistryPort": { - "type": "integer" + "type": "integer", + "minimum": 0 }, "dockerPrivateRegistryUser": { "type": "string" @@ -445,7 +451,10 @@ } }, "volumeMapping": { - "type": "array" + "type": "object", + "additionalProperties": { + "type": "string" + } }, "environment": { "type": "array", @@ -457,24 +466,16 @@ "type": "string" }, "addConsulService": { - "type": "integer" + "type": "boolean" }, "addConsulTraefikRules": { - "type": "integer" + "type": "boolean" }, "portMapping": { - "type": "array", - "items": { - "type": "object", - "required": [ "hostPort", "containerPort" ], - "properties": { - "hostPort": { - "type": "string" - }, - "containerPort": { - "type": "string" - } - } + "type": "object", + "additionalProperties": { + "type": "integer", + "minimum": 0 } }, "endpoints": { @@ -615,16 +616,6 @@ "comment": { "type": "string" }, - "value": { - "type": "string" - }, - "unit": { - "type": "string" - }, - "conditionStatement": { - "type": "string", - "enum": [ "greater", "less", "greaterOrEqual", "lessOrEqual", "equal" ] - }, "violationTriggerRules": { "type": "array", "items": { @@ -644,7 +635,7 @@ }, "Metric": { "type": "object", - "required": [ "id", "scale", "expression" ], + "required": [ "id", "scale" ], "properties": { "descriptor": { "type": "string" @@ -683,14 +674,21 @@ "underlyingMetrics": { "type": "array", "items": { - "$ref": "#/definitions/Metric" + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/Metric" + } + ] } } } }, "Expression": { "type": "object", - "required": [ "expression", "expressionLanguage" ], + "required": [ "id", "expression", "expressionLanguage" ], "properties": { "id": { "type": "string" @@ -827,7 +825,7 @@ "minimum": 0 }, "skipRule": { - "type": "integer" + "type": "boolean" }, "containerNameOverride": { "type": "string" diff --git a/AppController/src/test/java/eu/DECIDEh2020/appManager/AppDescriptionFactoryTest.java b/AppController/src/test/java/eu/DECIDEh2020/appManager/AppDescriptionFactoryTest.java index d66dc8a357e8dd78322da90e770e9a3d2b5765de..43a735b1ed5de6ffbde6a0c8ccdc3b4109f3492e 100644 --- a/AppController/src/test/java/eu/DECIDEh2020/appManager/AppDescriptionFactoryTest.java +++ b/AppController/src/test/java/eu/DECIDEh2020/appManager/AppDescriptionFactoryTest.java @@ -1,10 +1,8 @@ package eu.DECIDEh2020.appManager; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import eu.DECIDEh2020.appManager.exceptions.DECIDEValidationException; import eu.DECIDEh2020.appManager.models.AppDescription; -import org.everit.json.schema.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Test; @@ -20,17 +18,11 @@ public class AppDescriptionFactoryTest { @Test public void createAppDescription() { AppDescription appDescription = AppDescriptionFactory.createAppDescription("TestApp"); -// appDescription.getMicroservices().get(0).setPublicIP(true); - try { - log.debug(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(appDescription)); - } catch (JsonProcessingException e) { - log.error("pretty print app description", e); - } try { AppDescriptionFactory.validateAppDescription(appDescription); assert true; } catch (DECIDEValidationException e) { - log.error("validating test resource", ((ValidationException)e.getCause()).toJSON().toString(4)); + log.error("reading and validating test resource", e); assert false; } } @@ -42,11 +34,8 @@ public class AppDescriptionFactoryTest { AppDescription appDescription = new ObjectMapper().readValue(path.toFile(), AppDescription.class); AppDescriptionFactory.validateAppDescription(appDescription); assert true; - } catch (DECIDEValidationException e) { - log.error("validating test resource", ((ValidationException)e.getCause()).toJSON().toString(4)); - assert false; - } catch (IOException e) { - log.error("reading test resource", e); + } catch (DECIDEValidationException | IOException e) { + log.error("reading and validating test resource", e); assert false; } } diff --git a/AppController/src/test/resources/DECIDE.json b/AppController/src/test/resources/DECIDE.json index 11593efd1879bbff184d66808112ff5e5ace664c..d43fa36f63f25256266bb75f0d2edd198ee134de 100644 --- a/AppController/src/test/resources/DECIDE.json +++ b/AppController/src/test/resources/DECIDE.json @@ -40,31 +40,28 @@ ], "nfrs": [ { - "type": "Availability", + "kind": "availability", "tags": [ "application" ], - "abstractValue": "Medium", - "value": 99.8, + "quantitativeAvailability": "99.8", "unit": "percentage" }, { - "type": "Performance", + "kind": "performance", "tags": [ "application" ], - "abstractValue": "Medium", - "value": 300, + "quantitativeResponseTime": 300, "unit": "millisecond" }, { - "type": "Location", + "kind": "location", "tags": [ "application" ], - "abstractValue": "Single Country", - "value": [ "Italy", "Germany" ] + "qualitativeRegions": [ "europe" ], + "qualitativeCountries": [ "italy" ], + "qualitativePolicy": "sameUserCountry" }, { - "type": "Scalability", + "kind": "scalability", "tags": [ "backend-services" ], - "abstractValue": "High", - "value": 2000, - "unit": "requests/second" + "scaleBy": [ "messageCount", "processorLoad" ] } ], "recommendedPatterns": [ @@ -116,7 +113,7 @@ "id": "35de5140-7e26-4ce1-a343-b5ce8ef87442", "comment": "Uptime will not be less then 97% of the time", "termName": "Availability Uptime", - "value": "97", + "value": 97, "unit": "percentage", "metrics": [ { @@ -144,7 +141,7 @@ "id": "35de5140-7e26-4ce1-a343-b5ce8ef87442", "comment": "Uptime will not be less then 97% of the time over a day", "termName": "Availability MTBF", - "value": "97", + "value": 97, "unit": "second", "metrics": [ { @@ -189,7 +186,7 @@ "comment": "CPU utilization will not be less then 95% of the time over a day", "termName": "CPU-utilization-SQO", "monitoringResult": "result", - "value": "95", + "value": 95, "unit": "percentage", "calculationFormula": "CPU-utilization LT 95", "violationTriggerRules": [ @@ -208,11 +205,7 @@ { "id": "CSA_002", "descriptor": "CloudServiceAvailability", - "scale": "nominal", - "expression": { - "expression": "EMPTY", - "expressionLanguage": "iso8000" - } + "scale": "nominal" } ] }, @@ -221,7 +214,7 @@ "comment": "CPU utilization will not be less then 95% of the time over a day", "termName": "CPU-utilization-SLO", "monitoringResult": "result", - "value": "95", + "value": 95, "unit": "percentage", "calculationFormula": "CPU-utilization LT 95", "violationTriggerRules": [ @@ -242,7 +235,7 @@ "comment": "Uptime will not be less then 97% of the time over a day", "termName": "Aggregated-Uptime-SLO", "monitoringResult": "result", - "value": "97", + "value": 97, "unit": "percentage", "calculationFormula": "Uptime GT 97", "violationTriggerRules": [ @@ -266,5 +259,5 @@ ], "virtualMachines": [ ], - "applicationInstanceId": "???" + "appInstanceId": "???" }