hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Lucene-hadoop Wiki] Update of "DistributedLockServer" by JimKellerman
Date Thu, 22 Feb 2007 00:08:30 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Lucene-hadoop Wiki" for change notification.

The following page has been changed by JimKellerman:
http://wiki.apache.org/lucene-hadoop/DistributedLockServer

The comment on the change is:
Revised LockserverClient API

------------------------------------------------------------------------------
  package org.apache.hbase.lockserver.client;
  
  import java.util.Map;
+ import java.util.EnumSet;
  
  public interface LockserverClient {
  
@@ -49, +50 @@

    /** Minimum value for lock delay in open() */
    public static final int MIN_LOCK_DELAY = 2 * 1000;    // two seconds
    
+   /** Open modes. */
+   public enum OpenMode {
+     READONLY,           // Open read-only no lock
+     WRITE_AND_LOCK,     // Open for writing and locking
+     SET_ACL,            // Open to change ACL
+     CREATE,             // Create if does not exist, otherwise open WRITE_AND_LOCK
+     MUST_CREATE         // Create only if does exist, WRITE_AND_LOCK mode if successful
+   }
+   
-   /**
-    * Open modes. May be OR'd together
-    */
-   /** Open read-only no lock */
-   public static final int MODE_READONLY = 1;
-   /** Open for writing and locking */
-   public static final int MODE_WRITE_AND_LOCK = 2;
-   /** Open to change ACL */
-   public static final int MODE_SETACL = 4;
-   /** Create if does not exist */
-   public static final int MODE_CREATE = 8;
-   /** Create only if does exist */
-   public static final int MODE_MUST_CREATE = 16;
    /**
     * Opens the specified path with the specified mode.
     * @param path
@@ -70, +67 @@

     *                    it can no longer communicate with the client 
     *                    (milliseconds). If zero is specified MIN_LOCK_DELAY is assumed.
     */
-   public void open(String path, int mode, int lockDelay);
+   public void open(String path, OpenMode mode, int lockDelay);
+ 
-   
-   /**
-    * Event types client can register for.
+   /** Event types client can register for. */
+   public enum Events {
+     CONTENTS_CHANGED,   // Contents of node changed
+     CHILD_ADDED,        // Child node added
+     CHILD_REMOVED,      // Child node removed
+     CHILD_MODIFIED,     // Child node modified
+     MASTER_FAILOVER,    // Master lock server failed over
-    * Values may be OR'd together.
-    */
-   /** Contents of node changed */
-   public static final int EVENT_CONTENTS = 1;
-   /** Child node added */
-   public static final int EVENT_CHILD_ADDED = 2;
-   /** Child node removed */
-   public static final int EVENT_CHILD_REMOVED = 4;
-   /** Child node modified */
-   public static final int EVENT_CHILD_MODIFIED = 8;
-   /** Master lock server failed over */
-   public static final int EVENT_MASTER_FAILOVER = 16;
-   /** Unable to communicate with lock server - session in jeopardy */
+     HANDLE_WARNING,     // Unable to communicate with lock server - session in jeopardy
-   public static final int EVENT_HANDLE_WARNING = 32;
-   /** Communicated with lock server before time out - session safe */
+     HANDLE_SAFE,        // Communicated with lock server before time out - session safe
-   public static final int EVENT_HANDLE_SAFE = 64;
-   /** Unable to communicate with lock server - session invalid */
+     HANDLE_EXPIRED      // Unable to communicate with lock server - session invalid
-   public static final int EVENT_HANDLE_EXPIRED = 128;
+   }
+ 
    /**
     * Register to receive lock server events
     * @param handler - event handler object
     * @param eventMask -  mask of desired event types
     */
-   public void setEventHandler(LockEventHandler handler, int eventMask);
+   public void setEventHandler(LockEventHandler handler, EnumSet<Events> eventMask);
  
    /** Terminates session. Releases allocated resources. */
    public void close();
@@ -133, +122 @@

    /** Deletes the node if it has no children */
    public void delete();
    
-   /**
-    * Locking modes
+   /** Locking modes */
+   public enum LockMode {
+     LOCK_SHARED,        // Multiple readers
+     LOCK_EXCLUSIVE      // Single writer
+   }
-    */
-   /** Multiple readers */
-   public final static int LOCK_SHARED = 1;
-   /** Single writer */
-   public final static int LOCK_EXCLUSIVE = 2;
    
    /**
     * Acquire a lock. Block if the lock cannot be obtained immediately.
-    * @param lockMode one of the lock modes above
+    * @param mode one of the lock modes above
     */
-   public void lock(int lockMode);
+   public void lock(LockMode mode);
    
    /**
     * Attempt to acquire a lock. Do not block if the lock cannot be obtained immediately.
-    * @param lockMode - one of the lock modes above
+    * @param mode - one of the lock modes above
     * @return - true if lock was acquired, false if lock was not acquired.
     */
-   public boolean tryLock(int lockMode);
+   public boolean tryLock(LockMode mode);
    
    /** Releases the currently held lock */
    public void unlock();

Mime
View raw message