accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [02/10] git commit: ACCUMULO-1452 remove any junk _tmp files when openning the tablet
Date Thu, 12 Sep 2013 16:38:20 GMT
ACCUMULO-1452 remove any junk _tmp files when openning the tablet


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

Branch: refs/heads/1.5.1-SNAPSHOT
Commit: a238494dd803f5c800dfcaf90b81dab3d1c7d9a6
Parents: 0531614
Author: Eric Newton <eric.newton@gmail.com>
Authored: Thu Sep 12 11:20:46 2013 -0400
Committer: Eric Newton <eric.newton@gmail.com>
Committed: Thu Sep 12 11:20:46 2013 -0400

----------------------------------------------------------------------
 .../accumulo/server/tabletserver/Tablet.java    | 24 ++++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a238494d/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
index 20ae892..f3c756a 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
@@ -372,7 +372,7 @@ public class Tablet {
   private long persistedTime;
   private Object timeLock = new Object();
   
-  private Path location; // absolute path of this tablets dir
+  private final Path location; // absolute path of this tablets dir
   private TServerInstance lastLocation;
   
   private Configuration conf;
@@ -406,8 +406,6 @@ public class Tablet {
   
   private AtomicReference<ConstraintChecker> constraintChecker = new AtomicReference<ConstraintChecker>();
   
-  private String tabletDirectory;
-  
   private int writesInProgress = 0;
   
   private static final Logger log = Logger.getLogger(Tablet.class);
@@ -1333,7 +1331,6 @@ public class Tablet {
       Set<String> scanFiles, long initFlushID, long initCompactID) throws IOException
{
     this.location = new Path(ServerConstants.getTablesDir() + "/" + extent.getTableId().toString()
+ location.toString());
     this.lastLocation = lastLocation;
-    this.tabletDirectory = location.toString();
     this.conf = conf;
     this.acuTableConf = ServerConfiguration.getTableConfiguration(extent.getTableId().toString());
     
@@ -1484,6 +1481,8 @@ public class Tablet {
           + " entries created)");
     }
     
+    removeOldTemporaryFiles();
+    
     // do this last after tablet is completely setup because it
     // could cause major compaction to start
     datafileManager = new DatafileManager(datafiles);
@@ -1495,6 +1494,21 @@ public class Tablet {
     log.log(TLevel.TABLET_HIST, extent + " opened ");
   }
   
+  private void removeOldTemporaryFiles() {
+    // remove any temporary files created by a previous tablet server
+    try {
+      for (FileStatus tmp : fs.globStatus(new Path(location, "*_tmp"))){
+        try {
+          fs.delete(tmp.getPath(), true);
+        } catch (IOException ex) {
+          log.error("Unable to remove old temp file " + tmp.getPath() + ": " + ex);
+        }
+      }
+    } catch (IOException ex) {
+      log.error("Error scanning for old temp files in " + location);
+    }
+  }
+
   private void setupDefaultSecurityLabels(KeyExtent extent) {
     if (extent.getTableId().toString().equals(Constants.METADATA_TABLE_ID)) {
       defaultSecurityLabel = new byte[0];
@@ -3520,7 +3534,7 @@ public class Tablet {
       
       log.log(TLevel.TABLET_HIST, extent + " split " + low + " " + high);
       
-      newTablets.put(high, new SplitInfo(tabletDirectory, highDatafileSizes, time, lastFlushID,
lastCompactID));
+      newTablets.put(high, new SplitInfo(location.toString(), highDatafileSizes, time, lastFlushID,
lastCompactID));
       newTablets.put(low, new SplitInfo(lowDirectory, lowDatafileSizes, time, lastFlushID,
lastCompactID));
       
       long t2 = System.currentTimeMillis();


Mime
View raw message