accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [5/6] accumulo git commit: ACCUMULO-3416 Clean up TabletOperations
Date Thu, 15 Jan 2015 22:42:04 GMT
ACCUMULO-3416 Clean up TabletOperations

Remove unused method and consolidate remaining method into Tablet


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

Branch: refs/heads/master
Commit: 112f5e76aca55b2b883d3433c53da988a697f1ff
Parents: f6574fa
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Thu Jan 15 17:06:22 2015 -0500
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Thu Jan 15 17:41:32 2015 -0500

----------------------------------------------------------------------
 .../accumulo/server/util/TabletOperations.java  | 93 --------------------
 .../apache/accumulo/tserver/tablet/Tablet.java  | 42 ++++++++-
 2 files changed, 40 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/112f5e76/server/base/src/main/java/org/apache/accumulo/server/util/TabletOperations.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TabletOperations.java
b/server/base/src/main/java/org/apache/accumulo/server/util/TabletOperations.java
deleted file mode 100644
index b1e2d35..0000000
--- a/server/base/src/main/java/org/apache/accumulo/server/util/TabletOperations.java
+++ /dev/null
@@ -1,93 +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.server.util;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-
-import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.util.UtilWaitThread;
-import org.apache.accumulo.server.ServerConstants;
-import org.apache.accumulo.server.fs.VolumeManager;
-import org.apache.accumulo.server.fs.VolumeManagerImpl;
-import org.apache.accumulo.server.tablets.UniqueNameAllocator;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
-
-import com.google.common.base.Optional;
-
-public class TabletOperations {
-
-  private static final Logger log = Logger.getLogger(TabletOperations.class);
-
-  public static String createTabletDirectory(VolumeManager fs, String tableId, Text endRow)
{
-    String lowDirectory;
-
-    UniqueNameAllocator namer = UniqueNameAllocator.getInstance();
-    String volume = fs.choose(Optional.of(tableId), ServerConstants.getBaseUris()) + Constants.HDFS_TABLES_DIR
+ Path.SEPARATOR;
-
-    while (true) {
-      try {
-        if (endRow == null) {
-          lowDirectory = Constants.DEFAULT_TABLET_LOCATION;
-          Path lowDirectoryPath = new Path(volume + "/" + tableId + "/" + lowDirectory);
-          if (fs.exists(lowDirectoryPath) || fs.mkdirs(lowDirectoryPath)) {
-            FileSystem pathFs = fs.getVolumeByPath(lowDirectoryPath).getFileSystem();
-            return lowDirectoryPath.makeQualified(pathFs.getUri(), pathFs.getWorkingDirectory()).toString();
-          }
-          log.warn("Failed to create " + lowDirectoryPath + " for unknown reason");
-        } else {
-          lowDirectory = "/" + Constants.GENERATED_TABLET_DIRECTORY_PREFIX + namer.getNextName();
-          Path lowDirectoryPath = new Path(volume + "/" + tableId + "/" + lowDirectory);
-          if (fs.exists(lowDirectoryPath))
-            throw new IllegalStateException("Dir exist when it should not " + lowDirectoryPath);
-          if (fs.mkdirs(lowDirectoryPath)) {
-            FileSystem lowDirectoryFs = fs.getVolumeByPath(lowDirectoryPath).getFileSystem();
-            return lowDirectoryPath.makeQualified(lowDirectoryFs.getUri(), lowDirectoryFs.getWorkingDirectory()).toString();
-          }
-        }
-      } catch (IOException e) {
-        log.warn(e);
-      }
-
-      log.warn("Failed to create dir for tablet in table " + tableId + " in volume " + volume
+ " + will retry ...");
-      UtilWaitThread.sleep(3000);
-
-    }
-  }
-
-  public static String createTabletDirectory(String tableDir, Text endRow) {
-    while (true) {
-      try {
-        VolumeManager fs = VolumeManagerImpl.get();
-        return createTabletDirectory(fs, tableDir, endRow);
-      } catch (IOException e) {
-        log.warn("problem creating tablet directory", e);
-      } catch (IllegalArgumentException exception) {
-        /* thrown in some edge cases of DNS failure by Hadoop instead of UnknownHostException
*/
-        if (exception.getCause() instanceof UnknownHostException) {
-          log.warn("problem creating tablet directory", exception);
-        } else {
-          throw exception;
-        }
-      }
-      UtilWaitThread.sleep(3000);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/112f5e76/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index af8334b..a73356d 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -90,6 +90,7 @@ import org.apache.accumulo.core.util.LocalityGroupUtil;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.server.AccumuloServerContext;
+import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.conf.TableConfiguration;
 import org.apache.accumulo.server.fs.FileRef;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -108,7 +109,6 @@ import org.apache.accumulo.server.util.FileUtil;
 import org.apache.accumulo.server.util.MasterMetadataUtil;
 import org.apache.accumulo.server.util.MetadataTableUtil;
 import org.apache.accumulo.server.util.ReplicationTableUtil;
-import org.apache.accumulo.server.util.TabletOperations;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
 import org.apache.accumulo.tserver.InMemoryMap;
@@ -145,6 +145,7 @@ import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NoNodeException;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
 
 /**
  *
@@ -2236,7 +2237,7 @@ public class Tablet implements TabletCommitter {
       KeyExtent low = new KeyExtent(extent.getTableId(), midRow, extent.getPrevEndRow());
       KeyExtent high = new KeyExtent(extent.getTableId(), extent.getEndRow(), midRow);
 
-      String lowDirectory = TabletOperations.createTabletDirectory(getTabletServer().getFileSystem(),
extent.getTableId().toString(), midRow);
+      String lowDirectory = createTabletDirectory(getTabletServer().getFileSystem(), extent.getTableId().toString(),
midRow);
 
       // write new tablet information to MetadataTable
       SortedMap<FileRef,DataFileValue> lowDatafileSizes = new TreeMap<FileRef,DataFileValue>();
@@ -2722,4 +2723,41 @@ public class Tablet implements TabletCommitter {
   public AtomicLong getScannedCounter() {
     return scannedCount;
   }
+
+  private static String createTabletDirectory(VolumeManager fs, String tableId, Text endRow)
{
+    String lowDirectory;
+
+    UniqueNameAllocator namer = UniqueNameAllocator.getInstance();
+    String volume = fs.choose(Optional.of(tableId), ServerConstants.getBaseUris()) + Constants.HDFS_TABLES_DIR
+ Path.SEPARATOR;
+
+    while (true) {
+      try {
+        if (endRow == null) {
+          lowDirectory = Constants.DEFAULT_TABLET_LOCATION;
+          Path lowDirectoryPath = new Path(volume + "/" + tableId + "/" + lowDirectory);
+          if (fs.exists(lowDirectoryPath) || fs.mkdirs(lowDirectoryPath)) {
+            FileSystem pathFs = fs.getVolumeByPath(lowDirectoryPath).getFileSystem();
+            return lowDirectoryPath.makeQualified(pathFs.getUri(), pathFs.getWorkingDirectory()).toString();
+          }
+          log.warn("Failed to create " + lowDirectoryPath + " for unknown reason");
+        } else {
+          lowDirectory = "/" + Constants.GENERATED_TABLET_DIRECTORY_PREFIX + namer.getNextName();
+          Path lowDirectoryPath = new Path(volume + "/" + tableId + "/" + lowDirectory);
+          if (fs.exists(lowDirectoryPath))
+            throw new IllegalStateException("Dir exist when it should not " + lowDirectoryPath);
+          if (fs.mkdirs(lowDirectoryPath)) {
+            FileSystem lowDirectoryFs = fs.getVolumeByPath(lowDirectoryPath).getFileSystem();
+            return lowDirectoryPath.makeQualified(lowDirectoryFs.getUri(), lowDirectoryFs.getWorkingDirectory()).toString();
+          }
+        }
+      } catch (IOException e) {
+        log.warn(e);
+      }
+
+      log.warn("Failed to create dir for tablet in table " + tableId + " in volume " + volume
+ " + will retry ...");
+      UtilWaitThread.sleep(3000);
+
+    }
+  }
+
 }


Mime
View raw message