accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [01/16] ACCUMULO-3242 Add proper retry logic to ZooReader, ZooReaderWriter and ZooUtil removing the RetryingInstance.
Date Mon, 20 Oct 2014 01:05:42 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6 6ad16a9c5 -> 0e4159c3f
  refs/heads/master f118b2211 -> 8bea7aba9


http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/master/src/main/java/org/apache/accumulo/master/Master.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index 2f04922..f894afc 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -135,7 +135,7 @@ import com.google.common.collect.Iterables;
 
 /**
  * The Master is responsible for assigning and balancing tablets to tablet servers.
- * 
+ *
  * The master will also coordinate log recoveries and reports general status.
  */
 public class Master implements LiveTServerSet.Listener, TableObserver, CurrentState {
@@ -997,7 +997,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
 
     try {
       final AgeOffStore<Master> store = new AgeOffStore<Master>(new org.apache.accumulo.fate.ZooStore<Master>(ZooUtil.getRoot(instance)
+ Constants.ZFATE,
-          ZooReaderWriter.getRetryingInstance()), 1000 * 60 * 60 * 8);
+          ZooReaderWriter.getInstance()), 1000 * 60 * 60 * 8);
 
       int threads = this.getConfiguration().getConfiguration().getCount(Property.MASTER_FATE_THREADPOOL_SIZE);
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java
index 49227ef..ebceaa0 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java
@@ -30,73 +30,73 @@ import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 class FinishCancelCompaction extends MasterRepo {
   private static final long serialVersionUID = 1L;
   private String tableId;
-  
+
   public FinishCancelCompaction(String tableId) {
     this.tableId = tableId;
   }
-  
+
   @Override
   public Repo<Master> call(long tid, Master environment) throws Exception {
     Utils.getReadLock(tableId, tid).unlock();
     return null;
   }
-  
+
   @Override
   public void undo(long tid, Master environment) throws Exception {
-    
+
   }
 }
 
 /**
- * 
+ *
  */
 public class CancelCompactions extends MasterRepo {
-  
+
   private static final long serialVersionUID = 1L;
   private String tableId;
   private String namespaceId;
-  
+
   public CancelCompactions(String tableId) {
     this.tableId = tableId;
     Instance inst = HdfsZooInstance.getInstance();
     this.namespaceId = Tables.getNamespaceId(inst, tableId);
   }
-  
+
   @Override
   public long isReady(long tid, Master environment) throws Exception {
     return Utils.reserveNamespace(namespaceId, tid, false, true, TableOperation.COMPACT_CANCEL)
         + Utils.reserveTable(tableId, tid, false, true, TableOperation.COMPACT_CANCEL);
   }
-  
+
   @Override
   public Repo<Master> call(long tid, Master environment) throws Exception {
     String zCompactID = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_COMPACT_ID;
     String zCancelID = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + tableId
         + Constants.ZTABLE_COMPACT_CANCEL_ID;
-    
-    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
-    
+
+    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
+
     byte[] currentValue = zoo.getData(zCompactID, null);
-    
+
     String cvs = new String(currentValue, Constants.UTF8);
     String[] tokens = cvs.split(",");
     final long flushID = Long.parseLong(tokens[0]);
-    
+
     zoo.mutate(zCancelID, null, null, new Mutator() {
       @Override
       public byte[] mutate(byte[] currentValue) throws Exception {
         long cid = Long.parseLong(new String(currentValue, Constants.UTF8));
-        
+
         if (cid < flushID)
           return Long.toString(flushID).getBytes(Constants.UTF8);
         else
           return Long.toString(cid).getBytes(Constants.UTF8);
       }
     });
-    
+
     return new FinishCancelCompaction(tableId);
   }
-  
+
   @Override
   public void undo(long tid, Master environment) throws Exception {
     Utils.unreserveNamespace(namespaceId, tid, false);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java
index e3b0405..a643ccb 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java
@@ -89,7 +89,7 @@ class CompactionDriver extends MasterRepo {
     String zCancelID = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + tableId
         + Constants.ZTABLE_COMPACT_CANCEL_ID;
 
-    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
 
     if (Long.parseLong(new String(zoo.getData(zCancelID, null))) >= compactId) {
       // compaction was canceled
@@ -317,7 +317,7 @@ public class CompactRange extends MasterRepo {
   public Repo<Master> call(final long tid, Master environment) throws Exception {
     String zTablePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_COMPACT_ID;
 
-    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
     byte[] cid;
     try {
       cid = zoo.mutate(zTablePath, null, null, new Mutator() {
@@ -362,7 +362,7 @@ public class CompactRange extends MasterRepo {
   static void removeIterators(final long txid, String tableId) throws Exception {
     String zTablePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_COMPACT_ID;
 
-    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
 
     zoo.mutate(zTablePath, null, null, new Mutator() {
       @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
index 41f24cd..d69973b 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
@@ -53,7 +53,7 @@ public class RenameNamespace extends MasterRepo {
 
     Instance instance = master.getInstance();
 
-    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
 
     Utils.tableNameLock.lock();
     try {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
index 8c5ed00..b1bbb67 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
@@ -67,7 +67,7 @@ public class RenameTable extends MasterRepo {
       throw new ThriftTableOperationException(tableId, oldTableName, TableOperation.RENAME,
TableOperationExceptionType.INVALID_NAME,
           "Namespace in new table name does not match the old table name");
 
-    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
 
     Utils.tableNameLock.lock();
     try {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java
index c2bb7a9..7ede305 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java
@@ -41,7 +41,7 @@ import org.apache.zookeeper.KeeperException;
 
 public class Utils {
   private static final byte[] ZERO_BYTE = new byte[] {'0'};
-  
+
   static void checkTableDoesNotExist(Instance instance, String tableName, String tableId,
TableOperation operation) throws ThriftTableOperationException {
 
     String id = Tables.getNameToIdMap(instance).get(tableName);
@@ -54,7 +54,7 @@ public class Utils {
 
     String tableId = null;
     try {
-      IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+      IZooReaderWriter zoo = ZooReaderWriter.getInstance();
       final String ntp = ZooUtil.getRoot(instance) + Constants.ZTABLES;
       byte[] nid = zoo.mutate(ntp, ZERO_BYTE, ZooUtil.PUBLIC, new Mutator() {
         @Override
@@ -79,7 +79,7 @@ public class Utils {
     if (getLock(tableId, tid, writeLock).tryLock()) {
       if (tableMustExist) {
         Instance instance = HdfsZooInstance.getInstance();
-        IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance();
+        IZooReaderWriter zk = ZooReaderWriter.getInstance();
         if (!zk.exists(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId))
           throw new ThriftTableOperationException(tableId, "", op, TableOperationExceptionType.NOTFOUND,
"Table does not exist");
       }
@@ -103,7 +103,7 @@ public class Utils {
     if (getLock(namespaceId, id, writeLock).tryLock()) {
       if (mustExist) {
         Instance instance = HdfsZooInstance.getInstance();
-        IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance();
+        IZooReaderWriter zk = ZooReaderWriter.getInstance();
         if (!zk.exists(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES + "/" + namespaceId))
           throw new ThriftTableOperationException(namespaceId, "", op, TableOperationExceptionType.NAMESPACE_NOTFOUND,
"Namespace does not exist");
       }
@@ -119,7 +119,7 @@ public class Utils {
     String resvPath = ZooUtil.getRoot(instance) + Constants.ZHDFS_RESERVATIONS + "/"
         + Base64.encodeBase64String(directory.getBytes(Constants.UTF8));
 
-    IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance();
+    IZooReaderWriter zk = ZooReaderWriter.getInstance();
 
     if (ZooReservation.attempt(zk, resvPath, String.format("%016x", tid), "")) {
       return 0;
@@ -131,7 +131,7 @@ public class Utils {
     Instance instance = HdfsZooInstance.getInstance();
     String resvPath = ZooUtil.getRoot(instance) + Constants.ZHDFS_RESERVATIONS + "/"
         + Base64.encodeBase64String(directory.getBytes(Constants.UTF8));
-    ZooReservation.release(ZooReaderWriter.getRetryingInstance(), resvPath, String.format("%016x",
tid));
+    ZooReservation.release(ZooReaderWriter.getInstance(), resvPath, String.format("%016x",
tid));
   }
 
   private static Lock getLock(String tableId, long tid, boolean writeLock) throws Exception
{

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java b/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java
index 759bb70..5ab5d75 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java
@@ -75,7 +75,7 @@ public class FateAdmin {
     Instance instance = HdfsZooInstance.getInstance();
     String path = ZooUtil.getRoot(instance) + Constants.ZFATE;
     String masterPath = ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK;
-    IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance();
+    IZooReaderWriter zk = ZooReaderWriter.getInstance();
     ZooStore<Master> zs = new ZooStore<Master>(path, zk);
 
     if (jc.getParsedCommand().equals("fail")) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c023f74e/server/tserver/src/main/java/org/apache/accumulo/tserver/Tablet.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/Tablet.java
index de930aa..0778f5b 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/Tablet.java
@@ -811,7 +811,7 @@ public class Tablet {
     void bringMinorCompactionOnline(FileRef tmpDatafile, FileRef newDatafile, FileRef absMergeFile,
DataFileValue dfv, CommitSession commitSession, long flushId)
         throws IOException {
 
-      IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+      IZooReaderWriter zoo = ZooReaderWriter.getInstance();
       if (extent.isRootTablet()) {
         try {
           if (!zoo.isLockHeld(tabletServer.getLock().getLockID())) {
@@ -977,7 +977,7 @@ public class Tablet {
 
         t1 = System.currentTimeMillis();
 
-        IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
+        IZooReaderWriter zoo = ZooReaderWriter.getInstance();
 
         dataSourceDeletions.incrementAndGet();
 
@@ -2319,7 +2319,7 @@ public class Tablet {
     try {
       String zTablePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + extent.getTableId()
           + Constants.ZTABLE_FLUSH_ID;
-      return Long.parseLong(new String(ZooReaderWriter.getRetryingInstance().getData(zTablePath,
null), Constants.UTF8));
+      return Long.parseLong(new String(ZooReaderWriter.getInstance().getData(zTablePath,
null), Constants.UTF8));
     } catch (InterruptedException e) {
       throw new RuntimeException(e);
     } catch (NumberFormatException nfe) {
@@ -2338,7 +2338,7 @@ public class Tablet {
         + Constants.ZTABLE_COMPACT_CANCEL_ID;
 
     try {
-      return Long.parseLong(new String(ZooReaderWriter.getRetryingInstance().getData(zTablePath,
null), Constants.UTF8));
+      return Long.parseLong(new String(ZooReaderWriter.getInstance().getData(zTablePath,
null), Constants.UTF8));
     } catch (KeeperException e) {
       throw new RuntimeException(e);
     } catch (InterruptedException e) {
@@ -2351,7 +2351,7 @@ public class Tablet {
       String zTablePath = Constants.ZROOT + "/" + HdfsZooInstance.getInstance().getInstanceID()
+ Constants.ZTABLES + "/" + extent.getTableId()
           + Constants.ZTABLE_COMPACT_ID;
 
-      String[] tokens = new String(ZooReaderWriter.getRetryingInstance().getData(zTablePath,
null), Constants.UTF8).split(",");
+      String[] tokens = new String(ZooReaderWriter.getInstance().getData(zTablePath, null),
Constants.UTF8).split(",");
       long compactID = Long.parseLong(tokens[0]);
 
       CompactionIterators iters = new CompactionIterators();


Mime
View raw message