accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1442310 [1/3] - in /accumulo/trunk: proxy/ proxy/examples/python/ proxy/examples/ruby/ proxy/src/main/java/org/apache/accumulo/proxy/ proxy/src/main/java/org/apache/accumulo/proxy/thrift/ proxy/src/main/thrift/ proxy/src/test/java/org/apac...
Date Mon, 04 Feb 2013 19:40:10 GMT
Author: ecn
Date: Mon Feb  4 19:40:09 2013
New Revision: 1442310

URL: http://svn.apache.org/viewvc?rev=1442310&view=rev
Log:
ACCUMULO-1037 allow the proxy to run a copy of miniaccumulo

Modified:
    accumulo/trunk/proxy/examples/python/TestClient.py
    accumulo/trunk/proxy/examples/ruby/test_client.rb
    accumulo/trunk/proxy/proxy.properties
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/AccumuloProxy.java
    accumulo/trunk/proxy/src/main/thrift/proxy.thrift
    accumulo/trunk/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java
    accumulo/trunk/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java

Modified: accumulo/trunk/proxy/examples/python/TestClient.py
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/python/TestClient.py?rev=1442310&r1=1442309&r2=1442310&view=diff
==============================================================================
--- accumulo/trunk/proxy/examples/python/TestClient.py (original)
+++ accumulo/trunk/proxy/examples/python/TestClient.py Mon Feb  4 19:40:09 2013
@@ -30,7 +30,7 @@ protocol = TCompactProtocol.TCompactProt
 client = AccumuloProxy.Client(protocol)
 transport.open()
 
-login = client.login(UserPass("root","secret"))
+login = PrincipalToken("root","secret")
 
 print client.listTables(login)
 

Modified: accumulo/trunk/proxy/examples/ruby/test_client.rb
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/ruby/test_client.rb?rev=1442310&r1=1442309&r2=1442310&view=diff
==============================================================================
--- accumulo/trunk/proxy/examples/ruby/test_client.rb (original)
+++ accumulo/trunk/proxy/examples/ruby/test_client.rb Mon Feb  4 19:40:09 2013
@@ -24,13 +24,13 @@ socket = Thrift::Socket.new(server, 4242
 transport = Thrift::FramedTransport.new(socket)
 proto = Thrift::CompactProtocol.new(transport)
 proxy = AccumuloProxy::Client.new(proto)
-us = UserPass.new({'username'=> 'root', 'password' => 'secret'})
+login = PrincipalToken.new({'principal' => 'root', 'token' => 'secret'})
 
 # open up the connect
 transport.open()
 
 # Test if the server is up
-login = proxy.login(us)
+proxy.ping(login)
 
 # print out a table list
 puts "List of tables: #{proxy.listTables(login).inspect}"

Modified: accumulo/trunk/proxy/proxy.properties
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/proxy.properties?rev=1442310&r1=1442309&r2=1442310&view=diff
==============================================================================
--- accumulo/trunk/proxy/proxy.properties (original)
+++ accumulo/trunk/proxy/proxy.properties Mon Feb  4 19:40:09 2013
@@ -1,9 +1,7 @@
-accumulo.proxy.apis=org.apache.accumulo.proxy.thrift.AccumuloProxy
-
 org.apache.accumulo.proxy.ProxyServer.useMockInstance=false
-org.apache.accumulo.proxy.thrift.AccumuloProxy.implementor=org.apache.accumulo.proxy.ProxyServer
-org.apache.accumulo.proxy.thrift.AccumuloProxy.protocolFactory=org.apache.thrift.protocol.TCompactProtocol$Factory
-org.apache.accumulo.proxy.thrift.AccumuloProxy.port=42424
+org.apache.accumulo.proxy.ProxyServer.useMiniAccumulo=false
+org.apache.accumulo.proxy.ProxyServer.protocolFactory=org.apache.thrift.protocol.TCompactProtocol$Factory
+org.apache.accumulo.proxy.ProxyServer.port=42424
 
 org.apache.accumulo.proxy.ProxyServer.instancename=test
 org.apache.accumulo.proxy.ProxyServer.zookeepers=localhost:2181

Modified: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java?rev=1442310&r1=1442309&r2=1442310&view=diff
==============================================================================
--- accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java (original)
+++ accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java Mon Feb  4 19:40:09
2013
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.proxy;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -23,6 +24,9 @@ import java.lang.reflect.Constructor;
 import java.util.Properties;
 
 import org.apache.accumulo.core.cli.Help;
+import org.apache.accumulo.proxy.thrift.AccumuloProxy;
+import org.apache.accumulo.test.MiniAccumuloCluster;
+import org.apache.log4j.Logger;
 import org.apache.thrift.TProcessor;
 import org.apache.thrift.protocol.TProtocolFactory;
 import org.apache.thrift.server.THsHaServer;
@@ -32,9 +36,12 @@ import org.apache.thrift.transport.TNonb
 
 import com.beust.jcommander.IStringConverter;
 import com.beust.jcommander.Parameter;
+import com.google.common.io.Files;
 
 public class Proxy {
   
+  private static final Logger log = Logger.getLogger(Proxy.class); 
+  
   public static class PropertiesConverter implements IStringConverter<Properties> {
     @Override
     public Properties convert(String fileName) {
@@ -63,38 +70,44 @@ public class Proxy {
     Opts opts = new Opts();
     opts.parseArgs(Proxy.class.getName(), args);
     
-    String[] apis = opts.prop.getProperty("accumulo.proxy.apis").split(",");
-    if (apis.length == 0) {
-      System.err.println("No apis listed in the accumulo.proxy.apis property");
+    String api = ProxyServer.class.getName();
+    
+    if (!opts.prop.containsKey(api + ".port")) {
+      System.err.println("No port in the " + api + ".port property");
       System.exit(1);
     }
-    for (String api : apis) {
-      // check existence of properties
-      if (!opts.prop.containsKey(api + ".implementor")) {
-        System.err.println("No implementor listed in the " + api + ".implementor property");
-        System.exit(1);
-      }
-      if (!opts.prop.containsKey(api + ".port")) {
-        System.err.println("No port in the " + api + ".port property");
-        System.exit(1);
-      }
-      
-      Class<?> apiclass = Class.forName(api);
-      
-      Class<?> implementor = Class.forName(opts.prop.getProperty(api + ".implementor"));
-      
-      Class<? extends TProtocolFactory> protoFactoryClass = Class.forName(opts.prop.getProperty(api
+ ".protocolFactory")).asSubclass(TProtocolFactory.class);
-
-      int port = Integer.parseInt(opts.prop.getProperty(api + ".port"));
-      TServer server = createProxyServer(apiclass, implementor, port, protoFactoryClass,
opts.prop);
-      server.serve();
+    
+    String useMini = opts.prop.getProperty(api + ".useMiniAccumulo"); 
+    if (useMini != null && Boolean.parseBoolean(useMini)) {
+      log.info("Creating mini cluster");
+      final File folder = Files.createTempDir();
+      final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(folder, "secret");
+      accumulo.start();
+      opts.prop.setProperty(api+".instancename", accumulo.getInstanceName());
+      opts.prop.setProperty(api+".zookeepers", accumulo.getZookeepers());
+      Runtime.getRuntime().addShutdownHook(new Thread() {
+        public void start() {
+          try {
+            accumulo.stop();
+          } catch (Exception e) {
+            throw new RuntimeException();
+          } finally {
+            folder.delete();
+          }
+        }
+      });
     }
+
+    Class<? extends TProtocolFactory> protoFactoryClass = Class.forName(opts.prop.getProperty(api
+ ".protocolFactory")).asSubclass(TProtocolFactory.class);
+    int port = Integer.parseInt(opts.prop.getProperty(api + ".port"));
+    TServer server = createProxyServer(AccumuloProxy.class, ProxyServer.class, port, protoFactoryClass,
opts.prop);
+    server.serve();
   }
   
   public static TServer createProxyServer(Class<?> api, Class<?> implementor,
final int port, Class<? extends TProtocolFactory> protoClass,
       Properties properties) throws Exception {
     final TNonblockingServerSocket socket = new TNonblockingServerSocket(port);
-
+    
     // create the implementor
     Object impl = implementor.getConstructor(Properties.class).newInstance(properties);
     



Mime
View raw message