org.jgroups.protocols
Class Locking

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.Locking
Direct Known Subclasses:
CENTRAL_LOCK, PEER_LOCK

public abstract class Locking
extends Protocol

Base locking protocol, handling most of the protocol communication with other instances. To use distributed locking, LockService is placed on a channel. LockService talks to a subclass of Locking via events.

Since:
2.12
Author:
Bela Ban
See Also:
CENTRAL_LOCK, PEER_LOCK

Nested Class Summary
protected  class Locking.ClientCondition
           
protected  class Locking.ClientLock
           
static class Locking.LockingHeader
           
protected static class Locking.Request
           
protected  class Locking.ServerCondition
           
protected  class Locking.ServerLock
          Server side queue for handling of lock requests (lock, release).
protected static class Locking.Type
           
 
Field Summary
protected  boolean bypass_bundling
           
protected  java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Map<Owner,Locking.ClientLock>> client_locks
           
protected  Address local_addr
           
protected  java.util.Set<LockNotification> lock_listeners
           
protected  java.util.concurrent.ConcurrentMap<java.lang.String,Locking.ServerLock> server_locks
           
protected  View view
           
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
Locking()
           
 
Method Summary
 void addLockListener(LockNotification listener)
           
protected  Locking.ClientLock createLock(java.lang.String lock_name)
           
 java.lang.Object down(Event evt)
          An event is to be sent down the stack.
 java.lang.String getAddress()
           
 boolean getBypassBundling()
           
protected  Locking.ClientLock getLock(java.lang.String name)
           
protected  Locking.ClientLock getLock(java.lang.String name, boolean create_if_absent)
           
protected  Locking.ClientLock getLock(java.lang.String name, Owner owner, boolean create_if_absent)
           
protected  Owner getOwner()
           
 java.lang.String getView()
           
protected  void handleAwaitRequest(java.lang.String lock_name, Owner owner)
           
protected  void handleCreateAwaitingRequest(java.lang.String lock_name, Owner owner)
           
protected  void handleCreateLockRequest(java.lang.String lock_name, Owner owner)
           
protected  void handleDeleteAwaitingRequest(java.lang.String lock_name, Owner owner)
           
protected  void handleDeleteAwaitRequest(java.lang.String lock_name, Owner owner)
           
protected  void handleDeleteLockRequest(java.lang.String lock_name)
           
protected  void handleLockDeniedResponse(java.lang.String lock_name, Owner owner)
           
protected  void handleLockGrantedResponse(java.lang.String lock_name, Owner owner, Address sender)
           
protected  void handleLockRequest(Locking.Request req)
           
protected  void handleSignalRequest(Locking.Request req)
           
protected  void handleSignalResponse(java.lang.String lock_name, Owner owner)
           
protected  void handleView(View view)
           
protected  void notifyAwaited(java.lang.String lock_name, Owner owner)
           
protected  void notifyAwaiting(java.lang.String lock_name, Owner owner)
           
protected  void notifyLockCreated(java.lang.String lock_name)
           
protected  void notifyLockDeleted(java.lang.String lock_name)
           
protected  void notifyLocked(java.lang.String lock_name, Owner owner)
           
protected  void notifyUnlocked(java.lang.String lock_name, Owner owner)
           
 java.lang.String printLocks()
           
protected  void removeClientLock(java.lang.String lock_name, Owner owner)
           
 void removeLockListener(LockNotification listener)
           
protected abstract  void sendAwaitConditionRequest(java.lang.String lock_name, Owner owner)
           
protected abstract  void sendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)
           
protected abstract  void sendGrantLockRequest(java.lang.String lock_name, Owner owner, long timeout, boolean is_trylock)
           
protected  void sendLockResponse(Locking.Type type, Owner dest, java.lang.String lock_name)
           
protected abstract  void sendReleaseLockRequest(java.lang.String lock_name, Owner owner)
           
protected  void sendRequest(Address dest, Locking.Type type, java.lang.String lock_name, Owner owner, long timeout, boolean is_trylock)
           
protected abstract  void sendSignalConditionRequest(java.lang.String lock_name, boolean all)
           
protected  void sendSignalResponse(Owner dest, java.lang.String lock_name)
           
 void setBypassBundling(boolean bypass_bundling)
           
 void unlockAll()
           
 java.lang.Object up(Event evt)
          An event was received from the layer below.
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bypass_bundling

protected boolean bypass_bundling

local_addr

protected Address local_addr

view

protected View view

server_locks

protected final java.util.concurrent.ConcurrentMap<java.lang.String,Locking.ServerLock> server_locks

client_locks

protected final java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Map<Owner,Locking.ClientLock>> client_locks

lock_listeners

protected final java.util.Set<LockNotification> lock_listeners
Constructor Detail

Locking

public Locking()
Method Detail

getBypassBundling

public boolean getBypassBundling()

setBypassBundling

public void setBypassBundling(boolean bypass_bundling)

addLockListener

public void addLockListener(LockNotification listener)

removeLockListener

public void removeLockListener(LockNotification listener)

getAddress

public java.lang.String getAddress()

getView

public java.lang.String getView()

down

public java.lang.Object down(Event evt)
Description copied from class: Protocol
An event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack using down_prot.down(). In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack using up_prot.up().

Overrides:
down in class Protocol

up

public java.lang.Object up(Event evt)
Description copied from class: Protocol
An event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack using down_prot.down() or c) the event (or another event) is sent up the stack using up_prot.up().

Overrides:
up in class Protocol

getLock

protected Locking.ClientLock getLock(java.lang.String name)

getLock

protected Locking.ClientLock getLock(java.lang.String name,
                                     boolean create_if_absent)

unlockAll

public void unlockAll()

printLocks

public java.lang.String printLocks()

handleView

protected void handleView(View view)

createLock

protected Locking.ClientLock createLock(java.lang.String lock_name)

getOwner

protected Owner getOwner()

sendGrantLockRequest

protected abstract void sendGrantLockRequest(java.lang.String lock_name,
                                             Owner owner,
                                             long timeout,
                                             boolean is_trylock)

sendReleaseLockRequest

protected abstract void sendReleaseLockRequest(java.lang.String lock_name,
                                               Owner owner)

sendAwaitConditionRequest

protected abstract void sendAwaitConditionRequest(java.lang.String lock_name,
                                                  Owner owner)

sendSignalConditionRequest

protected abstract void sendSignalConditionRequest(java.lang.String lock_name,
                                                   boolean all)

sendDeleteAwaitConditionRequest

protected abstract void sendDeleteAwaitConditionRequest(java.lang.String lock_name,
                                                        Owner owner)

sendRequest

protected void sendRequest(Address dest,
                           Locking.Type type,
                           java.lang.String lock_name,
                           Owner owner,
                           long timeout,
                           boolean is_trylock)

sendLockResponse

protected void sendLockResponse(Locking.Type type,
                                Owner dest,
                                java.lang.String lock_name)

sendSignalResponse

protected void sendSignalResponse(Owner dest,
                                  java.lang.String lock_name)

handleLockRequest

protected void handleLockRequest(Locking.Request req)

handleLockGrantedResponse

protected void handleLockGrantedResponse(java.lang.String lock_name,
                                         Owner owner,
                                         Address sender)

handleLockDeniedResponse

protected void handleLockDeniedResponse(java.lang.String lock_name,
                                        Owner owner)

handleAwaitRequest

protected void handleAwaitRequest(java.lang.String lock_name,
                                  Owner owner)

handleDeleteAwaitRequest

protected void handleDeleteAwaitRequest(java.lang.String lock_name,
                                        Owner owner)

handleSignalResponse

protected void handleSignalResponse(java.lang.String lock_name,
                                    Owner owner)

handleSignalRequest

protected void handleSignalRequest(Locking.Request req)

handleCreateLockRequest

protected void handleCreateLockRequest(java.lang.String lock_name,
                                       Owner owner)

handleDeleteLockRequest

protected void handleDeleteLockRequest(java.lang.String lock_name)

handleCreateAwaitingRequest

protected void handleCreateAwaitingRequest(java.lang.String lock_name,
                                           Owner owner)

handleDeleteAwaitingRequest

protected void handleDeleteAwaitingRequest(java.lang.String lock_name,
                                           Owner owner)

getLock

protected Locking.ClientLock getLock(java.lang.String name,
                                     Owner owner,
                                     boolean create_if_absent)

removeClientLock

protected void removeClientLock(java.lang.String lock_name,
                                Owner owner)

notifyLockCreated

protected void notifyLockCreated(java.lang.String lock_name)

notifyLockDeleted

protected void notifyLockDeleted(java.lang.String lock_name)

notifyLocked

protected void notifyLocked(java.lang.String lock_name,
                            Owner owner)

notifyUnlocked

protected void notifyUnlocked(java.lang.String lock_name,
                              Owner owner)

notifyAwaiting

protected void notifyAwaiting(java.lang.String lock_name,
                              Owner owner)

notifyAwaited

protected void notifyAwaited(java.lang.String lock_name,
                             Owner owner)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.