Author: ecn
Date: Thu Sep 13 14:19:27 2012
New Revision: 1384340

URL: http://svn.apache.org/viewvc?rev=1384340&view=rev
Log:
ACCUMULO-722: complete files in ZNN when recoverLease is called, move the root 
node to ZNN

Modified:
    
accumulo/branches/ACCUMULO-722/distnn/src/main/java/org/apache/hadoop/hdfs/server/namenode/ZookeeperNameNode.java

Modified: 
accumulo/branches/ACCUMULO-722/distnn/src/main/java/org/apache/hadoop/hdfs/server/namenode/ZookeeperNameNode.java
URL: 
http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-722/distnn/src/main/java/org/apache/hadoop/hdfs/server/namenode/ZookeeperNameNode.java?rev=1384340&r1=1384339&r2=1384340&view=diff
==============================================================================
--- 
accumulo/branches/ACCUMULO-722/distnn/src/main/java/org/apache/hadoop/hdfs/server/namenode/ZookeeperNameNode.java
 (original)
+++ 
accumulo/branches/ACCUMULO-722/distnn/src/main/java/org/apache/hadoop/hdfs/server/namenode/ZookeeperNameNode.java
 Thu Sep 13 14:19:27 2012
@@ -120,7 +120,7 @@ public class ZookeeperNameNode implement
   }
   
   // Metadata for these files are stored in zookeeper
-  static Pattern metaDataFileNames = 
Pattern.compile("/accumulo(|/instance_id.*|/version.*|/walogArchive|/wal(/.*|$)|/recovery.*|/tables$|/tables/(\\!0|\\!1|\\!2|\\!3)(/.*|$))");
+  static Pattern metaDataFileNames = 
Pattern.compile("/$|/accumulo(|/instance_id.*|/version.*|/walogArchive|/wal(/.*|$)|/recovery.*|/tables$|/tables/(\\!0|\\!1|\\!2|\\!3)(/.*|$))");
   
   static private boolean isZooName(String path) {
     boolean result = metaDataFileNames.matcher(path).matches();
@@ -314,8 +314,28 @@ public class ZookeeperNameNode implement
   
   @Override
   public boolean recoverLease(String src, String clientName) throws 
IOException {
-    notImplementedWarning(src, clientName);
-    return true;
+    log.info("recoverLease " + src);
+    String path = DNNConstants.NAMESPACE_PATH + src;
+    try {
+      long length = 0;
+      for (String child : keeper.getChildren().forPath(path)) {
+        Object object = deserialize(keeper.getData().forPath(path + "/" + 
child));
+        if (object instanceof BlockInfo) {
+          BlockInfo info = (BlockInfo)object;
+          Block block = new Block(info.id);
+          String blockPath = DNNConstants.BLOCKS_PATH + "/" + 
block.getBlockName();
+          info = (BlockInfo)deserialize(keeper.getData().forPath(blockPath));
+          if (!info.complete) {
+            info.complete = true;
+            keeper.setData().forPath(blockPath);
+          }
+        }
+      }
+      return true;
+    } catch (Exception ex) {
+      log.error(ex, ex);
+      return false;
+    }
   }
   
   @Override


Reply via email to