-
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.
- Loading branch information
Showing
14 changed files
with
615 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "automatic" | ||
} |
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,25 @@ | ||
{ | ||
"type": "java", | ||
"endpoints": { | ||
"http": { | ||
"/cart/checkout": ["sleep,1000", "sql://backend-db/?query=SELECT * from carts", ["http://ext-payment-1/pay", "http://ext-payment-2/pay"]], | ||
"/cart/add": ["sql://backend-db/?query=SELECT * from carts"], | ||
"error": [{"call": "error,500,Cart not found", "probability": 0.5}], | ||
"/data": ["sleep,50", "log,warn,do some logging", "log,more logging", { | ||
"call": "data", | ||
"id": "price", | ||
"type": "double", | ||
"value": [1,2,3] | ||
}, { | ||
"call": "data", | ||
"id": "randomThingy", | ||
"chance": "integer,min:5,max:13" | ||
}, { | ||
"call": "data", | ||
"id": "stuff", | ||
"chance": "letter,casing:upper" | ||
}] | ||
} | ||
}, | ||
"name": "backend" | ||
} |
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 @@ | ||
{"type":"mysql","databases":{"shop":{"carts":["id","name","value"],"customers":["id","name","email"]}},"name":"backend-db"} |
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,41 @@ | ||
{ | ||
"type": "nodejs", | ||
"options": { | ||
"connectionDelay": 500, | ||
"httpLibrary": "request-promise" | ||
}, | ||
"endpoints": { | ||
"http": { | ||
"/logo.png": ["sleep,1000"], | ||
"/script.js": ["sleep,5000"], | ||
"/checkout": ["http://backend/cart/checkout", "image,logo.png", "script,script.js","ajax,cache"], | ||
"/addtocart": ["http://backend/cart/add", "slow,1500"], | ||
"/cache": [["sleep,5000","sleep,5"], "cache,1024"], | ||
"/schedule": ["sleep,50", { | ||
"call": "error,500,oops", | ||
"schedule": "0-30 * * * * * *" | ||
}], | ||
"/test": [{ | ||
"call": "http://localhost:9876/cache", | ||
"catchExceptions": false, | ||
"remoteTimeout": 2000 | ||
}], | ||
"/data": ["sleep,50", "log,warn,do some logging", "log,more logging", { | ||
"call": "data", | ||
"id": "price", | ||
"type": "double", | ||
"value": [1,2,3] | ||
}, { | ||
"call": "data", | ||
"id": "randomThingy", | ||
"chance": "integer,min:5,max:13" | ||
}, { | ||
"call": "data", | ||
"id": "stuff", | ||
"chance": "letter,casing:upper" | ||
}], | ||
"/script": ["code,sample.js"] | ||
} | ||
}, | ||
"name": "frontend" | ||
} |
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,7 @@ | ||
.idea | ||
*.class | ||
target/maven-* | ||
extras/*.jar | ||
target/ | ||
node.log | ||
javanode.iml |
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,15 @@ | ||
FROM maven:3-jdk-11 AS build | ||
WORKDIR /home/app | ||
COPY src /home/app/src | ||
COPY pom.xml /home/app | ||
RUN mvn -f /home/app/pom.xml clean package | ||
|
||
FROM openjdk:11-jre | ||
RUN mkdir -p /app/dependency-jars | ||
WORKDIR /app | ||
COPY --from=build /home/app/target /app/ | ||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypointk8s.sh | ||
COPY extras/* /app/ | ||
EXPOSE 8080 | ||
CMD ["/entrypoint.sh"] |
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,4 @@ | ||
#!/bin/bash | ||
echo java -jar "javanode-1.0-SNAPSHOT.jar" 8080 | ||
APP_CONFIG="$(</config.json)" java -jar "javanode-1.0-SNAPSHOT.jar" 8080 | ||
|
Empty file.
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,2 @@ | ||
#!/bin/bash | ||
mvn package |
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,134 @@ | ||
<?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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.cisco.open.appsimulator.java</groupId> | ||
<artifactId>javanode</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>javanode</name> | ||
<properties> | ||
<jettyVersion>11.0.0.beta3</jettyVersion> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.servlet</groupId> | ||
<artifactId>jakarta.servlet-api</artifactId> | ||
<version>5.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.49</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mongodb</groupId> | ||
<artifactId>mongo-java-driver</artifactId> | ||
<version>3.12.7</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-server</artifactId> | ||
<version>${jettyVersion}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-servlet</artifactId> | ||
<version>${jettyVersion}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-client</artifactId> | ||
<version>${jettyVersion}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.json</groupId> | ||
<artifactId>javax.json-api</artifactId> | ||
<version>1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>javax.json</artifactId> | ||
<version>1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.sf.ehcache</groupId> | ||
<artifactId>ehcache</artifactId> | ||
<version>2.10.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>2.0.16</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.5.12</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>java</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<mainClass>com.cisco.open.appsimulator.JavaNode</mainClass> | ||
<arguments> | ||
<argument>8080</argument> | ||
</arguments> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>com.cisco.open.appsimulator.JavaNode</mainClass> | ||
<classpathPrefix>dependency-jars/</classpathPrefix> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<!-- Copy project dependency --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>2.5.1</version> | ||
<executions> | ||
<execution> | ||
<id>copy-dependencies</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<!-- exclude junit, we need runtime dependency only --> | ||
<includeScope>runtime</includeScope> | ||
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
<configuration> | ||
<release>11</release> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,2 @@ | ||
#!/bin/bash | ||
env APP_CONFIG="$(<../examples/backend.json)" mvn -e compile exec:java |
17 changes: 17 additions & 0 deletions
17
src/services/java/src/main/java/com/cisco/open/appsimulator/HttpException.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,17 @@ | ||
package com.cisco.open.appsimulator; | ||
|
||
import java.io.IOException; | ||
|
||
public class HttpException extends IOException | ||
{ | ||
protected int code; | ||
|
||
public HttpException(int code, String message) { | ||
super(message); | ||
this.code = code; | ||
} | ||
|
||
public int getCode() { | ||
return this.code; | ||
} | ||
} |
Oops, something went wrong.