Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #177 from zznate/thrifton

Fixed up deamon so thrift starts. Cause we love thrift.
  • Loading branch information...
commit 179d98350dbf5b409c104d6106635d69a4d4bfe1 2 parents 70e20dc + 6c2d532
@zznate authored
View
33 src/main/java/org/usergrid/vx/client/thrift/FramedConnWrapper.java
@@ -0,0 +1,33 @@
+package org.usergrid.vx.client.thrift;
+
+import org.apache.cassandra.thrift.Cassandra;
+import org.apache.thrift.protocol.*;
+import org.apache.thrift.transport.*;
+
+public class FramedConnWrapper {
+
+ private TTransport transport;
+ private TProtocol proto;
+ private TSocket socket;
+
+ public FramedConnWrapper(String host, int port) {
+ socket = new TSocket(host, port);
+ transport = new TFramedTransport(socket);
+ proto = new TBinaryProtocol(transport);
+ }
+
+ public void open() throws Exception {
+ transport.open();
+ }
+
+ public void close() throws Exception {
+ transport.close();
+ socket.close();
+ }
+
+ public Cassandra.Client getClient() {
+ Cassandra.Client client = new Cassandra.Client(proto);
+ return client;
+ }
+}
+
View
7 src/main/java/org/usergrid/vx/server/IntravertDeamon.java
@@ -15,14 +15,15 @@
*/
package org.usergrid.vx.server;
-import com.google.common.base.CharMatcher;
-import com.google.common.base.Preconditions;
import org.apache.cassandra.service.CassandraDaemon;
+import org.apache.cassandra.thrift.ThriftServer;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
public class IntravertDeamon extends CassandraDaemon {
@@ -57,11 +58,13 @@ public void init(String[] arguments) throws IOException {
@Override
public void start() {
+ super.start();
intravertServer.start();
}
@Override
public void stop() {
+ super.stop();
logger.info("Stopping IntravertDeamon");
intravertServer.stop();
}
View
4 src/test/java/org/usergrid/vx/experimental/CassandraRunner.java
@@ -185,8 +185,8 @@ private void startCassandra() {
System.setProperty("log4j.defaultInitOverride","true");
System.setProperty("log4j.configuration", "log4j.properties");
System.setProperty("cassandra.ring_delay_ms","1000");
- System.setProperty("cassandra.start_rpc","true");
- System.setProperty("cassandra.start_native_transport","true");
+ System.setProperty("cassandra.start_rpc","true");
+ System.setProperty("cassandra.start_native_transport","true");
executor.execute(new Runnable() {
public void run() {
View
2  src/test/java/org/usergrid/vx/experimental/PerfTestingITest.java
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.cassandra.thrift.Cassandra;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
@@ -28,6 +29,7 @@
import org.junit.runner.RunWith;
import org.usergrid.vx.client.IntraClient2;
import org.usergrid.vx.client.IntraClient2.Transport;
+import org.usergrid.vx.client.thrift.FramedConnWrapper;
import org.vertx.java.core.Vertx;
/* unless testing performance chances this should like be ignored */
View
25 src/test/java/org/usergrid/vx/experimental/ThriftITest.java
@@ -0,0 +1,25 @@
+package org.usergrid.vx.experimental;
+
+import junit.framework.Assert;
+
+import org.apache.cassandra.thrift.Cassandra;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.usergrid.vx.client.thrift.FramedConnWrapper;
+
+@RunWith(CassandraRunner.class)
+@RequiresKeyspace(ksName = "myks")
+@RequiresColumnFamily(ksName = "myks", cfName = "mycf")
+public class ThriftITest {
+
+ @Test
+ @RequiresColumnFamily(ksName = "myks", cfName = "mycf")
+ public void aThriftSanityTest() throws Exception {
+ Thread.sleep(1000);
+ FramedConnWrapper wrap = new FramedConnWrapper("localhost",9160);
+ wrap.open();
+ Cassandra.Client c = wrap.getClient();
+ Assert.assertTrue( c.describe_keyspaces().size() > 1 );
+ wrap.close();
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.