accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject git commit: ACCUMULO-1976 Fix upgrade broken by ACCUMULO-2093
Date Tue, 07 Jan 2014 02:23:45 GMT
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 9c092cadd -> ea8fe5414


ACCUMULO-1976 Fix upgrade broken by ACCUMULO-2093


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: ea8fe54145b306310a93e9df65ea5277dff2853e
Parents: 9c092ca
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Mon Jan 6 21:19:00 2014 -0500
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Mon Jan 6 21:22:16 2014 -0500

----------------------------------------------------------------------
 .../accumulo/server/tables/TableManager.java    |  5 ++-
 .../java/org/apache/accumulo/master/Master.java | 41 ++++++++++++--------
 2 files changed, 28 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8fe541/server/base/src/main/java/org/apache/accumulo/server/tables/TableManager.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/tables/TableManager.java
b/server/base/src/main/java/org/apache/accumulo/server/tables/TableManager.java
index 0766a17..0f73ae4 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/tables/TableManager.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/tables/TableManager.java
@@ -59,7 +59,7 @@ public class TableManager {
 
   public static void prepareNewNamespaceState(String instanceId, String namespaceId, String
namespace, NodeExistsPolicy existsPolicy) throws KeeperException,
       InterruptedException {
-    // state gets created last
+    log.debug("Creating ZooKeeper entries for new namespace " + namespace + " (ID: " + namespaceId
+ ")");
     String zPath = Constants.ZROOT + "/" + instanceId + Constants.ZNAMESPACES + "/" + namespaceId;
 
     IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
@@ -71,6 +71,7 @@ public class TableManager {
   public static void prepareNewTableState(String instanceId, String tableId, String namespaceId,
String tableName, TableState state,
       NodeExistsPolicy existsPolicy) throws KeeperException, InterruptedException {
     // state gets created last
+    log.debug("Creating ZooKeeper entries for new table " + tableName + " (ID: " + tableId
+ ") in namespace (ID: " + namespaceId + ")");
     Pair<String,String> qualifiedTableName = Tables.qualify(tableName);
     tableName = qualifiedTableName.getSecond();
     String zTablePath = Constants.ZROOT + "/" + instanceId + Constants.ZTABLES + "/" + tableId;
@@ -79,10 +80,10 @@ public class TableManager {
     zoo.putPersistentData(zTablePath + Constants.ZTABLE_CONF, new byte[0], existsPolicy);
     zoo.putPersistentData(zTablePath + Constants.ZTABLE_NAMESPACE, namespaceId.getBytes(Constants.UTF8),
existsPolicy);
     zoo.putPersistentData(zTablePath + Constants.ZTABLE_NAME, tableName.getBytes(Constants.UTF8),
existsPolicy);
-    zoo.putPersistentData(zTablePath + Constants.ZTABLE_STATE, state.name().getBytes(Constants.UTF8),
existsPolicy);
     zoo.putPersistentData(zTablePath + Constants.ZTABLE_FLUSH_ID, "0".getBytes(Constants.UTF8),
existsPolicy);
     zoo.putPersistentData(zTablePath + Constants.ZTABLE_COMPACT_ID, "0".getBytes(Constants.UTF8),
existsPolicy);
     zoo.putPersistentData(zTablePath + Constants.ZTABLE_COMPACT_CANCEL_ID, "0".getBytes(Constants.UTF8),
existsPolicy);
+    zoo.putPersistentData(zTablePath + Constants.ZTABLE_STATE, state.name().getBytes(Constants.UTF8),
existsPolicy);
   }
 
   public synchronized static TableManager getInstance() {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8fe541/server/master/src/main/java/org/apache/accumulo/master/Master.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index 304366c..86a35cd 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -64,6 +64,7 @@ import org.apache.accumulo.core.security.NamespacePermission;
 import org.apache.accumulo.core.security.SecurityUtil;
 import org.apache.accumulo.core.security.TablePermission;
 import org.apache.accumulo.core.util.Daemon;
+import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.AgeOffStore;
@@ -127,6 +128,8 @@ import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.data.Stat;
 
+import com.google.common.collect.Iterables;
+
 /**
  * The Master is responsible for assigning and balancing tablets to tablet servers.
  * 
@@ -228,7 +231,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
     String dirZPath = ZooUtil.getRoot(instance) + RootTable.ZROOT_TABLET_PATH;
 
     if (!zoo.exists(dirZPath)) {
-      Path oldPath = fs.getFullPath(FileType.TABLE, "/!0/root_tablet");
+      Path oldPath = fs.getFullPath(FileType.TABLE, "/" + MetadataTable.ID + "/root_tablet");
       if (fs.exists(oldPath)) {
         String newPath = fs.choose(ServerConstants.getTablesDirs()) + "/" + RootTable.ID;
         fs.mkdirs(new Path(newPath));
@@ -270,30 +273,36 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
         // create initial namespaces
         String namespaces = ZooUtil.getRoot(instance) + Constants.ZNAMESPACES;
         zoo.putPersistentData(namespaces, new byte[0], NodeExistsPolicy.SKIP);
-        if (!Namespaces.exists(instance, Namespaces.ACCUMULO_NAMESPACE_ID))
-          TableManager.prepareNewNamespaceState(instance.getInstanceID(), Namespaces.ACCUMULO_NAMESPACE_ID,
Namespaces.ACCUMULO_NAMESPACE,
-              NodeExistsPolicy.SKIP);
-        if (!Namespaces.exists(instance, Namespaces.DEFAULT_NAMESPACE_ID))
-          TableManager.prepareNewNamespaceState(instance.getInstanceID(), Namespaces.DEFAULT_NAMESPACE_ID,
Namespaces.DEFAULT_NAMESPACE, NodeExistsPolicy.SKIP);
+        for (Pair<String,String> namespace : Iterables.concat(
+            Collections.singleton(new Pair<String,String>(Namespaces.ACCUMULO_NAMESPACE,
Namespaces.ACCUMULO_NAMESPACE_ID)),
+            Collections.singleton(new Pair<String,String>(Namespaces.DEFAULT_NAMESPACE,
Namespaces.DEFAULT_NAMESPACE_ID)))) {
+          String ns = namespace.getFirst();
+          String id = namespace.getSecond();
+          log.debug("Upgrade creating namespace \"" + ns + "\" (ID: " + id + ")");
+          if (!Namespaces.exists(instance, id))
+            TableManager.prepareNewNamespaceState(instance.getInstanceID(), id, ns, NodeExistsPolicy.SKIP);
+        }
 
         // create root table
-        if (!Tables.exists(instance, RootTable.ID)) {
-          TableManager.prepareNewTableState(instance.getInstanceID(), RootTable.ID, Namespaces.ACCUMULO_NAMESPACE_ID,
RootTable.NAME, TableState.ONLINE,
-              NodeExistsPolicy.SKIP);
-          Initialize.initMetadataConfig(RootTable.ID);
-          // ensure root user can flush root table
-          security.grantTablePermission(SystemCredentials.get().toThrift(instance), security.getRootUsername(),
RootTable.ID, TablePermission.ALTER_TABLE);
-        }
+        log.debug("Upgrade creating table " + RootTable.NAME + " (ID: " + RootTable.ID +
")");
+        TableManager.prepareNewTableState(instance.getInstanceID(), RootTable.ID, Namespaces.ACCUMULO_NAMESPACE_ID,
RootTable.NAME, TableState.ONLINE,
+            NodeExistsPolicy.SKIP);
+        Initialize.initMetadataConfig(RootTable.ID);
+        // ensure root user can flush root table
+        security.grantTablePermission(SystemCredentials.get().toThrift(instance), security.getRootUsername(),
RootTable.ID, TablePermission.ALTER_TABLE);
 
         // put existing tables in the correct namespaces
         String tables = ZooUtil.getRoot(instance) + Constants.ZTABLES;
-        for (Entry<String,String> table : Tables.getIdToNameMap(instance).entrySet())
{
-          String targetNamespace = (MetadataTable.ID.equals(table.getKey()) || RootTable.ID.equals(table.getKey()))
? Namespaces.ACCUMULO_NAMESPACE_ID
+        for (String tableId : zoo.getChildren(tables)) {
+          String targetNamespace = (MetadataTable.ID.equals(tableId) || RootTable.ID.equals(tableId))
? Namespaces.ACCUMULO_NAMESPACE_ID
               : Namespaces.DEFAULT_NAMESPACE_ID;
-          zoo.putPersistentData(tables + "/" + table.getKey() + Constants.ZTABLE_NAMESPACE,
targetNamespace.getBytes(Constants.UTF8), NodeExistsPolicy.SKIP);
+          log.debug("Upgrade moving table " + new String(zoo.getData(tables + "/" + tableId
+ Constants.ZTABLE_NAME, null), Constants.UTF8) + " (ID: "
+              + tableId + ") into namespace with ID " + targetNamespace);
+          zoo.putPersistentData(tables + "/" + tableId + Constants.ZTABLE_NAMESPACE, targetNamespace.getBytes(Constants.UTF8),
NodeExistsPolicy.SKIP);
         }
 
         // rename metadata table
+        log.debug("Upgrade renaming table " + MetadataTable.OLD_NAME + " (ID: " + MetadataTable.ID
+ ") to " + MetadataTable.NAME);
         zoo.putPersistentData(tables + "/" + MetadataTable.ID + Constants.ZTABLE_NAME, Tables.qualify(MetadataTable.NAME).getSecond().getBytes(Constants.UTF8),
             NodeExistsPolicy.OVERWRITE);
 


Mime
View raw message