accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [20/34] accumulo git commit: ACCUMULO-3423 reduce the number of calls to add a flag to the metadata table
Date Fri, 24 Apr 2015 23:21:06 GMT
ACCUMULO-3423 reduce the number of calls to add a flag to the metadata table


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

Branch: refs/heads/master
Commit: 65d01458b69c20ec5ae3f83a4beb266481e8c840
Parents: 8f5e002
Author: Eric Newton <eric.newton@gmail.com>
Authored: Thu Apr 16 12:03:12 2015 -0400
Committer: Eric Newton <eric.newton@gmail.com>
Committed: Thu Apr 16 12:03:12 2015 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/server/TabletLevel.java | 34 ++++++++++++++++++++
 .../accumulo/server/util/MetadataTableUtil.java |  7 ++--
 .../apache/accumulo/tserver/TabletLevel.java    | 34 --------------------
 .../apache/accumulo/tserver/TabletServer.java   | 16 ++++-----
 .../tserver/log/TabletServerLogger.java         | 10 ++++--
 5 files changed, 52 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/65d01458/server/base/src/main/java/org/apache/accumulo/server/TabletLevel.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/TabletLevel.java b/server/base/src/main/java/org/apache/accumulo/server/TabletLevel.java
new file mode 100644
index 0000000..91e5ee9
--- /dev/null
+++ b/server/base/src/main/java/org/apache/accumulo/server/TabletLevel.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import org.apache.accumulo.core.data.KeyExtent;
+
+public enum TabletLevel {
+  ROOT,
+  META,
+  NORMAL;
+
+  public static TabletLevel getLevel(KeyExtent extent) {
+    if (!extent.isMeta())
+      return NORMAL;
+    if (extent.isRootTablet())
+      return ROOT;
+    return META;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/65d01458/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
index 6d6253d..09a5b40 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
@@ -81,6 +81,7 @@ import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.accumulo.server.AccumuloServerContext;
 import org.apache.accumulo.server.ServerConstants;
+import org.apache.accumulo.server.TabletLevel;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.fs.FileRef;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -1057,9 +1058,9 @@ public class MetadataTableUtil {
     return tabletEntries;
   }
 
-  public static void addNewLogMarker(ClientContext context, ZooLock zooLock, final TServerInstance
tabletSession, final Path filename, KeyExtent extent) {
+  public static void addNewLogMarker(ClientContext context, ZooLock zooLock, final TServerInstance
tabletSession, final Path filename, TabletLevel level) {
     log.debug("Adding log entry " + filename);
-    if (extent.isRootTablet()) {
+    if (level == TabletLevel.ROOT) {
       retryZooKeeperUpdate(context, zooLock, new ZooOperation() {
         @Override
         public void run(IZooReaderWriter rw) throws KeeperException, InterruptedException,
IOException {
@@ -1077,7 +1078,7 @@ public class MetadataTableUtil {
       Mutation m = new Mutation(CurrentLogsSection.getRowPrefix() + tabletSession.toString());
       m.put(CurrentLogsSection.COLF, new Text(filename.toString()), new Value(EMPTY_BYTES));
       String tableName = MetadataTable.NAME;
-      if (extent.isMeta()) {
+      if (level == TabletLevel.META) {
         tableName = RootTable.NAME;
       }
       BatchWriter bw = null;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/65d01458/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletLevel.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletLevel.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletLevel.java
deleted file mode 100644
index 1e82393..0000000
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletLevel.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.tserver;
-
-import org.apache.accumulo.core.data.KeyExtent;
-
-public enum TabletLevel {
-  ROOT,
-  META,
-  NORMAL;
-
-  public static TabletLevel getLevel(KeyExtent extent) {
-    if (!extent.isMeta())
-      return NORMAL;
-    if (extent.isRootTablet())
-      return ROOT;
-    return META;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/65d01458/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 7c64cee..f527a2a 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
@@ -149,6 +149,7 @@ import org.apache.accumulo.server.Accumulo;
 import org.apache.accumulo.server.AccumuloServerContext;
 import org.apache.accumulo.server.GarbageCollectionLogger;
 import org.apache.accumulo.server.ServerOpts;
+import org.apache.accumulo.server.TabletLevel;
 import org.apache.accumulo.server.client.ClientServiceHandler;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ServerConfigurationFactory;
@@ -3038,23 +3039,18 @@ public class TabletServer extends AccumuloServerContext implements
Runnable {
     }
   }
 
-  public void addLoggersToMetadata(DfsLogger copy, KeyExtent extent) {
-    TabletLevel level = TabletLevel.getLevel(extent);
+  public void addLoggersToMetadata(DfsLogger copy, TabletLevel level) {
     // serialize the updates to the metadata per level: avoids updating the level more than
once
     // updating one level, may cause updates to other levels, so we need to release the lock
on metadataTableLogs
     synchronized (levelLocks[level.ordinal()]) {
       EnumSet<TabletLevel> set = null;
-      synchronized (metadataTableLogs) {
-        set = metadataTableLogs.putIfAbsent(copy, EnumSet.of(level));
-      }
+      set = metadataTableLogs.putIfAbsent(copy, EnumSet.of(level));
       if (set == null || !set.contains(level) || level == TabletLevel.ROOT) {
         log.info("Writing log marker for level " + level + " " + copy.getFileName());
-        MetadataTableUtil.addNewLogMarker(this, this.getLock(), this.getTabletSession(),
copy.getPath(), extent);
-      }
-      synchronized (metadataTableLogs) {
-        set = metadataTableLogs.get(copy);
-        set.add(level);
+        MetadataTableUtil.addNewLogMarker(this, this.getLock(), this.getTabletSession(),
copy.getPath(), level);
       }
+      set = metadataTableLogs.get(copy);
+      set.add(level);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/65d01458/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
index dd54798..2541e50 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -41,6 +42,7 @@ import org.apache.accumulo.core.protobuf.ProtobufUtil;
 import org.apache.accumulo.core.replication.ReplicationConfigurationUtil;
 import org.apache.accumulo.core.util.SimpleThreadPool;
 import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.server.TabletLevel;
 import org.apache.accumulo.server.conf.TableConfiguration;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.replication.StatusUtil;
@@ -227,8 +229,12 @@ public class TabletServerLogger {
             log.debug("Creating next WAL");
             DfsLogger alog = new DfsLogger(tserver.getServerConfig(), syncCounter, flushCounter);
             alog.open(tserver.getClientAddressString());
+            EnumSet<TabletLevel> levels = EnumSet.noneOf(TabletLevel.class);
             for (Tablet tablet : tserver.getOnlineTablets()) {
-              tserver.addLoggersToMetadata(alog, tablet.getExtent());
+              levels.add(TabletLevel.getLevel(tablet.getExtent()));
+            }
+            for (TabletLevel level : levels) {
+              tserver.addLoggersToMetadata(alog, level);
             }
             log.debug("Created next WAL " + alog.getFileName());
             while (!nextLog.offer(alog, 12, TimeUnit.HOURS)) {
@@ -308,7 +314,7 @@ public class TabletServerLogger {
                 // Scribble out a tablet definition and then write to the metadata table
                 defineTablet(commitSession);
                 if (currentLogId == logId.get())
-                  tserver.addLoggersToMetadata(copy, commitSession.getExtent());
+                  tserver.addLoggersToMetadata(copy, TabletLevel.getLevel(commitSession.getExtent()));
               } finally {
                 commitSession.finishUpdatingLogsUsed();
               }


Mime
View raw message