public class HashtableServerImpl extends java.rmi.server.UnicastRemoteObject implements HashtableServer
| Modifier and Type | Field and Description |
|---|---|
float |
CACHE_CLEANUP_TARGET |
int |
CACHE_TABLE_SIZE |
int |
CACHE_WINDOW |
int |
cacheInvalidationScheme |
java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> |
cacheTable |
int |
changeMasterCount |
java.util.concurrent.ConcurrentHashMap<java.lang.String,NodeMetadata> |
metaDataTable |
int |
myId |
int |
numServers |
boolean |
recordStats |
java.util.concurrent.ConcurrentHashMap<java.lang.Integer,HashtableServer> |
servers |
boolean |
useCaching |
| Constructor and Description |
|---|
HashtableServerImpl(java.lang.String url)
server-id unaware contructor
|
HashtableServerImpl(java.lang.String url,
int serverId)
server-id aware contructor
|
HashtableServerImpl(java.lang.String url,
int serverId,
Config configParams)
Constructor for the caching case
|
| Modifier and Type | Method and Description |
|---|---|
Node |
cacheEvict(java.lang.String nodeId)
cache eviction thread invokes this method when removing a copy from the cache table (cache replacement)
|
void |
cacheEvictMasterNotify(java.lang.String cachingServerId,
java.util.Hashtable<java.lang.String,java.lang.Long> evictedNodes)
cache eviction thread invokes this method on the master site informing it of the cache eviction
|
void |
cacheInvalidate(java.lang.String nodeId)
Master server invokes this function on a remote server when asking it to invalidate its cache copy
|
java.util.Vector<ResultObject> |
cachePut(java.util.Map<java.lang.Integer,java.util.Vector<Node>> nodes,
long storageSystemThreadId)
Bulk call for cachePut
|
ResultObject |
cachePut(java.lang.String nodeId,
Node node,
int masterCopySite,
long storageSystemThreadId)
Once a node has been fetched for caching, insert into cache table.
|
void |
clearStatContainers()
Clear stat containers
|
void |
configureServer(java.util.Vector<java.lang.String> hostList)
Configure server to hold rmi handles of other servers
Allows for inter-server communication
|
boolean |
contains(java.lang.String key)
Check if the table contains a given key
|
void |
enableStats()
Turn on stat recording
|
ResultObject |
exec(NodeData n) |
java.util.Vector<ResultObject> |
execBulk(java.util.Vector<NodeData> keyList) |
ResultObject |
get(java.lang.String key,
long storageSystemThreadId)
Given a node id, returns a node to the storage system (application)
Forks off to getUseCache in the useCaching = true case
|
java.util.Vector<java.lang.String> |
getAllKeys()
Get all node ids present in the main table (does not include cache table)
|
java.util.Vector<Node> |
getAllNodes()
Get all nodes present in the main table (does not include cache table)
|
java.util.Vector<Node> |
getCachedObjects(java.util.Vector<java.lang.String> nodeIds) |
ClusterMeasures |
getClusterMeasures() |
java.util.Vector<ResultObject> |
getLocalNodes(java.util.Vector<java.lang.String> nodeIds,
long storageSystemThreadId)
Storage system invokes this method on the server when requesting nodes and status for those nodes which are not available
Only used in caching case
|
Node |
getNodeForCaching(java.lang.String nodeId,
int cachingSite)
Remote server invokes this method on the master site when requesting a cache copy
|
Node |
getNodeFromCacheTable(java.lang.String nodeId)
get node for nodeId from the cache table
returns null if node not found
|
Node |
getNodeFromTable(java.lang.String nodeId)
get a node from the table
|
ResultObject |
getNodeProperties(NodeData n)
retrieve the node data for a node, given its node ids and the required properties
|
java.util.Vector<Node> |
getNodesForCaching(java.util.Vector<java.lang.String> nodeIds,
int cachingSite)
Bulk call for getNodeForCaching
|
int |
getNumServers() |
java.util.Vector<ResultObject> |
getObjects(java.util.Vector<java.lang.String> keyList)
getObjects from the hash table.
|
java.util.Vector<ResultObject> |
getObjectsProperties(java.util.Vector<NodeData> keyList)
Bulk call to get object properties for a set of nodes
|
int |
getServerId() |
java.lang.String |
getStats()
Get the stats, called after program run terminates
|
void |
loadNodes(java.util.Vector<Node> nodes)
To load initial nodes into the table, used by the file loader
|
void |
locationChange(int nodeId,
java.lang.String servername)
Inform the homesite that a node has been relocated.
|
ResultObject |
lock(int nodeId)
Lock an object to prevent its relocation
|
static void |
main(java.lang.String[] args) |
java.util.Date |
ping()
Test if the hashtable server is up
|
ResultObject |
put(java.lang.String key,
java.lang.Object value)
put the node into the table, given a node-id
Forks off to putUseCache in the useCaching = true case
|
ResultObject |
put(java.lang.String key,
java.lang.Object value,
int callerServerId)
put for the write through cache case
|
java.util.Vector<ResultObject> |
putObjects(java.util.concurrent.ConcurrentHashMap<java.lang.String,Node> objList)
putObjects back into the hash table
|
java.util.Vector<ResultObject> |
putObjects(java.util.concurrent.ConcurrentHashMap<java.lang.String,Node> objList,
int callingServerId)
put objects back into the hash table for the write through cache case
|
ResultObject |
putUseCache(java.lang.String key,
java.lang.Object value,
int callingServerId)
putUseCache for the write through cache case
also takes in a calling server id, to keep track of cache invaldations (write through cache = no invalidation on calling server)
|
ResultObject |
relocate(int nodeId,
java.lang.String serverName)
called on the homesite when relocating a node to a remote server
homesite makes a note of it in the location table
|
void |
removeLocationTableEntry(java.lang.String key)
Remove a key from the location table
|
void |
setNumServers(int n) |
ResultObject |
updateNodeProperties(NodeData value)
update the properties of a node, given the node id and the updated property map
|
java.util.Vector<ResultObject> |
updateNodePropertiesParallel(java.util.Vector<NodeData> objList)
This is the reflection counterpart of putObjects, used for bulk update of node properties
repeatedly calls the updateNodeProperties (can be done in parallel)
|
void |
writeThroughToCache(java.lang.String paramString,
java.lang.Object value)
write through to local cache, so that master does need to invalidate the copy on put
|
void |
writeThroughToCacheBulk(java.util.concurrent.ConcurrentHashMap<java.lang.String,Node> map)
bulk call for writeThroughToCache
|
clone, exportObject, exportObject, exportObject, unexportObjectpublic int myId
public java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> cacheTable
public java.util.concurrent.ConcurrentHashMap<java.lang.String,NodeMetadata> metaDataTable
public int changeMasterCount
public boolean useCaching
public boolean recordStats
public int cacheInvalidationScheme
public int CACHE_TABLE_SIZE
public int CACHE_WINDOW
public float CACHE_CLEANUP_TARGET
public int numServers
public java.util.concurrent.ConcurrentHashMap<java.lang.Integer,HashtableServer> servers
public HashtableServerImpl(java.lang.String url)
throws java.rmi.RemoteException
url - java.rmi.RemoteExceptionpublic HashtableServerImpl(java.lang.String url,
int serverId)
throws java.rmi.RemoteException
url - serverId - java.rmi.RemoteExceptionpublic HashtableServerImpl(java.lang.String url,
int serverId,
Config configParams)
throws java.rmi.RemoteException
url - serverId - configParams - java.rmi.RemoteExceptionpublic void configureServer(java.util.Vector<java.lang.String> hostList)
hostList - public void enableStats()
public java.util.Date ping()
ping in interface HashtableServerpublic ResultObject get(java.lang.String key, long storageSystemThreadId)
get in interface HashtableServerkey - storageSystemThreadId - public ResultObject put(java.lang.String key, java.lang.Object value) throws java.rmi.RemoteException
put in interface HashtableServerkey - value - java.rmi.RemoteExceptionpublic ResultObject put(java.lang.String key, java.lang.Object value, int callerServerId) throws java.rmi.RemoteException
put in interface HashtableServerkey - value - callerServerId - java.rmi.RemoteExceptionpublic ResultObject putUseCache(java.lang.String key, java.lang.Object value, int callingServerId) throws java.rmi.RemoteException
key - value - callingServerId - java.rmi.RemoteExceptionpublic ResultObject getNodeProperties(NodeData n) throws java.rmi.RemoteException
getNodeProperties in interface HashtableServern - java.rmi.RemoteExceptionpublic ResultObject updateNodeProperties(NodeData value) throws java.rmi.RemoteException
updateNodeProperties in interface HashtableServervalue - java.rmi.RemoteExceptionpublic ResultObject exec(NodeData n) throws java.rmi.RemoteException
exec in interface HashtableServerjava.rmi.RemoteExceptionpublic java.util.Vector<ResultObject> execBulk(java.util.Vector<NodeData> keyList) throws java.rmi.RemoteException
execBulk in interface HashtableServerjava.rmi.RemoteExceptionpublic java.util.Vector<ResultObject> getObjects(java.util.Vector<java.lang.String> keyList)
getObjects in interface HashtableServerkeyList - public java.util.Vector<ResultObject> putObjects(java.util.concurrent.ConcurrentHashMap<java.lang.String,Node> objList) throws java.rmi.RemoteException
putObjects in interface HashtableServerobjList - java.rmi.RemoteExceptionpublic java.util.Vector<ResultObject> putObjects(java.util.concurrent.ConcurrentHashMap<java.lang.String,Node> objList, int callingServerId) throws java.rmi.RemoteException
putObjects in interface HashtableServerobjList - callingServerId - java.rmi.RemoteExceptionpublic java.util.Vector<ResultObject> getObjectsProperties(java.util.Vector<NodeData> keyList) throws java.rmi.RemoteException
getObjectsProperties in interface HashtableServerkeyList - java.rmi.RemoteExceptionpublic java.util.Vector<Node> getCachedObjects(java.util.Vector<java.lang.String> nodeIds) throws java.rmi.RemoteException
getCachedObjects in interface HashtableServerjava.rmi.RemoteExceptionpublic java.util.Vector<ResultObject> updateNodePropertiesParallel(java.util.Vector<NodeData> objList) throws java.rmi.RemoteException
updateNodePropertiesParallel in interface HashtableServerobjList - - hashtable of nodeId/Node data objectjava.rmi.RemoteExceptionpublic Node getNodeFromCacheTable(java.lang.String nodeId) throws java.rmi.RemoteException
getNodeFromCacheTable in interface HashtableServernodeId - java.rmi.RemoteExceptionpublic ResultObject cachePut(java.lang.String nodeId, Node node, int masterCopySite, long storageSystemThreadId)
cachePut in interface HashtableServernodeId - node - masterCopySite - storageSystemThreadId - public java.util.Vector<ResultObject> cachePut(java.util.Map<java.lang.Integer,java.util.Vector<Node>> nodes, long storageSystemThreadId)
cachePut in interface HashtableServernodes - - Map of master site v/s list of nodes obtained from that master sitestorageSystemThreadId - public void cacheInvalidate(java.lang.String nodeId)
cacheInvalidate in interface HashtableServernodeId - - node for which invalidation has to take placepublic Node cacheEvict(java.lang.String nodeId)
nodeId - public void cacheEvictMasterNotify(java.lang.String cachingServerId,
java.util.Hashtable<java.lang.String,java.lang.Long> evictedNodes)
throws java.rmi.RemoteException
cacheEvictMasterNotify in interface HashtableServercachingServerId - evictedNodes - java.rmi.RemoteExceptionpublic Node getNodeForCaching(java.lang.String nodeId, int cachingSite)
getNodeForCaching in interface HashtableServernodeID - cachingSite - public java.util.Vector<Node> getNodesForCaching(java.util.Vector<java.lang.String> nodeIds, int cachingSite)
getNodesForCaching in interface HashtableServerpublic void writeThroughToCache(java.lang.String paramString,
java.lang.Object value)
writeThroughToCache in interface HashtableServerparamString - value - public void writeThroughToCacheBulk(java.util.concurrent.ConcurrentHashMap<java.lang.String,Node> map)
writeThroughToCacheBulk in interface HashtableServermap - public java.util.Vector<ResultObject> getLocalNodes(java.util.Vector<java.lang.String> nodeIds, long storageSystemThreadId)
getLocalNodes in interface HashtableServernodeIds - public Node getNodeFromTable(java.lang.String nodeId) throws java.rmi.RemoteException
getNodeFromTable in interface HashtableServernodeId - java.rmi.RemoteExceptionpublic boolean contains(java.lang.String key)
contains in interface HashtableServerkey - public java.util.Vector<Node> getAllNodes()
getAllNodes in interface HashtableServerpublic java.util.Vector<java.lang.String> getAllKeys()
getAllKeys in interface HashtableServerpublic java.lang.String getStats()
getStats in interface HashtableServerpublic void clearStatContainers()
clearStatContainers in interface HashtableServerpublic void loadNodes(java.util.Vector<Node> nodes) throws java.rmi.RemoteException
loadNodes in interface HashtableServernodes - java.rmi.RemoteExceptionpublic int getServerId()
throws java.rmi.RemoteException
getServerId in interface HashtableServerjava.rmi.RemoteExceptionpublic int getNumServers()
throws java.rmi.RemoteException
getNumServers in interface HashtableServerjava.rmi.RemoteExceptionpublic void setNumServers(int n)
throws java.rmi.RemoteException
setNumServers in interface HashtableServerjava.rmi.RemoteExceptionpublic ResultObject relocate(int nodeId, java.lang.String serverName)
relocate in interface HashtableServernodeId - serverName - public void locationChange(int nodeId,
java.lang.String servername)
locationChange in interface HashtableServernodeId - servername - public ResultObject lock(int nodeId) throws java.rmi.RemoteException
lock in interface HashtableServernodeId - java.rmi.RemoteExceptionpublic void removeLocationTableEntry(java.lang.String key)
removeLocationTableEntry in interface HashtableServerkey - public ClusterMeasures getClusterMeasures()
getClusterMeasures in interface HashtableServerpublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception