accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1410144 - in /accumulo/trunk: ./ test/ test/src/ test/src/main/ test/src/main/java/ test/src/main/java/org/ test/src/main/java/org/apache/ test/src/main/java/org/apache/accumulo/ test/src/main/java/org/apache/accumulo/test/ test/src/test/ ...
Date Fri, 16 Nov 2012 01:46:18 GMT
Author: kturner
Date: Fri Nov 16 01:46:17 2012
New Revision: 1410144

URL: http://svn.apache.org/viewvc?rev=1410144&view=rev
Log:
ACCUMULO-14 initial checkin of MiniAccumuloCluster

Added:
    accumulo/trunk/test/pom.xml
    accumulo/trunk/test/src/
    accumulo/trunk/test/src/main/
    accumulo/trunk/test/src/main/java/
    accumulo/trunk/test/src/main/java/org/
    accumulo/trunk/test/src/main/java/org/apache/
    accumulo/trunk/test/src/main/java/org/apache/accumulo/
    accumulo/trunk/test/src/main/java/org/apache/accumulo/test/
    accumulo/trunk/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java
    accumulo/trunk/test/src/test/
    accumulo/trunk/test/src/test/java/
    accumulo/trunk/test/src/test/java/org/
    accumulo/trunk/test/src/test/java/org/apache/
    accumulo/trunk/test/src/test/java/org/apache/accumulo/
    accumulo/trunk/test/src/test/java/org/apache/accumulo/test/
    accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java
Modified:
    accumulo/trunk/pom.xml
    accumulo/trunk/test/   (props changed)

Modified: accumulo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/pom.xml?rev=1410144&r1=1410143&r2=1410144&view=diff
==============================================================================
--- accumulo/trunk/pom.xml (original)
+++ accumulo/trunk/pom.xml Fri Nov 16 01:46:17 2012
@@ -53,6 +53,7 @@
     <module>start</module>
     <module>examples</module>
     <module>assemble</module>
+    <module>test</module>
   </modules>
 
   <build>
@@ -491,7 +492,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
-        <version>4.4</version>
+        <version>4.11</version>
         <scope>test</scope>
       </dependency>
 
@@ -549,6 +550,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.accumulo</groupId>
+        <artifactId>accumulo-test</artifactId>
+        <version>1.5.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.accumulo</groupId>
         <artifactId>examples-simple</artifactId>
         <version>1.5.0-SNAPSHOT</version>
       </dependency>

Propchange: accumulo/trunk/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 16 01:46:17 2012
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Added: accumulo/trunk/test/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/pom.xml?rev=1410144&view=auto
==============================================================================
--- accumulo/trunk/test/pom.xml (added)
+++ accumulo/trunk/test/pom.xml Fri Nov 16 01:46:17 2012
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <parent>
+    <groupId>org.apache.accumulo</groupId>
+    <artifactId>accumulo</artifactId>
+    <version>1.5.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>accumulo-test</artifactId>
+  <name>accumulo-test</name>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-jar-plugin</artifactId>
+          <configuration>
+            <outputDirectory>../lib</outputDirectory>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestSections>
+              <manifestSection>
+                <name>accumulo/test/</name>
+                <manifestEntries>
+                  <Sealed>true</Sealed>
+                </manifestEntries>
+              </manifestSection>
+            </manifestSections>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.accumulo</groupId>
+      <artifactId>accumulo-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.accumulo</groupId>
+      <artifactId>accumulo-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>zookeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-core</artifactId>
+    </dependency>
+
+  </dependencies>
+
+</project>

Added: accumulo/trunk/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java?rev=1410144&view=auto
==============================================================================
--- accumulo/trunk/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java (added)
+++ accumulo/trunk/test/src/main/java/org/apache/accumulo/test/MiniAccumuloCluster.java Fri
Nov 16 01:46:17 2012
@@ -0,0 +1,363 @@
+/**
+ * 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.
+ */
+package org.apache.accumulo.test;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.ServerSocket;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.TimerTask;
+
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.server.conf.ServerConfiguration;
+import org.apache.accumulo.server.master.Master;
+import org.apache.accumulo.server.tabletserver.TabletServer;
+import org.apache.accumulo.server.util.Initialize;
+import org.apache.accumulo.server.util.time.SimpleTimer;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+
+/**
+ * A utility class that will create Zookeeper and Accumulo processes that write all of their
data to a single local directory. This class makes it easy to test
+ * code against a real Accumulo instance. Its much more accurate for testing than MockAccumulo,
but much slower than MockAccumulo.
+ */
+public class MiniAccumuloCluster {
+  
+  private static final String INSTANCE_SECRET = "DONTTELL";
+  private static final String INSTANCE_NAME = "miniInstance";
+
+  private static class LogWriter extends Thread {
+    private BufferedReader in;
+    private BufferedWriter out;
+    
+    /**
+     * @param errorStream
+     * @param logDir
+     * @throws IOException
+     */
+    public LogWriter(InputStream stream, File logFile) throws IOException {
+      this.setDaemon(true);
+      this.in = new BufferedReader(new InputStreamReader(stream));
+      out = new BufferedWriter(new FileWriter(logFile));
+      
+      SimpleTimer.getInstance().schedule(new TimerTask() {
+        @Override
+        public void run() {
+          try {
+            flush();
+          } catch (IOException e) {
+            e.printStackTrace();
+          }
+        }
+      }, 1000, 1000);
+    }
+    
+    public synchronized void flush() throws IOException {
+      if (out != null)
+        out.flush();
+    }
+
+    public void run() {
+      String line;
+      
+      try {
+        while ((line = in.readLine()) != null) {
+          out.append(line);
+          out.append("\n");
+        }
+        
+        synchronized (this) {
+          out.close();
+          out = null;
+          in.close();
+        }
+
+      } catch (IOException e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+  private File baseDir;
+  private File libDir;
+  private File confDir;
+  private File zooKeeperDir;
+  private File accumuloDir;
+  private File zooCfgFile;
+  private File logDir;
+  private File walogDir;
+  
+  private Process zooKeeperProcess;
+  private Process masterProcess;
+  private Process tabletServerProcess;
+  private Process loggerProcess;
+
+  private int zooKeeperPort;
+  
+  private List<LogWriter> logWriters = new ArrayList<MiniAccumuloCluster.LogWriter>();
+  private String rootPassword;
+
+
+
+  private int getRandomFreePort() {
+    Random r = new Random();
+    int count = 0;
+    
+    while (count < 13) {
+      int port = r.nextInt((1 << 16) - 1024) + 1024;
+      
+      ServerSocket so = null;
+      try {
+        so = new ServerSocket(port);
+        so.setReuseAddress(true);
+        return port;
+      } catch (IOException ioe) {
+        
+      } finally {
+        if (so != null)
+          try {
+            so.close();
+          } catch (IOException e) {}
+      }
+      
+    }
+    
+    throw new RuntimeException("Unable to find port");
+  }
+
+  private Process exec(Class<? extends Object> clazz, String... args) throws IOException
{
+    String javaHome = System.getProperty("java.home");
+    String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
+    String classpath = System.getProperty("java.class.path");
+    
+    classpath = confDir.getAbsolutePath() + File.pathSeparator + classpath;
+
+    String className = clazz.getCanonicalName();
+    
+    ArrayList<String> argList = new ArrayList<String>();
+    
+    argList.addAll(Arrays.asList(javaBin, "-cp", classpath, "-Xmx128m", "-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=75",
+        className));
+    argList.addAll(Arrays.asList(args));
+    
+    ProcessBuilder builder = new ProcessBuilder(argList);
+    
+    builder.environment().put("ACCUMULO_HOME", baseDir.getAbsolutePath());
+    builder.environment().put("ACCUMULO_LOG_DIR", logDir.getAbsolutePath());
+
+    Process process = builder.start();
+
+    LogWriter lw;
+    lw = new LogWriter(process.getErrorStream(), new File(logDir, clazz.getSimpleName() +
"_" + process.hashCode() + ".err"));
+    logWriters.add(lw);
+    lw.start();
+    lw = new LogWriter(process.getInputStream(), new File(logDir, clazz.getSimpleName() +
"_" + process.hashCode() + ".out"));
+    logWriters.add(lw);
+    lw.start();
+
+    return process;
+  }
+
+  private void init() {
+
+    Level prevLevel = Logger.getLogger("org.apache").getLevel();
+    Logger.getLogger("org.apache").setLevel(Level.ERROR);
+
+    ServerConfiguration.getSiteConfiguration().set(Property.INSTANCE_DFS_URI, "file:///");
+    ServerConfiguration.getSiteConfiguration().set(Property.INSTANCE_DFS_DIR, accumuloDir.getAbsolutePath());
+    ServerConfiguration.getSiteConfiguration().set(Property.INSTANCE_ZK_HOST, "localhost:"
+ zooKeeperPort);
+    ServerConfiguration.getSiteConfiguration().set(Property.INSTANCE_SECRET, INSTANCE_SECRET);
+    
+    Initialize.main(new String[] {"--instance-name", INSTANCE_NAME, "--password", rootPassword});
+    
+    Logger.getLogger("org.apache").setLevel(prevLevel);
+  }
+
+  private void appendProp(FileWriter fileWriter, Property key, String value, Map<String,String>
siteConfig) throws IOException {
+    appendProp(fileWriter, key.getKey(), value, siteConfig);
+  }
+
+  private void appendProp(FileWriter fileWriter, String key, String value, Map<String,String>
siteConfig) throws IOException {
+    if (!siteConfig.containsKey(key))
+      fileWriter.append("<property><name>" + key + "</name><value>"
+ value + "</value></property>\n");
+  }
+
+  /**
+   * 
+   * @param dir
+   *          An empty or nonexistant temp directoy that Accumulo and Zookeeper can store
data in. Creating the directory is left to the user. Java 7, Guava,
+   *          and Junit provide methods for creating temporary directories.
+   * @param rootPassword
+   *          Initial root password for instance.
+   * @param siteConfig
+   *          Any system properties that needs to be set before Accumulo processes are started.
These are properties that would normally be placed in
+   *          accumulo-site.xml
+   * @throws IOException
+   */
+
+  public MiniAccumuloCluster(File dir, String rootPassword, Map<String,String> siteConfig)
throws IOException {
+
+    if (dir.exists() && !dir.isDirectory())
+      throw new IllegalArgumentException("Must pass in directory, " + dir + " is a file");
+    
+    if (dir.exists() && dir.list().length != 0)
+      throw new IllegalArgumentException("Directory " + dir + " is not empty");
+    
+    this.rootPassword = rootPassword;
+
+    baseDir = dir;
+    libDir = new File(dir, "lib");
+    confDir = new File(dir, "conf");
+    accumuloDir = new File(dir, "accumulo");
+    zooKeeperDir = new File(dir, "zookeeper");
+    logDir = new File(dir, "logs");
+    walogDir = new File(dir, "walogs");
+    
+    confDir.mkdirs();
+    accumuloDir.mkdirs();
+    zooKeeperDir.mkdirs();
+    logDir.mkdirs();
+    walogDir.mkdirs();
+    libDir.mkdirs();
+    
+    zooKeeperPort = getRandomFreePort();
+
+    File siteFile = new File(confDir, "accumulo-site.xml");
+    
+    FileWriter fileWriter = new FileWriter(siteFile);
+    fileWriter.append("<configuration>\n");
+    
+    appendProp(fileWriter, Property.INSTANCE_DFS_URI, "file:///", siteConfig);
+    appendProp(fileWriter, Property.INSTANCE_DFS_DIR, accumuloDir.getAbsolutePath(), siteConfig);
+    appendProp(fileWriter, Property.INSTANCE_ZK_HOST, "localhost:" + zooKeeperPort, siteConfig);
+    appendProp(fileWriter, Property.INSTANCE_SECRET, INSTANCE_SECRET, siteConfig);
+    appendProp(fileWriter, Property.MASTER_CLIENTPORT, "" + getRandomFreePort(), siteConfig);
+    appendProp(fileWriter, Property.TSERV_CLIENTPORT, "" + getRandomFreePort(), siteConfig);
+    appendProp(fileWriter, Property.LOGGER_DIR, walogDir.getAbsolutePath(), siteConfig);
+    appendProp(fileWriter, Property.TSERV_DATACACHE_SIZE, "10M", siteConfig);
+    appendProp(fileWriter, Property.TSERV_INDEXCACHE_SIZE, "10M", siteConfig);
+    appendProp(fileWriter, Property.TSERV_MAXMEM, "50M", siteConfig);
+    appendProp(fileWriter, Property.TSERV_WALOG_MAX_SIZE, "100M", siteConfig);
+    appendProp(fileWriter, Property.TSERV_NATIVEMAP_ENABLED, "false", siteConfig);
+    // since there is a small amount of memory, check more frequently for majc... setting
may not be needed in 1.5
+    appendProp(fileWriter, Property.TSERV_MAJC_DELAY, "3", siteConfig);
+    appendProp(fileWriter, Property.GENERAL_CLASSPATHS, libDir.getAbsolutePath(), siteConfig);
+    appendProp(fileWriter, Property.GENERAL_DYNAMIC_CLASSPATHS, libDir.getAbsolutePath(),
siteConfig);
+
+    for (Entry<String,String> entry : siteConfig.entrySet())
+      fileWriter.append("<property><name>" + entry.getKey() + "</name><value>"
+ entry.getValue() + "</value></property>\n");
+    fileWriter.append("</configuration>\n");
+    fileWriter.close();
+    
+    zooCfgFile = new File(confDir, "zoo.cfg");
+    fileWriter = new FileWriter(zooCfgFile);
+    fileWriter.append("tickTime=1000\n");
+    fileWriter.append("initLimit=10\n");
+    fileWriter.append("syncLimit=5\n");
+    fileWriter.append("clientPort=" + zooKeeperPort + "\n");
+    fileWriter.append("maxClientCnxns=100\n");
+    fileWriter.append("dataDir=" + zooKeeperDir.getAbsolutePath() + "\n");
+    fileWriter.close();
+    
+  }
+
+  /**
+   * Starts Accumulo and Zookeeper processes. Can only be called once.
+   * 
+   * @throws IOException
+   * @throws InterruptedException
+   * @throws IllegalStateException
+   *           if already started
+   */
+
+  public void start() throws IOException, InterruptedException {
+    if (zooKeeperProcess != null)
+      throw new IllegalStateException("Already started");
+
+    Runtime.getRuntime().addShutdownHook(new Thread() {
+      public void run() {
+        try {
+          MiniAccumuloCluster.this.stop();
+        } catch (IOException e) {
+          e.printStackTrace();
+        } catch (InterruptedException e) {
+          e.printStackTrace();
+        }
+      }
+    });
+
+    zooKeeperProcess = exec(ZooKeeperServerMain.class, zooCfgFile.getAbsolutePath());
+   
+    // sleep a little bit to let zookeeper come up before calling init, seems to work better
+    UtilWaitThread.sleep(250);
+
+    init();
+   
+    tabletServerProcess = exec(TabletServer.class);
+    masterProcess = exec(Master.class);
+  }
+
+  /**
+   * @return Accumulo instance name
+   */
+
+  public String getInstanceName() {
+    return INSTANCE_NAME;
+  }
+  
+  /**
+   * @return zookeeper connection string
+   */
+
+  public String getZookeepers() {
+    return "localhost:" + zooKeeperPort;
+  }
+
+  /**
+   * Stops Accumulo and Zookeeper processes. If stop is not called, there is a shutdown hook
that is setup to kill the processes. Howerver its probably best to
+   * call stop in a finally block as soon as possible.
+   * 
+   * @throws IOException
+   * @throws InterruptedException
+   */
+
+  public void stop() throws IOException, InterruptedException {
+    if (zooKeeperProcess != null)
+      zooKeeperProcess.destroy();
+    if (masterProcess != null)
+      masterProcess.destroy();
+    if (tabletServerProcess != null)
+      tabletServerProcess.destroy();
+    if (loggerProcess != null)
+      loggerProcess.destroy();
+    
+    for (LogWriter lw : logWriters)
+      lw.flush();
+  }
+}

Added: accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java?rev=1410144&view=auto
==============================================================================
--- accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java
(added)
+++ accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java
Fri Nov 16 01:46:17 2012
@@ -0,0 +1,137 @@
+/**
+ * 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.
+ */
+package org.apache.accumulo.test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map.Entry;
+import java.util.UUID;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.ZooKeeperInstance;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.LongCombiner;
+import org.apache.accumulo.core.iterators.user.SummingCombiner;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.core.security.TablePermission;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+
+public class MiniAccumuloClusterTest {
+  
+  public static TemporaryFolder folder = new TemporaryFolder();
+  
+  private static MiniAccumuloCluster accumulo;
+
+  @BeforeClass
+  public static void setupMiniCluster() throws Exception {
+
+    folder.create();
+    
+    accumulo = new MiniAccumuloCluster(folder.getRoot(), "superSecret", new HashMap<String,String>());
+    
+    accumulo.start();
+    
+  }
+
+  @Test(timeout = 30000)
+  public void test() throws Exception {
+    Connector conn = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZookeepers()).getConnector("root",
"superSecret");
+    
+    conn.tableOperations().create("table1");
+    
+    conn.securityOperations().createUser("user1", "pass1".getBytes(), new Authorizations("A",
"B"));
+    conn.securityOperations().grantTablePermission("user1", "table1", TablePermission.WRITE);
+    conn.securityOperations().grantTablePermission("user1", "table1", TablePermission.READ);
+    
+    IteratorSetting is = new IteratorSetting(10, SummingCombiner.class);
+    SummingCombiner.setEncodingType(is, LongCombiner.Type.STRING);
+    SummingCombiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column("META",
"COUNT")));
+    
+    conn.tableOperations().attachIterator("table1", is);
+
+    Connector uconn = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZookeepers()).getConnector("user1",
"pass1");
+    
+    BatchWriter bw = uconn.createBatchWriter("table1", new BatchWriterConfig());
+    
+    UUID uuid = UUID.randomUUID();
+    
+    Mutation m = new Mutation(uuid.toString());
+    m.put("META", "SIZE", new ColumnVisibility("A|B"), "8");
+    m.put("META", "CRC", new ColumnVisibility("A|B"), "456");
+    m.put("META", "COUNT", new ColumnVisibility("A|B"), "1");
+    m.put("DATA", "IMG", new ColumnVisibility("A&B"), "ABCDEFGH");
+    
+    bw.addMutation(m);
+    bw.flush();
+    
+    m = new Mutation(uuid.toString());
+    m.put("META", "COUNT", new ColumnVisibility("A|B"), "1");
+    m.put("META", "CRC", new ColumnVisibility("A|B"), "123");
+    bw.addMutation(m);
+
+    bw.close();
+    
+    int count = 0;
+    Scanner scanner = uconn.createScanner("table1", new Authorizations("A"));
+    for (Entry<Key,Value> entry : scanner) {
+      if (entry.getKey().getColumnQualifierData().toString().equals("COUNT")) {
+        Assert.assertEquals("2", entry.getValue().toString());
+      } else if (entry.getKey().getColumnQualifierData().toString().equals("SIZE")) {
+        Assert.assertEquals("8", entry.getValue().toString());
+      } else if (entry.getKey().getColumnQualifierData().toString().equals("CRC")) {
+        Assert.assertEquals("123", entry.getValue().toString());
+      } else {
+        Assert.assertTrue(false);
+      }
+      count++;
+    }
+    
+    Assert.assertEquals(3, count);
+    
+    count = 0;
+    scanner = uconn.createScanner("table1", new Authorizations("A", "B"));
+    for (Entry<Key,Value> entry : scanner) {
+      if (entry.getKey().getColumnQualifierData().toString().equals("IMG")) {
+        Assert.assertEquals("ABCDEFGH", entry.getValue().toString());
+      }
+      count++;
+    }
+    
+    Assert.assertEquals(4, count);
+    
+    conn.tableOperations().delete("table1");
+  }
+  
+  @AfterClass
+  public static void tearDownMiniCluster() throws Exception {
+    accumulo.stop();
+    folder.delete();
+  }
+  
+}



Mime
View raw message