Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D07BB176C5 for ; Fri, 9 Jan 2015 02:44:07 +0000 (UTC) Received: (qmail 1830 invoked by uid 500); 9 Jan 2015 02:44:09 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 1730 invoked by uid 500); 9 Jan 2015 02:44:08 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 131 invoked by uid 99); 9 Jan 2015 02:44:06 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jan 2015 02:44:06 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2121690DDE4; Fri, 9 Jan 2015 02:44:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ctubbsii@apache.org To: commits@accumulo.apache.org Date: Fri, 09 Jan 2015 02:44:26 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [22/66] [abbrv] accumulo git commit: ACCUMULO-3451 Format master branch (1.7.0-SNAPSHOT) http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/maven-plugin/src/it/plugin-test/src/main/java/org/apache/accumulo/plugin/CustomFilter.java ---------------------------------------------------------------------- diff --git a/maven-plugin/src/it/plugin-test/src/main/java/org/apache/accumulo/plugin/CustomFilter.java b/maven-plugin/src/it/plugin-test/src/main/java/org/apache/accumulo/plugin/CustomFilter.java index 9a0497a..97be677 100644 --- a/maven-plugin/src/it/plugin-test/src/main/java/org/apache/accumulo/plugin/CustomFilter.java +++ b/maven-plugin/src/it/plugin-test/src/main/java/org/apache/accumulo/plugin/CustomFilter.java @@ -21,13 +21,13 @@ import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.Filter; /** - * + * */ public class CustomFilter extends Filter { - + @Override public boolean accept(Key k, Value v) { return k.getColumnFamily().toString().equals("allowed"); } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/maven-plugin/src/it/plugin-test/src/test/java/org/apache/accumulo/plugin/PluginIT.java ---------------------------------------------------------------------- diff --git a/maven-plugin/src/it/plugin-test/src/test/java/org/apache/accumulo/plugin/PluginIT.java b/maven-plugin/src/it/plugin-test/src/test/java/org/apache/accumulo/plugin/PluginIT.java index 1e3fe37..6d3267a 100644 --- a/maven-plugin/src/it/plugin-test/src/test/java/org/apache/accumulo/plugin/PluginIT.java +++ b/maven-plugin/src/it/plugin-test/src/test/java/org/apache/accumulo/plugin/PluginIT.java @@ -43,17 +43,17 @@ import org.junit.BeforeClass; import org.junit.Test; public class PluginIT { - + private static Instance instance; private static Connector connector; - + @BeforeClass public static void setUp() throws Exception { String instanceName = "plugin-it-instance"; instance = new MiniAccumuloInstance(instanceName, new File("target/accumulo-maven-plugin/" + instanceName)); connector = instance.getConnector("root", new PasswordToken("ITSecret")); } - + @Test public void testInstanceConnection() { assertTrue(instance != null); @@ -61,7 +61,7 @@ public class PluginIT { assertTrue(connector != null); assertTrue(connector instanceof Connector); } - + @Test public void testCreateTable() throws AccumuloException, AccumuloSecurityException, TableExistsException, IOException { String tableName = "testCreateTable"; @@ -69,7 +69,7 @@ public class PluginIT { assertTrue(connector.tableOperations().exists(tableName)); assertTrue(new File("target/accumulo-maven-plugin/" + instance.getInstanceName() + "/testCreateTablePassed").createNewFile()); } - + @Test public void writeToTable() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, IOException { String tableName = "writeToTable"; @@ -91,7 +91,7 @@ public class PluginIT { assertEquals(1, count); assertTrue(new File("target/accumulo-maven-plugin/" + instance.getInstanceName() + "/testWriteToTablePassed").createNewFile()); } - + @Test public void checkIterator() throws IOException, AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException { String tableName = "checkIterator"; @@ -108,7 +108,7 @@ public class PluginIT { m.put("allowed", "CQ3", "V3"); bw.addMutation(m); bw.close(); - + // check filter Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY); IteratorSetting is = new IteratorSetting(5, CustomFilter.class); @@ -119,7 +119,7 @@ public class PluginIT { assertEquals("allowed", entry.getKey().getColumnFamily().toString()); } assertEquals(4, count); - + // check filter negated scanner.clearScanIterators(); CustomFilter.setNegate(is, true); @@ -132,5 +132,5 @@ public class PluginIT { assertEquals(2, count); assertTrue(new File("target/accumulo-maven-plugin/" + instance.getInstanceName() + "/testCheckIteratorPassed").createNewFile()); } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java ---------------------------------------------------------------------- diff --git a/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java index 798499d..5e6a905 100644 --- a/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java +++ b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java @@ -43,16 +43,16 @@ public abstract class AbstractAccumuloMojo extends AbstractMojo { } else if (miniClasspath != null && !miniClasspath.isEmpty()) { classpathItems.addAll(Arrays.asList(miniClasspath.split(File.pathSeparator))); } - + // Hack to prevent sisu-guava, a maven 3.0.4 dependency, from effecting normal accumulo behavior. String sisuGuava = null; for (String items : classpathItems) if (items.contains("sisu-guava")) sisuGuava = items; - + if (sisuGuava != null) classpathItems.remove(sisuGuava); - + macConfig.setClasspathItems(classpathItems.toArray(new String[classpathItems.size()])); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java ---------------------------------------------------------------------- diff --git a/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java index 0bd36e4..5d51ed6 100644 --- a/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java +++ b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java @@ -31,7 +31,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; @ThreadSafe @Mojo(name = "stop", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST) public class StopMojo extends AbstractAccumuloMojo { - + @Override public void execute() throws MojoExecutionException { for (MiniAccumuloClusterImpl mac : StartMojo.runningClusters) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/main/java/org/apache/accumulo/cluster/RemoteShell.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/RemoteShell.java b/minicluster/src/main/java/org/apache/accumulo/cluster/RemoteShell.java index 5db279c..5a44acf 100644 --- a/minicluster/src/main/java/org/apache/accumulo/cluster/RemoteShell.java +++ b/minicluster/src/main/java/org/apache/accumulo/cluster/RemoteShell.java @@ -28,8 +28,7 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; /** - * Execute a command, leveraging Hadoop's {@link ShellCommandExecutor}, on a remote host. SSH configuration provided - * by {@link RemoteShellOptions}. + * Execute a command, leveraging Hadoop's {@link ShellCommandExecutor}, on a remote host. SSH configuration provided by {@link RemoteShellOptions}. */ public class RemoteShell extends ShellCommandExecutor { private static final Logger log = LoggerFactory.getLogger(RemoteShell.class); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java index 733f8d0..9b467bc 100644 --- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java +++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java @@ -129,7 +129,7 @@ public class StandaloneClusterControl implements ClusterControl { public void adminStopAll() throws IOException { File confDir = getConfDir(); String master = getHosts(new File(confDir, "masters")).get(0); - String[] cmd = new String[] { accumuloPath, Admin.class.getName(), "stopAll" }; + String[] cmd = new String[] {accumuloPath, Admin.class.getName(), "stopAll"}; Entry pair = exec(master, cmd); if (0 != pair.getKey().intValue()) { throw new IOException("stopAll did not finish successfully, retcode=" + pair.getKey() + ", stdout=" + pair.getValue()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java index 68e30fa..c8c499d 100644 --- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java +++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java @@ -24,17 +24,17 @@ import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; /** * Holds configuration for {@link MiniAccumuloCluster}. Required configurations must be passed to constructor(s) and all other configurations are optional. - * + * * @since 1.5.0 */ public class MiniAccumuloConfig { private MiniAccumuloConfigImpl impl; - + MiniAccumuloConfig(MiniAccumuloConfigImpl config) { this.impl = config; } - + MiniAccumuloConfigImpl getImpl() { return impl; } @@ -49,10 +49,10 @@ public class MiniAccumuloConfig { public MiniAccumuloConfig(File dir, String rootPassword) { this.impl = new MiniAccumuloConfigImpl(dir, rootPassword); } - + /** * Calling this method is optional. If not set, it defaults to two. - * + * * @param numTservers * the number of tablet servers that mini accumulo cluster should start */ @@ -63,7 +63,7 @@ public class MiniAccumuloConfig { /** * Calling this method is optional. If not set, defaults to 'miniInstance' - * + * * @since 1.6.0 */ public MiniAccumuloConfig setInstanceName(String instanceName) { @@ -73,7 +73,7 @@ public class MiniAccumuloConfig { /** * Calling this method is optional. If not set, it defaults to an empty map. - * + * * @param siteConfig * key/values that you normally put in accumulo-site.xml can be put here. */ @@ -84,10 +84,10 @@ public class MiniAccumuloConfig { /** * Calling this method is optional. A random port is generated by default - * + * * @param zooKeeperPort * A valid (and unused) port to use for the zookeeper - * + * * @since 1.6.0 */ public MiniAccumuloConfig setZooKeeperPort(int zooKeeperPort) { @@ -97,10 +97,10 @@ public class MiniAccumuloConfig { /** * Configure the time to wait for ZooKeeper to startup. Calling this method is optional. The default is 20000 milliseconds - * + * * @param zooKeeperStartupTime * Time to wait for ZooKeeper to startup, in milliseconds - * + * * @since 1.6.1 */ public MiniAccumuloConfig setZooKeeperStartupTime(long zooKeeperStartupTime) { @@ -110,15 +110,15 @@ public class MiniAccumuloConfig { /** * Sets the amount of memory to use in the master process. Calling this method is optional. Default memory is 128M - * + * * @param serverType * the type of server to apply the memory settings * @param memory * amount of memory to set - * + * * @param memoryUnit * the units for which to apply with the memory size - * + * * @since 1.6.0 */ public MiniAccumuloConfig setMemory(ServerType serverType, long memory, MemoryUnit memoryUnit) { @@ -129,13 +129,13 @@ public class MiniAccumuloConfig { /** * Sets the default memory size to use. This value is also used when a ServerType has not been configured explicitly. Calling this method is optional. Default * memory is 128M - * + * * @param memory * amount of memory to set - * + * * @param memoryUnit * the units for which to apply with the memory size - * + * * @since 1.6.0 */ public MiniAccumuloConfig setDefaultMemory(long memory, MemoryUnit memoryUnit) { @@ -152,7 +152,7 @@ public class MiniAccumuloConfig { /** * @return name of configured instance - * + * * @since 1.6.0 */ public String getInstanceName() { @@ -161,7 +161,7 @@ public class MiniAccumuloConfig { /** * @return The configured zookeeper port - * + * * @since 1.6.0 */ public int getZooKeeperPort() { @@ -171,9 +171,9 @@ public class MiniAccumuloConfig { /** * @param serverType * get configuration for this server type - * + * * @return memory configured in bytes, returns default if this server type is not configured - * + * * @since 1.6.0 */ public long getMemory(ServerType serverType) { @@ -182,7 +182,7 @@ public class MiniAccumuloConfig { /** * @return memory configured in bytes - * + * * @since 1.6.0 */ public long getDefaultMemory() { @@ -212,7 +212,7 @@ public class MiniAccumuloConfig { /** * @return is the current configuration in jdwpEnabled mode? - * + * * @since 1.6.0 */ public boolean isJDWPEnabled() { @@ -223,7 +223,7 @@ public class MiniAccumuloConfig { * @param jdwpEnabled * should the processes run remote jdwpEnabled servers? * @return the current instance - * + * * @since 1.6.0 */ public MiniAccumuloConfig setJDWPEnabled(boolean jdwpEnabled) { @@ -233,7 +233,7 @@ public class MiniAccumuloConfig { /** * @return the paths to use for loading native libraries - * + * * @since 1.6.0 */ public String[] getNativeLibPaths() { @@ -242,10 +242,10 @@ public class MiniAccumuloConfig { /** * Sets the path for processes to use for loading native libraries - * + * * @param nativePathItems * the nativePathItems to set - * + * * @since 1.6.0 */ public MiniAccumuloConfig setNativeLibPaths(String... nativePathItems) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java index e0c93a6..b94cb0b 100644 --- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java +++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloInstance.java @@ -29,7 +29,7 @@ import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.hadoop.conf.Configuration; /** - * + * * @since 1.6.0 */ public class MiniAccumuloInstance extends ZooKeeperInstance { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java index cee0db7..c45abc0 100644 --- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java +++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java @@ -30,16 +30,16 @@ import java.util.regex.Pattern; import org.apache.accumulo.core.cli.Help; import org.apache.accumulo.core.util.Pair; import org.apache.commons.io.FileUtils; +import org.apache.log4j.Logger; import com.beust.jcommander.IStringConverter; import com.beust.jcommander.Parameter; import com.google.common.io.Files; -import org.apache.log4j.Logger; /** * A runner for starting up a {@link MiniAccumuloCluster} from the command line using an optional configuration properties file. An example property file looks * like the following: - * + * *
  * rootPassword=secret
  * instanceName=testInstance
@@ -53,15 +53,15 @@ import org.apache.log4j.Logger;
  * shutdownPort=4446
  * site.instance.secret=HUSH
  * 
- * + * * All items in the properties file above are optional and a default value will be provided in their absence. Any site configuration properties (typically found * in the accumulo-site.xml file) should be prefixed with "site." in the properties file. - * + * * @since 1.6.0 */ public class MiniAccumuloRunner { private static final Logger log = Logger.getLogger(MiniAccumuloRunner.class); - + private static final String ROOT_PASSWORD_PROP = "rootPassword"; private static final String SHUTDOWN_PORT_PROP = "shutdownPort"; private static final String DEFAULT_MEMORY_PROP = "defaultMemory"; @@ -132,7 +132,7 @@ public class MiniAccumuloRunner { /** * Runs the {@link MiniAccumuloCluster} given a -p argument with a property file. Establishes a shutdown port for asynchronous operation. - * + * * @param args * An optional -p argument can be specified with the path to a valid properties file. */ @@ -202,14 +202,14 @@ public class MiniAccumuloRunner { log.error("InterruptedException attempting to stop Accumulo.", e); return; } - + try { FileUtils.deleteDirectory(miniDir); } catch (IOException e) { log.error("IOException attempting to clean up miniDir.", e); return; } - + System.out.println("\nShut down gracefully on " + new Date()); } }); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ZooKeeperBindException.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ZooKeeperBindException.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ZooKeeperBindException.java index 21bc972..50217ce 100644 --- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ZooKeeperBindException.java +++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ZooKeeperBindException.java @@ -23,8 +23,7 @@ public class ZooKeeperBindException extends RuntimeException { private static final long serialVersionUID = 1L; - public ZooKeeperBindException() { - } + public ZooKeeperBindException() {} public ZooKeeperBindException(String message) { super(message); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterStartStopTest.java ---------------------------------------------------------------------- diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterStartStopTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterStartStopTest.java index 6e8d936..10bb08a 100644 --- a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterStartStopTest.java +++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterStartStopTest.java @@ -29,14 +29,14 @@ import org.junit.Test; import org.junit.rules.TestName; public class MiniAccumuloClusterStartStopTest { - + private static final Logger log = Logger.getLogger(MiniAccumuloClusterStartStopTest.class); private File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests/" + this.getClass().getName()); private MiniAccumuloCluster accumulo; @Rule public TestName testName = new TestName(); - + @Before public void setupTestCluster() throws IOException { baseDir.mkdirs(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/CleanShutdownMacTest.java ---------------------------------------------------------------------- diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/CleanShutdownMacTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/CleanShutdownMacTest.java index 800e91b..81f9d3d 100644 --- a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/CleanShutdownMacTest.java +++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/CleanShutdownMacTest.java @@ -47,7 +47,7 @@ public class CleanShutdownMacTest { cluster.setShutdownExecutor(mockService); EasyMock.expect(future.get()).andReturn(0).anyTimes(); - EasyMock.expect(mockService.submit(EasyMock.anyObject(Callable.class))).andReturn(future).anyTimes(); + EasyMock.expect(mockService. submit(EasyMock.anyObject(Callable.class))).andReturn(future).anyTimes(); EasyMock.expect(mockService.shutdownNow()).andReturn(Collections. emptyList()).once(); EasyMock.replay(mockService, future); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java ---------------------------------------------------------------------- diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java index 41ad88c..3339fb0 100644 --- a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java +++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java @@ -76,7 +76,8 @@ public class MiniAccumuloClusterImplTest { testTableID = tableops.tableIdMap().get(TEST_TABLE); Scanner s = conn.createScanner(TEST_TABLE, Authorizations.EMPTY); - for (@SuppressWarnings("unused") Entry e : s) {} + for (@SuppressWarnings("unused") + Entry e : s) {} } @Test(timeout = 10000) http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java ---------------------------------------------------------------------- diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java index 4b048eb..7eb4fbf 100644 --- a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java +++ b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java @@ -42,9 +42,9 @@ 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 { @Override public Properties convert(String fileName) { @@ -63,36 +63,36 @@ public class Proxy { return prop; } } - + public static class Opts extends Help { @Parameter(names = "-p", required = true, description = "properties file name", converter = PropertiesConverter.class) Properties prop; } - + public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(Proxy.class.getName(), args); - + boolean useMini = Boolean.parseBoolean(opts.prop.getProperty("useMiniAccumulo", "false")); boolean useMock = Boolean.parseBoolean(opts.prop.getProperty("useMockInstance", "false")); String instance = opts.prop.getProperty("instance"); String zookeepers = opts.prop.getProperty("zookeepers"); - + if (!useMini && !useMock && instance == null) { System.err.println("Properties file must contain one of : useMiniAccumulo=true, useMockInstance=true, or instance="); 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 (!opts.prop.containsKey("port")) { System.err.println("No port property"); System.exit(1); } - + if (useMini) { log.info("Creating mini cluster"); final File folder = Files.createTempDir(); @@ -114,35 +114,35 @@ public class Proxy { } }); } - + Class protoFactoryClass = Class.forName(opts.prop.getProperty("protocolFactory", TCompactProtocol.Factory.class.getName())) .asSubclass(TProtocolFactory.class); int port = Integer.parseInt(opts.prop.getProperty("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 protoClass, Properties properties) throws Exception { final TNonblockingServerSocket socket = new TNonblockingServerSocket(port); - + // 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") Constructor proxyProcConstructor = (Constructor) proxyProcClass.getConstructor(proxyIfaceClass); - + final TProcessor processor = proxyProcConstructor.newInstance(RpcWrapper.service(impl)); - + THsHaServer.Args args = new THsHaServer.Args(socket); args.processor(processor); final long maxFrameSize = AccumuloConfiguration.getMemoryInBytes(properties.getProperty("maxFrameSize", "16M")); if (maxFrameSize > Integer.MAX_VALUE) throw new RuntimeException(maxFrameSize + " is larger than MAX_INT"); - args.transportFactory(new TFramedTransport.Factory((int)maxFrameSize)); + args.transportFactory(new TFramedTransport.Factory((int) maxFrameSize)); args.protocolFactory(protoClass.newInstance()); args.maxReadBufferBytes = maxFrameSize; return new THsHaServer(args); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java ---------------------------------------------------------------------- diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java index b1f039c..af12815 100644 --- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java +++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java @@ -41,9 +41,9 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.BatchScanner; import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.BatchWriterConfig; +import org.apache.accumulo.core.client.ClientConfiguration; import org.apache.accumulo.core.client.ConditionalWriter; import org.apache.accumulo.core.client.ConditionalWriter.Result; -import org.apache.accumulo.core.client.ClientConfiguration; import org.apache.accumulo.core.client.ConditionalWriterConfig; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Instance; @@ -115,26 +115,26 @@ import com.google.common.cache.RemovalNotification; /** * Proxy Server exposing the Accumulo API via Thrift.. - * + * * @since 1.5 */ public class ProxyServer implements AccumuloProxy.Iface { - + public static final Logger logger = Logger.getLogger(ProxyServer.class); protected Instance instance; - + protected Class tokenClass; - + static protected class ScannerPlusIterator { public ScannerBase scanner; public Iterator> iterator; } - + static protected class BatchWriterPlusException { public BatchWriter writer; public MutationsRejectedException exception = null; } - + static class CloseWriter implements RemovalListener { @Override public void onRemoval(RemovalNotification notification) { @@ -147,10 +147,10 @@ public class ProxyServer implements AccumuloProxy.Iface { logger.warn(e, e); } } - + public CloseWriter() {} } - + static class CloseScanner implements RemovalListener { @Override public void onRemoval(RemovalNotification notification) { @@ -160,10 +160,10 @@ public class ProxyServer implements AccumuloProxy.Iface { scanner.close(); } } - + public CloseScanner() {} } - + public static class CloseConditionalWriter implements RemovalListener { @Override public void onRemoval(RemovalNotification notification) { @@ -174,40 +174,42 @@ public class ProxyServer implements AccumuloProxy.Iface { protected Cache scannerCache; protected Cache writerCache; protected Cache conditionalWriterCache; - + public ProxyServer(Properties props) { - + String useMock = props.getProperty("useMockInstance"); if (useMock != null && Boolean.parseBoolean(useMock)) instance = new MockInstance(); else - instance = new ZooKeeperInstance(ClientConfiguration.loadDefault().withInstance(props.getProperty("instance")).withZkHosts(props.getProperty("zookeepers"))); - + instance = new ZooKeeperInstance(ClientConfiguration.loadDefault().withInstance(props.getProperty("instance")) + .withZkHosts(props.getProperty("zookeepers"))); + try { String tokenProp = props.getProperty("tokenClass", PasswordToken.class.getName()); tokenClass = Class.forName(tokenProp).asSubclass(AuthenticationToken.class); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } - + scannerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseScanner()).build(); - + writerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseWriter()).build(); - + conditionalWriterCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseConditionalWriter()) .build(); } - + protected Connector getConnector(ByteBuffer login) throws Exception { String[] pair = new String(login.array(), login.position(), login.remaining(), UTF_8).split(",", 2); if (instance.getInstanceID().equals(pair[0])) { Credentials creds = Credentials.deserialize(pair[1]); return instance.getConnector(creds.getPrincipal(), creds.getToken()); } else { - throw new org.apache.accumulo.core.client.AccumuloSecurityException(pair[0], org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode.INVALID_INSTANCEID); + throw new org.apache.accumulo.core.client.AccumuloSecurityException(pair[0], + org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode.INVALID_INSTANCEID); } } - + private void handleAccumuloException(AccumuloException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException { if (e.getCause() instanceof ThriftTableOperationException) { @@ -218,14 +220,14 @@ public class ProxyServer implements AccumuloProxy.Iface { } throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); } - + private void handleAccumuloSecurityException(AccumuloSecurityException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException { if (e.getSecurityErrorCode().equals(SecurityErrorCode.TABLE_DOESNT_EXIST)) throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString()); throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString()); } - + private void handleExceptionTNF(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { @@ -244,7 +246,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); } } - + private void handleExceptionTEE(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.TableExistsException, TException { @@ -262,7 +264,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); } } - + private void handleExceptionMRE(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException { @@ -280,7 +282,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); } } - + private void handleException(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { try { @@ -293,11 +295,11 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); } } - + @Override public int addConstraint(ByteBuffer login, String tableName, String constraintClassName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { - + try { return getConnector(login).tableOperations().addConstraint(tableName, constraintClassName); } catch (Exception e) { @@ -305,11 +307,11 @@ public class ProxyServer implements AccumuloProxy.Iface { return -1; } } - + @Override public void addSplits(ByteBuffer login, String tableName, Set splits) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { - + try { SortedSet sorted = new TreeSet(); for (ByteBuffer split : splits) { @@ -320,7 +322,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void clearLocatorCache(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { @@ -331,7 +333,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e.toString()); } } - + @Override public void compactTable(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow, List iterators, boolean flush, boolean wait, CompactionStrategyConfig compactionStrategy) @@ -340,7 +342,7 @@ public class ProxyServer implements AccumuloProxy.Iface { try { CompactionConfig compactionConfig = new CompactionConfig().setStartRow(ByteBufferUtil.toText(startRow)).setEndRow(ByteBufferUtil.toText(endRow)) .setIterators(getIteratorSettings(iterators)).setFlush(flush).setWait(wait); - + if (compactionStrategy != null) { org.apache.accumulo.core.client.admin.CompactionStrategyConfig ccc = new org.apache.accumulo.core.client.admin.CompactionStrategyConfig( compactionStrategy.getClassName()); @@ -354,18 +356,18 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void cancelCompaction(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException, TException { - + try { getConnector(login).tableOperations().cancelCompaction(tableName); } catch (Exception e) { handleExceptionTNF(e); } } - + private List getIteratorSettings(List iterators) { List result = new ArrayList(); if (iterators != null) { @@ -375,7 +377,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } return result; } - + @Override public void createTable(ByteBuffer login, String tableName, boolean versioningIter, org.apache.accumulo.proxy.thrift.TimeType type) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -383,7 +385,7 @@ public class ProxyServer implements AccumuloProxy.Iface { try { if (type == null) type = org.apache.accumulo.proxy.thrift.TimeType.MILLIS; - + NewTableConfiguration tConfig = new NewTableConfiguration().setTimeType(TimeType.valueOf(type.toString())); if (!versioningIter) tConfig = tConfig.withoutDefaultIterators(); @@ -394,7 +396,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public void deleteTable(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -404,7 +406,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void deleteRows(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -414,7 +416,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public boolean tableExists(ByteBuffer login, String tableName) throws TException { try { @@ -423,7 +425,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e); } } - + @Override public void flushTable(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow, boolean wait) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -434,7 +436,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public Map> getLocalityGroups(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -454,7 +456,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public ByteBuffer getMaxRow(ByteBuffer login, String tableName, Set auths, ByteBuffer startRow, boolean startInclusive, ByteBuffer endRow, boolean endInclusive) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -476,13 +478,13 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public Map getTableProperties(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { Map ret = new HashMap(); - + for (Map.Entry entry : getConnector(login).tableOperations().getProperties(tableName)) { ret.put(entry.getKey(), entry.getValue()); } @@ -492,7 +494,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public List listSplits(ByteBuffer login, String tableName, int maxSplits) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -508,7 +510,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public Set listTables(ByteBuffer login) throws TException { try { @@ -517,11 +519,11 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e); } } - + @Override public Map listConstraints(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { - + try { return getConnector(login).tableOperations().listConstraints(tableName); } catch (Exception e) { @@ -529,7 +531,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public void mergeTablets(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -540,7 +542,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void offlineTable(ByteBuffer login, String tableName, boolean wait) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -550,7 +552,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void onlineTable(ByteBuffer login, String tableName, boolean wait) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -560,18 +562,18 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void removeConstraint(ByteBuffer login, String tableName, int constraint) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { - + try { getConnector(login).tableOperations().removeConstraint(tableName, constraint); } catch (Exception e) { handleExceptionTNF(e); } } - + @Override public void removeTableProperty(ByteBuffer login, String tableName, String property) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -581,7 +583,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void renameTable(ByteBuffer login, String oldTableName, String newTableName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, @@ -592,7 +594,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTEE(e); } } - + @Override public void setLocalityGroups(ByteBuffer login, String tableName, Map> groupStrings) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -610,7 +612,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void setTableProperty(ByteBuffer login, String tableName, String property, String value) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -620,7 +622,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public Map tableIdMap(ByteBuffer login) throws TException { try { @@ -629,7 +631,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e); } } - + @Override public List getDiskUsage(ByteBuffer login, Set tables) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -648,7 +650,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public Map getSiteConfiguration(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -659,7 +661,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public Map getSystemConfiguration(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -670,7 +672,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public List getTabletServers(ByteBuffer login) throws TException { try { @@ -679,7 +681,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e); } } - + @Override public List getActiveScans(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -734,11 +736,11 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public List getActiveCompactions(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { - + try { List result = new ArrayList(); List active = getConnector(login).instanceOperations().getActiveCompactions(tserver); @@ -758,7 +760,7 @@ public class ProxyServer implements AccumuloProxy.Iface { pcomp.outputFile = comp.getOutputFile(); pcomp.reason = CompactionReason.valueOf(comp.getReason().toString()); pcomp.type = CompactionType.valueOf(comp.getType().toString()); - + pcomp.iterators = new ArrayList(); if (comp.getIterators() != null) { for (IteratorSetting setting : comp.getIterators()) { @@ -775,7 +777,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public void removeProperty(ByteBuffer login, String property) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -785,7 +787,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public void setProperty(ByteBuffer login, String property, String value) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -795,7 +797,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public boolean testClassLoad(ByteBuffer login, String className, String asTypeName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -806,7 +808,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return false; } } - + @Override public boolean authenticateUser(ByteBuffer login, String user, Map properties) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -817,7 +819,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return false; } } - + @Override public void changeUserAuthorizations(ByteBuffer login, String user, Set authorizations) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -831,7 +833,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public void changeLocalUserPassword(ByteBuffer login, String user, ByteBuffer password) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -841,7 +843,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public void createLocalUser(ByteBuffer login, String user, ByteBuffer password) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -851,7 +853,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public void dropLocalUser(ByteBuffer login, String user) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -861,7 +863,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public List getUserAuthorizations(ByteBuffer login, String user) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -872,7 +874,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public void grantSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -882,7 +884,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public void grantTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -893,7 +895,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public boolean hasSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -904,7 +906,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return false; } } - + @Override public boolean hasTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -916,7 +918,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return false; } } - + @Override public Set listLocalUsers(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -927,7 +929,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public void revokeSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -937,7 +939,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public void revokeTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -948,7 +950,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + private Authorizations getAuthorizations(Set authorizations) { List auths = new ArrayList(); for (ByteBuffer bbauth : authorizations) { @@ -956,13 +958,13 @@ public class ProxyServer implements AccumuloProxy.Iface { } return new Authorizations(auths.toArray(new String[0])); } - + @Override public String createScanner(ByteBuffer login, String tableName, ScanOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { Connector connector = getConnector(login); - + Authorizations auth; if (opts != null && opts.isSetAuthorizations()) { auth = getAuthorizations(opts.authorizations); @@ -970,7 +972,7 @@ public class ProxyServer implements AccumuloProxy.Iface { auth = connector.securityOperations().getUserAuthorizations(connector.whoami()); } Scanner scanner = connector.createScanner(tableName, auth); - + if (opts != null) { if (opts.iterators != null) { for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) { @@ -992,9 +994,9 @@ public class ProxyServer implements AccumuloProxy.Iface { } } } - + UUID uuid = UUID.randomUUID(); - + ScannerPlusIterator spi = new ScannerPlusIterator(); spi.scanner = scanner; spi.iterator = scanner.iterator(); @@ -1005,13 +1007,13 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public String createBatchScanner(ByteBuffer login, String tableName, BatchScanOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { Connector connector = getConnector(login); - + int threads = 10; Authorizations auth; if (opts != null && opts.isSetAuthorizations()) { @@ -1021,9 +1023,9 @@ public class ProxyServer implements AccumuloProxy.Iface { } if (opts != null && opts.threads > 0) threads = opts.threads; - + BatchScanner scanner = connector.createBatchScanner(tableName, auth, threads); - + if (opts != null) { if (opts.iterators != null) { for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) { @@ -1031,9 +1033,9 @@ public class ProxyServer implements AccumuloProxy.Iface { scanner.addScanIterator(is); } } - + ArrayList ranges = new ArrayList(); - + if (opts.ranges == null) { ranges.add(new Range()); } else { @@ -1044,7 +1046,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } } scanner.setRanges(ranges); - + if (opts.columns != null) { for (ScanColumn col : opts.columns) { if (col.isSetColQualifier()) @@ -1054,9 +1056,9 @@ public class ProxyServer implements AccumuloProxy.Iface { } } } - + UUID uuid = UUID.randomUUID(); - + ScannerPlusIterator spi = new ScannerPlusIterator(); spi.scanner = scanner; spi.iterator = scanner.iterator(); @@ -1067,34 +1069,34 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + private ScannerPlusIterator getScanner(String scanner) throws UnknownScanner { - + UUID uuid = null; try { uuid = UUID.fromString(scanner); } catch (IllegalArgumentException e) { throw new UnknownScanner(e.getMessage()); } - + ScannerPlusIterator spi = scannerCache.getIfPresent(uuid); if (spi == null) { throw new UnknownScanner("Scanner never existed or no longer exists"); } return spi; } - + @Override public boolean hasNext(String scanner) throws UnknownScanner, TException { ScannerPlusIterator spi = getScanner(scanner); - + return (spi.iterator.hasNext()); } - + @Override public KeyValueAndPeek nextEntry(String scanner) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { - + ScanResult scanResult = nextK(scanner, 1); if (scanResult.results.size() > 0) { return new KeyValueAndPeek(scanResult.results.get(0), scanResult.isMore()); @@ -1102,11 +1104,11 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new NoMoreEntriesException(); } } - + @Override public ScanResult nextK(String scanner, int k) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { - + // fetch the scanner ScannerPlusIterator spi = getScanner(scanner); Iterator> batchScanner = spi.iterator; @@ -1129,7 +1131,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return ret; } } - + @Override public void closeScanner(String scanner) throws UnknownScanner, TException { UUID uuid = null; @@ -1138,7 +1140,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } catch (IllegalArgumentException e) { throw new UnknownScanner(e.getMessage()); } - + try { if (scannerCache.asMap().remove(uuid) == null) { throw new UnknownScanner("Scanner never existed or no longer exists"); @@ -1149,7 +1151,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e.toString()); } } - + @Override public void updateAndFlush(ByteBuffer login, String tableName, Map> cells) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1165,15 +1167,15 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionMRE(e); } } - + private static final ColumnVisibility EMPTY_VIS = new ColumnVisibility(); - + private void addCellsToWriter(Map> cells, BatchWriterPlusException bwpe) { if (bwpe.exception != null) return; - + HashMap vizMap = new HashMap(); - + for (Map.Entry> entry : cells.entrySet()) { Mutation m = new Mutation(ByteBufferUtil.toBytes(entry.getKey())); addUpdatesToMutation(vizMap, m, entry.getValue()); @@ -1184,7 +1186,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } } } - + private void addUpdatesToMutation(HashMap vizMap, Mutation m, List cu) { for (ColumnUpdate update : cu) { ColumnVisibility viz = EMPTY_VIS; @@ -1209,7 +1211,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } } } - + private static ColumnVisibility getCahcedCV(HashMap vizMap, byte[] cv) { ColumnVisibility viz; Text vizText = new Text(cv); @@ -1219,7 +1221,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } return viz; } - + @Override public String createWriter(ByteBuffer login, String tableName, WriterOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { @@ -1233,7 +1235,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public void update(String writer, Map> cells) throws TException { try { @@ -1243,7 +1245,7 @@ public class ProxyServer implements AccumuloProxy.Iface { // just drop it, this is a oneway thrift call and throwing a TException seems to make all subsequent thrift calls fail } } - + @Override public void flush(String writer) throws UnknownWriter, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException { try { @@ -1259,7 +1261,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e); } } - + @Override public void closeWriter(String writer) throws UnknownWriter, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException { try { @@ -1276,7 +1278,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e); } } - + private BatchWriterPlusException getWriter(String writer) throws UnknownWriter { UUID uuid = null; try { @@ -1284,14 +1286,14 @@ public class ProxyServer implements AccumuloProxy.Iface { } catch (IllegalArgumentException iae) { throw new UnknownWriter(iae.getMessage()); } - + BatchWriterPlusException bwpe = writerCache.getIfPresent(uuid); if (bwpe == null) { throw new UnknownWriter("Writer never existed or no longer exists"); } return bwpe; } - + private BatchWriterPlusException getWriter(ByteBuffer login, String tableName, WriterOptions opts) throws Exception { BatchWriterConfig cfg = new BatchWriterConfig(); if (opts != null) { @@ -1311,7 +1313,7 @@ public class ProxyServer implements AccumuloProxy.Iface { result.writer = getConnector(login).createBatchWriter(tableName, cfg); return result; } - + private org.apache.accumulo.core.client.Durability getDurability(Durability durability) { switch (durability) { case DEFAULT: @@ -1331,11 +1333,11 @@ public class ProxyServer implements AccumuloProxy.Iface { private IteratorSetting getIteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting setting) { return new IteratorSetting(setting.priority, setting.name, setting.iteratorClass, setting.getProperties()); } - + private IteratorScope getIteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope scope) { return IteratorScope.valueOf(scope.toString().toLowerCase()); } - + private EnumSet getIteratorScopes(Set scopes) { EnumSet scopes_ = EnumSet.noneOf(IteratorScope.class); for (org.apache.accumulo.proxy.thrift.IteratorScope scope : scopes) { @@ -1343,7 +1345,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } return scopes_; } - + private EnumSet getProxyIteratorScopes(Set scopes) { EnumSet scopes_ = EnumSet.noneOf(org.apache.accumulo.proxy.thrift.IteratorScope.class); for (IteratorScope scope : scopes) { @@ -1351,7 +1353,7 @@ public class ProxyServer implements AccumuloProxy.Iface { } return scopes_; } - + @Override public void attachIterator(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.IteratorSetting setting, Set scopes) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1362,7 +1364,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void checkIteratorConflicts(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.IteratorSetting setting, Set scopes) throws org.apache.accumulo.proxy.thrift.AccumuloException, @@ -1373,7 +1375,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public void cloneTable(ByteBuffer login, String tableName, String newTableName, boolean flush, Map propertiesToSet, Set propertiesToExclude) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1381,28 +1383,28 @@ public class ProxyServer implements AccumuloProxy.Iface { try { propertiesToExclude = propertiesToExclude == null ? new HashSet() : propertiesToExclude; propertiesToSet = propertiesToSet == null ? new HashMap() : propertiesToSet; - + getConnector(login).tableOperations().clone(tableName, newTableName, flush, propertiesToSet, propertiesToExclude); } catch (Exception e) { handleExceptionTEE(e); } } - + @Override public void exportTable(ByteBuffer login, String tableName, String exportDir) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { - + try { getConnector(login).tableOperations().exportTable(tableName, exportDir); } catch (Exception e) { handleExceptionTNF(e); } } - + @Override public void importTable(ByteBuffer login, String tableName, String importDir) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableExistsException, TException { - + try { getConnector(login).tableOperations().importTable(tableName, importDir); } catch (TableExistsException e) { @@ -1411,7 +1413,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public org.apache.accumulo.proxy.thrift.IteratorSetting getIteratorSetting(ByteBuffer login, String tableName, String iteratorName, org.apache.accumulo.proxy.thrift.IteratorScope scope) throws org.apache.accumulo.proxy.thrift.AccumuloException, @@ -1424,7 +1426,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public Map> listIterators(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1441,7 +1443,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + @Override public void removeIterator(ByteBuffer login, String tableName, String iterName, Set scopes) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1452,7 +1454,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public Set splitRangeByTablets(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.Range range, int maxSplits) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1469,11 +1471,11 @@ public class ProxyServer implements AccumuloProxy.Iface { return null; } } - + private org.apache.accumulo.proxy.thrift.Range getRange(Range r) { return new org.apache.accumulo.proxy.thrift.Range(getProxyKey(r.getStartKey()), r.isStartKeyInclusive(), getProxyKey(r.getEndKey()), r.isEndKeyInclusive()); } - + private org.apache.accumulo.proxy.thrift.Key getProxyKey(Key k) { if (k == null) return null; @@ -1482,11 +1484,11 @@ public class ProxyServer implements AccumuloProxy.Iface { result.setTimestamp(k.getTimestamp()); return result; } - + private Range getRange(org.apache.accumulo.proxy.thrift.Range range) { return new Range(Util.fromThrift(range.start), Util.fromThrift(range.stop)); } - + @Override public void importDirectory(ByteBuffer login, String tableName, String importDir, String failureDir, boolean setTime) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException, @@ -1497,12 +1499,12 @@ public class ProxyServer implements AccumuloProxy.Iface { handleExceptionTNF(e); } } - + @Override public org.apache.accumulo.proxy.thrift.Range getRowRange(ByteBuffer row) throws TException { return getRange(new Range(ByteBufferUtil.toText(row))); } - + @Override public org.apache.accumulo.proxy.thrift.Key getFollowing(org.apache.accumulo.proxy.thrift.Key key, org.apache.accumulo.proxy.thrift.PartialKey part) throws TException { @@ -1511,7 +1513,7 @@ public class ProxyServer implements AccumuloProxy.Iface { Key followingKey = key_.followingKey(part_); return getProxyKey(followingKey); } - + @Override public void pingTabletServer(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { @@ -1521,7 +1523,7 @@ public class ProxyServer implements AccumuloProxy.Iface { handleException(e); } } - + @Override public ByteBuffer login(String principal, Map loginProperties) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { try { @@ -1535,7 +1537,7 @@ public class ProxyServer implements AccumuloProxy.Iface { throw new TException(e); } } - + private AuthenticationToken getToken(String principal, Map properties) throws AccumuloSecurityException, AccumuloException { AuthenticationToken.Properties props = new AuthenticationToken.Properties(); props.putAllStrings(properties); @@ -1550,7 +1552,7 @@ public class ProxyServer implements AccumuloProxy.Iface { token.init(props); return token; } - + @Override public boolean testTableClassLoad(ByteBuffer login, String tableName, String className, String asTypeName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1562,7 +1564,7 @@ public class ProxyServer implements AccumuloProxy.Iface { return false; } } - + @Override public String createConditionalWriter(ByteBuffer login, String tableName, ConditionalWriterOptions options) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, @@ -1580,81 +1582,81 @@ public class ProxyServer implements AccumuloProxy.Iface { cwc.setAuthorizations(getAuthorizations(options.getAuthorizations())); if (options.isSetDurability() && options.getDurability() != null) cwc.setDurability(getDurability(options.getDurability())); - + ConditionalWriter cw = getConnector(login).createConditionalWriter(tableName, cwc); - + UUID id = UUID.randomUUID(); - + conditionalWriterCache.put(id, cw); - + return id.toString(); } catch (Exception e) { handleExceptionTNF(e); return null; } } - + @Override public Map updateRowsConditionally(String conditionalWriter, Map updates) throws UnknownWriter, org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException { - + ConditionalWriter cw = conditionalWriterCache.getIfPresent(UUID.fromString(conditionalWriter)); - + if (cw == null) { throw new UnknownWriter(); } - + try { HashMap vizMap = new HashMap(); - + ArrayList cmuts = new ArrayList(updates.size()); for (Entry cu : updates.entrySet()) { ConditionalMutation cmut = new ConditionalMutation(ByteBufferUtil.toBytes(cu.getKey())); - + for (Condition tcond : cu.getValue().conditions) { org.apache.accumulo.core.data.Condition cond = new org.apache.accumulo.core.data.Condition(tcond.column.getColFamily(), tcond.column.getColQualifier()); - + if (tcond.getColumn().getColVisibility() != null && tcond.getColumn().getColVisibility().length > 0) { cond.setVisibility(getCahcedCV(vizMap, tcond.getColumn().getColVisibility())); } - + if (tcond.isSetValue()) cond.setValue(tcond.getValue()); - + if (tcond.isSetTimestamp()) cond.setTimestamp(tcond.getTimestamp()); - + if (tcond.isSetIterators()) { cond.setIterators(getIteratorSettings(tcond.getIterators()).toArray(new IteratorSetting[tcond.getIterators().size()])); } - + cmut.addCondition(cond); } - + addUpdatesToMutation(vizMap, cmut, cu.getValue().updates); - + cmuts.add(cmut); } - + Iterator results = cw.write(cmuts.iterator()); - + HashMap resultMap = new HashMap(); - + while (results.hasNext()) { Result result = results.next(); ByteBuffer row = ByteBuffer.wrap(result.getMutation().getRow()); ConditionalStatus status = ConditionalStatus.valueOf(result.getStatus().name()); resultMap.put(row, status); } - + return resultMap; } catch (Exception e) { handleException(e); return null; } } - + @Override public void closeConditionalWriter(String conditionalWriter) throws TException { ConditionalWriter cw = conditionalWriterCache.getIfPresent(UUID.fromString(conditionalWriter)); @@ -1663,12 +1665,12 @@ public class ProxyServer implements AccumuloProxy.Iface { conditionalWriterCache.invalidate(UUID.fromString(conditionalWriter)); } } - + @Override public ConditionalStatus updateRowConditionally(ByteBuffer login, String tableName, ByteBuffer row, ConditionalUpdates updates) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { - + String cwid = createConditionalWriter(login, tableName, new ConditionalWriterOptions()); try { return updateRowsConditionally(cwid, Collections.singletonMap(row, updates)).get(row); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java ---------------------------------------------------------------------- diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java b/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java index 4850c19..99ebb38 100644 --- a/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java +++ b/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java @@ -42,14 +42,14 @@ import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TTransportException; public class TestProxyClient { - + protected AccumuloProxy.Client proxy; protected TTransport transport; - + public TestProxyClient(String host, int port) throws TTransportException { this(host, port, new TCompactProtocol.Factory()); } - + public TestProxyClient(String host, int port, TProtocolFactory protoFactory) throws TTransportException { final TSocket socket = new TSocket(host, port); socket.setTimeout(600000); @@ -58,41 +58,41 @@ public class TestProxyClient { proxy = new AccumuloProxy.Client(protocol); transport.open(); } - + public AccumuloProxy.Client proxy() { return proxy; } - + public static void main(String[] args) throws Exception { - + TestProxyClient tpc = new TestProxyClient("localhost", 42424); String principal = "root"; Map props = new TreeMap(); props.put("password", "secret"); - + System.out.println("Logging in"); ByteBuffer login = tpc.proxy.login(principal, props); - + System.out.println("Creating user: "); if (!tpc.proxy().listLocalUsers(login).contains("testuser")) { tpc.proxy().createLocalUser(login, "testuser", ByteBuffer.wrap("testpass".getBytes(UTF_8))); } System.out.println("UserList: " + tpc.proxy().listLocalUsers(login)); - + System.out.println("Listing: " + tpc.proxy().listTables(login)); - + System.out.println("Deleting: "); String testTable = "testtableOMGOMGOMG"; - + System.out.println("Creating: "); - + if (tpc.proxy().tableExists(login, testTable)) tpc.proxy().deleteTable(login, testTable); - + tpc.proxy().createTable(login, testTable, true, TimeType.MILLIS); - + System.out.println("Listing: " + tpc.proxy().listTables(login)); - + System.out.println("Writing: "); Date start = new Date(); Date then = new Date(); @@ -104,7 +104,7 @@ public class TestProxyClient { ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes(UTF_8)), ByteBuffer.wrap(("cq" + i).getBytes(UTF_8))); update.setValue(Util.randStringBuffer(10)); mutations.put(ByteBuffer.wrap(result.getBytes(UTF_8)), Collections.singletonList(update)); - + if (i % 1000 == 0) { tpc.proxy().updateAndFlush(login, testTable, mutations); mutations.clear(); @@ -113,12 +113,12 @@ public class TestProxyClient { tpc.proxy().updateAndFlush(login, testTable, mutations); Date end = new Date(); System.out.println(" End of writing: " + (end.getTime() - start.getTime())); - + tpc.proxy().deleteTable(login, testTable); tpc.proxy().createTable(login, testTable, true, TimeType.MILLIS); - + // Thread.sleep(1000); - + System.out.println("Writing async: "); start = new Date(); then = new Date(); @@ -134,7 +134,7 @@ public class TestProxyClient { tpc.proxy().update(writer, mutations); mutations.clear(); } - + end = new Date(); System.out.println(" End of writing: " + (end.getTime() - start.getTime())); start = end; @@ -142,29 +142,29 @@ public class TestProxyClient { tpc.proxy().closeWriter(writer); end = new Date(); System.out.println(" End of closing: " + (end.getTime() - start.getTime())); - + System.out.println("Reading: "); - + String regex = "cf1.*"; - + IteratorSetting is = new IteratorSetting(50, regex, RegExFilter.class); RegExFilter.setRegexs(is, null, regex, null, null, false); - + String cookie = tpc.proxy().createScanner(login, testTable, null); - + int i = 0; start = new Date(); then = new Date(); boolean hasNext = true; - + int k = 1000; while (hasNext) { ScanResult kvList = tpc.proxy().nextK(cookie, k); - + Date now = new Date(); System.out.println(i + " " + (now.getTime() - then.getTime())); then = now; - + i += kvList.getResultsSize(); // for (TKeyValue kv:kvList.getResults()) System.out.println(new Key(kv.getKey())); hasNext = kvList.isMore(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/proxy/src/main/java/org/apache/accumulo/proxy/Util.java ---------------------------------------------------------------------- diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Util.java b/proxy/src/main/java/org/apache/accumulo/proxy/Util.java index bc0db72..29e5a40 100644 --- a/proxy/src/main/java/org/apache/accumulo/proxy/Util.java +++ b/proxy/src/main/java/org/apache/accumulo/proxy/Util.java @@ -26,35 +26,35 @@ import org.apache.accumulo.proxy.thrift.IteratorSetting; import org.apache.accumulo.proxy.thrift.Key; public class Util { - + private static Random random = new Random(0); - + public static String randString(int numbytes) { return new BigInteger(numbytes * 5, random).toString(32); } - + public static ByteBuffer randStringBuffer(int numbytes) { return ByteBuffer.wrap(new BigInteger(numbytes * 5, random).toString(32).getBytes(UTF_8)); } - + public static IteratorSetting iteratorSetting2ProxyIteratorSetting(org.apache.accumulo.core.client.IteratorSetting is) { return new IteratorSetting(is.getPriority(), is.getName(), is.getIteratorClass(), is.getOptions()); } - + public static Key toThrift(org.apache.accumulo.core.data.Key key) { Key pkey = new Key(ByteBuffer.wrap(key.getRow().getBytes()), ByteBuffer.wrap(key.getColumnFamily().getBytes()), ByteBuffer.wrap(key.getColumnQualifier() .getBytes()), ByteBuffer.wrap(key.getColumnVisibility().getBytes())); pkey.setTimestamp(key.getTimestamp()); return pkey; } - + public static org.apache.accumulo.core.data.Key fromThrift(Key pkey) { if (pkey == null) return null; - return new org.apache.accumulo.core.data.Key(deNullify(pkey.getRow()), deNullify(pkey.getColFamily()), deNullify(pkey.getColQualifier()), deNullify(pkey.getColVisibility()), - pkey.getTimestamp()); + return new org.apache.accumulo.core.data.Key(deNullify(pkey.getRow()), deNullify(pkey.getColFamily()), deNullify(pkey.getColQualifier()), + deNullify(pkey.getColVisibility()), pkey.getTimestamp()); } - + protected static byte[] deNullify(byte[] in) { if (in == null) return new byte[0];