Author: billie
Date: Tue Aug  7 18:40:58 2012
New Revision: 1370427

URL: http://svn.apache.org/viewvc?rev=1370427&view=rev
Log:
ACCUMULO-647 allowed zookeeper code to use other ACL schemes and removed 
hardcoded accumulo user from fate

Modified:
    accumulo/trunk/conf/   (props changed)
    
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
    
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
    
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
    
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
    
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
    
accumulo/trunk/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooReaderWriter.java

Propchange: accumulo/trunk/conf/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Aug  7 18:40:58 2012
@@ -11,3 +11,6 @@ accumulo_user_manual.pdf
 log4j.properties
 generic_logger.xml
 monitor_logger.xml
+generic_logger.xml.bkp
+log4j.properties.bkp
+monitor_logger.xml.bkp

Modified: 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java?rev=1370427&r1=1370426&r2=1370427&view=diff
==============================================================================
--- 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
 (original)
+++ 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
 Tue Aug  7 18:40:58 2012
@@ -59,8 +59,8 @@ public class ZooLock implements Watcher 
   
   private String asyncLock;
   
-  public ZooLock(String zookeepers, int timeInMillis, String auth, String 
path) {
-    this(new ZooCache(zookeepers, timeInMillis), 
ZooReaderWriter.getInstance(zookeepers, timeInMillis, auth), path);
+  public ZooLock(String zookeepers, int timeInMillis, String scheme, byte[] 
auth, String path) {
+    this(new ZooCache(zookeepers, timeInMillis), 
ZooReaderWriter.getInstance(zookeepers, timeInMillis, scheme, auth), path);
   }
   
   protected ZooLock(ZooCache zc, IZooReaderWriter zrw, String path) {

Modified: 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java?rev=1370427&r1=1370426&r2=1370427&view=diff
==============================================================================
--- 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
 (original)
+++ 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
 Tue Aug  7 18:40:58 2012
@@ -38,8 +38,9 @@ public class ZooQueueLock implements Que
   private String path;
   private boolean ephemeral;
   
-  public ZooQueueLock(String zookeepers, int timeInMillis, String auth, String 
path, boolean ephemeral) throws KeeperException, InterruptedException {
-    this(ZooReaderWriter.getRetryingInstance(zookeepers, timeInMillis, auth), 
path, ephemeral);
+  public ZooQueueLock(String zookeepers, int timeInMillis, String scheme, 
byte[] auth, String path, boolean ephemeral) throws KeeperException,
+      InterruptedException {
+    this(ZooReaderWriter.getRetryingInstance(zookeepers, timeInMillis, scheme, 
auth), path, ephemeral);
   }
   
   protected ZooQueueLock(IZooReaderWriter zrw, String path, boolean ephemeral) 
{

Modified: 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java?rev=1370427&r1=1370426&r2=1370427&view=diff
==============================================================================
--- 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
 (original)
+++ 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
 Tue Aug  7 18:40:58 2012
@@ -28,12 +28,12 @@ public class ZooReader implements IZooRe
   protected String keepers;
   protected int timeout;
   
-  protected ZooKeeper getSession(String keepers, int timeout, String auth) {
-    return ZooSession.getSession(keepers, timeout, auth);
+  protected ZooKeeper getSession(String keepers, int timeout, String scheme, 
byte[] auth) {
+    return ZooSession.getSession(keepers, timeout, scheme, auth);
   }
   
   protected ZooKeeper getZooKeeper() {
-    return getSession(keepers, timeout, null);
+    return getSession(keepers, timeout, null, null);
   }
   
   @Override

Modified: 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java?rev=1370427&r1=1370426&r2=1370427&view=diff
==============================================================================
--- 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
 (original)
+++ 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
 Tue Aug  7 18:40:58 2012
@@ -43,7 +43,8 @@ public class ZooReaderWriter extends Zoo
   
   private static ZooReaderWriter instance = null;
   private static IZooReaderWriter retryingInstance = null;
-  private final String auth;
+  private final String scheme;
+  private final byte[] auth;
   
   @Override
   public ZooKeeper getZooKeeper() {
@@ -51,12 +52,13 @@ public class ZooReaderWriter extends Zoo
     if (sm != null) {
       sm.checkPermission(ZOOWRITER_PERMISSION);
     }
-    return getSession(keepers, timeout, auth);
+    return getSession(keepers, timeout, scheme, auth);
   }
   
-  public ZooReaderWriter(String string, int timeInMillis, String auth) {
+  public ZooReaderWriter(String string, int timeInMillis, String scheme, 
byte[] auth) {
     super(string, timeInMillis);
-    this.auth = "accumulo:" + auth;
+    this.scheme = scheme;
+    this.auth = auth;
   }
   
   @Override
@@ -143,9 +145,9 @@ public class ZooReaderWriter extends Zoo
     } while (true);
   }
   
-  public static synchronized ZooReaderWriter getInstance(String zookeepers, 
int timeInMillis, String auth) {
+  public static synchronized ZooReaderWriter getInstance(String zookeepers, 
int timeInMillis, String scheme, byte[] auth) {
     if (instance == null)
-      instance = new ZooReaderWriter(zookeepers, timeInMillis, auth);
+      instance = new ZooReaderWriter(zookeepers, timeInMillis, scheme, auth);
     return instance;
   }
   
@@ -154,10 +156,10 @@ public class ZooReaderWriter extends Zoo
    * 
    * @return an instance that retries when Zookeeper connection errors occur.
    */
-  public static synchronized IZooReaderWriter getRetryingInstance(String 
zookeepers, int timeInMillis, String auth) {
+  public static synchronized IZooReaderWriter getRetryingInstance(String 
zookeepers, int timeInMillis, String scheme, byte[] auth) {
     
     if (retryingInstance == null) {
-      final IZooReaderWriter inst = getInstance(zookeepers, timeInMillis, 
auth);
+      final IZooReaderWriter inst = getInstance(zookeepers, timeInMillis, 
scheme, auth);
       
       InvocationHandler ih = new InvocationHandler() {
         @Override

Modified: 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java?rev=1370427&r1=1370426&r2=1370427&view=diff
==============================================================================
--- 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
 (original)
+++ 
accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooSession.java
 Tue Aug  7 18:40:58 2012
@@ -46,8 +46,8 @@ class ZooSession {
   
   private static Map<String,ZooSessionInfo> sessions = new 
HashMap<String,ZooSessionInfo>();
   
-  private static String sessionKey(String keepers, int timeout, String auth) {
-    return keepers + ":" + timeout + ":" + (auth == null ? "" : auth);
+  private static String sessionKey(String keepers, int timeout, String scheme, 
byte[] auth) {
+    return keepers + ":" + timeout + ":" + (scheme == null ? "" : scheme) + 
":" + (auth == null ? "" : new String(auth));
   }
   
   private static class ZooWatcher implements Watcher {
@@ -70,7 +70,7 @@ class ZooSession {
     
   }
   
-  public static ZooKeeper connect(String host, int timeout, String auth, 
Watcher watcher) {
+  public static ZooKeeper connect(String host, int timeout, String scheme, 
byte[] auth, Watcher watcher) {
     final int TIME_BETWEEN_CONNECT_CHECKS_MS = 100;
     final int TOTAL_CONNECT_TIME_WAIT_MS = 10 * 1000;
     boolean tryAgain = true;
@@ -84,7 +84,7 @@ class ZooSession {
         for (int i = 0; i < TOTAL_CONNECT_TIME_WAIT_MS / 
TIME_BETWEEN_CONNECT_CHECKS_MS && tryAgain; i++) {
           if (zooKeeper.getState().equals(States.CONNECTED)) {
             if (auth != null)
-              zooKeeper.addAuthInfo("digest", auth.getBytes());
+              zooKeeper.addAuthInfo(scheme, auth);
             tryAgain = false;
           } else
             UtilWaitThread.sleep(TIME_BETWEEN_CONNECT_CHECKS_MS);
@@ -116,15 +116,15 @@ class ZooSession {
   }
   
   public static synchronized ZooKeeper getSession(String zooKeepers, int 
timeout) {
-    return getSession(zooKeepers, timeout, null);
+    return getSession(zooKeepers, timeout, null, null);
   }
   
-  public static synchronized ZooKeeper getSession(String zooKeepers, int 
timeout, String auth) {
+  public static synchronized ZooKeeper getSession(String zooKeepers, int 
timeout, String scheme, byte[] auth) {
     
-    String sessionKey = sessionKey(zooKeepers, timeout, auth);
+    String sessionKey = sessionKey(zooKeepers, timeout, scheme, auth);
     
     // a read-only session can use a session with authorizations, so cache a 
copy for it w/out auths
-    String readOnlySessionKey = sessionKey(zooKeepers, timeout, null);
+    String readOnlySessionKey = sessionKey(zooKeepers, timeout, null, null);
     
     ZooSessionInfo zsi = sessions.get(sessionKey);
     if (zsi != null && zsi.zooKeeper.getState() == States.CLOSED) {
@@ -137,7 +137,7 @@ class ZooSession {
     if (zsi == null) {
       ZooWatcher watcher = new ZooWatcher();
       log.debug("Connecting to " + zooKeepers + " with timeout " + timeout + " 
with auth");
-      zsi = new ZooSessionInfo(connect(zooKeepers, timeout, auth, watcher), 
watcher);
+      zsi = new ZooSessionInfo(connect(zooKeepers, timeout, scheme, auth, 
watcher), watcher);
       sessions.put(sessionKey, zsi);
       if (auth != null && !sessions.containsKey(readOnlySessionKey))
         sessions.put(readOnlySessionKey, zsi);

Modified: 
accumulo/trunk/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooReaderWriter.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooReaderWriter.java?rev=1370427&r1=1370426&r2=1370427&view=diff
==============================================================================
--- 
accumulo/trunk/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooReaderWriter.java
 (original)
+++ 
accumulo/trunk/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooReaderWriter.java
 Tue Aug  7 18:40:58 2012
@@ -30,11 +30,13 @@ import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
 
 public class ZooReaderWriter extends 
org.apache.accumulo.fate.zookeeper.ZooReaderWriter {
+  private static final String SCHEME = "digest";
+  private static final String USER = "accumulo";
   private static ZooReaderWriter instance = null;
   private static IZooReaderWriter retryingInstance = null;
   
-  public ZooReaderWriter(String string, int timeInMillis, String auth) {
-    super(string, timeInMillis, auth);
+  public ZooReaderWriter(String string, int timeInMillis, String secret) {
+    super(string, timeInMillis, SCHEME, (USER + ":" + secret).getBytes());
   }
   
   public static synchronized ZooReaderWriter getInstance() {


Reply via email to