Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to rest express netty 4 #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
target/
.settings/
*.iml
.idea/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ A few examples to illustrate how RestExpress works.

* echo - An echo service with no database back-end.
* blogging - A blogging service with a MongoDB back-end.
* benchmark - ?
* benchmark - A kickstart project for creating a simple RestExpress project
4 changes: 2 additions & 2 deletions benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<url>https://github.com/RestExpress/RestExpress-Examples</url>
<groupId>org.restexpress.examples</groupId>
<artifactId>restexpress-benchmark-example</artifactId>
<version>0.1-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.strategicgains</groupId>
<artifactId>RestExpress</artifactId>
<version>0.10.4</version>
<version>0.11.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
2 changes: 1 addition & 1 deletion benchmark/src/main/java/com/benchmark/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.benchmark;

import org.jboss.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpMethod;
import org.restexpress.Request;
import org.restexpress.Response;
import org.restexpress.RestExpress;
Expand Down
8 changes: 6 additions & 2 deletions echo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ The service suite supports the following functionality.
Echo
====

This URL simply sends back the same string that is sent in on the 'echo' query-string parameter. There is no serialization involved in the response. The body is not parsed.

URL: /echo/{delay_ms}
Methods: GET, PUT, POST, DELETE

GET, DELETE: send back the same string that is sent in on the 'echo' query-string parameter.

PUT, POST: send back the body contents.

There is no serialization involved in the response. The body is not parsed.

Success
=======

Expand Down
4 changes: 2 additions & 2 deletions echo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<url>https://github.com/RestExpress/RestExpress-Examples</url>
<groupId>org.restexpress.examples</groupId>
<artifactId>restexpress-echo-example</artifactId>
<version>0.1-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.strategicgains</groupId>
<artifactId>RestExpress</artifactId>
<version>0.10.5</version>
<version>0.11.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
11 changes: 11 additions & 0 deletions echo/src/jmeter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RestExpress Test Plan.jmx
=========================

Simple performance tests for GET Echo and Success requests.

RestExpress Test Plan v2.jmx
============================

Tests added to decode GZIP data and DEFLATE data for PUT Echo requests.

v2 is compatible with JMeter 2.11, but it is not compatible with JMeter 2.8.
631 changes: 631 additions & 0 deletions echo/src/jmeter/RestExpress Test Plan v2.jmx

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions echo/src/main/java/com/echo/controller/EchoController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.echo.controller;

import org.jboss.netty.buffer.ChannelBuffer;
import io.netty.buffer.ByteBuf;
import org.restexpress.Request;
import org.restexpress.Response;

Expand All @@ -14,11 +14,16 @@ public class EchoController
private static final String ECHO_PARAMETER_NOT_FOUND = "'echo' header or query-string parameter not found";
private static final String ECHO_HEADER = "echo";

public ChannelBuffer create(Request request, Response response)
public ByteBuf create(Request request, Response response)
{
delay(request);
response.setResponseCreated();
return request.getBody();

// copy the body for the result
// do NOT return the ByteBuf directly because is a shared buffer
// Netty will release the buffer twice (once for the request and once for the response)
// which will result in an IllegalReferenceCountException
return request.getBody().copy();
}

public String delete(Request request, Response response)
Expand All @@ -40,9 +45,14 @@ public String read(Request request, Response response)
return echo;
}

public ChannelBuffer update(Request request, Response response)
public ByteBuf update(Request request, Response response)
{
delay(request);
return request.getBody();

// copy the body for the result
// do NOT return the ByteBuf directly because is a shared buffer
// Netty will release the buffer twice (once for the request and once for the response)
// which will result in an IllegalReferenceCountException
return request.getBody().copy();
}
}