accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [13/25] git commit: ACCUMULO-2061 Add a utility method to pull a Path with the instance_id
Date Fri, 21 Mar 2014 02:13:16 GMT
ACCUMULO-2061 Add a utility method to pull a Path with the instance_id

Consolidates a little bit of code in one place.


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: c25a41fe905cda4aa914f232db5cc26b3254f4a0
Parents: 03baf91
Author: Josh Elser <elserj@apache.org>
Authored: Thu Mar 20 17:39:13 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Thu Mar 20 18:59:30 2014 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/accumulo/server/Accumulo.java    |  7 +++++++
 .../java/org/apache/accumulo/server/ServerConstants.java  |  2 +-
 .../apache/accumulo/server/client/HdfsZooInstance.java    | 10 +++++-----
 .../org/apache/accumulo/server/conf/ZooConfiguration.java | 10 ++++------
 4 files changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/c25a41fe/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
index f7f2298..925c0d0 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
@@ -32,6 +32,7 @@ import org.apache.accumulo.core.util.AddressUtil;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.util.Version;
 import org.apache.accumulo.core.volume.Volume;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ServerConfiguration;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -91,6 +92,12 @@ public class Accumulo {
     return getAccumuloPersistentVersion(v.getFileSystem(), path);
   }
 
+  public static synchronized Path getAccumuloInstanceIdPath(VolumeManager fs) {
+    // It doesn't matter which Volume is used as they should all have the instance ID stored
+    Volume v = fs.getVolumes().iterator().next();
+    return ServerConstants.getInstanceIdLocation(v);
+  }
+
   public static void enableTracing(String address, String application) {
     try {
       DistributedTrace.enable(HdfsZooInstance.getInstance(), ZooReaderWriter.getInstance(),
application, address);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c25a41fe/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java b/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
index 7dd0a08..b577abb 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
@@ -76,7 +76,7 @@ public class ServerConstants {
       String currentIid;
       Integer currentVersion;
       try {
-        currentIid = ZooUtil.getInstanceIDFromHdfs(new Path(baseDir, INSTANCE_ID_DIR), ServerConfiguration.getSiteConfiguration());
+        currentIid = ZooUtil.getInstanceIDFromHdfs(path, ServerConfiguration.getSiteConfiguration());
         Path vpath = new Path(baseDir, VERSION_DIR);
         currentVersion = Accumulo.getAccumuloPersistentVersion(vpath.getFileSystem(CachedConfiguration.getInstance()),
vpath);
       } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c25a41fe/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
b/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
index ee928f3..620188c 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
@@ -39,14 +39,14 @@ import org.apache.accumulo.core.util.ByteBufferUtil;
 import org.apache.accumulo.core.util.OpTimer;
 import org.apache.accumulo.core.util.StringUtil;
 import org.apache.accumulo.core.util.TextUtil;
-import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.server.ServerConstants;
+import org.apache.accumulo.server.Accumulo;
 import org.apache.accumulo.server.conf.ServerConfiguration;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.fs.VolumeManagerImpl;
 import org.apache.accumulo.server.zookeeper.ZooLock;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
@@ -134,9 +134,9 @@ public class HdfsZooInstance implements Instance {
       } catch (IOException e) {
         throw new RuntimeException(e);
       }
-      Volume randVolume = fs.getVolumes().iterator().next();
-      log.trace("Looking for instanceId from " + randVolume);
-      String instanceIdFromFile = ZooUtil.getInstanceIDFromHdfs(ServerConstants.getInstanceIdLocation(randVolume),
acuConf);
+      Path instanceIdPath = Accumulo.getAccumuloInstanceIdPath(fs);
+      log.trace("Looking for instanceId from " + instanceIdPath);
+      String instanceIdFromFile = ZooUtil.getInstanceIDFromHdfs(instanceIdPath, acuConf);
       instanceId = instanceIdFromFile;
     }
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c25a41fe/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
index 94e468b..0c03aac 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
@@ -26,15 +26,13 @@ import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.util.CachedConfiguration;
-import org.apache.accumulo.core.volume.Volume;
-import org.apache.accumulo.core.volume.VolumeConfiguration;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.server.ServerConstants;
+import org.apache.accumulo.server.Accumulo;
 import org.apache.accumulo.server.client.HdfsZooInstance.AccumuloNotInitializedException;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.fs.VolumeManagerImpl;
+import org.apache.hadoop.fs.Path;
 import org.apache.log4j.Logger;
 
 public class ZooConfiguration extends AccumuloConfiguration {
@@ -70,8 +68,8 @@ public class ZooConfiguration extends AccumuloConfiguration {
       } catch (IOException e) {
         throw new RuntimeException(e);
       }
-      Volume randVolume = fs.getVolumes().iterator().next();
-      String deprecatedInstanceIdFromHdfs = ZooUtil.getInstanceIDFromHdfs(ServerConstants.getInstanceIdLocation(randVolume),
parent);
+      Path instanceIdPath = Accumulo.getAccumuloInstanceIdPath(fs);
+      String deprecatedInstanceIdFromHdfs = ZooUtil.getInstanceIDFromHdfs(instanceIdPath,
parent);
       instanceId = deprecatedInstanceIdFromHdfs;
     }
     return instance;


Mime
View raw message