wt.org
Class WTPrincipalCache
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
wt.util.RMIServer
wt.cache.CacheManager
wt.org.WTPrincipalCache
- All Implemented Interfaces:
- CacheServer, Remote, Serializable, Unreferenced
- public class WTPrincipalCache
- extends CacheManager
This class implements a principal cache service. It follows the 2-level
cache paradigm. Creation and updates to users and groups must be
communicated to the cache by the Organization Services manager.
- See Also:
- Serialized Form
Method Summary |
void |
addOneParentGroup(ObjectIdentifier child,
ObjectIdentifier parent)
|
private boolean |
addOrphanGroup(long id)
|
void |
addOrphanGroup(ObjectIdentifier oid)
|
private int |
findOneParentGroupIndex(long[] oneParents,
long id)
|
private int |
findOrphanGroupIndex(long[] orphans,
long id)
|
Object |
get(Object key)
Cover method for CacheManager get that tests for a set of keys
refering to the same object
Key is expected to be an ObjectIdentifier
The return Object is a WTPrincipalCacheElement. |
WTPrincipal |
getAuthUser(String name)
|
protected ObjectIdentifier |
getCachedOIDByDirKey(DirectoryKey dirKey)
|
int |
getDefaultSize()
Get desired size of this cache. |
Map |
getGroupMembers(DirectoryKey dirKey)
|
Map |
getGroupMembers(ObjectIdentifier oid)
|
Map |
getGroupMembers(WTGroup group)
|
private ObjectIdentifier[] |
getOidsFromPrincipals(Map principals)
|
private ObjectIdentifier[] |
getOidsFromRefs(Map refs)
|
WTOrganization |
getOrganization(DirectoryKey dirKey)
|
WTOrganization |
getOrganization(ObjectIdentifier oid)
|
WTOrganization |
getOrganization(WTPrincipal principal)
|
Map |
getOrganizationSubordinates(DirectoryKey dirKey)
|
Map |
getOrganizationSubordinates(ObjectIdentifier oid)
|
Map |
getParentGroups(DirectoryKey dirKey)
|
Map |
getParentGroups(ObjectIdentifier oid)
|
Map |
getParentGroups(WTPrincipal principal)
|
WTPrincipal |
getPrincipal(AuthNameKey key)
|
WTPrincipal |
getPrincipal(DirectoryKey key)
|
WTPrincipal |
getPrincipal(ObjectIdentifier oid)
|
WTPrincipal |
getPrincipal(String dn,
String service)
|
WTPrincipal |
getPrincipal(WTPrincipal principal)
|
ObjectIdentifier |
hasOneParent(ObjectIdentifier oid)
|
boolean |
isOrphanGroup(ObjectIdentifier oid)
|
protected void |
overflow(Object key,
Object value)
Override super.overflow to caputure overflow occurences and clean up
supporting caches. |
void |
put(Object key,
Object value)
Put a cache entry with given key. |
void |
putAuthNameAlias(String name,
String alias)
|
void |
putAuthNameKey(AuthNameKey key,
ObjectIdentifier oid)
|
void |
putDirectoryKey(DirectoryKey key,
ObjectIdentifier oid)
|
void |
putDirectoryKey(WTPrincipal principal)
|
void |
putDirectoryKey(WTPrincipal principal,
ObjectIdentifier oid)
|
protected void |
putEntry(Object key,
Object value)
Protected method which allows subclasses of CacheManager to
take some action when a new entry is being put into the local cache. |
void |
putGroupMembers(DirectoryKey dirKey,
Map members)
|
void |
putGroupMembers(DirectoryKey dirKey,
Set members)
|
void |
putGroupMembers(ObjectIdentifier oid,
Map members)
|
void |
putGroupMembers(WTGroup group,
Map members)
|
void |
putOrganization(DirectoryKey dirKey,
WTOrganization org)
|
void |
putOrganization(ObjectIdentifier oid,
WTOrganization org)
|
void |
putOrganization(WTPrincipal principal,
WTOrganization org)
|
void |
putOrganizationSubordinates(DirectoryKey dirKey,
Map subordinates)
|
void |
putOrganizationSubordinates(ObjectIdentifier oid,
Map subordinates)
|
void |
putOrganizationSubordinates(WTOrganization org,
Map subordinates)
|
void |
putParentGroups(DirectoryKey dirKey,
Map parents)
|
void |
putParentGroups(ObjectIdentifier oid,
Map parents)
|
void |
putParentGroups(WTPrincipal principal,
Map parents)
|
void |
putPrincipal(ObjectIdentifier oid,
WTPrincipal principal)
|
void |
putPrincipal(WTPrincipal principal)
|
protected void |
removeEntry(Object key)
Protected method which allows subclasses of CacheManager to
take some action when a entry is being removed from the local cache. |
void |
removeOneParentGroup(ObjectIdentifier oid)
|
void |
removeOrphanGroup(ObjectIdentifier oid)
|
void |
removePrincipal(WTPrincipal principal)
|
void |
replacePrincipal(WTPrincipal principal)
|
private void |
reportCacheStats()
|
void |
reset()
Reset local cache after master reconnect. |
Methods inherited from class wt.cache.CacheManager |
checkAccess, getDefaultName, getEntry, isCacheHost, ping, putEntry, reference, registerSlave, remove, remove, removeEntry, unreferenced, update, updateEntry, updateEntry |
Methods inherited from class wt.util.RMIServer |
clone, exportObject, exportObject, exportObject, getClientSocketFactory, getPort, getServerSocketFactory, getStub, isHostInList, isLocalHost, setPort, writeReplace |
lock
Object lock
size
int size
authNames
Cache authNames
rAuthNames
Cache rAuthNames
authNameAliases
Cache authNameAliases
dirKeys
Cache dirKeys
rDirKeys
Cache rDirKeys
dirKeyCache
WTDirKeyCache dirKeyCache
authNameCache
WTAuthNameCache authNameCache
orphanGroups
private volatile long[] orphanGroups
orphanGroupCount
private volatile int orphanGroupCount
oneParentGroups
private volatile long[] oneParentGroups
oneParentGroupCount
private volatile int oneParentGroupCount
oneParentGroupMap
private HashMap oneParentGroupMap
TIME_TO_LIVE_DEFAULT
private static int TIME_TO_LIVE_DEFAULT
TTL_RANDOMIZER_DEFAULT
private static int TTL_RANDOMIZER_DEFAULT
cacheSummaryInterval
private static int cacheSummaryInterval
cacheHits
private static int cacheHits
maxCachedMembers
private static int maxCachedMembers
maxCachedParents
private static int maxCachedParents
timeToLive
private static long timeToLive
timeToLiveRandomizer
private static long timeToLiveRandomizer
VERBOSE
protected static boolean VERBOSE
STACKTRACE
protected static boolean STACKTRACE
SYNCH_VERBOSE_THRESHOLD
protected static int SYNCH_VERBOSE_THRESHOLD
WTPrincipalCache
public WTPrincipalCache()
throws RemoteException
- Contruct a new policy list cache.
overflow
protected void overflow(Object key,
Object value)
- Override super.overflow to caputure overflow occurences and clean up
supporting caches. It is assumed that this method is called only when
putEntry has been called, and that method calls super.putEntry which
then detects a cache overflow condition. Consequently, any thread
synchronization that needs to be done will have been done by putEntry,
and this method does not need to do any synchronization. In fact, if
this method does any explicit synchronization, deadlock could occur.
- Overrides:
overflow
in class CacheManager
removeEntry
protected void removeEntry(Object key)
- Description copied from class:
CacheManager
- Protected method which allows subclasses of CacheManager to
take some action when a entry is being removed from the local cache.
This method is invoked to remove the entry in the local cache as a result
of a local
remove
call or a call forwarded from a master cache.
If this cache has a master cache, the remove
call will already
be forwarded to the master before this method is invoked. Slave caches
will be notified to remove their entries after this method returns.
This method must not cause a recursive remove
call.
This method is not called when entries are being removed by the overflow
or reset
methods.
Supported API: true
- Overrides:
removeEntry
in class CacheManager
- Parameters:
key
- the key object (null = clear entire cache)
reportCacheStats
private void reportCacheStats()
getAuthUser
public WTPrincipal getAuthUser(String name)
putAuthNameAlias
public void putAuthNameAlias(String name,
String alias)
putParentGroups
public void putParentGroups(WTPrincipal principal,
Map parents)
putParentGroups
public void putParentGroups(DirectoryKey dirKey,
Map parents)
putParentGroups
public void putParentGroups(ObjectIdentifier oid,
Map parents)
getParentGroups
public Map getParentGroups(WTPrincipal principal)
throws WTException
- Throws:
WTException
getParentGroups
public Map getParentGroups(DirectoryKey dirKey)
throws WTException
- Throws:
WTException
getParentGroups
public Map getParentGroups(ObjectIdentifier oid)
throws WTException
- Throws:
WTException
putGroupMembers
public void putGroupMembers(WTGroup group,
Map members)
putGroupMembers
public void putGroupMembers(DirectoryKey dirKey,
Map members)
putGroupMembers
public void putGroupMembers(DirectoryKey dirKey,
Set members)
putGroupMembers
public void putGroupMembers(ObjectIdentifier oid,
Map members)
getGroupMembers
public Map getGroupMembers(WTGroup group)
throws WTException
- Throws:
WTException
getGroupMembers
public Map getGroupMembers(DirectoryKey dirKey)
throws WTException
- Throws:
WTException
getGroupMembers
public Map getGroupMembers(ObjectIdentifier oid)
throws WTException
- Throws:
WTException
putOrganization
public void putOrganization(WTPrincipal principal,
WTOrganization org)
putOrganization
public void putOrganization(DirectoryKey dirKey,
WTOrganization org)
putOrganization
public void putOrganization(ObjectIdentifier oid,
WTOrganization org)
getOrganization
public WTOrganization getOrganization(WTPrincipal principal)
throws WTException
- Throws:
WTException
getOrganization
public WTOrganization getOrganization(DirectoryKey dirKey)
throws WTException
- Throws:
WTException
getOrganization
public WTOrganization getOrganization(ObjectIdentifier oid)
throws WTException
- Throws:
WTException
putOrganizationSubordinates
public void putOrganizationSubordinates(WTOrganization org,
Map subordinates)
putOrganizationSubordinates
public void putOrganizationSubordinates(DirectoryKey dirKey,
Map subordinates)
putOrganizationSubordinates
public void putOrganizationSubordinates(ObjectIdentifier oid,
Map subordinates)
getOrganizationSubordinates
public Map getOrganizationSubordinates(DirectoryKey dirKey)
throws WTException
- Throws:
WTException
getOrganizationSubordinates
public Map getOrganizationSubordinates(ObjectIdentifier oid)
throws WTException
- Throws:
WTException
getPrincipal
public WTPrincipal getPrincipal(AuthNameKey key)
getPrincipal
public WTPrincipal getPrincipal(String dn,
String service)
getPrincipal
public WTPrincipal getPrincipal(WTPrincipal principal)
getPrincipal
public WTPrincipal getPrincipal(DirectoryKey key)
getPrincipal
public WTPrincipal getPrincipal(ObjectIdentifier oid)
get
public Object get(Object key)
- Cover method for CacheManager get that tests for a set of keys
refering to the same object
Key is expected to be an ObjectIdentifier
The return Object is a WTPrincipalCacheElement.
- Overrides:
get
in class CacheManager
- Parameters:
key
- the key object
- Returns:
- the corresponding cached object or null if not in cache
putAuthNameKey
public void putAuthNameKey(AuthNameKey key,
ObjectIdentifier oid)
putDirectoryKey
public void putDirectoryKey(DirectoryKey key,
ObjectIdentifier oid)
putDirectoryKey
public void putDirectoryKey(WTPrincipal principal)
putDirectoryKey
public void putDirectoryKey(WTPrincipal principal,
ObjectIdentifier oid)
putPrincipal
public void putPrincipal(WTPrincipal principal)
putPrincipal
public void putPrincipal(ObjectIdentifier oid,
WTPrincipal principal)
replacePrincipal
public void replacePrincipal(WTPrincipal principal)
removePrincipal
public void removePrincipal(WTPrincipal principal)
put
public void put(Object key,
Object value)
- Description copied from class:
CacheManager
- Put a cache entry with given key.
The entry will also be put in the master cache, and any slave caches
will have their corresponding entry removed.
Supported API: true
- Overrides:
put
in class CacheManager
- Parameters:
key
- the key objectvalue
- the value object
putEntry
protected void putEntry(Object key,
Object value)
- Description copied from class:
CacheManager
- Protected method which allows subclasses of CacheManager to
take some action when a new entry is being put into the local cache.
This method is invoked to put the entry in the local cache as a result
of a local
put
call or a call forwarded from a slave cache
or when a local get
call downloads the entry from a master cache.
If this cache has a master cache, the put
call will already
be forwarded to the master before this method is invoked. Slave caches
will be notified to remove their entries after this method returns.
This method must not cause a recursive put
call.
Supported API: true
- Overrides:
putEntry
in class CacheManager
- Parameters:
key
- the key objectvalue
- the value object
reset
public void reset()
throws RemoteException
- Description copied from class:
CacheManager
- Reset local cache after master reconnect.
Called after recovery from communication failure when a connection to a
new master has been established. The current cache contents are cleared
and the local cache is registered as a slave of the new master.
NOTE: This may be called as a result of calling other cache updating operations
since that is when the disconnect and reconnect may take place. When this
happens, this method is called before the other methods return.
Supported API: true
- Overrides:
reset
in class CacheManager
- Throws:
RemoteException
getDefaultSize
public int getDefaultSize()
- Description copied from class:
CacheManager
- Get desired size of this cache.
This method attemps to find a size property called
wt.cache.size.CacheName
where cacheName
is the name of this cache. Subclasses can override this
method to control cache size in some other way. If no property is found, the default
size is 100.
Supported API: true
- Overrides:
getDefaultSize
in class CacheManager
getOidsFromPrincipals
private ObjectIdentifier[] getOidsFromPrincipals(Map principals)
getOidsFromRefs
private ObjectIdentifier[] getOidsFromRefs(Map refs)
getCachedOIDByDirKey
protected ObjectIdentifier getCachedOIDByDirKey(DirectoryKey dirKey)
addOrphanGroup
public void addOrphanGroup(ObjectIdentifier oid)
addOrphanGroup
private boolean addOrphanGroup(long id)
findOrphanGroupIndex
private int findOrphanGroupIndex(long[] orphans,
long id)
isOrphanGroup
public boolean isOrphanGroup(ObjectIdentifier oid)
removeOrphanGroup
public void removeOrphanGroup(ObjectIdentifier oid)
addOneParentGroup
public void addOneParentGroup(ObjectIdentifier child,
ObjectIdentifier parent)
findOneParentGroupIndex
private int findOneParentGroupIndex(long[] oneParents,
long id)
hasOneParent
public ObjectIdentifier hasOneParent(ObjectIdentifier oid)
removeOneParentGroup
public void removeOneParentGroup(ObjectIdentifier oid)