You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2015/05/29 23:18:02 UTC

[1/8] accumulo git commit: ACCUMULO-3169 Handle table not found case in clone

Repository: accumulo
Updated Branches:
  refs/heads/1.6 182fbce76 -> 76c545bb3
  refs/heads/1.7 0eef354c5 -> f7be66e69
  refs/heads/master 6021fdb2d -> f15a451d0


ACCUMULO-3169 Handle table not found case in clone

* Ensure that we can retrieve the namespaceId for the given srcTableId when we
  construct a CloneTable fate operation.
* Throw an appropriate exception which propagates to the client when we can't.


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

Branch: refs/heads/1.6
Commit: 76c545bb3bdb4c59963cc00417a663ab1ae046f1
Parents: 182fbce
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:01:40 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:09:01 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/master/tableOps/CloneTable.java    | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/76c545bb/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
index da0afd8..b7e335f 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
@@ -231,7 +231,8 @@ public class CloneTable extends MasterRepo {
   private static final long serialVersionUID = 1L;
   private CloneInfo cloneInfo;
 
-  public CloneTable(String user, String srcTableId, String tableName, Map<String,String> propertiesToSet, Set<String> propertiesToExclude) {
+  public CloneTable(String user, String srcTableId, String tableName, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
+      throws ThriftTableOperationException {
     cloneInfo = new CloneInfo();
     cloneInfo.user = user;
     cloneInfo.srcTableId = srcTableId;
@@ -239,7 +240,15 @@ public class CloneTable extends MasterRepo {
     cloneInfo.propertiesToExclude = propertiesToExclude;
     cloneInfo.propertiesToSet = propertiesToSet;
     Instance inst = HdfsZooInstance.getInstance();
-    cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, cloneInfo.srcTableId);
+    try {
+      cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, cloneInfo.srcTableId);
+    } catch (IllegalArgumentException e) {
+      if (inst == null || cloneInfo.srcTableId == null) {
+        // just throw the exception if the illegal argument was thrown by the argument checker and not due to table non-existence
+        throw e;
+      }
+      throw new ThriftTableOperationException(cloneInfo.srcTableId, "", TableOperation.CLONE, TableOperationExceptionType.NOTFOUND, "Table does not exist");
+    }
   }
 
   @Override


[2/8] accumulo git commit: ACCUMULO-3169 Handle table not found case in clone

Posted by ct...@apache.org.
ACCUMULO-3169 Handle table not found case in clone

* Ensure that we can retrieve the namespaceId for the given srcTableId when we
  construct a CloneTable fate operation.
* Throw an appropriate exception which propagates to the client when we can't.


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

Branch: refs/heads/1.7
Commit: 76c545bb3bdb4c59963cc00417a663ab1ae046f1
Parents: 182fbce
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:01:40 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:09:01 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/master/tableOps/CloneTable.java    | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/76c545bb/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
index da0afd8..b7e335f 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
@@ -231,7 +231,8 @@ public class CloneTable extends MasterRepo {
   private static final long serialVersionUID = 1L;
   private CloneInfo cloneInfo;
 
-  public CloneTable(String user, String srcTableId, String tableName, Map<String,String> propertiesToSet, Set<String> propertiesToExclude) {
+  public CloneTable(String user, String srcTableId, String tableName, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
+      throws ThriftTableOperationException {
     cloneInfo = new CloneInfo();
     cloneInfo.user = user;
     cloneInfo.srcTableId = srcTableId;
@@ -239,7 +240,15 @@ public class CloneTable extends MasterRepo {
     cloneInfo.propertiesToExclude = propertiesToExclude;
     cloneInfo.propertiesToSet = propertiesToSet;
     Instance inst = HdfsZooInstance.getInstance();
-    cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, cloneInfo.srcTableId);
+    try {
+      cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, cloneInfo.srcTableId);
+    } catch (IllegalArgumentException e) {
+      if (inst == null || cloneInfo.srcTableId == null) {
+        // just throw the exception if the illegal argument was thrown by the argument checker and not due to table non-existence
+        throw e;
+      }
+      throw new ThriftTableOperationException(cloneInfo.srcTableId, "", TableOperation.CLONE, TableOperationExceptionType.NOTFOUND, "Table does not exist");
+    }
   }
 
   @Override


[5/8] accumulo git commit: Merge branch '1.6' into 1.7

Posted by ct...@apache.org.
Merge branch '1.6' into 1.7

Conflicts:
	server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java


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

Branch: refs/heads/master
Commit: 782dc23731b0bb161be203832c0bac45591c4ffb
Parents: 0eef354 76c545b
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:13:55 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:13:55 2015 -0400

----------------------------------------------------------------------
 .../accumulo/master/tableOps/CloneTable.java       | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/782dc237/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
----------------------------------------------------------------------
diff --cc server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
index eb2370e,b7e335f..84529a6
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
@@@ -19,11 -19,212 +19,14 @@@ package org.apache.accumulo.master.tabl
  import java.util.Map;
  import java.util.Set;
  
+ import org.apache.accumulo.core.client.Instance;
 -import org.apache.accumulo.core.client.NamespaceNotFoundException;
 -import org.apache.accumulo.core.client.impl.Namespaces;
  import org.apache.accumulo.core.client.impl.Tables;
  import org.apache.accumulo.core.client.impl.thrift.TableOperation;
+ import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
 -import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
+ import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
 -import org.apache.accumulo.core.master.state.tables.TableState;
 -import org.apache.accumulo.core.security.TablePermission;
  import org.apache.accumulo.fate.Repo;
 -import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
  import org.apache.accumulo.master.Master;
  import org.apache.accumulo.server.client.HdfsZooInstance;
 -import org.apache.accumulo.server.security.AuditedSecurityOperation;
 -import org.apache.accumulo.server.security.SystemCredentials;
 -import org.apache.accumulo.server.tables.TableManager;
 -import org.apache.accumulo.server.util.MetadataTableUtil;
 -import org.apache.log4j.Logger;
 -
 -class CloneInfo implements Serializable {
 -
 -  private static final long serialVersionUID = 1L;
 -
 -  String srcTableId;
 -  String tableName;
 -  String tableId;
 -  String namespaceId;
 -  String srcNamespaceId;
 -  Map<String,String> propertiesToSet;
 -  Set<String> propertiesToExclude;
 -
 -  public String user;
 -}
 -
 -class FinishCloneTable extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -  private CloneInfo cloneInfo;
 -
 -  public FinishCloneTable(CloneInfo cloneInfo) {
 -    this.cloneInfo = cloneInfo;
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    return 0;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    // directories are intentionally not created.... this is done because directories should be unique
 -    // because they occupy a different namespace than normal tablet directories... also some clones
 -    // may never create files.. therefore there is no need to consume namenode space w/ directories
 -    // that are not used... tablet will create directories as needed
 -
 -    TableManager.getInstance().transitionTableState(cloneInfo.tableId, TableState.ONLINE);
 -
 -    Utils.unreserveNamespace(cloneInfo.srcNamespaceId, tid, false);
 -    if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId))
 -      Utils.unreserveNamespace(cloneInfo.namespaceId, tid, false);
 -    Utils.unreserveTable(cloneInfo.srcTableId, tid, false);
 -    Utils.unreserveTable(cloneInfo.tableId, tid, true);
 -
 -    environment.getEventCoordinator().event("Cloned table %s from %s", cloneInfo.tableName, cloneInfo.srcTableId);
 -
 -    Logger.getLogger(FinishCloneTable.class).debug("Cloned table " + cloneInfo.srcTableId + " " + cloneInfo.tableId + " " + cloneInfo.tableName);
 -
 -    return null;
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {}
 -
 -}
 -
 -class CloneMetadata extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -  private CloneInfo cloneInfo;
 -
 -  public CloneMetadata(CloneInfo cloneInfo) {
 -    this.cloneInfo = cloneInfo;
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    return 0;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    Logger.getLogger(CloneMetadata.class).info(
 -        String.format("Cloning %s with tableId %s from srcTableId %s", cloneInfo.tableName, cloneInfo.tableId, cloneInfo.srcTableId));
 -    Instance instance = HdfsZooInstance.getInstance();
 -    // need to clear out any metadata entries for tableId just in case this
 -    // died before and is executing again
 -    MetadataTableUtil.deleteTable(cloneInfo.tableId, false, SystemCredentials.get(), environment.getMasterLock());
 -    MetadataTableUtil.cloneTable(instance, cloneInfo.srcTableId, cloneInfo.tableId, environment.getFileSystem());
 -    return new FinishCloneTable(cloneInfo);
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {
 -    MetadataTableUtil.deleteTable(cloneInfo.tableId, false, SystemCredentials.get(), environment.getMasterLock());
 -  }
 -
 -}
 -
 -class CloneZookeeper extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -
 -  private CloneInfo cloneInfo;
 -
 -  public CloneZookeeper(CloneInfo cloneInfo) throws NamespaceNotFoundException {
 -    this.cloneInfo = cloneInfo;
 -    Instance inst = HdfsZooInstance.getInstance();
 -    this.cloneInfo.namespaceId = Namespaces.getNamespaceId(inst, Tables.qualify(this.cloneInfo.tableName).getFirst());
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    long val = 0;
 -    if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId))
 -      val += Utils.reserveNamespace(cloneInfo.namespaceId, tid, false, true, TableOperation.CLONE);
 -    val += Utils.reserveTable(cloneInfo.tableId, tid, true, false, TableOperation.CLONE);
 -    return val;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    Utils.tableNameLock.lock();
 -    try {
 -      // write tableName & tableId to zookeeper
 -      Instance instance = HdfsZooInstance.getInstance();
 -
 -      Utils.checkTableDoesNotExist(instance, cloneInfo.tableName, cloneInfo.tableId, TableOperation.CLONE);
 -
 -      TableManager.getInstance().cloneTable(cloneInfo.srcTableId, cloneInfo.tableId, cloneInfo.tableName, cloneInfo.namespaceId, cloneInfo.propertiesToSet,
 -          cloneInfo.propertiesToExclude, NodeExistsPolicy.OVERWRITE);
 -      Tables.clearCache(instance);
 -
 -      return new CloneMetadata(cloneInfo);
 -    } finally {
 -      Utils.tableNameLock.unlock();
 -    }
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {
 -    Instance instance = HdfsZooInstance.getInstance();
 -    TableManager.getInstance().removeTable(cloneInfo.tableId);
 -    if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId))
 -      Utils.unreserveNamespace(cloneInfo.namespaceId, tid, false);
 -    Utils.unreserveTable(cloneInfo.tableId, tid, true);
 -    Tables.clearCache(instance);
 -  }
 -
 -}
 -
 -class ClonePermissions extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -
 -  private CloneInfo cloneInfo;
 -
 -  public ClonePermissions(CloneInfo cloneInfo) {
 -    this.cloneInfo = cloneInfo;
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    return 0;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    // give all table permissions to the creator
 -    for (TablePermission permission : TablePermission.values()) {
 -      try {
 -        AuditedSecurityOperation.getInstance().grantTablePermission(SystemCredentials.get().toThrift(environment.getInstance()), cloneInfo.user,
 -            cloneInfo.tableId, permission, cloneInfo.namespaceId);
 -      } catch (ThriftSecurityException e) {
 -        Logger.getLogger(FinishCloneTable.class).error(e.getMessage(), e);
 -        throw e;
 -      }
 -    }
 -
 -    // setup permissions in zookeeper before table info in zookeeper
 -    // this way concurrent users will not get a spurious pemission denied
 -    // error
 -    try {
 -      return new CloneZookeeper(cloneInfo);
 -    } catch (NamespaceNotFoundException e) {
 -      throw new ThriftTableOperationException(null, cloneInfo.tableName, TableOperation.CLONE, TableOperationExceptionType.NAMESPACE_NOTFOUND,
 -          "Namespace for target table not found");
 -    }
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {
 -    AuditedSecurityOperation.getInstance().deleteTable(SystemCredentials.get().toThrift(environment.getInstance()), cloneInfo.tableId, cloneInfo.namespaceId);
 -  }
 -}
  
  public class CloneTable extends MasterRepo {
  


[8/8] accumulo git commit: Merge branch '1.7'

Posted by ct...@apache.org.
Merge branch '1.7'


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

Branch: refs/heads/master
Commit: f15a451d0d2fd03f11dbb52844d15ed60428ea84
Parents: 6021fdb f7be66e
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:15:38 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:15:38 2015 -0400

----------------------------------------------------------------------
 .../accumulo/master/tableOps/CloneTable.java       | 17 +++++++++++++++--
 .../accumulo/tracer/AsyncSpanReceiverTest.java     | 14 +++++++-------
 2 files changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------



[7/8] accumulo git commit: ACCUMULO-3862 Fix generics on Map parameter

Posted by ct...@apache.org.
ACCUMULO-3862 Fix generics on Map parameter


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

Branch: refs/heads/1.7
Commit: f7be66e6938b40c888efc1ea7b6d161ab9e6ce05
Parents: 782dc23
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:15:13 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:15:13 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/tracer/AsyncSpanReceiverTest.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f7be66e6/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
----------------------------------------------------------------------
diff --git a/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java b/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
index 6744efc..e735373 100644
--- a/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
+++ b/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
@@ -16,17 +16,17 @@
  */
 package org.apache.accumulo.tracer;
 
-import org.apache.accumulo.tracer.thrift.RemoteSpan;
-import org.apache.htrace.HTraceConfiguration;
-import org.apache.htrace.Span;
-import org.apache.htrace.impl.MilliSpan;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import static org.junit.Assert.assertEquals;
+import org.apache.accumulo.tracer.thrift.RemoteSpan;
+import org.apache.htrace.HTraceConfiguration;
+import org.apache.htrace.Span;
+import org.apache.htrace.impl.MilliSpan;
+import org.junit.Test;
 
 public class AsyncSpanReceiverTest {
   static class TestReceiver extends AsyncSpanReceiver<String,String> {
@@ -51,7 +51,7 @@ public class AsyncSpanReceiverTest {
     }
 
     @Override
-    protected String getSpanKey(Map data) {
+    protected String getSpanKey(Map<String,String> data) {
       return "DEST";
     }
 


[6/8] accumulo git commit: ACCUMULO-3862 Fix generics on Map parameter

Posted by ct...@apache.org.
ACCUMULO-3862 Fix generics on Map parameter


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

Branch: refs/heads/master
Commit: f7be66e6938b40c888efc1ea7b6d161ab9e6ce05
Parents: 782dc23
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:15:13 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:15:13 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/tracer/AsyncSpanReceiverTest.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f7be66e6/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
----------------------------------------------------------------------
diff --git a/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java b/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
index 6744efc..e735373 100644
--- a/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
+++ b/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
@@ -16,17 +16,17 @@
  */
 package org.apache.accumulo.tracer;
 
-import org.apache.accumulo.tracer.thrift.RemoteSpan;
-import org.apache.htrace.HTraceConfiguration;
-import org.apache.htrace.Span;
-import org.apache.htrace.impl.MilliSpan;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import static org.junit.Assert.assertEquals;
+import org.apache.accumulo.tracer.thrift.RemoteSpan;
+import org.apache.htrace.HTraceConfiguration;
+import org.apache.htrace.Span;
+import org.apache.htrace.impl.MilliSpan;
+import org.junit.Test;
 
 public class AsyncSpanReceiverTest {
   static class TestReceiver extends AsyncSpanReceiver<String,String> {
@@ -51,7 +51,7 @@ public class AsyncSpanReceiverTest {
     }
 
     @Override
-    protected String getSpanKey(Map data) {
+    protected String getSpanKey(Map<String,String> data) {
       return "DEST";
     }
 


[4/8] accumulo git commit: Merge branch '1.6' into 1.7

Posted by ct...@apache.org.
Merge branch '1.6' into 1.7

Conflicts:
	server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java


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

Branch: refs/heads/1.7
Commit: 782dc23731b0bb161be203832c0bac45591c4ffb
Parents: 0eef354 76c545b
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:13:55 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:13:55 2015 -0400

----------------------------------------------------------------------
 .../accumulo/master/tableOps/CloneTable.java       | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/782dc237/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
----------------------------------------------------------------------
diff --cc server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
index eb2370e,b7e335f..84529a6
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
@@@ -19,11 -19,212 +19,14 @@@ package org.apache.accumulo.master.tabl
  import java.util.Map;
  import java.util.Set;
  
+ import org.apache.accumulo.core.client.Instance;
 -import org.apache.accumulo.core.client.NamespaceNotFoundException;
 -import org.apache.accumulo.core.client.impl.Namespaces;
  import org.apache.accumulo.core.client.impl.Tables;
  import org.apache.accumulo.core.client.impl.thrift.TableOperation;
+ import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
 -import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
+ import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
 -import org.apache.accumulo.core.master.state.tables.TableState;
 -import org.apache.accumulo.core.security.TablePermission;
  import org.apache.accumulo.fate.Repo;
 -import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
  import org.apache.accumulo.master.Master;
  import org.apache.accumulo.server.client.HdfsZooInstance;
 -import org.apache.accumulo.server.security.AuditedSecurityOperation;
 -import org.apache.accumulo.server.security.SystemCredentials;
 -import org.apache.accumulo.server.tables.TableManager;
 -import org.apache.accumulo.server.util.MetadataTableUtil;
 -import org.apache.log4j.Logger;
 -
 -class CloneInfo implements Serializable {
 -
 -  private static final long serialVersionUID = 1L;
 -
 -  String srcTableId;
 -  String tableName;
 -  String tableId;
 -  String namespaceId;
 -  String srcNamespaceId;
 -  Map<String,String> propertiesToSet;
 -  Set<String> propertiesToExclude;
 -
 -  public String user;
 -}
 -
 -class FinishCloneTable extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -  private CloneInfo cloneInfo;
 -
 -  public FinishCloneTable(CloneInfo cloneInfo) {
 -    this.cloneInfo = cloneInfo;
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    return 0;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    // directories are intentionally not created.... this is done because directories should be unique
 -    // because they occupy a different namespace than normal tablet directories... also some clones
 -    // may never create files.. therefore there is no need to consume namenode space w/ directories
 -    // that are not used... tablet will create directories as needed
 -
 -    TableManager.getInstance().transitionTableState(cloneInfo.tableId, TableState.ONLINE);
 -
 -    Utils.unreserveNamespace(cloneInfo.srcNamespaceId, tid, false);
 -    if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId))
 -      Utils.unreserveNamespace(cloneInfo.namespaceId, tid, false);
 -    Utils.unreserveTable(cloneInfo.srcTableId, tid, false);
 -    Utils.unreserveTable(cloneInfo.tableId, tid, true);
 -
 -    environment.getEventCoordinator().event("Cloned table %s from %s", cloneInfo.tableName, cloneInfo.srcTableId);
 -
 -    Logger.getLogger(FinishCloneTable.class).debug("Cloned table " + cloneInfo.srcTableId + " " + cloneInfo.tableId + " " + cloneInfo.tableName);
 -
 -    return null;
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {}
 -
 -}
 -
 -class CloneMetadata extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -  private CloneInfo cloneInfo;
 -
 -  public CloneMetadata(CloneInfo cloneInfo) {
 -    this.cloneInfo = cloneInfo;
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    return 0;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    Logger.getLogger(CloneMetadata.class).info(
 -        String.format("Cloning %s with tableId %s from srcTableId %s", cloneInfo.tableName, cloneInfo.tableId, cloneInfo.srcTableId));
 -    Instance instance = HdfsZooInstance.getInstance();
 -    // need to clear out any metadata entries for tableId just in case this
 -    // died before and is executing again
 -    MetadataTableUtil.deleteTable(cloneInfo.tableId, false, SystemCredentials.get(), environment.getMasterLock());
 -    MetadataTableUtil.cloneTable(instance, cloneInfo.srcTableId, cloneInfo.tableId, environment.getFileSystem());
 -    return new FinishCloneTable(cloneInfo);
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {
 -    MetadataTableUtil.deleteTable(cloneInfo.tableId, false, SystemCredentials.get(), environment.getMasterLock());
 -  }
 -
 -}
 -
 -class CloneZookeeper extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -
 -  private CloneInfo cloneInfo;
 -
 -  public CloneZookeeper(CloneInfo cloneInfo) throws NamespaceNotFoundException {
 -    this.cloneInfo = cloneInfo;
 -    Instance inst = HdfsZooInstance.getInstance();
 -    this.cloneInfo.namespaceId = Namespaces.getNamespaceId(inst, Tables.qualify(this.cloneInfo.tableName).getFirst());
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    long val = 0;
 -    if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId))
 -      val += Utils.reserveNamespace(cloneInfo.namespaceId, tid, false, true, TableOperation.CLONE);
 -    val += Utils.reserveTable(cloneInfo.tableId, tid, true, false, TableOperation.CLONE);
 -    return val;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    Utils.tableNameLock.lock();
 -    try {
 -      // write tableName & tableId to zookeeper
 -      Instance instance = HdfsZooInstance.getInstance();
 -
 -      Utils.checkTableDoesNotExist(instance, cloneInfo.tableName, cloneInfo.tableId, TableOperation.CLONE);
 -
 -      TableManager.getInstance().cloneTable(cloneInfo.srcTableId, cloneInfo.tableId, cloneInfo.tableName, cloneInfo.namespaceId, cloneInfo.propertiesToSet,
 -          cloneInfo.propertiesToExclude, NodeExistsPolicy.OVERWRITE);
 -      Tables.clearCache(instance);
 -
 -      return new CloneMetadata(cloneInfo);
 -    } finally {
 -      Utils.tableNameLock.unlock();
 -    }
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {
 -    Instance instance = HdfsZooInstance.getInstance();
 -    TableManager.getInstance().removeTable(cloneInfo.tableId);
 -    if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId))
 -      Utils.unreserveNamespace(cloneInfo.namespaceId, tid, false);
 -    Utils.unreserveTable(cloneInfo.tableId, tid, true);
 -    Tables.clearCache(instance);
 -  }
 -
 -}
 -
 -class ClonePermissions extends MasterRepo {
 -
 -  private static final long serialVersionUID = 1L;
 -
 -  private CloneInfo cloneInfo;
 -
 -  public ClonePermissions(CloneInfo cloneInfo) {
 -    this.cloneInfo = cloneInfo;
 -  }
 -
 -  @Override
 -  public long isReady(long tid, Master environment) throws Exception {
 -    return 0;
 -  }
 -
 -  @Override
 -  public Repo<Master> call(long tid, Master environment) throws Exception {
 -    // give all table permissions to the creator
 -    for (TablePermission permission : TablePermission.values()) {
 -      try {
 -        AuditedSecurityOperation.getInstance().grantTablePermission(SystemCredentials.get().toThrift(environment.getInstance()), cloneInfo.user,
 -            cloneInfo.tableId, permission, cloneInfo.namespaceId);
 -      } catch (ThriftSecurityException e) {
 -        Logger.getLogger(FinishCloneTable.class).error(e.getMessage(), e);
 -        throw e;
 -      }
 -    }
 -
 -    // setup permissions in zookeeper before table info in zookeeper
 -    // this way concurrent users will not get a spurious pemission denied
 -    // error
 -    try {
 -      return new CloneZookeeper(cloneInfo);
 -    } catch (NamespaceNotFoundException e) {
 -      throw new ThriftTableOperationException(null, cloneInfo.tableName, TableOperation.CLONE, TableOperationExceptionType.NAMESPACE_NOTFOUND,
 -          "Namespace for target table not found");
 -    }
 -  }
 -
 -  @Override
 -  public void undo(long tid, Master environment) throws Exception {
 -    AuditedSecurityOperation.getInstance().deleteTable(SystemCredentials.get().toThrift(environment.getInstance()), cloneInfo.tableId, cloneInfo.namespaceId);
 -  }
 -}
  
  public class CloneTable extends MasterRepo {
  


[3/8] accumulo git commit: ACCUMULO-3169 Handle table not found case in clone

Posted by ct...@apache.org.
ACCUMULO-3169 Handle table not found case in clone

* Ensure that we can retrieve the namespaceId for the given srcTableId when we
  construct a CloneTable fate operation.
* Throw an appropriate exception which propagates to the client when we can't.


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

Branch: refs/heads/master
Commit: 76c545bb3bdb4c59963cc00417a663ab1ae046f1
Parents: 182fbce
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri May 29 17:01:40 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri May 29 17:09:01 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/master/tableOps/CloneTable.java    | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/76c545bb/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
index da0afd8..b7e335f 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
@@ -231,7 +231,8 @@ public class CloneTable extends MasterRepo {
   private static final long serialVersionUID = 1L;
   private CloneInfo cloneInfo;
 
-  public CloneTable(String user, String srcTableId, String tableName, Map<String,String> propertiesToSet, Set<String> propertiesToExclude) {
+  public CloneTable(String user, String srcTableId, String tableName, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
+      throws ThriftTableOperationException {
     cloneInfo = new CloneInfo();
     cloneInfo.user = user;
     cloneInfo.srcTableId = srcTableId;
@@ -239,7 +240,15 @@ public class CloneTable extends MasterRepo {
     cloneInfo.propertiesToExclude = propertiesToExclude;
     cloneInfo.propertiesToSet = propertiesToSet;
     Instance inst = HdfsZooInstance.getInstance();
-    cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, cloneInfo.srcTableId);
+    try {
+      cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, cloneInfo.srcTableId);
+    } catch (IllegalArgumentException e) {
+      if (inst == null || cloneInfo.srcTableId == null) {
+        // just throw the exception if the illegal argument was thrown by the argument checker and not due to table non-existence
+        throw e;
+      }
+      throw new ThriftTableOperationException(cloneInfo.srcTableId, "", TableOperation.CLONE, TableOperationExceptionType.NOTFOUND, "Table does not exist");
+    }
   }
 
   @Override