Permalink
Browse files

Merge pull request #212 from zznate/two_point_ow

Two 0
  • Loading branch information...
zznate committed May 31, 2013
2 parents 7698211 + 9fc937b commit ba0d3ff78a2cde2c97b5a3d8934179775581f1a7
Showing with 238 additions and 191 deletions.
  1. +25 −4 pom.xml
  2. +8 −7 src/main/java/org/usergrid/vx/client/HelloClient.java
  3. +8 −8 src/main/java/org/usergrid/vx/client/IntraClient2.java
  4. +11 −8 src/main/java/org/usergrid/vx/client/NoMatchClient.java
  5. +4 −3 src/main/java/org/usergrid/vx/handler/IntraHandlerBase.java
  6. +1 −1 src/main/java/org/usergrid/vx/handler/PayloadRoutingHandler.java
  7. +1 −1 src/main/java/org/usergrid/vx/handler/http/HelloHandler.java
  8. +2 −2 src/main/java/org/usergrid/vx/handler/http/NoMatchHandler.java
  9. +5 −5 src/main/java/org/usergrid/vx/handler/http/OperationsRequestHandler.java
  10. +5 −5 src/main/java/org/usergrid/vx/handler/http/payload/IntraHandlerJson.java
  11. +5 −5 src/main/java/org/usergrid/vx/handler/http/rest/IntraHandlerRest.java
  12. +1 −1 src/main/java/org/usergrid/vx/handler/http/rest/IntravertRestUtils.java
  13. +3 −1 src/main/java/org/usergrid/vx/server/IntravertCassandraServer.java
  14. +5 −3 src/main/java/org/usergrid/vx/server/IntravertDeamon.java
  15. +1 −1 src/main/java/org/usergrid/vx/server/operations/AbstractIntravertHandler.java
  16. +3 −3 src/main/java/org/usergrid/vx/server/operations/AssumeHandler.java
  17. +3 −3 src/main/java/org/usergrid/vx/server/operations/AutotimestampHandler.java
  18. +4 −4 src/main/java/org/usergrid/vx/server/operations/BatchHandler.java
  19. +3 −3 src/main/java/org/usergrid/vx/server/operations/ComponentSelectHandler.java
  20. +3 −3 src/main/java/org/usergrid/vx/server/operations/ConsistencyHandler.java
  21. +4 −3 src/main/java/org/usergrid/vx/server/operations/CounterHandler.java
  22. +3 −3 src/main/java/org/usergrid/vx/server/operations/CqlQueryHandler.java
  23. +3 −3 src/main/java/org/usergrid/vx/server/operations/CreateColumnFamilyHandler.java
  24. +2 −2 src/main/java/org/usergrid/vx/server/operations/CreateFilterHandler.java
  25. +3 −3 src/main/java/org/usergrid/vx/server/operations/CreateKeyspaceHandler.java
  26. +2 −2 src/main/java/org/usergrid/vx/server/operations/CreateMultiProcessHandler.java
  27. +2 −2 src/main/java/org/usergrid/vx/server/operations/CreateProcessorHandler.java
  28. +4 −4 src/main/java/org/usergrid/vx/server/operations/CreateServiceProcessHandler.java
  29. +1 −1 src/main/java/org/usergrid/vx/server/operations/FilterHandler.java
  30. +3 −3 src/main/java/org/usergrid/vx/server/operations/FilterModeHandler.java
  31. +3 −3 src/main/java/org/usergrid/vx/server/operations/GetHandler.java
  32. +3 −3 src/main/java/org/usergrid/vx/server/operations/ListColumnFamilyHandler.java
  33. +1 −1 src/main/java/org/usergrid/vx/server/operations/ListKeyspacesHandler.java
  34. +3 −3 src/main/java/org/usergrid/vx/server/operations/MultiProcessorHandler.java
  35. +2 −2 src/main/java/org/usergrid/vx/server/operations/ProcessorHandler.java
  36. +6 −6 src/main/java/org/usergrid/vx/server/operations/ReadHandler.java
  37. +4 −4 src/main/java/org/usergrid/vx/server/operations/ResultModeHandler.java
  38. +3 −3 src/main/java/org/usergrid/vx/server/operations/ServiceProcessorHandler.java
  39. +3 −3 src/main/java/org/usergrid/vx/server/operations/SetColumnFamilyHandler.java
  40. +3 −3 src/main/java/org/usergrid/vx/server/operations/SetHandler.java
  41. +3 −3 src/main/java/org/usergrid/vx/server/operations/SetKeyspaceHandler.java
  42. +3 −3 src/main/java/org/usergrid/vx/server/operations/SliceHandler.java
  43. +5 −3 src/test/java/org/usergrid/vx/experimental/CompositeITest.java
  44. +5 −3 src/test/java/org/usergrid/vx/experimental/IntraServiceITest.java
  45. +1 −1 src/test/java/org/usergrid/vx/experimental/PerfTestingITest.java
  46. +52 −44 src/test/java/org/usergrid/vx/experimental/RawJsonITest.java
  47. +10 −6 src/test/java/org/usergrid/vx/handler/http/rest/IntravertRestUtilsUnitTest.java
View
29 pom.xml
@@ -16,7 +16,7 @@
<jackson-version>1.9.9</jackson-version>
<groovy-version>2.0.4</groovy-version>
<cloj-version>1.3.0</cloj-version>
- <vertx-version>1.3.1.final</vertx-version>
+ <vertx-version>2.0.0-beta3</vertx-version>
</properties>
<dependencies>
@@ -27,8 +27,14 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.vert-x</groupId>
- <artifactId>vertx-platform</artifactId>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>3.2.9.Final</version>
+</dependency>
+
+ <dependency>
+ <groupId>io.vertx</groupId>
+ <artifactId>vertx-core</artifactId>
<version>${vertx-version}</version>
<exclusions>
<exclusion>
@@ -37,8 +43,22 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>io.vertx</groupId>
+ <artifactId>vertx-platform</artifactId>
+ <version>${vertx-version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!--
<dependency>
- <groupId>org.vert-x</groupId>
+ <groupId>io.vertx</groupId>
<artifactId>vertx-lang-java</artifactId>
<version>${vertx-version}</version>
<exclusions>
@@ -48,6 +68,7 @@
</exclusion>
</exclusions>
</dependency>
+ -->
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
@@ -19,12 +19,13 @@
import org.slf4j.LoggerFactory;
import org.vertx.java.core.Handler;
-import org.vertx.java.core.SimpleHandler;
+
import org.vertx.java.core.Vertx;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpClient;
import org.vertx.java.core.http.HttpClientRequest;
import org.vertx.java.core.http.HttpClientResponse;
+import org.vertx.java.platform.PlatformLocator;
public class HelloClient implements Handler<HttpClientResponse> {
@@ -39,18 +40,18 @@ public static void main(String[] args) throws Exception {
}
public HelloClient() {
- vertx = Vertx.newVertx();
+ vertx = new PlatformLocator().factory.createPlatformManager().vertx();
this.httpClient = vertx.createHttpClient().setHost("localhost").setPort(8080).setMaxPoolSize(1)
.setKeepAlive(true);
}
public void post() {
HttpClientRequest req = httpClient.request("POST", "/intravert/hello", this);
String value = "";
- req.putHeader("content-length", value.length());
+ req.putHeader("content-length", String.valueOf(value.length()));
req.write(value);
- req.exceptionHandler(new Handler<Exception>() {
- public void handle(Exception arg0) {
+ req.exceptionHandler(new Handler<Throwable>() {
+ public void handle(Throwable arg0) {
System.out.println("Something went wrong in client " + arg0);
}
});
@@ -65,8 +66,8 @@ public void handle(Exception arg0) {
@Override
public void handle(HttpClientResponse response) {
- response.endHandler(new SimpleHandler() {
- public void handle() {
+ response.endHandler(new Handler<Void>() {
+ public void handle(Void v) {
System.out.println("This is the end. My only friend, the end.");
}
});
@@ -7,12 +7,12 @@
import org.usergrid.vx.experimental.IntraReq;
import org.usergrid.vx.experimental.IntraRes;
import org.vertx.java.core.Handler;
-import org.vertx.java.core.SimpleHandler;
import org.vertx.java.core.Vertx;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpClient;
import org.vertx.java.core.http.HttpClientRequest;
import org.vertx.java.core.http.HttpClientResponse;
+import org.vertx.java.platform.PlatformLocator;
import java.io.IOException;
import java.io.OutputStream;
@@ -34,7 +34,7 @@
private Transport transport;
public IntraClient2(String host,int port){
- vertx = Vertx.newVertx();
+ vertx = PlatformLocator.factory.createPlatformManager().vertx();
httpClient = vertx.createHttpClient().setHost(host)
.setPort(port).setMaxPoolSize(10).setKeepAlive(true);
setTransport(Transport.JSON);
@@ -84,17 +84,17 @@ public void handle(Buffer arg0) {
}
});
- resp.endHandler(new SimpleHandler() {
- @Override
- protected void handle() {
- doneSignal.countDown();
- }
+ resp.endHandler(new Handler<Void>() {
+ @Override
+ public void handle(Void arg0) {
+ doneSignal.countDown();
+ }
});
}
});
- req.putHeader(CONTENT_LENGTH, outRequest.length());
+ req.putHeader(CONTENT_LENGTH, outRequest.length()+"");
req.end(outRequest);
doneSignal.await();
return mapper.readValue(buffer.getBytes(), IntraRes.class);
@@ -19,16 +19,18 @@
import org.slf4j.LoggerFactory;
import org.vertx.java.core.Handler;
-import org.vertx.java.core.SimpleHandler;
+
import org.vertx.java.core.Vertx;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpClient;
import org.vertx.java.core.http.HttpClientRequest;
import org.vertx.java.core.http.HttpClientResponse;
+import org.vertx.java.platform.PlatformLocator;
+
public class NoMatchClient implements Handler<HttpClientResponse> {
@SuppressWarnings("unused")
- private static Logger logger = LoggerFactory.getLogger(HelloClient.class);
+ private static Logger logger = LoggerFactory.getLogger(NoMatchClient.class);
private static Vertx vertx;
private HttpClient httpClient;
@@ -38,17 +40,18 @@ public static void main(String[] args) throws Exception {
}
public NoMatchClient(){
- vertx = Vertx.newVertx();
+ vertx = new PlatformLocator().factory.createPlatformManager().vertx();
this.httpClient = vertx.createHttpClient().setHost("localhost").setPort(8080).setMaxPoolSize(1).setKeepAlive(true);
}
public void post(){
HttpClientRequest req = httpClient.request("POST", "/intravert/wrtwrtrwt", this);
String value ="";
- req.putHeader("content-length", value.length());
+ req.putHeader("content-length", String.valueOf(value.length()));
req.write(value);
- req.exceptionHandler(new Handler<Exception>(){
- public void handle(Exception arg0) {
+
+ req.exceptionHandler(new Handler<Throwable>(){
+ public void handle(Throwable arg0) {
System.out.println("Something went wrong in client "+arg0);
}
});
@@ -62,8 +65,8 @@ public void handle(Exception arg0) {
@Override
public void handle(HttpClientResponse response) {
- response.endHandler(new SimpleHandler() {
- public void handle() {
+ response.endHandler(new Handler<Void>() {
+ public void handle(Void v) {
System.out.println("This is the end. My only friend, the end.");
}
});
@@ -6,7 +6,8 @@
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpServerRequest;
-import static org.jboss.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
+
+
/**
* Base class which uses {@link #handle(org.vertx.java.core.http.HttpServerRequest)}
@@ -34,8 +35,8 @@ public void handle(Buffer buffer) {
});
} catch (Exception e) {
- request.response.statusCode = BAD_REQUEST.getCode();
- request.response.end(ExceptionUtils.getFullStackTrace(e));
+ request.response().setStatusCode( 404 );
+ request.response().end(ExceptionUtils.getFullStackTrace(e));
}
}
@@ -29,7 +29,7 @@ public PayloadRoutingHandler(Vertx vertx) {
@Override
public void handle(Message<JsonObject> event) {
AtomicInteger idGenerator = new AtomicInteger(0);
- JsonArray operations = event.body.getArray(Operations.E);
+ JsonArray operations = event.body().getArray(Operations.E);
JsonObject operation = (JsonObject) operations.get(idGenerator.get());
operation.putNumber(Operations.ID, idGenerator.get());
operation.putObject(Operations.STATE, new JsonObject().putArray(Operations.COMPONENTS,
@@ -23,7 +23,7 @@
@Override
public void handle(HttpServerRequest request) {
System.out.println("Request handled");
- request.response.end("ok");
+ request.response().end("ok");
}
}
@@ -27,8 +27,8 @@
@Override
public void handle(HttpServerRequest request) {
- logger.error("no matching endpoint for "+ request.uri);
- request.response.end("No Matching Endpoint.");
+ logger.error("no matching endpoint for "+ request.uri());
+ request.response().end("No Matching Endpoint.");
}
}
@@ -52,8 +52,8 @@ public void handle(Message<JsonObject> event) {
Integer currentId = idGenerator.get();
Integer opId = currentId - 1;
- String exceptionId = event.body.getString(Operations.EXCEPTION_ID);
- String exception = event.body.getString(Operations.EXCEPTION);
+ String exceptionId = event.body().getString(Operations.EXCEPTION_ID);
+ String exception = event.body().getString(Operations.EXCEPTION);
if (exception != null || exceptionId != null) {
results.putString(Operations.EXCEPTION, exception);
@@ -62,7 +62,7 @@ public void handle(Message<JsonObject> event) {
return;
}
- Map<String, Object> map = event.body.toMap();
+ Map<String, Object> map = event.body().toMap();
Object opResult = map.get(String.valueOf(opId));
String userId = ((JsonObject) operations.get(opId)).getObject(Operations.OP).getString(Operations.USER_OP_ID) ;
if (userId == null){
@@ -97,8 +97,8 @@ public void handle(Message<JsonObject> event) {
if (idGenerator.get() < operations.size()) {
JsonObject operation = (JsonObject) operations.get(idGenerator.get());
operation.putNumber(Operations.ID, idGenerator.get());
- if (event.body.getObject(Operations.STATE) != null) {
- state.mergeIn(event.body.getObject(Operations.STATE));
+ if (event.body().getObject(Operations.STATE) != null) {
+ state.mergeIn(event.body().getObject(Operations.STATE));
}
operation.putObject(Operations.STATE, state.copy());
idGenerator.incrementAndGet();
@@ -30,7 +30,7 @@
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.core.json.JsonObject;
-import static org.jboss.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
+
/**
* The handler is the main entry point for processing the Intravert
@@ -85,8 +85,8 @@ public void handleRequestAsync(final HttpServerRequest request, Buffer buffer) {
req.toJson(),
new IHResponse(request));
} catch (Exception e) {
- request.response.statusCode = BAD_REQUEST.getCode();
- request.response.end(ExceptionUtils.getFullStackTrace(e));
+ request.response().setStatusCode(404);
+ request.response().end(ExceptionUtils.getFullStackTrace(e));
}
}
@@ -103,9 +103,9 @@ public void handle(Message<JsonObject> event) {
if ( logger.isDebugEnabled()) {
logger.debug("in IntraHanlderJson's on handler topic {} with event {}",
PayloadRoutingHandler.IHJSON_HANDLER_TOPIC,
- event.body.toString() );
+ event.body().toString() );
}
- request.response.end(event.body.toString());
+ request.response().end(event.body().toString());
}
}
@@ -25,13 +25,13 @@ public IntraHandlerRest(Vertx vertx) {
@Override
public void handleRequestAsync(final HttpServerRequest request, Buffer buffer) {
IntraReq req = new IntraReq();
- if (request.method.equals("GET")) {
+ if (request.method().equals("GET")) {
handleGet(request, buffer, req);
- } else if (request.method.equals("POST")) {
+ } else if (request.method().equals("POST")) {
handlePost(request, buffer, req);
- } else if (request.method.equals("DELETE")) {
+ } else if (request.method().equals("DELETE")) {
handleDelete(request, buffer, req);
- } else if (request.method.equals("PUT")) {
+ } else if (request.method().equals("PUT")) {
handlePut(request, buffer, req);
}
delegateAndReply(request, req);
@@ -41,7 +41,7 @@ protected void delegateAndReply(final HttpServerRequest request, IntraReq req) {
vertx.eventBus().send("request.json", req.toJson(), new Handler<Message<JsonObject>>() {
@Override
public void handle(Message<JsonObject> event) {
- request.response.end(event.body.toString());
+ request.response().end(event.body().toString());
}
});
}
@@ -39,7 +39,7 @@
* @return The level specified by the header or ONE according to the conditions defined above.
*/
public static ConsistencyLevel fromHeader(HttpServerRequest request) {
- if (request.headers().containsKey(CONSISTENCY_LEVEL_HEADER)) {
+ if (request.headers().contains(CONSISTENCY_LEVEL_HEADER)) {
try {
return ConsistencyLevel.valueOf(request.headers().get(CONSISTENCY_LEVEL_HEADER));
} catch (IllegalArgumentException iae) {
@@ -29,6 +29,7 @@
import org.usergrid.vx.server.operations.*;
import org.vertx.java.core.Vertx;
import org.vertx.java.core.http.RouteMatcher;
+import org.vertx.java.platform.PlatformLocator;
public class IntravertCassandraServer implements CassandraDaemon.Server {
private static final int PORT = 8080;
@@ -47,7 +48,8 @@ public IntravertCassandraServer(String basePath) {
@Override
public void start() {
logger.info("Starting IntravertCassandraServer with base path {}", basePath);
- vertx = Vertx.newVertx();
+ PlatformLocator pl = new PlatformLocator();
+ vertx = pl.factory.createPlatformManager().vertx();
rm = new RouteMatcher();
// TODO Should we use a single instance of HelloHandler here?
rm.put(String.format("%s/hello", basePath), new HelloHandler());
Oops, something went wrong.

0 comments on commit ba0d3ff

Please sign in to comment.