accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1413007 - in /accumulo/trunk: core/src/main/java/org/apache/accumulo/core/conf/ server/src/main/java/org/apache/accumulo/server/master/ server/src/main/java/org/apache/accumulo/server/master/recovery/
Date Fri, 23 Nov 2012 18:10:59 GMT
Author: ecn
Date: Fri Nov 23 18:10:58 2012
New Revision: 1413007

URL: http://svn.apache.org/viewvc?rev=1413007&view=rev
Log:
ACCUMULO-688 make lease recovery configurable

Added:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/MapRRecoverLease.java
  (with props)
Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/Master.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoverLease.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java?rev=1413007&r1=1413006&r2=1413007&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java Fri Nov
23 18:10:58 2012
@@ -68,6 +68,7 @@ public enum Property {
   MASTER_THREADCHECK("master.server.threadcheck.time", "1s", PropertyType.TIMEDURATION, "The
time between adjustments of the server thread pool."),
   MASTER_RECOVERY_DELAY("master.recovery.delay", "10s", PropertyType.TIMEDURATION,
       "When a tablet server's lock is deleted, it takes time for it to completely quit. This
delay gives it time before log recoveries begin."),
+  MASTER_LEASE_RECOVERY_IMPLEMETATION("master.lease.recovery.implementation", "org.apache.accumulo.server.master.recovery.RecoverLease",
PropertyType.CLASSNAME, "A class that implements a mechansim to steal write access to a file"),
   
   // properties that are specific to tablet server behavior
   TSERV_PREFIX("tserver.", null, PropertyType.PREFIX, "Properties in this category affect
the behavior of the tablet servers"),

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/Master.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/Master.java?rev=1413007&r1=1413006&r2=1413007&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/Master.java (original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/Master.java Fri
Nov 23 18:10:58 2012
@@ -2099,8 +2099,11 @@ public class Master implements LiveTServ
         synchronized (recoveriesInProgress) {
           if (!recoveriesInProgress.contains(filename)) {
             Master.log.info("Starting recovery of " + filename + " created for " + host +
", tablet " + extent + " holds a reference");
+            AccumuloConfiguration aconf = getConfiguration().getConfiguration();
+            RecoverLease impl = createInstanceFromPropertyName(aconf, Property.MASTER_LEASE_RECOVERY_IMPLEMETATION,
RecoverLease.class, new RecoverLease());
+            impl.init(host, filename);
             long tid = fate.startTransaction();
-            fate.seedTransaction(tid, new RecoverLease(host, filename), true);
+            fate.seedTransaction(tid, impl, true);
             recoveriesInProgress.add(filename);
           }
         }

Added: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/MapRRecoverLease.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/MapRRecoverLease.java?rev=1413007&view=auto
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/MapRRecoverLease.java
(added)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/MapRRecoverLease.java
Fri Nov 23 18:10:58 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.master.recovery;
+
+import java.io.IOException;
+
+import org.apache.accumulo.fate.Repo;
+import org.apache.accumulo.server.master.Master;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.log4j.Logger;
+
+
+public class MapRRecoverLease extends RecoverLease {
+  private static final Logger log = Logger.getLogger(MapRRecoverLease.class);
+  
+  private static final long serialVersionUID = 1L;
+
+  public MapRRecoverLease() {
+  }
+  
+  @Override
+  public Repo<Master> call(long tid, Master master) throws Exception {
+    Path source = getSource(master);
+    FileSystem fs = master.getFileSystem();
+    log.info("Recovering file " + source.toString() +" by changing permission to readonly");
+    FsPermission roPerm = new FsPermission((short) 0444);
+    try {
+      fs.setPermission(source, roPerm);
+      return new SubmitFileForRecovery(server, file);
+    } catch (IOException ex) {
+      log.error("error recovering lease ", ex);
+      // lets do this again
+      MapRRecoverLease result = new MapRRecoverLease();
+      result.init(server, file);
+      return result;
+    }
+  }
+  
+}

Propchange: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/MapRRecoverLease.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoverLease.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoverLease.java?rev=1413007&r1=1413006&r2=1413007&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoverLease.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoverLease.java
Fri Nov 23 18:10:58 2012
@@ -33,11 +33,14 @@ public class RecoverLease extends Master
   
   private static final long serialVersionUID = 1L;
 
-  private String server;
-  private String file;
-  private long start;
+  protected String server;
+  protected String file;
+  protected long start;
 
-  public RecoverLease(String server, String file) {
+  public RecoverLease() {
+  }
+  
+  public void init(String server, String file) {
     this.server = server;
     this.file = file;
     this.start = System.currentTimeMillis();
@@ -88,12 +91,13 @@ public class RecoverLease extends Master
     try {
       fs.append(source).close();
       log.info("Recovered lease on " + source.toString() + " using append");
-
+      return new SubmitFileForRecovery(server, file);
     } catch (IOException ex) {
       log.error("error recovering lease using append", ex);
+      RecoverLease result = new RecoverLease();
+      result.init(server, file);
+      return result;
     }
-    // lets do this again
-    return new RecoverLease(server, file);
   }
   
 }



Mime
View raw message