You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/06/05 20:48:20 UTC

[1/8] git commit: ACCUMULO-378 More rb changes.

Repository: accumulo
Updated Branches:
  refs/heads/ACCUMULO-378 856f23590 -> 028b78000


ACCUMULO-378 More rb changes.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/ad4ea6b2
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/ad4ea6b2
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/ad4ea6b2

Branch: refs/heads/ACCUMULO-378
Commit: ad4ea6b248f49d5c79390d2e99f9804c0606ded3
Parents: 856f235
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 01:31:40 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 01:31:40 2014 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/core/Constants.java     |  5 ----
 .../client/admin/ReplicationOperations.java     | 21 ++++++++++++---
 .../core/client/impl/ReplicationClient.java     |  1 -
 .../client/impl/ReplicationOperationsImpl.java  |  8 ++++++
 .../core/replication/ReplicationConstants.java  | 28 ++++++++++++++++++++
 .../apache/accumulo/server/init/Initialize.java |  5 ++--
 .../DistributedWorkQueueWorkAssigner.java       |  4 +--
 .../MasterReplicationCoordinator.java           |  4 +--
 .../replication/SequentialWorkAssigner.java     |  4 +--
 .../replication/UnorderedWorkAssigner.java      |  4 +--
 .../replication/SequentialWorkAssignerTest.java |  6 ++---
 .../replication/UnorderedWorkAssignerTest.java  |  5 ++--
 .../monitor/servlets/ReplicationServlet.java    |  4 +--
 .../apache/accumulo/tserver/TabletServer.java   |  3 ++-
 .../tserver/replication/ReplicationWorker.java  |  6 ++---
 .../replication/MultiTserverReplicationIT.java  |  3 ++-
 16 files changed, 80 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/core/src/main/java/org/apache/accumulo/core/Constants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/Constants.java b/core/src/main/java/org/apache/accumulo/core/Constants.java
index 795d6fe..3edba81 100644
--- a/core/src/main/java/org/apache/accumulo/core/Constants.java
+++ b/core/src/main/java/org/apache/accumulo/core/Constants.java
@@ -114,9 +114,4 @@ public class Constants {
   public static final String[] PATH_PROPERTY_ENV_VARS = new String[] {"ACCUMULO_HOME", "ACCUMULO_CONF_DIR"};
 
   public static final String HDFS_TABLES_DIR = "/tables";
-
-  // Constants for replication information in zookeeper
-  public static final String ZREPLICATION = "/replication";
-  public static final String ZREPLICATION_WORK_QUEUE = ZREPLICATION + "/workqueue";
-  public static final String ZREPLICATION_TSERVERS = ZREPLICATION + "/tservers";
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/core/src/main/java/org/apache/accumulo/core/client/admin/ReplicationOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/ReplicationOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/ReplicationOperations.java
index 5873f73..9267f67 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/ReplicationOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/ReplicationOperations.java
@@ -36,6 +36,13 @@ public interface ReplicationOperations {
    * @param name Name of the cluster, used for configuring replication on tables
    * @param system Type of system to be replicated to
    */
+  public void addPeer(String name, Class<? extends ReplicaSystem> system) throws AccumuloException, AccumuloSecurityException, PeerExistsException;
+
+  /**
+   * Defines a cluster with the given name using the given {@link ReplicaSystem}.
+   * @param name Name of the cluster, used for configuring replication on tables
+   * @param system Type of system to be replicated to
+   */
   public void addPeer(String name, ReplicaSystem system) throws AccumuloException, AccumuloSecurityException, PeerExistsException;
 
   /**
@@ -54,7 +61,8 @@ public interface ReplicationOperations {
   public void removePeer(String name) throws AccumuloException, AccumuloSecurityException, PeerNotFoundException;
 
   /**
-   * Waits for a table to be fully replicated.
+   * Waits for a table to be fully replicated, given the state of files pending replication for the provided table
+   * at the point in time which this method is invoked.
    * @param tableName The table to wait for
    * @throws AccumuloException
    * @throws AccumuloSecurityException
@@ -62,7 +70,9 @@ public interface ReplicationOperations {
   public void drain(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
 
   /**
-   * Waits for a table to be fully replicated as determined by the provided tables.
+   * Given the provided set of files that are pending replication for a table, wait for those
+   * files to be fully replicated to all configured peers. This allows for the accurate calculation
+   * when a table, at a given point in time, has been fully replicated.
    * @param tableName The table to wait for
    * @throws AccumuloException
    * @throws AccumuloSecurityException
@@ -70,7 +80,12 @@ public interface ReplicationOperations {
   public void drain(String tableName, Set<String> files) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
 
   /**
-   * Gets all of the referenced files for a table.
+   * Gets all of the referenced files for a table from the metadata table. The result of this method
+   * is intended to be directly supplied to {@link #drain(String, Set)}. This helps determine when all
+   * data from a given point in time has been fully replicated.
+   * <p>
+   * This also allows callers to get the {@link Set} of files for a table at some time, and later provide that
+   * {@link Set} to {@link #drain(String,Set)} to wait for all of those files to be replicated.
    * @param tableName
    * @throws TableNotFoundException
    */

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationClient.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationClient.java
index 13c027a..8f15839 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationClient.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.core.client.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
-import java.net.UnknownHostException;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
index 51a5367..8c50ecc 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
@@ -77,6 +77,14 @@ public class ReplicationOperationsImpl implements ReplicationOperations {
   }
 
   @Override
+  public void addPeer(String name, Class<? extends ReplicaSystem> system) throws AccumuloException, AccumuloSecurityException, PeerExistsException {
+    checkNotNull(name);
+    checkNotNull(system);
+
+    addPeer(name, system.getName());
+  }
+
+  @Override
   public void addPeer(String name, ReplicaSystem system) throws AccumuloException, AccumuloSecurityException, PeerExistsException {
     checkNotNull(name);
     checkNotNull(system);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/core/src/main/java/org/apache/accumulo/core/replication/ReplicationConstants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationConstants.java b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationConstants.java
new file mode 100644
index 0000000..517920c
--- /dev/null
+++ b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationConstants.java
@@ -0,0 +1,28 @@
+/*
+ * 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.core.replication;
+
+/**
+ * 
+ */
+public class ReplicationConstants {
+  // Constants for replication information in zookeeper
+  public static final String ZOO_BASE = "/replication";
+  public static final String ZOO_WORK_QUEUE = ZOO_BASE + "/workqueue";
+  public static final String ZOO_TSERVERS = ZOO_BASE + "/tservers";
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
index 1d9fb86..78fa4e7 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
@@ -50,6 +50,7 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.LogColumnFamily;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.security.SecurityUtil;
 import org.apache.accumulo.core.util.CachedConfiguration;
 import org.apache.accumulo.core.volume.VolumeConfiguration;
@@ -480,8 +481,8 @@ public class Initialize {
     zoo.putPersistentData(zkInstanceRoot + Constants.ZRECOVERY, ZERO_CHAR_ARRAY, NodeExistsPolicy.FAIL);
     zoo.putPersistentData(zkInstanceRoot + Constants.ZMONITOR, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL);
     zoo.putPersistentData(zkInstanceRoot + Constants.ZMONITOR_LOCK, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL);
-    zoo.putPersistentData(zkInstanceRoot + Constants.ZREPLICATION, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL);
-    zoo.putPersistentData(zkInstanceRoot + Constants.ZREPLICATION_TSERVERS, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL);
+    zoo.putPersistentData(zkInstanceRoot + ReplicationConstants.ZOO_BASE, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL);
+    zoo.putPersistentData(zkInstanceRoot + ReplicationConstants.ZOO_TSERVERS, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL);
   }
 
   private static String getInstanceNamePath(Opts opts) throws IOException, KeeperException, InterruptedException {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/master/src/main/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssigner.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssigner.java b/server/master/src/main/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssigner.java
index 4815305..234b153 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssigner.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssigner.java
@@ -20,7 +20,6 @@ import java.util.Collection;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -30,6 +29,7 @@ import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.protobuf.ProtobufUtil;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.ReplicationSchema.OrderSection;
 import org.apache.accumulo.core.replication.ReplicationSchema.WorkSection;
 import org.apache.accumulo.core.replication.ReplicationTarget;
@@ -114,7 +114,7 @@ public abstract class DistributedWorkQueueWorkAssigner implements WorkAssigner {
    * @param conf
    */
   protected void initializeWorkQueue(AccumuloConfiguration conf) {
-    workQueue = new DistributedWorkQueue(ZooUtil.getRoot(conn.getInstance()) + Constants.ZREPLICATION_WORK_QUEUE, conf);
+    workQueue = new DistributedWorkQueue(ZooUtil.getRoot(conn.getInstance()) + ReplicationConstants.ZOO_WORK_QUEUE, conf);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java b/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
index 974aaa9..11c04be 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
@@ -21,9 +21,9 @@ import java.util.Iterator;
 import java.util.Random;
 import java.util.Set;
 
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.thrift.ReplicationCoordinator;
 import org.apache.accumulo.core.replication.thrift.ReplicationCoordinatorErrorCode;
 import org.apache.accumulo.core.replication.thrift.ReplicationCoordinatorException;
@@ -83,7 +83,7 @@ public class MasterReplicationCoordinator implements ReplicationCoordinator.Ifac
     TServerInstance tserver = getRandomTServer(tservers, rand.nextInt(tservers.size()));
     String replServiceAddr;
     try {
-      replServiceAddr = new String(reader.getData(ZooUtil.getRoot(inst) + Constants.ZREPLICATION_TSERVERS + "/" + tserver.hostPort(), null), StandardCharsets.UTF_8);
+      replServiceAddr = new String(reader.getData(ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_TSERVERS + "/" + tserver.hostPort(), null), StandardCharsets.UTF_8);
     } catch (KeeperException | InterruptedException e) {
       log.error("Could not fetch repliation service port for tserver", e);
       throw new ReplicationCoordinatorException(ReplicationCoordinatorErrorCode.SERVICE_CONFIGURATION_UNAVAILABLE,

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java b/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java
index e56763e..4b2936c 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java
@@ -24,9 +24,9 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.ReplicationTarget;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.server.replication.DistributedWorkQueueWorkAssignerHelper;
@@ -137,7 +137,7 @@ public class SequentialWorkAssigner extends DistributedWorkQueueWorkAssigner {
         // tableID -> workKey
         Entry<String,String> entry = iter.next();
         // Null equates to the work for this target was finished
-        if (null == zooCache.get(ZooUtil.getRoot(instanceId) + Constants.ZREPLICATION_WORK_QUEUE + "/" + entry.getValue())) {
+        if (null == zooCache.get(ZooUtil.getRoot(instanceId) + ReplicationConstants.ZOO_WORK_QUEUE + "/" + entry.getValue())) {
           log.debug("Removing {} from work assignment state", entry.getValue());
           iter.remove();
           elementsRemoved++;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/master/src/main/java/org/apache/accumulo/master/replication/UnorderedWorkAssigner.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/UnorderedWorkAssigner.java b/server/master/src/main/java/org/apache/accumulo/master/replication/UnorderedWorkAssigner.java
index b6706ef..9042e2d 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/replication/UnorderedWorkAssigner.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/replication/UnorderedWorkAssigner.java
@@ -20,9 +20,9 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.ReplicationTarget;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
@@ -133,7 +133,7 @@ public class UnorderedWorkAssigner extends DistributedWorkQueueWorkAssigner {
     while (work.hasNext()) {
       String filename = work.next();
       // Null equates to the work was finished
-      if (null == zooCache.get(ZooUtil.getRoot(instanceId) + Constants.ZREPLICATION_WORK_QUEUE + "/" + filename)) {
+      if (null == zooCache.get(ZooUtil.getRoot(instanceId) + ReplicationConstants.ZOO_WORK_QUEUE + "/" + filename)) {
         work.remove();
       }
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
index e7ff4ca..3d96ea1 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
@@ -26,7 +26,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
 
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
@@ -35,6 +34,7 @@ import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.protobuf.ProtobufUtil;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.ReplicationSchema.OrderSection;
 import org.apache.accumulo.core.replication.ReplicationSchema.WorkSection;
 import org.apache.accumulo.core.replication.ReplicationTarget;
@@ -329,11 +329,11 @@ public class SequentialWorkAssignerTest {
 
     // file1 replicated
     expect(
-        zooCache.get(ZooUtil.getRoot("instance") + Constants.ZREPLICATION_WORK_QUEUE + "/"
+        zooCache.get(ZooUtil.getRoot("instance") + ReplicationConstants.ZOO_WORK_QUEUE + "/"
             + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file1", new ReplicationTarget("cluster1", "1", "1")))).andReturn(null);
     // file2 still needs to replicate
     expect(
-        zooCache.get(ZooUtil.getRoot("instance") + Constants.ZREPLICATION_WORK_QUEUE + "/"
+        zooCache.get(ZooUtil.getRoot("instance") + ReplicationConstants.ZOO_WORK_QUEUE + "/"
             + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", "2")))).andReturn(new byte[0]);
 
     replay(workQueue, zooCache, conn, inst);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
index 0c9384e..2199808 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
@@ -38,6 +38,7 @@ import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.protobuf.ProtobufUtil;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.ReplicationSchema.OrderSection;
 import org.apache.accumulo.core.replication.ReplicationSchema.WorkSection;
 import org.apache.accumulo.core.replication.ReplicationTarget;
@@ -238,8 +239,8 @@ public class UnorderedWorkAssignerTest {
 
     expect(conn.getInstance()).andReturn(inst);
     expect(inst.getInstanceID()).andReturn("id");
-    expect(cache.get(Constants.ZROOT + "/id" + Constants.ZREPLICATION_WORK_QUEUE + "/wal1")).andReturn(null);
-    expect(cache.get(Constants.ZROOT + "/id" + Constants.ZREPLICATION_WORK_QUEUE + "/wal2")).andReturn(null);
+    expect(cache.get(Constants.ZROOT + "/id" + ReplicationConstants.ZOO_WORK_QUEUE + "/wal1")).andReturn(null);
+    expect(cache.get(Constants.ZROOT + "/id" + ReplicationConstants.ZOO_WORK_QUEUE + "/wal2")).andReturn(null);
 
     replay(cache, inst, conn);
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
index ab83b4a..9936946 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
@@ -27,7 +27,6 @@ import java.util.Set;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchScanner;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
@@ -42,6 +41,7 @@ import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.ReplicationSchema.WorkSection;
 import org.apache.accumulo.core.replication.ReplicationTarget;
 import org.apache.accumulo.core.replication.StatusUtil;
@@ -207,7 +207,7 @@ public class ReplicationServlet extends BasicServlet {
 
     // Read the files from the workqueue in zk
     String zkRoot = ZooUtil.getRoot(inst);
-    final String workQueuePath = zkRoot + Constants.ZREPLICATION_WORK_QUEUE;
+    final String workQueuePath = zkRoot + ReplicationConstants.ZOO_WORK_QUEUE;
 
     DistributedWorkQueue workQueue = new DistributedWorkQueue(workQueuePath, ServerConfiguration.getSystemConfiguration(inst));
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index dd3c16e..e1a62de 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -111,6 +111,7 @@ import org.apache.accumulo.core.master.thrift.TabletServerStatus;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.replication.thrift.ReplicationServicer;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.SecurityUtil;
@@ -2893,7 +2894,7 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
     try {
       // The replication service is unique to the thrift service for a tserver, not just a host.
       // Advertise the host and port for replication service given the host and port for the tserver.
-      ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(getInstance()) + Constants.ZREPLICATION_TSERVERS + "/" + clientAddress.toString(),
+      ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(getInstance()) + ReplicationConstants.ZOO_TSERVERS + "/" + clientAddress.toString(),
           sp.address.toString().getBytes(StandardCharsets.UTF_8), NodeExistsPolicy.OVERWRITE);
     } catch (Exception e) {
       log.error("Could not advertise replication service port", e);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
index a223511..20da0d6 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
@@ -18,11 +18,11 @@ package org.apache.accumulo.tserver.replication;
 
 import java.util.concurrent.ThreadPoolExecutor;
 
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.security.SystemCredentials;
@@ -63,10 +63,10 @@ public class ReplicationWorker implements Runnable {
       DistributedWorkQueue workQueue;
       if (defaultDelay != delay && defaultPeriod != period) {
         log.debug("Configuration DistributedWorkQueue with delay and period of {} and {}", delay, period);
-        workQueue = new DistributedWorkQueue(ZooUtil.getRoot(inst) + Constants.ZREPLICATION_WORK_QUEUE, conf, delay, period);
+        workQueue = new DistributedWorkQueue(ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_WORK_QUEUE, conf, delay, period);
       } else {
         log.debug("Configuring DistributedWorkQueue with default delay and period");
-        workQueue = new DistributedWorkQueue(ZooUtil.getRoot(inst) + Constants.ZREPLICATION_WORK_QUEUE, conf);
+        workQueue = new DistributedWorkQueue(ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_WORK_QUEUE, conf);
       }
 
       workQueue.startProcessing(new ReplicationProcessor(inst, conf, fs, SystemCredentials.get()), executor);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ad4ea6b2/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java b/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java
index 96e8b52..0f4cf5b 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java
@@ -24,6 +24,7 @@ import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.replication.ReplicationConstants;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooReader;
@@ -68,7 +69,7 @@ public class MultiTserverReplicationIT extends ConfigurableMacIT {
 
     for (String tserver : tserverHost) {
       try {
-        byte[] portData = zreader.getData(ZooUtil.getRoot(inst) + Constants.ZREPLICATION_TSERVERS + "/" + tserver, null);
+        byte[] portData = zreader.getData(ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_TSERVERS + "/" + tserver, null);
         HostAndPort replAddress = HostAndPort.fromString(new String(portData, StandardCharsets.UTF_8));
         replicationServices.add(replAddress);
       } catch (Exception e) {


[6/8] git commit: Merge branch '1.6.1-SNAPSHOT'

Posted by el...@apache.org.
Merge branch '1.6.1-SNAPSHOT'


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3af0642a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3af0642a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3af0642a

Branch: refs/heads/ACCUMULO-378
Commit: 3af0642ac5400bf4ff922e22e45900dda4052ec2
Parents: 2149b64 8ebf617
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 13:33:07 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 13:33:07 2014 -0400

----------------------------------------------------------------------
 .../accumulo/server/master/balancer/TableLoadBalancerTest.java      | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------



[8/8] git commit: ACCUMULO-378 Change plural property to match other convention

Posted by el...@apache.org.
ACCUMULO-378 Change plural property to match other convention


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/028b7800
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/028b7800
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/028b7800

Branch: refs/heads/ACCUMULO-378
Commit: 028b78000a23409070e7c973731597ea69d846bc
Parents: 5257b80
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 14:47:11 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 14:47:11 2014 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/core/conf/Property.java |  4 +--
 .../accumulo/master/replication/WorkMaker.java  |  4 +--
 .../master/replication/WorkMakerTest.java       |  2 +-
 .../monitor/servlets/ReplicationServlet.java    |  2 +-
 .../test/replication/CyclicReplicationIT.java   |  4 +--
 .../test/replication/ReplicationIT.java         | 12 ++++-----
 .../test/replication/ReplicationTest.java       | 26 ++++++++++----------
 .../UnorderedWorkAssignerReplicationIT.java     | 12 ++++-----
 8 files changed, 33 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/core/src/main/java/org/apache/accumulo/core/conf/Property.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
index 59955f3..29993b3 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
@@ -430,7 +430,7 @@ public enum Property {
   TABLE_COMPACTION_STRATEGY_PREFIX("table.majc.compaction.strategy.opts.", null, PropertyType.PREFIX,
       "Properties in this category are used to configure the compaction strategy."),
   TABLE_REPLICATION("table.replication", "false", PropertyType.BOOLEAN, "Is replication enabled for the given table"),
-  TABLE_REPLICATION_TARGETS("table.replication.target.", null, PropertyType.PREFIX, "Enumerate a mapping of other systems which this table should " +
+  TABLE_REPLICATION_TARGET("table.replication.target.", null, PropertyType.PREFIX, "Enumerate a mapping of other systems which this table should " +
       "replicate their data to. The key suffix is the identifying cluster name and the value is an identifier for a location on the target system, " +
       "e.g. the ID of the table on the target to replicate to"),
 
@@ -683,7 +683,7 @@ public enum Property {
 
     return validTableProperties.contains(key) || key.startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey())
         || key.startsWith(Property.TABLE_ITERATOR_PREFIX.getKey()) || key.startsWith(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey())
-        || key.startsWith(Property.TABLE_COMPACTION_STRATEGY_PREFIX.getKey()) || key.startsWith(Property.TABLE_REPLICATION_TARGETS.getKey());
+        || key.startsWith(Property.TABLE_COMPACTION_STRATEGY_PREFIX.getKey()) || key.startsWith(Property.TABLE_REPLICATION_TARGET.getKey());
   }
 
   private static final EnumSet<Property> fixedProperties = EnumSet.of(Property.TSERV_CLIENTPORT, Property.TSERV_NATIVEMAP_ENABLED,

http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java
index 68109a6..76e7621 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java
@@ -139,9 +139,9 @@ public class WorkMaker {
   }
 
   protected Map<String,String> getReplicationTargets(TableConfiguration tableConf) {
-    final Map<String,String> props = tableConf.getAllPropertiesWithPrefix(Property.TABLE_REPLICATION_TARGETS);
+    final Map<String,String> props = tableConf.getAllPropertiesWithPrefix(Property.TABLE_REPLICATION_TARGET);
     final Map<String,String> targets = new HashMap<>();
-    final int propKeyLength = Property.TABLE_REPLICATION_TARGETS.getKey().length();
+    final int propKeyLength = Property.TABLE_REPLICATION_TARGET.getKey().length();
 
     for (Entry<String,String> prop : props.entrySet()) {
       targets.put(prop.getKey().substring(propKeyLength), prop.getValue());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
index 0c4afc9..9bc3102 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
@@ -187,7 +187,7 @@ public class WorkMakerTest {
 
     WorkMaker workMaker = new WorkMaker(conn);
 
-    conn.tableOperations().setProperty(ReplicationTable.NAME, Property.TABLE_REPLICATION_TARGETS.getKey() + "remote_cluster_1", "4");
+    conn.tableOperations().setProperty(ReplicationTable.NAME, Property.TABLE_REPLICATION_TARGET.getKey() + "remote_cluster_1", "4");
 
     workMaker.setBatchWriter(bw);
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
index 9936946..69c5b55 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java
@@ -121,7 +121,7 @@ public class ReplicationServlet extends BasicServlet {
       }
     }
 
-    final String targetPrefix = Property.TABLE_REPLICATION_TARGETS.getKey();
+    final String targetPrefix = Property.TABLE_REPLICATION_TARGET.getKey();
 
     // The total set of configured targets
     Set<ReplicationTarget> allConfiguredTargets = new HashSet<>();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java b/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
index a75113b..c84e53d 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
@@ -154,12 +154,12 @@ public class CyclicReplicationIT {
       // Replicate master1 in the master1 cluster to master2 in the master2 cluster
       connMaster1.tableOperations().setProperty(master1Table, Property.TABLE_REPLICATION.getKey(), "true");
       connMaster1.tableOperations().setProperty(master1Table,
-          Property.TABLE_REPLICATION_TARGETS.getKey() + master2Cluster.getInstanceName(), master2TableId);
+          Property.TABLE_REPLICATION_TARGET.getKey() + master2Cluster.getInstanceName(), master2TableId);
 
       // Replicate master2 in the master2 cluster to master1 in the master2 cluster
       connMaster2.tableOperations().setProperty(master2Table, Property.TABLE_REPLICATION.getKey(), "true");
       connMaster2.tableOperations().setProperty(master2Table,
-          Property.TABLE_REPLICATION_TARGETS.getKey() + master1Cluster.getInstanceName(), master1TableId);
+          Property.TABLE_REPLICATION_TARGET.getKey() + master1Cluster.getInstanceName(), master1TableId);
 
       // Give our replication user the ability to write to the respective table
       connMaster1.securityOperations().grantTablePermission(master1UserName, master1Table, TablePermission.WRITE);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
index d051e75..2af81f6 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
@@ -145,7 +145,7 @@ public class ReplicationIT extends ConfigurableMacIT {
   
       // Replicate this table to the peerClusterName in a table with the peerTableId table id
       connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId);
+      connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId);
   
       // Write some data to table1
       BatchWriter bw = connMaster.createBatchWriter(masterTable, new BatchWriterConfig());
@@ -315,10 +315,10 @@ public class ReplicationIT extends ConfigurableMacIT {
 
       // Replicate this table to the peerClusterName in a table with the peerTableId table id
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId1);
+      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId1);
 
       connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId2);
+      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId2);
 
       // Write some data to table1
       BatchWriter bw = connMaster.createBatchWriter(masterTable1, new BatchWriterConfig());
@@ -453,7 +453,7 @@ public class ReplicationIT extends ConfigurableMacIT {
 
     // Replicate this table to the peerClusterName in a table with the peerTableId table id
     connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION.getKey(), "true");
-    connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId);
+    connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId);
 
     // Write some data to table1
     BatchWriter bw = connMaster.createBatchWriter(masterTable, new BatchWriterConfig());
@@ -562,10 +562,10 @@ public class ReplicationIT extends ConfigurableMacIT {
 
       // Replicate this table to the peerClusterName in a table with the peerTableId table id
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId1);
+      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId1);
 
       connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId2);
+      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId2);
 
       // Write some data to table1
       BatchWriter bw = connMaster.createBatchWriter(masterTable1, new BatchWriterConfig());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/test/src/test/java/org/apache/accumulo/test/replication/ReplicationTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationTest.java b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationTest.java
index 8554950..7ea4c84 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationTest.java
@@ -401,7 +401,7 @@ public class ReplicationTest extends ConfigurableMacIT {
 
     conn.tableOperations().create(table1);
     conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION.getKey(), "true");
-    conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+    conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
     Thread.sleep(1000);
 
     // Write some data to table1
@@ -419,7 +419,7 @@ public class ReplicationTest extends ConfigurableMacIT {
 
     conn.tableOperations().create(table2);
     conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION.getKey(), "true");
-    conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+    conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
     Thread.sleep(1000);
 
     // Write some data to table2
@@ -437,7 +437,7 @@ public class ReplicationTest extends ConfigurableMacIT {
 
     conn.tableOperations().create(table3);
     conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION.getKey(), "true");
-    conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+    conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
     Thread.sleep(1000);
 
     // Write some data to table3
@@ -564,13 +564,13 @@ public class ReplicationTest extends ConfigurableMacIT {
 
     conn.tableOperations().create(table1);
     conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION.getKey(), "true");
-    conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+    conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
     conn.tableOperations().create(table2);
     conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION.getKey(), "true");
-    conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+    conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
     conn.tableOperations().create(table3);
     conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION.getKey(), "true");
-    conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+    conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
 
     // Write some data to table1
     BatchWriter bw = conn.createBatchWriter(table1, new BatchWriterConfig());
@@ -637,7 +637,7 @@ public class ReplicationTest extends ConfigurableMacIT {
     Assert.assertNotNull(tableId);
 
     conn.tableOperations().setProperty(table, Property.TABLE_REPLICATION.getKey(), "true");
-    conn.tableOperations().setProperty(table, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+    conn.tableOperations().setProperty(table, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
     // just sleep
     conn.instanceOperations().setProperty(Property.REPLICATION_PEERS.getKey() + "cluster1",
         ReplicaSystemFactory.getPeerConfigurationValue(MockReplicaSystem.class, "50000"));
@@ -762,7 +762,7 @@ public class ReplicationTest extends ConfigurableMacIT {
         // Enable replication on table1
         conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION.getKey(), "true");
         // Replicate table1 to cluster1 in the table with id of '4'
-        conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "4");
+        conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "4");
         conn.instanceOperations().setProperty(Property.REPLICATION_PEERS.getKey() + "cluster1",
             ReplicaSystemFactory.getPeerConfigurationValue(MockReplicaSystem.class, "100000"));
         break;
@@ -931,7 +931,7 @@ public class ReplicationTest extends ConfigurableMacIT {
         // Enable replication on table1
         conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION.getKey(), "true");
         // Replicate table1 to cluster1 in the table with id of '4'
-        conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "4");
+        conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "4");
         attempts = 0;
       } catch (Exception e) {
         attempts--;
@@ -1049,7 +1049,7 @@ public class ReplicationTest extends ConfigurableMacIT {
     try {
       conn.tableOperations().create(table1);
       conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION.getKey(), "true");
-      conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+      conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
       conn.instanceOperations().setProperty(Property.REPLICATION_PEERS.getKey() + "cluster1",
           ReplicaSystemFactory.getPeerConfigurationValue(MockReplicaSystem.class, null));
 
@@ -1068,7 +1068,7 @@ public class ReplicationTest extends ConfigurableMacIT {
 
       conn.tableOperations().create(table2);
       conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION.getKey(), "true");
-      conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+      conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
 
       // Write some data to table2
       bw = conn.createBatchWriter(table2, new BatchWriterConfig());
@@ -1085,7 +1085,7 @@ public class ReplicationTest extends ConfigurableMacIT {
 
       conn.tableOperations().create(table3);
       conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION.getKey(), "true");
-      conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "1");
+      conn.tableOperations().setProperty(table3, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "1");
 
       // Write some data to table3
       bw = conn.createBatchWriter(table3, new BatchWriterConfig());
@@ -1235,7 +1235,7 @@ public class ReplicationTest extends ConfigurableMacIT {
           // Enable replication on table1
           conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION.getKey(), "true");
           // Replicate table1 to cluster1 in the table with id of '4'
-          conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGETS.getKey() + "cluster1", "4");
+          conn.tableOperations().setProperty(table1, Property.TABLE_REPLICATION_TARGET.getKey() + "cluster1", "4");
           // Use the MockReplicaSystem impl and sleep for 5seconds
           conn.instanceOperations().setProperty(Property.REPLICATION_PEERS.getKey() + "cluster1",
               ReplicaSystemFactory.getPeerConfigurationValue(MockReplicaSystem.class, "1000"));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/028b7800/test/src/test/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java b/test/src/test/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
index b90d7f7..558c75f 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
@@ -145,7 +145,7 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacIT {
 
       // Replicate this table to the peerClusterName in a table with the peerTableId table id
       connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId);
+      connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId);
 
       // Write some data to table1
       BatchWriter bw = connMaster.createBatchWriter(masterTable, new BatchWriterConfig());
@@ -306,10 +306,10 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacIT {
 
       // Replicate this table to the peerClusterName in a table with the peerTableId table id
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId1);
+      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId1);
 
       connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId2);
+      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId2);
 
       // Write some data to table1
       BatchWriter bw = connMaster.createBatchWriter(masterTable1, new BatchWriterConfig());
@@ -459,7 +459,7 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacIT {
 
     // Replicate this table to the peerClusterName in a table with the peerTableId table id
     connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION.getKey(), "true");
-    connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId);
+    connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId);
 
     // Write some data to table1
     BatchWriter bw = connMaster.createBatchWriter(masterTable, new BatchWriterConfig());
@@ -568,10 +568,10 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacIT {
 
       // Replicate this table to the peerClusterName in a table with the peerTableId table id
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId1);
+      connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId1);
 
       connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION.getKey(), "true");
-      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGETS.getKey() + peerClusterName, peerTableId2);
+      connMaster.tableOperations().setProperty(masterTable2, Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId2);
 
       // Write some data to table1
       BatchWriter bw = connMaster.createBatchWriter(masterTable1, new BatchWriterConfig());


[7/8] git commit: Merge remote-tracking branch 'origin/master' into ACCUMULO-378

Posted by el...@apache.org.
Merge remote-tracking branch 'origin/master' into ACCUMULO-378


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/5257b80a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/5257b80a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/5257b80a

Branch: refs/heads/ACCUMULO-378
Commit: 5257b80abb34d3843d9a6958e41f06979ea30139
Parents: ad4ea6b 3af0642
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 13:33:30 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 13:33:30 2014 -0400

----------------------------------------------------------------------
 .../core/client/mock/MockTableOperationsTest.java        | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------



[5/8] git commit: ACCUMULO-2857 Messed up the merge

Posted by el...@apache.org.
ACCUMULO-2857 Messed up the merge


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8ebf6179
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8ebf6179
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8ebf6179

Branch: refs/heads/ACCUMULO-378
Commit: 8ebf6179433de4ad50c21f51a4c0c10520f34d31
Parents: 38ff000
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 13:32:51 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 13:32:51 2014 -0400

----------------------------------------------------------------------
 .../accumulo/server/master/balancer/TableLoadBalancerTest.java      | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8ebf6179/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
index 3642bc3..5c134a5 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
@@ -136,7 +136,6 @@ public class TableLoadBalancerTest {
     String t1Id = tops.tableIdMap().get("t1"), t2Id = tops.tableIdMap().get("t2"), t3Id = tops.tableIdMap().get("t3");
     state = new TreeMap<TServerInstance,TabletServerStatus>();
     TServerInstance svr = mkts("10.0.0.1", "0x01020304");
-    state.put(svr, status("t1", 10, "t2", 10, "t3", 10));
     state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
     
     Set<KeyExtent> migrations = Collections.emptySet();


[4/8] git commit: Merge branch '1.6.1-SNAPSHOT'

Posted by el...@apache.org.
Merge branch '1.6.1-SNAPSHOT'

Conflicts:
	core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperationsImpl.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2149b643
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2149b643
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2149b643

Branch: refs/heads/ACCUMULO-378
Commit: 2149b6430d8e15d4c11b5b310332365b8855874f
Parents: 47d5933 38ff000
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 13:29:47 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 13:29:47 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/client/mock/MockAccumulo.java      |  4 +++-
 .../apache/accumulo/core/client/mock/MockTable.java  | 12 +++++++++---
 .../core/client/mock/MockTableOperations.java        |  5 +++--
 .../core/client/mock/MockTableOperationsTest.java    | 11 +++++++++++
 .../master/balancer/TableLoadBalancerTest.java       | 15 +++++++++------
 5 files changed, 35 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2149b643/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
index a44a027,ee8880c..b1bba45
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
@@@ -16,432 -16,13 +16,433 @@@
   */
  package org.apache.accumulo.core.client.mock;
  
 -/**
 - * @deprecated since 1.6.0; not intended for public api and you should not use it.
 - */
 -@Deprecated
 -public class MockTableOperations extends MockTableOperationsImpl {
 +import java.io.DataInputStream;
 +import java.io.IOException;
 +import java.util.ArrayList;
 +import java.util.Collection;
 +import java.util.Collections;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Map.Entry;
 +import java.util.Set;
 +import java.util.SortedSet;
 +import java.util.TreeSet;
 +
 +import org.apache.accumulo.core.client.AccumuloException;
 +import org.apache.accumulo.core.client.AccumuloSecurityException;
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.client.NamespaceNotFoundException;
 +import org.apache.accumulo.core.client.TableExistsException;
 +import org.apache.accumulo.core.client.TableNotFoundException;
 +import org.apache.accumulo.core.client.admin.DiskUsage;
 +import org.apache.accumulo.core.client.admin.FindMax;
 +import org.apache.accumulo.core.client.impl.TableOperationsHelper;
 +import org.apache.accumulo.core.client.admin.TimeType;
 +import org.apache.accumulo.core.client.impl.Tables;
 +import org.apache.accumulo.core.conf.AccumuloConfiguration;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.Mutation;
 +import org.apache.accumulo.core.data.Range;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.core.file.FileOperations;
 +import org.apache.accumulo.core.file.FileSKVIterator;
 +import org.apache.accumulo.core.metadata.MetadataTable;
 +import org.apache.accumulo.core.metadata.RootTable;
 +import org.apache.accumulo.core.security.Authorizations;
 +import org.apache.accumulo.core.security.ColumnVisibility;
 +import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
 +import org.apache.commons.lang.NotImplementedException;
 +import org.apache.hadoop.fs.FSDataOutputStream;
 +import org.apache.hadoop.fs.FileStatus;
 +import org.apache.hadoop.fs.FileSystem;
 +import org.apache.hadoop.fs.Path;
 +import org.apache.hadoop.io.Text;
 +
 +class MockTableOperations extends TableOperationsHelper {
 +  private static final byte[] ZERO = {0};
 +  private final MockAccumulo acu;
 +  private final String username;
  
    MockTableOperations(MockAccumulo acu, String username) {
 -    super(acu,username);
 +    this.acu = acu;
 +    this.username = username;
 +  }
 +
 +  @Override
 +  public SortedSet<String> list() {
 +    return new TreeSet<String>(acu.tables.keySet());
 +  }
 +
 +  @Override
 +  public boolean exists(String tableName) {
 +    return acu.tables.containsKey(tableName);
 +  }
 +
 +  private boolean namespaceExists(String namespace) {
 +    return acu.namespaces.containsKey(namespace);
 +  }
 +
 +  @Override
 +  public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException {
 +    create(tableName, true, TimeType.MILLIS);
 +  }
 +
 +  @Override
 +  public void create(String tableName, boolean versioningIter) throws AccumuloException, AccumuloSecurityException, TableExistsException {
 +    create(tableName, versioningIter, TimeType.MILLIS);
 +  }
 +
 +  @Override
 +  public void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException {
 +    String namespace = Tables.qualify(tableName).getFirst();
 +    if (!tableName.matches(Tables.VALID_NAME_REGEX)) {
 +      throw new IllegalArgumentException();
 +    }
 +    if (exists(tableName))
 +      throw new TableExistsException(tableName, tableName, "");
 +
 +    if (!namespaceExists(namespace)) {
 +      throw new IllegalArgumentException("Namespace (" + namespace + ") does not exist, create it first");
 +    }
 +    acu.createTable(username, tableName, versioningIter, timeType);
 +  }
 +
 +  @Override
 +  public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.addSplits(tableName, partitionKeys);
 +  }
 +
 +  @Deprecated
 +  @Override
 +  public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
 +    return listSplits(tableName);
 +  }
 +
 +  @Deprecated
 +  @Override
 +  public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
 +    return listSplits(tableName);
 +  }
 +
 +  @Override
 +  public Collection<Text> listSplits(String tableName) throws TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    return acu.getSplits(tableName);
 +  }
 +
 +  @Override
 +  public Collection<Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException {
 +    return listSplits(tableName);
 +  }
 +
 +  @Override
 +  public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.tables.remove(tableName);
 +  }
 +
 +  @Override
 +  public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
 +      TableExistsException {
 +    if (!exists(oldTableName))
 +      throw new TableNotFoundException(oldTableName, oldTableName, "");
 +    if (exists(newTableName))
 +      throw new TableExistsException(newTableName, newTableName, "");
 +    MockTable t = acu.tables.remove(oldTableName);
 +    String namespace = Tables.qualify(newTableName).getFirst();
 +    MockNamespace n = acu.namespaces.get(namespace);
 +    if (n == null) {
 +      n = new MockNamespace();
 +    }
 +    t.setNamespaceName(namespace);
 +    t.setNamespace(n);
 +    acu.namespaces.put(namespace, n);
 +    acu.tables.put(newTableName, t);
 +  }
 +
 +  @Deprecated
 +  @Override
 +  public void flush(String tableName) throws AccumuloException, AccumuloSecurityException {}
 +
 +  @Override
 +  public void setProperty(String tableName, String property, String value) throws AccumuloException, AccumuloSecurityException {
 +    acu.tables.get(tableName).settings.put(property, value);
 +  }
 +
 +  @Override
 +  public void removeProperty(String tableName, String property) throws AccumuloException, AccumuloSecurityException {
 +    acu.tables.get(tableName).settings.remove(property);
 +  }
 +
 +  @Override
 +  public Iterable<Entry<String,String>> getProperties(String tableName) throws TableNotFoundException {
 +    String namespace = Tables.qualify(tableName).getFirst();
 +    if (!exists(tableName)) {
 +      if (!namespaceExists(namespace))
 +        throw new TableNotFoundException(tableName, new NamespaceNotFoundException(null, namespace, null));
 +      throw new TableNotFoundException(null, tableName, null);
 +    }
 +
 +    Set<Entry<String,String>> props = new HashSet<Entry<String,String>>(acu.namespaces.get(namespace).settings.entrySet());
 +
 +    Set<Entry<String,String>> tableProps = acu.tables.get(tableName).settings.entrySet();
 +    for (Entry<String,String> e : tableProps) {
 +      if (props.contains(e)) {
 +        props.remove(e);
 +      }
 +      props.add(e);
 +    }
 +    return props;
 +  }
 +
 +  @Override
 +  public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.tables.get(tableName).setLocalityGroups(groups);
 +  }
 +
 +  @Override
 +  public Map<String,Set<Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    return acu.tables.get(tableName).getLocalityGroups();
 +  }
 +
 +  @Override
 +  public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException,
 +      TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    return Collections.singleton(range);
 +  }
 +
 +  @Override
 +  public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws IOException, AccumuloException,
 +      AccumuloSecurityException, TableNotFoundException {
 +    long time = System.currentTimeMillis();
 +    MockTable table = acu.tables.get(tableName);
 +    if (table == null) {
 +      throw new TableNotFoundException(null, tableName, "The table was not found");
 +    }
 +    Path importPath = new Path(dir);
 +    Path failurePath = new Path(failureDir);
 +
 +    FileSystem fs = acu.getFileSystem();
 +    /*
 +     * check preconditions
 +     */
 +    // directories are directories
 +    if (fs.isFile(importPath)) {
 +      throw new IOException("Import path must be a directory.");
 +    }
 +    if (fs.isFile(failurePath)) {
 +      throw new IOException("Failure path must be a directory.");
 +    }
 +    // failures are writable
 +    Path createPath = failurePath.suffix("/.createFile");
 +    FSDataOutputStream createStream = null;
 +    try {
 +      createStream = fs.create(createPath);
 +    } catch (IOException e) {
 +      throw new IOException("Error path is not writable.");
 +    } finally {
 +      if (createStream != null) {
 +        createStream.close();
 +      }
 +    }
 +    fs.delete(createPath, false);
 +    // failures are empty
 +    FileStatus[] failureChildStats = fs.listStatus(failurePath);
 +    if (failureChildStats.length > 0) {
 +      throw new IOException("Error path must be empty.");
 +    }
 +    /*
 +     * Begin the import - iterate the files in the path
 +     */
 +    for (FileStatus importStatus : fs.listStatus(importPath)) {
 +      try {
 +        FileSKVIterator importIterator = FileOperations.getInstance().openReader(importStatus.getPath().toString(), true, fs, fs.getConf(),
 +            AccumuloConfiguration.getDefaultConfiguration());
 +        while (importIterator.hasTop()) {
 +          Key key = importIterator.getTopKey();
 +          Value value = importIterator.getTopValue();
 +          if (setTime) {
 +            key.setTimestamp(time);
 +          }
 +          Mutation mutation = new Mutation(key.getRow());
 +          if (!key.isDeleted()) {
 +            mutation.put(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()), key.getTimestamp(),
 +                value);
 +          } else {
 +            mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()),
 +                key.getTimestamp());
 +          }
 +          table.addMutation(mutation);
 +          importIterator.next();
 +        }
 +      } catch (Exception e) {
 +        FSDataOutputStream failureWriter = null;
 +        DataInputStream failureReader = null;
 +        try {
 +          failureWriter = fs.create(failurePath.suffix("/" + importStatus.getPath().getName()));
 +          failureReader = fs.open(importStatus.getPath());
 +          int read = 0;
 +          byte[] buffer = new byte[1024];
 +          while (-1 != (read = failureReader.read(buffer))) {
 +            failureWriter.write(buffer, 0, read);
 +          }
 +        } finally {
 +          if (failureReader != null)
 +            failureReader.close();
 +          if (failureWriter != null)
 +            failureWriter.close();
 +        }
 +      }
 +      fs.delete(importStatus.getPath(), true);
 +    }
 +  }
 +
 +  @Override
 +  public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    offline(tableName, false);
 +  }
 +
 +  @Override
 +  public void offline(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    online(tableName, false);
 +  }
 +
 +  @Override
 +  public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void clearLocatorCache(String tableName) throws TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public Map<String,String> tableIdMap() {
 +    Map<String,String> result = new HashMap<String,String>();
-     for (String table : acu.tables.keySet()) {
++    for (Entry<String,MockTable> entry : acu.tables.entrySet()) {
++      String table = entry.getKey();
 +      if (RootTable.NAME.equals(table))
 +        result.put(table, RootTable.ID);
 +      else if (MetadataTable.NAME.equals(table))
 +        result.put(table, MetadataTable.ID);
 +      else
-         result.put(table, table);
++        result.put(table, entry.getValue().getTableId());
 +    }
 +    return result;
 +  }
 +
 +  @Override
 +  public List<DiskUsage> getDiskUsage(Set<String> tables) throws AccumuloException, AccumuloSecurityException {
 +
 +    List<DiskUsage> diskUsages = new ArrayList<DiskUsage>();
 +    diskUsages.add(new DiskUsage(new TreeSet<String>(tables), 0l));
 +
 +    return diskUsages;
 +  }
 +
 +  @Override
 +  public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.merge(tableName, start, end);
 +  }
 +
 +  @Override
 +  public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    MockTable t = acu.tables.get(tableName);
 +    Text startText = start != null ? new Text(start) : new Text();
 +    Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes());
 +    startText.append(ZERO, 0, 1);
 +    endText.append(ZERO, 0, 1);
 +    Set<Key> keep = new TreeSet<Key>(t.table.subMap(new Key(startText), new Key(endText)).keySet());
 +    t.table.keySet().removeAll(keep);
 +  }
 +
 +  @Override
 +  public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException,
 +      AccumuloException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void compact(String tableName, Text start, Text end, List<IteratorSetting> iterators, boolean flush, boolean wait) throws AccumuloSecurityException,
 +      TableNotFoundException, AccumuloException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
 +      throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
 +    throw new NotImplementedException();
 +  }
 +
 +  @Override
 +  public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive)
 +      throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
 +    MockTable table = acu.tables.get(tableName);
 +    if (table == null)
 +      throw new TableNotFoundException(tableName, tableName, "no such table");
 +
 +    return FindMax.findMax(new MockScanner(table, auths), startRow, startInclusive, endRow, endInclusive);
 +  }
 +
 +  @Override
 +  public void importTable(String tableName, String exportDir) throws TableExistsException, AccumuloException, AccumuloSecurityException {
 +    throw new NotImplementedException();
 +  }
 +
 +  @Override
 +  public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
 +    throw new NotImplementedException();
 +  }
 +
 +  @Override
 +  public boolean testClassLoad(String tableName, String className, String asTypeName) throws AccumuloException, AccumuloSecurityException,
 +      TableNotFoundException {
 +
 +    try {
 +      AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
 +    } catch (ClassNotFoundException e) {
 +      e.printStackTrace();
 +      return false;
 +    }
 +    return true;
    }
  }


[3/8] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Posted by el...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Conflicts:
	core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
	core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
	core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
	server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/38ff0000
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/38ff0000
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/38ff0000

Branch: refs/heads/ACCUMULO-378
Commit: 38ff0000879af97d24372cb004a81e10901e4276
Parents: 05cf918 9fcca2e
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 13:21:43 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 13:21:43 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/client/mock/MockAccumulo.java      |  4 +++-
 .../apache/accumulo/core/client/mock/MockTable.java  | 12 +++++++++---
 .../core/client/mock/MockTableOperationsImpl.java    |  5 +++--
 .../core/client/mock/MockTableOperationsTest.java    | 11 +++++++++++
 .../master/balancer/TableLoadBalancerTest.java       | 15 +++++++++------
 5 files changed, 35 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/38ff0000/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
index 2c26ecc,272d1af..32dbb28
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
@@@ -21,17 -21,14 +21,18 @@@ import java.util.EnumSet
  import java.util.HashMap;
  import java.util.Map;
  import java.util.SortedSet;
+ import java.util.concurrent.atomic.AtomicInteger;
  
 -import org.apache.accumulo.core.Constants;
  import org.apache.accumulo.core.client.BatchScanner;
  import org.apache.accumulo.core.client.admin.TimeType;
 +import org.apache.accumulo.core.client.impl.Namespaces;
 +import org.apache.accumulo.core.client.impl.Tables;
  import org.apache.accumulo.core.client.security.tokens.PasswordToken;
  import org.apache.accumulo.core.data.Mutation;
 +import org.apache.accumulo.core.metadata.MetadataTable;
 +import org.apache.accumulo.core.metadata.RootTable;
  import org.apache.accumulo.core.security.Authorizations;
 +import org.apache.accumulo.core.security.NamespacePermission;
  import org.apache.accumulo.core.security.SystemPermission;
  import org.apache.accumulo.core.security.TablePermission;
  import org.apache.hadoop.fs.FileSystem;
@@@ -43,7 -39,8 +44,8 @@@ public class MockAccumulo 
    final Map<String,String> systemProperties = new HashMap<String,String>();
    Map<String,MockUser> users = new HashMap<String,MockUser>();
    final FileSystem fs;
+   final AtomicInteger tableIdCounter = new AtomicInteger(0);
 -  
 +
    MockAccumulo(FileSystem fs) {
      this.fs = fs;
    }
@@@ -82,30 -76,13 +84,30 @@@
    public BatchScanner createBatchScanner(String tableName, Authorizations authorizations) {
      return new MockBatchScanner(tables.get(tableName), authorizations);
    }
 -  
 +
    public void createTable(String username, String tableName, boolean useVersions, TimeType timeType) {
 -    MockTable t = new MockTable(useVersions, timeType, Integer.toString(tableIdCounter.incrementAndGet()));
 +    String namespace = Tables.qualify(tableName).getFirst();
 +
 +    if (!namespaceExists(namespace)) {
 +      return;
 +    }
 +
 +    MockNamespace n = namespaces.get(namespace);
-     MockTable t = new MockTable(n, useVersions, timeType);
++    MockTable t = new MockTable(n, useVersions, timeType, Integer.toString(tableIdCounter.incrementAndGet()));
      t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
 +    t.setNamespaceName(namespace);
 +    t.setNamespace(n);
      tables.put(tableName, t);
    }
 -  
 +
 +  public void createNamespace(String username, String namespace) {
 +    if (!namespaceExists(namespace)) {
 +      MockNamespace n = new MockNamespace();
 +      n.userPermissions.put(username, EnumSet.allOf(NamespacePermission.class));
 +      namespaces.put(namespace, n);
 +    }
 +  }
 +
    public void addSplits(String tableName, SortedSet<Text> partitionKeys) {
      tables.get(tableName).addSplits(partitionKeys);
    }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/38ff0000/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
index cb50761,2e13d84..35cbdd2
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
@@@ -89,12 -88,12 +89,14 @@@ public class MockTable 
    Map<String,EnumSet<TablePermission>> userPermissions = new HashMap<String,EnumSet<TablePermission>>();
    private TimeType timeType;
    SortedSet<Text> splits = new ConcurrentSkipListSet<Text>();
 -  Map<String,Set<Text>> localityGroups = new TreeMap<String, Set<Text>>();
 +  Map<String,Set<Text>> localityGroups = new TreeMap<String,Set<Text>>();
 +  private MockNamespace namespace;
 +  private String namespaceName;
+   private String tableId;
    
-   MockTable(boolean limitVersion, TimeType timeType) {
+   MockTable(boolean limitVersion, TimeType timeType, String tableId) {
      this.timeType = timeType;
+     this.tableId = tableId;
      settings = IteratorUtil.generateInitialTableProperties(limitVersion);
      for (Entry<String,String> entry : AccumuloConfiguration.getDefaultConfiguration()) {
        String key = entry.getKey();
@@@ -103,18 -102,6 +105,18 @@@
      }
    }
    
-   MockTable(MockNamespace namespace, boolean limitVersion, TimeType timeType) {
-     this(limitVersion, timeType);
++  MockTable(MockNamespace namespace, boolean limitVersion, TimeType timeType, String tableId) {
++    this(limitVersion, timeType, tableId);
 +    Set<Entry<String,String>> set = namespace.settings.entrySet();
 +    Iterator<Entry<String,String>> entries = set.iterator();
 +    while (entries.hasNext()) {
 +      Entry<String,String> entry = entries.next();
 +      String key = entry.getKey();
 +      if (key.startsWith(Property.TABLE_PREFIX.getKey()))
 +        settings.put(key, entry.getValue());
 +    }
 +  }
 +  
    synchronized void addMutation(Mutation m) {
      if (m.size() == 0)
        throw new IllegalArgumentException("Can not add empty mutations");
@@@ -159,20 -145,8 +161,24 @@@
      if (reAdd)
        splits.add(start);
    }
 +  
 +  public void setNamespaceName(String n) {
 +    this.namespaceName = n;
 +  }
 +  
 +  public void setNamespace(MockNamespace n) {
 +    this.namespace = n;
 +  }
 +  
 +  public String getNamespaceName() {
 +    return this.namespaceName;
 +  }
 +  
 +  public MockNamespace getNamespace() {
 +    return this.namespace;
 +  }
+ 
+   public String getTableId() {
+     return this.tableId;
+   }
  }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/38ff0000/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperationsImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperationsImpl.java
index 8a8895f,0000000..de19137
mode 100644,000000..100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperationsImpl.java
@@@ -1,447 -1,0 +1,448 @@@
 +/*
 + * 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.core.client.mock;
 +
 +import java.io.DataInputStream;
 +import java.io.IOException;
 +import java.util.ArrayList;
 +import java.util.Collection;
 +import java.util.Collections;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Map.Entry;
 +import java.util.Set;
 +import java.util.SortedSet;
 +import java.util.TreeSet;
 +
 +import org.apache.accumulo.core.client.AccumuloException;
 +import org.apache.accumulo.core.client.AccumuloSecurityException;
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.client.NamespaceNotFoundException;
 +import org.apache.accumulo.core.client.TableExistsException;
 +import org.apache.accumulo.core.client.TableNotFoundException;
 +import org.apache.accumulo.core.client.admin.DiskUsage;
 +import org.apache.accumulo.core.client.admin.FindMax;
 +import org.apache.accumulo.core.client.impl.TableOperationsHelper;
 +import org.apache.accumulo.core.client.admin.TimeType;
 +import org.apache.accumulo.core.client.impl.Tables;
 +import org.apache.accumulo.core.conf.AccumuloConfiguration;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.Mutation;
 +import org.apache.accumulo.core.data.Range;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.core.file.FileOperations;
 +import org.apache.accumulo.core.file.FileSKVIterator;
 +import org.apache.accumulo.core.metadata.MetadataTable;
 +import org.apache.accumulo.core.metadata.RootTable;
 +import org.apache.accumulo.core.security.Authorizations;
 +import org.apache.accumulo.core.security.ColumnVisibility;
 +import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
 +import org.apache.commons.lang.NotImplementedException;
 +import org.apache.hadoop.fs.FSDataOutputStream;
 +import org.apache.hadoop.fs.FileStatus;
 +import org.apache.hadoop.fs.FileSystem;
 +import org.apache.hadoop.fs.Path;
 +import org.apache.hadoop.io.Text;
 +
 +class MockTableOperationsImpl extends TableOperationsHelper {
 +  private static final byte[] ZERO = {0};
 +  private final MockAccumulo acu;
 +  private final String username;
 +
 +  MockTableOperationsImpl(MockAccumulo acu, String username) {
 +    this.acu = acu;
 +    this.username = username;
 +  }
 +
 +  @Override
 +  public SortedSet<String> list() {
 +    return new TreeSet<String>(acu.tables.keySet());
 +  }
 +
 +  @Override
 +  public boolean exists(String tableName) {
 +    return acu.tables.containsKey(tableName);
 +  }
 +
 +  private boolean namespaceExists(String namespace) {
 +    return acu.namespaces.containsKey(namespace);
 +  }
 +
 +  @Override
 +  public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException {
 +    create(tableName, true, TimeType.MILLIS);
 +  }
 +
 +  @Override
 +  public void create(String tableName, boolean versioningIter) throws AccumuloException, AccumuloSecurityException, TableExistsException {
 +    create(tableName, versioningIter, TimeType.MILLIS);
 +  }
 +
 +  @Override
 +  public void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException {
 +    String namespace = Tables.qualify(tableName).getFirst();
 +    if (!tableName.matches(Tables.VALID_NAME_REGEX)) {
 +      throw new IllegalArgumentException();
 +    }
 +    if (exists(tableName))
 +      throw new TableExistsException(tableName, tableName, "");
 +
 +    if (!namespaceExists(namespace)) {
 +      throw new IllegalArgumentException("Namespace (" + namespace + ") does not exist, create it first");
 +    }
 +    acu.createTable(username, tableName, versioningIter, timeType);
 +  }
 +
 +  @Override
 +  public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.addSplits(tableName, partitionKeys);
 +  }
 +
 +  @Deprecated
 +  @Override
 +  public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
 +    return listSplits(tableName);
 +  }
 +
 +  @Deprecated
 +  @Override
 +  public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
 +    return listSplits(tableName);
 +  }
 +
 +  @Override
 +  public Collection<Text> listSplits(String tableName) throws TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    return acu.getSplits(tableName);
 +  }
 +
 +  @Override
 +  public Collection<Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException {
 +    return listSplits(tableName);
 +  }
 +
 +  @Override
 +  public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.tables.remove(tableName);
 +  }
 +
 +  @Override
 +  public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
 +      TableExistsException {
 +    if (!exists(oldTableName))
 +      throw new TableNotFoundException(oldTableName, oldTableName, "");
 +    if (exists(newTableName))
 +      throw new TableExistsException(newTableName, newTableName, "");
 +    MockTable t = acu.tables.remove(oldTableName);
 +    String namespace = Tables.qualify(newTableName).getFirst();
 +    MockNamespace n = acu.namespaces.get(namespace);
 +    if (n == null) {
 +      n = new MockNamespace();
 +    }
 +    t.setNamespaceName(namespace);
 +    t.setNamespace(n);
 +    acu.namespaces.put(namespace, n);
 +    acu.tables.put(newTableName, t);
 +  }
 +
 +  @Deprecated
 +  @Override
 +  public void flush(String tableName) throws AccumuloException, AccumuloSecurityException {}
 +
 +  @Override
 +  public void setProperty(String tableName, String property, String value) throws AccumuloException, AccumuloSecurityException {
 +    acu.tables.get(tableName).settings.put(property, value);
 +  }
 +
 +  @Override
 +  public void removeProperty(String tableName, String property) throws AccumuloException, AccumuloSecurityException {
 +    acu.tables.get(tableName).settings.remove(property);
 +  }
 +
 +  @Override
 +  public Iterable<Entry<String,String>> getProperties(String tableName) throws TableNotFoundException {
 +    String namespace = Tables.qualify(tableName).getFirst();
 +    if (!exists(tableName)) {
 +      if (!namespaceExists(namespace))
 +        throw new TableNotFoundException(tableName, new NamespaceNotFoundException(null, namespace, null));
 +      throw new TableNotFoundException(null, tableName, null);
 +    }
 +
 +    Set<Entry<String,String>> props = new HashSet<Entry<String,String>>(acu.namespaces.get(namespace).settings.entrySet());
 +
 +    Set<Entry<String,String>> tableProps = acu.tables.get(tableName).settings.entrySet();
 +    for (Entry<String,String> e : tableProps) {
 +      if (props.contains(e)) {
 +        props.remove(e);
 +      }
 +      props.add(e);
 +    }
 +    return props;
 +  }
 +
 +  @Override
 +  public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.tables.get(tableName).setLocalityGroups(groups);
 +  }
 +
 +  @Override
 +  public Map<String,Set<Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    return acu.tables.get(tableName).getLocalityGroups();
 +  }
 +
 +  @Override
 +  public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException,
 +      TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    return Collections.singleton(range);
 +  }
 +
 +  @Override
 +  public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws IOException, AccumuloException,
 +      AccumuloSecurityException, TableNotFoundException {
 +    long time = System.currentTimeMillis();
 +    MockTable table = acu.tables.get(tableName);
 +    if (table == null) {
 +      throw new TableNotFoundException(null, tableName, "The table was not found");
 +    }
 +    Path importPath = new Path(dir);
 +    Path failurePath = new Path(failureDir);
 +
 +    FileSystem fs = acu.getFileSystem();
 +    /*
 +     * check preconditions
 +     */
 +    // directories are directories
 +    if (fs.isFile(importPath)) {
 +      throw new IOException("Import path must be a directory.");
 +    }
 +    if (fs.isFile(failurePath)) {
 +      throw new IOException("Failure path must be a directory.");
 +    }
 +    // failures are writable
 +    Path createPath = failurePath.suffix("/.createFile");
 +    FSDataOutputStream createStream = null;
 +    try {
 +      createStream = fs.create(createPath);
 +    } catch (IOException e) {
 +      throw new IOException("Error path is not writable.");
 +    } finally {
 +      if (createStream != null) {
 +        createStream.close();
 +      }
 +    }
 +    fs.delete(createPath, false);
 +    // failures are empty
 +    FileStatus[] failureChildStats = fs.listStatus(failurePath);
 +    if (failureChildStats.length > 0) {
 +      throw new IOException("Error path must be empty.");
 +    }
 +    /*
 +     * Begin the import - iterate the files in the path
 +     */
 +    for (FileStatus importStatus : fs.listStatus(importPath)) {
 +      try {
 +        FileSKVIterator importIterator = FileOperations.getInstance().openReader(importStatus.getPath().toString(), true, fs, fs.getConf(),
 +            AccumuloConfiguration.getDefaultConfiguration());
 +        while (importIterator.hasTop()) {
 +          Key key = importIterator.getTopKey();
 +          Value value = importIterator.getTopValue();
 +          if (setTime) {
 +            key.setTimestamp(time);
 +          }
 +          Mutation mutation = new Mutation(key.getRow());
 +          if (!key.isDeleted()) {
 +            mutation.put(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()), key.getTimestamp(),
 +                value);
 +          } else {
 +            mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()),
 +                key.getTimestamp());
 +          }
 +          table.addMutation(mutation);
 +          importIterator.next();
 +        }
 +      } catch (Exception e) {
 +        FSDataOutputStream failureWriter = null;
 +        DataInputStream failureReader = null;
 +        try {
 +          failureWriter = fs.create(failurePath.suffix("/" + importStatus.getPath().getName()));
 +          failureReader = fs.open(importStatus.getPath());
 +          int read = 0;
 +          byte[] buffer = new byte[1024];
 +          while (-1 != (read = failureReader.read(buffer))) {
 +            failureWriter.write(buffer, 0, read);
 +          }
 +        } finally {
 +          if (failureReader != null)
 +            failureReader.close();
 +          if (failureWriter != null)
 +            failureWriter.close();
 +        }
 +      }
 +      fs.delete(importStatus.getPath(), true);
 +    }
 +  }
 +
 +  @Override
 +  public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    offline(tableName, false);
 +  }
 +
 +  @Override
 +  public void offline(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    online(tableName, false);
 +  }
 +
 +  @Override
 +  public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void clearLocatorCache(String tableName) throws TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public Map<String,String> tableIdMap() {
 +    Map<String,String> result = new HashMap<String,String>();
-     for (String table : acu.tables.keySet()) {
++    for (Entry<String,MockTable> entry : acu.tables.entrySet()) {
++      String table = entry.getKey();
 +      if (RootTable.NAME.equals(table))
 +        result.put(table, RootTable.ID);
 +      else if (MetadataTable.NAME.equals(table))
 +        result.put(table, MetadataTable.ID);
 +      else
-         result.put(table, table);
++        result.put(table, entry.getValue().getTableId());
 +    }
 +    return result;
 +  }
 +
 +  @Override
 +  public List<DiskUsage> getDiskUsage(Set<String> tables) throws AccumuloException, AccumuloSecurityException {
 +
 +    List<DiskUsage> diskUsages = new ArrayList<DiskUsage>();
 +    diskUsages.add(new DiskUsage(new TreeSet<String>(tables), 0l));
 +
 +    return diskUsages;
 +  }
 +
 +  @Override
 +  public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    acu.merge(tableName, start, end);
 +  }
 +
 +  @Override
 +  public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +    MockTable t = acu.tables.get(tableName);
 +    Text startText = start != null ? new Text(start) : new Text();
 +    Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes());
 +    startText.append(ZERO, 0, 1);
 +    endText.append(ZERO, 0, 1);
 +    Set<Key> keep = new TreeSet<Key>(t.table.subMap(new Key(startText), new Key(endText)).keySet());
 +    t.table.keySet().removeAll(keep);
 +  }
 +
 +  @Override
 +  public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException,
 +      AccumuloException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void compact(String tableName, Text start, Text end, List<IteratorSetting> iterators, boolean flush, boolean wait) throws AccumuloSecurityException,
 +      TableNotFoundException, AccumuloException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
 +      throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
 +    throw new NotImplementedException();
 +  }
 +
 +  @Override
 +  public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 +    if (!exists(tableName))
 +      throw new TableNotFoundException(tableName, tableName, "");
 +  }
 +
 +  @Override
 +  public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive)
 +      throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
 +    MockTable table = acu.tables.get(tableName);
 +    if (table == null)
 +      throw new TableNotFoundException(tableName, tableName, "no such table");
 +
 +    return FindMax.findMax(new MockScanner(table, auths), startRow, startInclusive, endRow, endInclusive);
 +  }
 +
 +  @Override
 +  public void importTable(String tableName, String exportDir) throws TableExistsException, AccumuloException, AccumuloSecurityException {
 +    throw new NotImplementedException();
 +  }
 +
 +  @Override
 +  public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
 +    throw new NotImplementedException();
 +  }
 +
 +  @Override
 +  public boolean testClassLoad(String tableName, String className, String asTypeName) throws AccumuloException, AccumuloSecurityException,
 +      TableNotFoundException {
 +
 +    try {
 +      AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
 +    } catch (ClassNotFoundException e) {
 +      e.printStackTrace();
 +      return false;
 +    }
 +    return true;
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/38ff0000/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/38ff0000/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
----------------------------------------------------------------------
diff --cc server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
index 82e5885,0000000..3642bc3
mode 100644,000000..100644
--- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
@@@ -1,165 -1,0 +1,168 @@@
 +/*
 + * 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.server.master.balancer;
 +
 +import java.util.ArrayList;
 +import java.util.Collections;
 +import java.util.HashMap;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Set;
 +import java.util.SortedMap;
 +import java.util.TreeMap;
 +
 +import org.apache.accumulo.core.client.Connector;
 +import org.apache.accumulo.core.client.admin.TableOperations;
 +import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
 +import org.apache.accumulo.core.client.mock.MockInstance;
 +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 +import org.apache.accumulo.core.data.KeyExtent;
 +import org.apache.accumulo.core.master.thrift.TableInfo;
 +import org.apache.accumulo.core.master.thrift.TabletServerStatus;
 +import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
 +import org.apache.accumulo.server.master.state.TServerInstance;
 +import org.apache.accumulo.server.master.state.TabletMigration;
 +import org.apache.hadoop.io.Text;
 +import org.apache.thrift.TException;
 +import org.junit.Assert;
 +import org.junit.Test;
 +
 +import com.google.common.net.HostAndPort;
 +
 +public class TableLoadBalancerTest {
 +  
 +  static private TServerInstance mkts(String address, String session) throws Exception {
 +    return new TServerInstance(HostAndPort.fromParts(address, 1234), session);
 +  }
 +  
 +  static private TabletServerStatus status(Object... config) {
 +    TabletServerStatus result = new TabletServerStatus();
 +    result.tableMap = new HashMap<String,TableInfo>();
 +    String tablename = null;
 +    for (Object c : config) {
 +      if (c instanceof String) {
 +        tablename = (String) c;
 +      } else {
 +        TableInfo info = new TableInfo();
 +        int count = (Integer) c;
 +        info.onlineTablets = count;
 +        info.tablets = count;
 +        result.tableMap.put(tablename, info);
 +      }
 +    }
 +    return result;
 +  }
 +  
 +  static MockInstance instance = new MockInstance("mockamatic");
 +  
 +  static SortedMap<TServerInstance,TabletServerStatus> state;
 +  
 +  static List<TabletStats> generateFakeTablets(TServerInstance tserver, String tableId) {
 +    List<TabletStats> result = new ArrayList<TabletStats>();
 +    TabletServerStatus tableInfo = state.get(tserver);
 +    // generate some fake tablets
 +    for (int i = 0; i < tableInfo.tableMap.get(tableId).onlineTablets; i++) {
 +      TabletStats stats = new TabletStats();
 +      stats.extent = new KeyExtent(new Text(tableId), new Text(tserver.host() + String.format("%03d", i + 1)), new Text(tserver.host()
 +          + String.format("%03d", i))).toThrift();
 +      result.add(stats);
 +    }
 +    return result;
 +  }
 +  
 +  static class DefaultLoadBalancer extends org.apache.accumulo.server.master.balancer.DefaultLoadBalancer {
 +    
 +    public DefaultLoadBalancer(String table) {
 +      super(table);
 +    }
 +    
 +    @Override
 +    public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException {
 +      return generateFakeTablets(tserver, tableId);
 +    }
 +  }
 +  
 +  // ugh... so wish I had provided mock objects to the LoadBalancer in the master
 +  static class TableLoadBalancer extends org.apache.accumulo.server.master.balancer.TableLoadBalancer {
 +    
 +    TableLoadBalancer() {
 +      super();
 +    }
 +    
 +    // need to use our mock instance
 +    @Override
 +    protected TableOperations getTableOperations() {
 +      try {
 +        return instance.getConnector("user", new PasswordToken("pass")).tableOperations();
 +      } catch (Exception e) {
 +        throw new RuntimeException(e);
 +      }
 +    }
 +    
 +    // use our new classname to test class loading
 +    @Override
 +    protected String getLoadBalancerClassNameForTable(String table) {
 +      return DefaultLoadBalancer.class.getName();
 +    }
 +    
 +    // we don't have real tablet servers to ask: invent some online tablets
 +    @Override
 +    public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException {
 +      return generateFakeTablets(tserver, tableId);
 +    }
 +  }
 +  
 +  @Test
 +  public void test() throws Exception {
 +    Connector c = instance.getConnector("user", new PasswordToken("pass"));
-     c.tableOperations().create("t1");
-     c.tableOperations().create("t2");
-     c.tableOperations().create("t3");
++    TableOperations tops = c.tableOperations();
++    tops.create("t1");
++    tops.create("t2");
++    tops.create("t3");
++    String t1Id = tops.tableIdMap().get("t1"), t2Id = tops.tableIdMap().get("t2"), t3Id = tops.tableIdMap().get("t3");
 +    state = new TreeMap<TServerInstance,TabletServerStatus>();
 +    TServerInstance svr = mkts("10.0.0.1", "0x01020304");
 +    state.put(svr, status("t1", 10, "t2", 10, "t3", 10));
++    state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
 +    
 +    Set<KeyExtent> migrations = Collections.emptySet();
 +    List<TabletMigration> migrationsOut = new ArrayList<TabletMigration>();
 +    TableLoadBalancer tls = new TableLoadBalancer();
 +    tls.balance(state, migrations, migrationsOut);
 +    Assert.assertEquals(0, migrationsOut.size());
 +    
 +    state.put(mkts("10.0.0.2", "0x02030405"), status());
 +    tls = new TableLoadBalancer();
 +    tls.balance(state, migrations, migrationsOut);
 +    int count = 0;
 +    Map<String,Integer> movedByTable = new HashMap<String,Integer>();
-     movedByTable.put("t1", new Integer(0));
-     movedByTable.put("t2", new Integer(0));
-     movedByTable.put("t3", new Integer(0));
++    movedByTable.put(t1Id, new Integer(0));
++    movedByTable.put(t2Id, new Integer(0));
++    movedByTable.put(t3Id, new Integer(0));
 +    for (TabletMigration migration : migrationsOut) {
 +      if (migration.oldServer.equals(svr))
 +        count++;
 +      String key = migration.tablet.getTableId().toString();
 +      movedByTable.put(key, movedByTable.get(key) + 1);
 +    }
 +    Assert.assertEquals(15, count);
 +    for (Integer moved : movedByTable.values()) {
 +      Assert.assertEquals(5, moved.intValue());
 +    }
 +  }
 +  
 +}


[2/8] git commit: ACCUMULO-2857 Return a more real tableID

Posted by el...@apache.org.
ACCUMULO-2857 Return a more real tableID


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/9fcca2ed
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/9fcca2ed
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/9fcca2ed

Branch: refs/heads/ACCUMULO-378
Commit: 9fcca2ede18a7b96bee4edb5ab105316ac383604
Parents: 6dfcf8f
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 5 12:53:26 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 5 12:53:26 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/client/mock/MockAccumulo.java     |  4 +++-
 .../apache/accumulo/core/client/mock/MockTable.java |  8 +++++++-
 .../core/client/mock/MockTableOperations.java       |  4 ++--
 .../core/client/mock/MockTableOperationsTest.java   | 11 +++++++++++
 .../master/balancer/TableLoadBalancerTest.java      | 16 +++++++++-------
 5 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
index 5977d1d..272d1af 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
@@ -21,6 +21,7 @@ import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.SortedSet;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchScanner;
@@ -38,6 +39,7 @@ public class MockAccumulo {
   final Map<String,String> systemProperties = new HashMap<String,String>();
   Map<String,MockUser> users = new HashMap<String,MockUser>();
   final FileSystem fs;
+  final AtomicInteger tableIdCounter = new AtomicInteger(0);
   
   MockAccumulo(FileSystem fs) {
     this.fs = fs;
@@ -76,7 +78,7 @@ public class MockAccumulo {
   }
   
   public void createTable(String username, String tableName, boolean useVersions, TimeType timeType) {
-    MockTable t = new MockTable(useVersions, timeType);
+    MockTable t = new MockTable(useVersions, timeType, Integer.toString(tableIdCounter.incrementAndGet()));
     t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
     tables.put(tableName, t);
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
index 3dcab11..2e13d84 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
@@ -89,9 +89,11 @@ public class MockTable {
   private TimeType timeType;
   SortedSet<Text> splits = new ConcurrentSkipListSet<Text>();
   Map<String,Set<Text>> localityGroups = new TreeMap<String, Set<Text>>();
+  private String tableId;
   
-  MockTable(boolean limitVersion, TimeType timeType) {
+  MockTable(boolean limitVersion, TimeType timeType, String tableId) {
     this.timeType = timeType;
+    this.tableId = tableId;
     settings = IteratorUtil.generateInitialTableProperties(limitVersion);
     for (Entry<String,String> entry : AccumuloConfiguration.getDefaultConfiguration()) {
       String key = entry.getKey();
@@ -143,4 +145,8 @@ public class MockTable {
     if (reAdd)
       splits.add(start);
   }
+
+  public String getTableId() {
+    return this.tableId;
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
index 64f8225..5b15351 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
@@ -296,8 +296,8 @@ public class MockTableOperations extends TableOperationsHelper {
   @Override
   public Map<String,String> tableIdMap() {
     Map<String,String> result = new HashMap<String,String>();
-    for (String table : acu.tables.keySet()) {
-      result.put(table, table);
+    for (Entry<String,MockTable> entry : acu.tables.entrySet()) {
+      result.put(entry.getKey(), entry.getValue().getTableId());
     }
     return result;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
index ea916e7..cea66a4 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
@@ -333,4 +333,15 @@ public class MockTableOperationsTest {
 
   }
 
+
+  @Test
+  public void testTableIdMap() throws Exception {
+    Instance inst = new MockInstance("testTableIdMap");
+    Connector conn = inst.getConnector("root", new PasswordToken(""));
+    TableOperations tops = conn.tableOperations();
+    tops.create("foo");
+
+    // Should get a table ID, not the table name
+    Assert.assertNotEquals("foo", tops.tableIdMap().get("foo"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java b/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
index 71ba50d..b7c6412 100644
--- a/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
@@ -128,12 +128,14 @@ public class TableLoadBalancerTest {
   @Test
   public void test() throws Exception {
     Connector c = instance.getConnector("user", new PasswordToken("pass"));
-    c.tableOperations().create("t1");
-    c.tableOperations().create("t2");
-    c.tableOperations().create("t3");
+    TableOperations tops = c.tableOperations();
+    tops.create("t1");
+    tops.create("t2");
+    tops.create("t3");
+    String t1Id = tops.tableIdMap().get("t1"), t2Id = tops.tableIdMap().get("t2"), t3Id = tops.tableIdMap().get("t3");
     state = new TreeMap<TServerInstance,TabletServerStatus>();
     TServerInstance svr = mkts("10.0.0.1:1234", "0x01020304");
-    state.put(svr, status("t1", 10, "t2", 10, "t3", 10));
+    state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
     
     Set<KeyExtent> migrations = Collections.emptySet();
     List<TabletMigration> migrationsOut = new ArrayList<TabletMigration>();
@@ -146,9 +148,9 @@ public class TableLoadBalancerTest {
     tls.balance(state, migrations, migrationsOut);
     int count = 0;
     Map<String,Integer> movedByTable = new HashMap<String,Integer>();
-    movedByTable.put("t1", new Integer(0));
-    movedByTable.put("t2", new Integer(0));
-    movedByTable.put("t3", new Integer(0));
+    movedByTable.put(t1Id, new Integer(0));
+    movedByTable.put(t2Id, new Integer(0));
+    movedByTable.put(t3Id, new Integer(0));
     for (TabletMigration migration : migrationsOut) {
       if (migration.oldServer.equals(svr))
         count++;