Browse Source

Add GreenLightning Test (#4089)

* Adding GreenLightning

* fix missing quote

create object for json production

* turn off telemetry for default test

* allow any external domain or ip

* Update to next version and template construction
Nathan Tippy 6 years ago
parent
commit
7db0a4f0ad

+ 1 - 0
.travis.yml

@@ -46,6 +46,7 @@ env:
      - "TESTDIR=Java/curacao"
      - "TESTDIR=Java/dropwizard"
      - "TESTDIR=Java/gemini"
+     - "TESTDIR=Java/greenlightning"
      - "TESTDIR=Java/grizzly"
      - "TESTDIR=Java/grizzly-jersey"
      - "TESTDIR=Java/jawn"

+ 23 - 0
frameworks/Java/greenlightning/README.md

@@ -0,0 +1,23 @@
+
+# GreenLightning Benchmarking Test
+
+### Test Type Implementation Source Code
+
+* [JSON](src/main/java/com/ociweb/gl/benchmark)
+* [PLAINTEXT](src/main/java/com/ociweb/gl/benchmark)
+
+## Important Libraries
+The tests were run with:
+* [Software](https://oci-pronghorn.gitbook.io/greenlightning/)
+* [Example](https://github.com/oci-pronghorn/GreenLightning/tree/master/slipstream)
+
+## Test URLs
+### JSON
+
+http://localhost:8080/json
+
+### PLAINTEXT
+
+http://localhost:8080/plaintext
+
+

+ 26 - 0
frameworks/Java/greenlightning/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "greenlightning",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "GreenLightning",
+        "language": "Java",
+        "flavor": "None",
+        "orm": "None",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "GreenLightning",
+        "notes": "",
+        "versus": "None"
+      }
+    }
+  ]
+}

+ 10 - 0
frameworks/Java/greenlightning/greenlightning.dockerfile

@@ -0,0 +1,10 @@
+FROM maven:3.5.3-jdk-10-slim as maven
+WORKDIR /greenlightning
+COPY pom.xml pom.xml
+COPY src src
+RUN mvn clean install -q -U
+
+FROM openjdk:10-jre-slim
+WORKDIR /greenlightning
+COPY --from=maven /greenlightning/target/greenlightning-test.jar app.jar
+CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-jar", "app.jar"]

+ 151 - 0
frameworks/Java/greenlightning/pom.xml

@@ -0,0 +1,151 @@
+<?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.ociweb.gl.benchmark</groupId>
+	<artifactId>greenlightning-test</artifactId>
+	<version>1.0.0</version>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>com.ociweb</groupId>
+			<artifactId>greenlightning</artifactId>
+			<version>[1.0.6,1.1)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.25</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<version>1.7.25</version>
+			<scope>runtime</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.12</version>
+			<type>jar</type>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+
+		<plugins>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.0</version>
+				<configuration>
+					<compilerArguments>
+						<profile>compact1</profile>
+					</compilerArguments>
+					<source>1.8</source>
+					<target>1.8</target>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<version>2.6</version>
+				<configuration>
+					<forceCreation>true</forceCreation>
+					<archive>
+						<manifestEntries>
+							<Build-Time>${maven.build.timestamp}</Build-Time>
+						</manifestEntries>
+					</archive>
+				</configuration>
+			</plugin>
+			
+			<plugin>
+			    <groupId>org.apache.maven.plugins</groupId>
+			    <artifactId>maven-surefire-plugin</artifactId>
+			    <version>2.5</version>
+			    <configuration>
+			        <argLine>-Xmx4g</argLine>
+			    </configuration>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-source-plugin</artifactId>
+				<version>2.4</version>
+				<executions>
+					<execution>
+						<id>attach-sources</id>
+						<phase>verify</phase>
+						<goals>
+							<goal>jar-no-fork</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-shade-plugin</artifactId>
+				<version>2.4.3</version>
+				<executions>
+					<execution>
+						<phase>package</phase>
+						<goals>
+							<goal>shade</goal>
+						</goals>
+						<configuration>
+							<filters>
+								<filter>
+									<artifact>*jnr-ffi:jnr-ffi*</artifact>
+									<excludes>
+										<exclude>**/jni/**</exclude>
+									</excludes>
+								</filter>
+							</filters>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+						<manifest>
+							<mainClass>com.ociweb.gl.benchmark.GreenLightning</mainClass>
+						</manifest>
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+
+					<finalName>greenlightning-test</finalName>
+					<appendAssemblyId>false</appendAssemblyId>
+
+				</configuration>
+
+				<executions>
+					<execution>
+						<id>make-assembly</id> <!-- this is used for inheritance merges -->
+						<phase>prepare-package</phase> <!-- bind to the packaging phase -->
+						<goals>
+							<goal>single</goal>
+						</goals>
+
+					</execution>
+				</executions>
+			</plugin>
+						
+		</plugins>
+	</build>
+
+
+</project>

+ 5 - 0
frameworks/Java/greenlightning/src/main/java/com/ociweb/gl/benchmark/Field.java

@@ -0,0 +1,5 @@
+package com.ociweb.gl.benchmark;
+
+public enum Field {
+	PAYLOAD
+}

+ 88 - 0
frameworks/Java/greenlightning/src/main/java/com/ociweb/gl/benchmark/FrameworkTest.java

@@ -0,0 +1,88 @@
+package com.ociweb.gl.benchmark;
+
+import com.ociweb.gl.api.GreenApp;
+/**
+ * ************************************************************************
+ * For greenlightning support, training or feature reqeusts please contact:
+ *   [email protected]   (314) 579-0066
+ * ************************************************************************
+ */
+import com.ociweb.gl.api.GreenFramework;
+import com.ociweb.gl.api.GreenRuntime;
+import com.ociweb.pronghorn.stage.scheduling.GraphManager;
+
+public class FrameworkTest implements GreenApp {
+
+	static final String payloadText="Hello, World!";
+	static final byte[] payload = payloadText.getBytes();
+
+	private int bindPort;
+    private String host;
+    private int concurrentWritesPerChannel;
+    private int queueLengthOfPendingRequests;
+    private int telemetryPort;//for monitoring
+    private int minMemoryOfInputPipes;
+
+    public FrameworkTest() {
+    	//this server works best with  -XX:+UseNUMA    	
+    	this(System.getProperty("host","*.*.*.*"), 
+    		 8080, 4, 16*1024, 1<<21, 
+    		 Integer.parseInt(System.getProperty("telemetry.port", "-1")));
+    }
+    
+    public FrameworkTest(String host, int port, 
+    		             int concurrentWritesPerChannel, 
+    		             int queueLengthOfPendingRequests, 
+    		             int minMemoryOfInputPipes,
+    		             int telemetryPort) {
+    	this.bindPort = port;
+    	this.host = host;
+    	this.concurrentWritesPerChannel = concurrentWritesPerChannel;
+    	this.queueLengthOfPendingRequests = queueLengthOfPendingRequests;
+    	this.minMemoryOfInputPipes = minMemoryOfInputPipes;
+    	this.telemetryPort = telemetryPort;
+    }
+
+	@Override
+    public void declareConfiguration(GreenFramework framework) {
+		
+		GraphManager.showThreadIdOnTelemetry = true;
+			
+		framework.useHTTP1xServer(bindPort, this::parallelBehavior) //standard auto-scale
+    			 .setHost(host)
+    			 .setConcurrentChannelsPerDecryptUnit(concurrentWritesPerChannel)
+    			 .setConcurrentChannelsPerEncryptUnit(concurrentWritesPerChannel)
+    			 .setMaxQueueIn(queueLengthOfPendingRequests)
+    			 .setMinimumInputPipeMemory(minMemoryOfInputPipes)
+    	         .useInsecureServer(); //turn off TLS
+        
+		framework.defineRoute()
+		         .path("/plaintext")
+		         .routeId(Struct.PLAINTEXT_ROUTE);
+		
+		framework.defineRoute()
+		        .path("/json")
+		        .routeId(Struct.JSON_ROUTE);
+	
+		if (telemetryPort>0) {
+			framework.enableTelemetry(host,telemetryPort);
+		}
+		
+    }
+
+	public void parallelBehavior(GreenRuntime runtime) {
+
+		runtime.addRestListener("PlainResponder",new PlainBehaviorInstance(runtime))
+		       .includeRoutes(Struct.PLAINTEXT_ROUTE);
+
+		runtime.addRestListener("JSONResponder",new JSONBehaviorInstance(runtime))
+		       .includeRoutes(Struct.JSON_ROUTE);
+
+	}
+	 
+    @Override
+    public void declareBehavior(GreenRuntime runtime) {   
+    	
+    }
+  
+}

+ 11 - 0
frameworks/Java/greenlightning/src/main/java/com/ociweb/gl/benchmark/GreenLightning.java

@@ -0,0 +1,11 @@
+package com.ociweb.gl.benchmark;
+
+import com.ociweb.gl.api.GreenRuntime;
+
+public class GreenLightning {
+
+	public static void main(String[] args) {
+		GreenRuntime.run(new FrameworkTest(),args);
+	}
+	
+}

+ 39 - 0
frameworks/Java/greenlightning/src/main/java/com/ociweb/gl/benchmark/JSONBehaviorInstance.java

@@ -0,0 +1,39 @@
+package com.ociweb.gl.benchmark;
+
+import com.ociweb.gl.api.GreenRuntime;
+import com.ociweb.gl.api.HTTPRequestReader;
+import com.ociweb.gl.api.HTTPResponseService;
+import com.ociweb.gl.api.RestListener;
+import com.ociweb.json.encode.JSONRenderer;
+import com.ociweb.pronghorn.network.config.HTTPContentTypeDefaults;
+
+public class JSONBehaviorInstance implements RestListener {
+
+
+	private final HTTPResponseService responseService;
+
+	
+	public JSONBehaviorInstance(GreenRuntime runtime) {
+		responseService = runtime.newCommandChannel().newHTTPResponseService(1<<14, 1<<8);		
+	}
+
+
+	@Override
+	public boolean restRequest(HTTPRequestReader request) {
+	
+		//NOTE: this is only done here for the framework test
+		//      in a normal production deployment this JSONRender will only
+		//      be created once and held as a member.
+		JSONRenderer<HTTPRequestReader> renderJSON = new JSONRenderer<HTTPRequestReader>()
+				.startObject()
+					.string("message", (o,t) -> t.write(FrameworkTest.payload) )
+				.endObject();
+				
+		return responseService.publishHTTPResponse(request, 
+				                            HTTPContentTypeDefaults.JSON,
+				                            w -> renderJSON.render(w,request)
+				                            );
+		
+	}
+
+}

+ 37 - 0
frameworks/Java/greenlightning/src/main/java/com/ociweb/gl/benchmark/PlainBehaviorInstance.java

@@ -0,0 +1,37 @@
+package com.ociweb.gl.benchmark;
+
+import com.ociweb.gl.api.GreenRuntime;
+import com.ociweb.gl.api.HTTPRequestReader;
+import com.ociweb.gl.api.HTTPResponseService;
+import com.ociweb.gl.api.RestListener;
+import com.ociweb.gl.api.Writable;
+import com.ociweb.pronghorn.network.config.HTTPContentTypeDefaults;
+import com.ociweb.pronghorn.pipe.ChannelWriter;
+
+public class PlainBehaviorInstance implements RestListener {
+
+	private final HTTPResponseService plainResponseService;
+	
+	//a lambda could be used if you like
+	private Writable writePayload = new Writable() {
+		@Override
+		public void write(ChannelWriter writer) {
+			writer.write(FrameworkTest.payload);
+		}		
+	};
+	
+	public PlainBehaviorInstance(GreenRuntime runtime) {
+		plainResponseService = runtime.newCommandChannel().newHTTPResponseService(1<<14, 1<<8); 
+	}
+
+	@Override
+	public boolean restRequest(HTTPRequestReader request) {
+		
+		return plainResponseService.publishHTTPResponse(request, 	
+					HTTPContentTypeDefaults.PLAIN,
+					writePayload
+				);
+		
+	}
+
+}

+ 11 - 0
frameworks/Java/greenlightning/src/main/java/com/ociweb/gl/benchmark/ResultObject.java

@@ -0,0 +1,11 @@
+package com.ociweb.gl.benchmark;
+
+public class ResultObject {
+
+	public final byte[] payload;
+	
+	public ResultObject(byte[] payload) {
+		this.payload=payload;
+	}
+	
+}

+ 6 - 0
frameworks/Java/greenlightning/src/main/java/com/ociweb/gl/benchmark/Struct.java

@@ -0,0 +1,6 @@
+package com.ociweb.gl.benchmark;
+
+public enum Struct {
+	PLAINTEXT_ROUTE, JSON_ROUTE
+
+}

+ 1 - 0
frameworks/Java/greenlightning/src/main/resources/GreenLight.props

@@ -0,0 +1 @@
+main=com.ociweb.gl.benchmark.FrameworkTest