accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject git commit: ACCUMULO-1735 update master state as soon as a meta tablet is assigned
Date Tue, 24 Sep 2013 18:38:10 GMT
Updated Branches:
  refs/heads/master 98fc95216 -> 49381c176


ACCUMULO-1735 update master state as soon as a meta tablet is assigned


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

Branch: refs/heads/master
Commit: 49381c176cc3aef04d2b665c74d0f7f882323506
Parents: 98fc952
Author: Eric Newton <eric.newton@gmail.com>
Authored: Tue Sep 24 14:38:21 2013 -0400
Committer: Eric Newton <eric.newton@gmail.com>
Committed: Tue Sep 24 14:38:21 2013 -0400

----------------------------------------------------------------------
 .../apache/accumulo/server/master/Master.java   | 61 +++++++++++++-------
 .../server/master/TabletGroupWatcher.java       |  4 ++
 .../master/state/RootTabletStateStore.java      |  2 +-
 .../master/state/ZooTabletStateStore.java       |  2 +-
 4 files changed, 46 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/49381c17/server/src/main/java/org/apache/accumulo/server/master/Master.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/Master.java b/server/src/main/java/org/apache/accumulo/server/master/Master.java
index 499f274..62ea7d7 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/Master.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/Master.java
@@ -171,6 +171,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
   
   final private static int ONE_SECOND = 1000;
   final private static Text METADATA_TABLE_ID = new Text(MetadataTable.ID);
+  final private static Text ROOT_TABLE_ID = new Text(RootTable.ID);
   final static long TIME_TO_WAIT_BETWEEN_SCANS = 60 * ONE_SECOND;
   final private static long TIME_BETWEEN_MIGRATION_CLEANUPS = 5 * 60 * ONE_SECOND;
   final static long WAIT_BETWEEN_ERRORS = ONE_SECOND;
@@ -223,8 +224,8 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
       /* SAFE_MODE */                 {_,     _,        X,        X,      X,         _, 
        X},
       /* NORMAL */                    {_,     _,        X,        X,      X,         _, 
        X},
       /* UNLOAD_METADATA_TABLETS */   {_,     _,        X,        X,      X,         X, 
        X},
-      /* UNLOAD_ROOT_TABLET */        {_,     _,        _,        X,      _,         X, 
        X},
-      /* STOP */                      {_,     _,        _,        _,      _,         _, 
        X}};
+      /* UNLOAD_ROOT_TABLET */        {_,     _,        _,        X,      X,         X, 
        X},
+      /* STOP */                      {_,     _,        _,        _,      _,         X, 
        X}};
   //@formatter:on
   synchronized private void setMasterState(MasterState newState) {
     if (state.equals(newState))
@@ -349,7 +350,6 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
   // The number of unassigned tablets that should be assigned: displayed on the monitor page
   private int displayUnassigned() {
     int result = 0;
-    Text meta = new Text(MetadataTable.ID);
     switch (getMasterState()) {
       case NORMAL:
         // Count offline tablets for online tables
@@ -368,13 +368,13 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
       case SAFE_MODE:
         // Count offline tablets for the METADATA table
         for (TabletGroupWatcher watcher : watchers) {
-          result += watcher.getStats(meta).unassigned();
+          result += watcher.getStats(METADATA_TABLE_ID).unassigned();
         }
         break;
       case UNLOAD_METADATA_TABLETS:
       case UNLOAD_ROOT_TABLET:
         for (TabletGroupWatcher watcher : watchers) {
-          result += watcher.getStats(meta).unassigned();
+          result += watcher.getStats(METADATA_TABLE_ID).unassigned();
         }
         break;
       default:
@@ -1267,7 +1267,6 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
       setName("Status Thread");
       EventCoordinator.Listener eventListener = nextEvent.getListener();
       while (stillMaster()) {
-        int count = 0;
         long wait = DEFAULT_WAIT_FOR_WATCHER;
         try {
           switch (getMasterGoalState()) {
@@ -1288,27 +1287,32 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
                   setMasterState(MasterState.SAFE_MODE);
                   break;
                 case SAFE_MODE:
-                  count = nonMetaDataTabletsAssignedOrHosted();
+                {
+                  int count = nonMetaDataTabletsAssignedOrHosted();
                   log.debug(String.format("There are %d non-metadata tablets assigned or
hosted", count));
                   if (count == 0)
                     setMasterState(MasterState.UNLOAD_METADATA_TABLETS);
-                  break;
+                }
+                break;
                 case UNLOAD_METADATA_TABLETS:
-                  count = assignedOrHosted(METADATA_TABLE_ID);
-                  count += assignedOrHosted(new Text(RootTable.ID));
+                {
+                  int count = assignedOrHosted(METADATA_TABLE_ID);
                   log.debug(String.format("There are %d metadata tablets assigned or hosted",
count));
-                  // Assumes last tablet hosted is the root tablet;
-                  // it's possible
-                  // that's not the case (root tablet is offline?)
-                  if (count == 1)
+                  if (count == 0)
                     setMasterState(MasterState.UNLOAD_ROOT_TABLET);
-                  break;
+                }
+                break;
                 case UNLOAD_ROOT_TABLET:
-                  count = assignedOrHosted(METADATA_TABLE_ID);
-                  count += assignedOrHosted(new Text(RootTable.ID));
-                  if (count > 0)
-                    log.debug(String.format("The root tablet is still assigned or hosted"));
-                  if (count == 0) {
+                {
+                  int count = assignedOrHosted(METADATA_TABLE_ID);
+                  if (count > 0) {
+                    log.debug(String.format("%d metadata tablets online", count));
+                    setMasterState(MasterState.UNLOAD_ROOT_TABLET);
+                  }
+                  int root_count = assignedOrHosted(ROOT_TABLE_ID);
+                  if (root_count > 0)
+                    log.debug("The root tablet is still assigned or hosted");
+                  if (count + root_count == 0) {
                     Set<TServerInstance> currentServers = tserverSet.getCurrentServers();
                     log.debug("stopping " + currentServers.size() + " tablet servers");
                     for (TServerInstance server : currentServers) {
@@ -1324,7 +1328,8 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
                     if (currentServers.size() == 0)
                       setMasterState(MasterState.STOP);
                   }
-                  break;
+                }
+                break;
                 default:
                   break;
               }
@@ -1795,4 +1800,18 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
   public void updateRecoveryInProgress(String file) {
     recoveriesInProgress.add(file);
   }
+
+  public void assignedTablet(KeyExtent extent) {
+    if (extent.isMeta()) {
+      if (getMasterState().equals(MasterState.UNLOAD_ROOT_TABLET)) {
+        setMasterState(MasterState.UNLOAD_METADATA_TABLETS);
+      }
+    }
+    if (extent.isRootTablet()) {
+      // probably too late, but try anyhow
+      if (getMasterState().equals(MasterState.STOP)) {
+        setMasterState(MasterState.UNLOAD_ROOT_TABLET);
+      }
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/49381c17/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
b/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
index 6c416a5..dbf3eca 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
@@ -106,6 +106,9 @@ class TabletGroupWatcher extends Daemon {
     EventCoordinator.Listener eventListener = this.master.nextEvent.getListener();
     
     while (this.master.stillMaster()) {
+      // slow things down a little, otherwise we spam the logs when there are many wake-up
events
+      UtilWaitThread.sleep(100);
+
       int totalUnloaded = 0;
       int unloaded = 0;
       try {
@@ -646,6 +649,7 @@ class TabletGroupWatcher extends Daemon {
       } else {
         Master.log.warn("Could not connect to server " + a.server);
       }
+      master.assignedTablet(a.tablet);
     }
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/49381c17/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
b/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
index e1e6424..bdf5478 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
@@ -40,6 +40,6 @@ public class RootTabletStateStore extends MetaDataStateStore {
   
   @Override
   public String name() {
-    return "Non-Root Metadata Tablets";
+    return "Metadata Tablets";
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/49381c17/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
b/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
index 47eed06..7c0bf1d 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
@@ -168,7 +168,7 @@ public class ZooTabletStateStore extends TabletStateStore {
   
   @Override
   public String name() {
-    return "Root Tablet";
+    return "Root Table";
   }
   
 }


Mime
View raw message