Author: kturner
Date: Tue Apr 23 20:19:25 2013
New Revision: 1471131
URL: http://svn.apache.org/r1471131
Log:
ACCUMULO-1200 ACCUMULO-1305 shortened proxy property names and added option for
running against mini accumulo
Modified:
accumulo/branches/1.4/src/proxy/README
accumulo/branches/1.4/src/proxy/pom.xml
accumulo/branches/1.4/src/proxy/proxy.properties
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java
Modified: accumulo/branches/1.4/src/proxy/README
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/README?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
--- accumulo/branches/1.4/src/proxy/README (original)
+++ accumulo/branches/1.4/src/proxy/README Tue Apr 23 20:19:25 2013
@@ -30,7 +30,7 @@ This will compile the thrift and java fi
Please note that the proxy can only function correctly when connected to an
Accumulo 1.4 instance, or when run standalone in the Mock configuration.
To run the server, edit the configuration file with parameters suited for your
Accumulo installation. If you wish to instead use an in-memory Mock instance,
set:
-org.apache.accumulo.proxy.ProxyServer.useMockInstance=true
+ useMockInstance=true
This option will override any "real" Accumulo instance information.
Once the properties file is configured correctly, run this command:
Modified: accumulo/branches/1.4/src/proxy/pom.xml
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/pom.xml?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
--- accumulo/branches/1.4/src/proxy/pom.xml (original)
+++ accumulo/branches/1.4/src/proxy/pom.xml Tue Apr 23 20:19:25 2013
@@ -80,7 +80,7 @@
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-test</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
Modified: accumulo/branches/1.4/src/proxy/proxy.properties
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/proxy.properties?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
--- accumulo/branches/1.4/src/proxy/proxy.properties (original)
+++ accumulo/branches/1.4/src/proxy/proxy.properties Tue Apr 23 20:19:25 2013
@@ -1,7 +1,23 @@
-org.apache.accumulo.proxy.ProxyServer.useMockInstance=false
-org.apache.accumulo.proxy.ProxyServer.protocolFactory=org.apache.thrift.protocol.TCompactProtocol$Factory
-org.apache.accumulo.proxy.ProxyServer.port=42424
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-org.apache.accumulo.proxy.ProxyServer.instancename=test
-org.apache.accumulo.proxy.ProxyServer.zookeepers=localhost:2181
+useMockInstance=false
+useMiniAccumulo=false
+protocolFactory=org.apache.thrift.protocol.TCompactProtocol$Factory
+port=42424
+
+instance=test
+zookeepers=localhost:2181
Modified:
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
---
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
(original)
+++
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
Tue Apr 23 20:19:25 2013
@@ -16,52 +16,91 @@
*/
package org.apache.accumulo.proxy;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Properties;
+
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.TCompactProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.server.THsHaServer;
import org.apache.thrift.server.TServer;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TNonblockingServerSocket;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.util.Properties;
+import com.google.common.io.Files;
public class Proxy {
- private static final Logger log = Logger.getLogger(Proxy.class);
+ private static final Logger log = Logger.getLogger(Proxy.class);
public static void main(String[] args) throws Exception {
- String api = ProxyServer.class.getName();
if(args.length != 2 || !args[0].equals("-p")) {
-
System.err.println("Missing '-p' option with a valid property file");
System.exit(1);
}
- Properties props = new Properties();
- try {
- FileInputStream is = new FileInputStream(new File(args[1]));
- props.load(is);
- is.close();
- } catch(IOException e) {
-
- System.err.println("There was an error opening the property file");
- System.exit(1);
+
+ Properties props = new Properties();
+ try {
+ FileInputStream is = new FileInputStream(new File(args[1]));
+ props.load(is);
+ is.close();
+ } catch (IOException e) {
+
+ System.err.println("There was an error opening the property file");
+ System.exit(1);
+
+ }
- }
+ boolean useMini =
Boolean.parseBoolean(props.getProperty("useMiniAccumulo", "false"));
+ boolean useMock =
Boolean.parseBoolean(props.getProperty("useMockInstance", "false"));
+ String instance = props.getProperty("instance");
+ String zookeepers = props.getProperty("zookeepers");
+
+ if (!useMini && !useMock && instance == null) {
+ System.err.println("Properties file must contain one of :
useMiniAccumulo=true, useMockInstance=true, or instance=<instance name>");
+ System.exit(1);
+ }
+
+ if (instance != null && zookeepers == null) {
+ System.err.println("When instance is set in properties file, zookeepers
must also be set.");
+ System.exit(1);
+ }
- if (!props.containsKey(api + ".port")) {
- System.err.println("No port in the " + api + ".port property");
+ if (!props.containsKey("port")) {
+ System.err.println("No port property");
System.exit(1);
}
- Class<? extends TProtocolFactory> protoFactoryClass =
Class.forName(props.getProperty(api +
".protocolFactory")).asSubclass(TProtocolFactory.class);
- int port = Integer.parseInt(props.getProperty(api + ".port"));
+ if (useMini) {
+ log.info("Creating mini cluster");
+ final File folder = Files.createTempDir();
+ final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(folder,
"secret");
+ accumulo.start();
+ props.setProperty("instance", accumulo.getInstanceName());
+ props.setProperty("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(props.getProperty("protocolFactory",
TCompactProtocol.Factory.class.getName()))
+ .asSubclass(TProtocolFactory.class);
+ int port = Integer.parseInt(props.getProperty("port"));
TServer server = createProxyServer(AccumuloProxy.class, ProxyServer.class,
port, protoFactoryClass, props);
server.serve();
}
@@ -72,7 +111,7 @@ public class Proxy {
// create the implementor
Object impl =
implementor.getConstructor(Properties.class).newInstance(properties);
-
+
Class<?> proxyProcClass = Class.forName(api.getName() + "$Processor");
Class<?> proxyIfaceClass = Class.forName(api.getName() + "$Iface");
@SuppressWarnings("unchecked")
Modified:
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
---
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
(original)
+++
accumulo/branches/1.4/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
Tue Apr 23 20:19:25 2013
@@ -152,12 +152,11 @@ public class ProxyServer implements Accu
public ProxyServer(Properties props) {
- String useMock =
props.getProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance");
+ String useMock = props.getProperty("useMockInstance");
if (useMock != null && Boolean.parseBoolean(useMock))
instance = new MockInstance();
else
- instance = new
ZooKeeperInstance(props.getProperty("org.apache.accumulo.proxy.ProxyServer.instancename"),
-
props.getProperty("org.apache.accumulo.proxy.ProxyServer.zookeepers"));
+ instance = new ZooKeeperInstance(props.getProperty("instance"),
props.getProperty("zookeepers"));
scannerCache = CacheBuilder.newBuilder().expireAfterAccess(10,
TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseScanner()).build();
Modified:
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
---
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
(original)
+++
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
Tue Apr 23 20:19:25 2013
@@ -131,9 +131,9 @@ public class SimpleTest {
accumulo.start();
Properties props = new Properties();
- props.put("org.apache.accumulo.proxy.ProxyServer.instancename",
accumulo.getInstanceName());
- props.put("org.apache.accumulo.proxy.ProxyServer.zookeepers",
accumulo.getZooKeepers());
-
+ props.put("instance", accumulo.getInstanceName());
+ props.put("zookeepers", accumulo.getZooKeepers());
+
protocolClass = getRandomProtocol();
System.out.println(protocolClass.getName());
Modified:
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
---
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java
(original)
+++
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyInstanceOperations.java
Tue Apr 23 20:19:25 2013
@@ -16,6 +16,14 @@
*/
package org.apache.accumulo.proxy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.ByteBuffer;
+import java.util.Properties;
+import java.util.TreeMap;
+
import org.apache.accumulo.proxy.thrift.AccumuloException;
import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
import org.apache.thrift.TException;
@@ -25,12 +33,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.nio.ByteBuffer;
-import java.util.Properties;
-import java.util.TreeMap;
-
-import static org.junit.Assert.*;
-
public class TestProxyInstanceOperations {
protected static TServer proxy;
protected static Thread thread;
@@ -42,7 +44,7 @@ public class TestProxyInstanceOperations
@BeforeClass
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance",
"true");
+ prop.setProperty("useMockInstance", "true");
proxy =
Proxy.createProxyServer(Class.forName("org.apache.accumulo.proxy.thrift.AccumuloProxy"),
Class.forName("org.apache.accumulo.proxy.ProxyServer"),
port, TCompactProtocol.Factory.class, prop);
Modified:
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
---
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
(original)
+++
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java
Tue Apr 23 20:19:25 2013
@@ -16,18 +16,39 @@
*/
package org.apache.accumulo.proxy;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.iterators.user.RegExFilter;
-import org.apache.accumulo.proxy.thrift.*;
-import org.apache.thrift.protocol.TCompactProtocol;
-import org.apache.thrift.server.TServer;
-import org.junit.*;
+import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
-import static org.junit.Assert.assertEquals;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.iterators.user.RegExFilter;
+import org.apache.accumulo.proxy.thrift.BatchScanOptions;
+import org.apache.accumulo.proxy.thrift.ColumnUpdate;
+import org.apache.accumulo.proxy.thrift.IteratorSetting;
+import org.apache.accumulo.proxy.thrift.Key;
+import org.apache.accumulo.proxy.thrift.KeyValue;
+import org.apache.accumulo.proxy.thrift.MutationsRejectedException;
+import org.apache.accumulo.proxy.thrift.Range;
+import org.apache.accumulo.proxy.thrift.ScanColumn;
+import org.apache.accumulo.proxy.thrift.ScanOptions;
+import org.apache.accumulo.proxy.thrift.ScanResult;
+import org.apache.accumulo.proxy.thrift.TimeType;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.server.TServer;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
public class TestProxyReadWrite {
@@ -43,7 +64,7 @@ public class TestProxyReadWrite {
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance",
"true");
+ prop.setProperty("useMockInstance", "true");
proxy =
Proxy.createProxyServer(Class.forName("org.apache.accumulo.proxy.thrift.AccumuloProxy"),
Class.forName("org.apache.accumulo.proxy.ProxyServer"),
port, TCompactProtocol.Factory.class, prop);
Modified:
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
---
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java
(original)
+++
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java
Tue Apr 23 20:19:25 2013
@@ -16,17 +16,32 @@
*/
package org.apache.accumulo.proxy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
import org.apache.accumulo.core.util.ByteBufferUtil;
-import org.apache.accumulo.proxy.thrift.*;
+import org.apache.accumulo.proxy.thrift.AccumuloException;
+import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
+import org.apache.accumulo.proxy.thrift.SystemPermission;
+import org.apache.accumulo.proxy.thrift.TableNotFoundException;
+import org.apache.accumulo.proxy.thrift.TablePermission;
+import org.apache.accumulo.proxy.thrift.TimeType;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.server.TServer;
-import org.junit.*;
-
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
public class TestProxySecurityOperations {
protected static TServer proxy;
@@ -42,7 +57,7 @@ public class TestProxySecurityOperations
@BeforeClass
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance",
"true");
+ prop.setProperty("useMockInstance", "true");
proxy =
Proxy.createProxyServer(Class.forName("org.apache.accumulo.proxy.thrift.AccumuloProxy"),
Class.forName("org.apache.accumulo.proxy.ProxyServer"),
port, TCompactProtocol.Factory.class, prop);
Modified:
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java
URL:
http://svn.apache.org/viewvc/accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java?rev=1471131&r1=1471130&r2=1471131&view=diff
==============================================================================
---
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java
(original)
+++
accumulo/branches/1.4/src/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java
Tue Apr 23 20:19:25 2013
@@ -16,16 +16,36 @@
*/
package org.apache.accumulo.proxy;
-import org.apache.accumulo.proxy.thrift.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.accumulo.proxy.thrift.AccumuloException;
+import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
+import org.apache.accumulo.proxy.thrift.ColumnUpdate;
+import org.apache.accumulo.proxy.thrift.MutationsRejectedException;
+import org.apache.accumulo.proxy.thrift.TableExistsException;
+import org.apache.accumulo.proxy.thrift.TableNotFoundException;
+import org.apache.accumulo.proxy.thrift.TimeType;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.server.TServer;
-import org.junit.*;
-
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
public class TestProxyTableOperations {
@@ -40,7 +60,8 @@ public class TestProxyTableOperations {
@BeforeClass
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance",
"true");
+ prop.setProperty("useMockInstance", "true");
+
proxy =
Proxy.createProxyServer(Class.forName("org.apache.accumulo.proxy.thrift.AccumuloProxy"),
Class.forName("org.apache.accumulo.proxy.ProxyServer"),
port, TCompactProtocol.Factory.class, prop);