public class HashtableServerImpl extends UnicastRemoteObject implements HashtableServer, HashtableServer_thrift.Iface
| Modifier and Type | Field and Description |
|---|---|
float |
CACHE_CLEANUP_TARGET |
int |
CACHE_TABLE_SIZE |
int |
CACHE_WINDOW |
int |
cacheInvalidationScheme |
ConcurrentHashMap<String,Object> |
cacheTable |
int |
changeMasterCount |
ConcurrentHashMap<String,NodeMetadata> |
metaDataTable |
int |
myId |
String |
myURL |
static HashMap<Byte,Class> |
nodeClassMap |
static HashMap<Byte,String> |
nodeClassNameMap |
static HashMap<String,Byte> |
nodeClassNametoIDMap |
int |
numServers |
boolean |
recordStats |
ConcurrentHashMap<Integer,HashtableServer> |
servers |
boolean |
USE_NODEDATA_REFLECTION |
boolean |
useCaching |
ref| Constructor and Description |
|---|
HashtableServerImpl(String url)
server-id unaware contructor
|
HashtableServerImpl(String url,
int serverId,
Config configParams,
boolean caching,
HashMap<Byte,String> nodeClassNameMap,
HashMap<Byte,Class> nodeClassMap)
Constructor for the caching case
|
| Modifier and Type | Method and Description |
|---|---|
Node |
cacheEvict(String nodeId)
cache eviction thread invokes this method when removing a copy from the cache table (cache replacement)
|
void |
cacheEvictMasterNotify(String cachingServerId,
Hashtable<String,Long> evictedNodes)
cache eviction thread invokes this method on the master site informing it of the cache eviction
|
void |
cacheInvalidate(String nodeId)
Master server invokes this function on a remote server when asking it to invalidate its cache copy
|
Vector<ResultObject> |
cachePut(Map<Integer,Vector<Node>> nodes,
long storageSystemThreadId)
Bulk call for cachePut
|
ResultObject |
cachePut(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(Vector<String> hostList)
Configure server to hold rmi handles of other servers
Allows for inter-server communication
|
boolean |
contains(String key)
Check if the table contains a given key
|
void |
enableStats()
Turn on stat recording
|
ResultObject |
exec(NodeData n)
Executes the methods of a node contained in this server
|
Vector<ResultObject> |
execBulk(Vector<NodeData> keyList) |
ResultObject_thrift |
get_thrift(String key,
long storageSystemThreadId) |
ResultObject |
get(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
|
List<String> |
getAllKeys_thrift() |
Vector<String> |
getAllKeys()
Get all node ids present in the main table (does not include cache table)
|
Vector<Node> |
getAllNodes()
Get all nodes present in the main table (does not include cache table)
|
Vector<Node> |
getCachedObjects(Vector<String> nodeIds) |
ClusterMeasures |
getClusterMeasures() |
Vector<ResultObject> |
getLocalNodes(Vector<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(String nodeId,
int cachingSite)
Remote server invokes this method on the master site when requesting a cache copy
|
Node |
getNodeFromCacheTable(String nodeId)
get node for nodeId from the cache table
returns null if node not found
|
Node |
getNodeFromTable(String nodeId)
get a node from the table
|
ResultObject_thrift |
getNodeProperties_thrift(NodeData_thrift n) |
ResultObject |
getNodeProperties(NodeData n)
retrieve the node data for a node, given its node ids and the required properties
|
Vector<Node> |
getNodesForCaching(Vector<String> nodeIds,
int cachingSite)
Bulk call for getNodeForCaching
|
int |
getNumServers() |
List<ResultObject_thrift> |
getObjects_thrift(List<String> keyList) |
Vector<ResultObject> |
getObjects(Vector<String> keyList)
getObjects from the hash table.
|
List<ResultObject_thrift> |
getObjectsProperties_thrift(List<NodeData_thrift> keyList) |
Vector<ResultObject> |
getObjectsProperties(Vector<NodeData> keyList)
Bulk call to get object properties for a set of nodes
|
int |
getServerId() |
String |
getStats()
Get the stats, called after program run terminates
|
void |
loadNodes(Vector<Node> nodes)
To load initial nodes into the table, used by the file loader
|
void |
locationChange_thrift(int nodeId,
String serverName) |
void |
locationChange(int nodeId,
String servername)
Inform the homesite that a node has been relocated.
|
ResultObject_thrift |
lock_thrift(int nodeId) |
ResultObject |
lock(int nodeId)
Lock an object to prevent its relocation
|
static void |
main(String[] args) |
Date |
ping()
Test if the hashtable server is up
|
ResultObject_thrift |
put_thrift(String key,
Node_thrift value) |
ResultObject |
put(String key,
Object value)
Puts an object into the hashtable based on the provided key.
|
ResultObject |
put(String key,
Object value,
int callerServerId)
Puts an object into the cache and invalidates the cache of the calling server if needed.
|
List<ResultObject_thrift> |
putObjects_thrift(Map<String,Node_thrift> nodeList_thrift) |
Vector<ResultObject> |
putObjects(ConcurrentHashMap<String,Node> objList)
putObjects back into the hash table
|
Vector<ResultObject> |
putObjects(ConcurrentHashMap<String,Node> objList,
int callingServerId)
put objects back into the hash table for the write through cache case
|
ResultObject |
putUseCache(String key,
Object value,
int callingServerId)
putUseCache for the write through cache case
also takes in a calling server id, to keep track of cache invalidation (write through cache = no invalidation on calling server)
|
ResultObject_thrift |
relocate_thrift(int nodeId,
String serverName) |
ResultObject |
relocate(int nodeId,
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(String key)
Remove a key from the location table
|
void |
setNumServers(int n) |
ResultObject_thrift |
updateNodeProperties_thrift(NodeData_thrift n) |
ResultObject |
updateNodeProperties(NodeData value)
update the properties of a node, given the node id and the updated property map
|
List<ResultObject_thrift> |
updateNodePropertiesParallel_thrift(List<NodeData_thrift> keyList) |
Vector<ResultObject> |
updateNodePropertiesParallel(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(String paramString,
Object value)
Writes an object to the local cache based on the
paramString. |
void |
writeThroughToCacheBulk(ConcurrentHashMap<String,Node> map)
bulk call for writeThroughToCache
|
clone, exportObject, exportObject, exportObject, unexportObjectgetClientHost, getLog, setLogpublic String myURL
public int myId
public ConcurrentHashMap<String,Object> cacheTable
public ConcurrentHashMap<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 boolean USE_NODEDATA_REFLECTION
public int numServers
public ConcurrentHashMap<Integer,HashtableServer> servers
public HashtableServerImpl(String url) throws RemoteException
url - RemoteExceptionpublic HashtableServerImpl(String url, int serverId, Config configParams, boolean caching, HashMap<Byte,String> nodeClassNameMap, HashMap<Byte,Class> nodeClassMap) throws RemoteException
url - serverId - configParams - RemoteExceptionpublic void configureServer(Vector<String> hostList)
hostList - public void enableStats()
public Date ping()
ping in interface HashtableServerpublic ResultObject get(String key, long storageSystemThreadId)
get in interface HashtableServerkey - storageSystemThreadId - public ResultObject put(String key, Object value) throws RemoteException
put in interface HashtableServerkey - The identifier of the object that is to be put into the hashtable.value - The object that is to be put into the hashtable.RemoteException - Thrown only if public ResultObject put(String key, Object value, int callerServerId) throws RemoteException
put in interface HashtableServerkey - The identifier of the object that is be be put into cache.value - The object that is be placed into cache.callerServerId - The id of the server that called put.RemoteException - Thrown if the value could not be put into the cache.StorageSystem.putNodeUseCache(String, Node)public ResultObject putUseCache(String key, Object value, int callingServerId) throws RemoteException
key - The identifier of the object that is be be put into cache.value - The object that is be placed into cache.callingServerId - The id of the server that called put.RemoteException - Thrown if the object could not be put into cachepublic ResultObject getNodeProperties(NodeData n) throws RemoteException
getNodeProperties in interface HashtableServern - RemoteExceptionpublic ResultObject updateNodeProperties(NodeData value) throws RemoteException
updateNodeProperties in interface HashtableServervalue - RemoteExceptionpublic ResultObject exec(NodeData n) throws RemoteException
exec in interface HashtableServern - - Contains the nodeId of the node whose methods are to be executed. The methods that are to be
executed are provided as a mapping of method name to parameters.RemoteExceptionpublic Vector<ResultObject> execBulk(Vector<NodeData> keyList) throws RemoteException
execBulk in interface HashtableServerRemoteExceptionpublic Vector<ResultObject> getObjects(Vector<String> keyList)
getObjects in interface HashtableServerkeyList - public Vector<ResultObject> putObjects(ConcurrentHashMap<String,Node> objList) throws RemoteException
putObjects in interface HashtableServerobjList - RemoteExceptionpublic Vector<ResultObject> putObjects(ConcurrentHashMap<String,Node> objList, int callingServerId) throws RemoteException
putObjects in interface HashtableServerobjList - callingServerId - RemoteExceptionpublic Vector<ResultObject> getObjectsProperties(Vector<NodeData> keyList) throws RemoteException
getObjectsProperties in interface HashtableServerkeyList - RemoteExceptionpublic Vector<Node> getCachedObjects(Vector<String> nodeIds) throws RemoteException
getCachedObjects in interface HashtableServerRemoteExceptionpublic Vector<ResultObject> updateNodePropertiesParallel(Vector<NodeData> objList) throws RemoteException
updateNodePropertiesParallel in interface HashtableServerobjList - - hashtable of nodeId/Node data objectRemoteExceptionpublic Node getNodeFromCacheTable(String nodeId) throws RemoteException
getNodeFromCacheTable in interface HashtableServernodeId - RemoteExceptionpublic ResultObject cachePut(String nodeId, Node node, int masterCopySite, long storageSystemThreadId)
cachePut in interface HashtableServernodeId - node - masterCopySite - storageSystemThreadId - public Vector<ResultObject> cachePut(Map<Integer,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(String nodeId)
cacheInvalidate in interface HashtableServernodeId - - node for which invalidation has to take placepublic Node cacheEvict(String nodeId)
nodeId - public void cacheEvictMasterNotify(String cachingServerId, Hashtable<String,Long> evictedNodes) throws RemoteException
cacheEvictMasterNotify in interface HashtableServercachingServerId - evictedNodes - RemoteExceptionpublic Node getNodeForCaching(String nodeId, int cachingSite)
getNodeForCaching in interface HashtableServernodeId - cachingSite - public Vector<Node> getNodesForCaching(Vector<String> nodeIds, int cachingSite)
getNodesForCaching in interface HashtableServerpublic void writeThroughToCache(String paramString, Object value)
paramString. The master does not need to invalidate
the copy on put.writeThroughToCache in interface HashtableServerparamString - The identification of the value that is to be written to the cachevalue - The object that is to be written to cachepublic void writeThroughToCacheBulk(ConcurrentHashMap<String,Node> map)
writeThroughToCacheBulk in interface HashtableServermap - public Vector<ResultObject> getLocalNodes(Vector<String> nodeIds, long storageSystemThreadId)
getLocalNodes in interface HashtableServernodeIds - public Node getNodeFromTable(String nodeId) throws RemoteException
getNodeFromTable in interface HashtableServernodeId - RemoteExceptionpublic boolean contains(String key)
contains in interface HashtableServerkey - public Vector<Node> getAllNodes()
getAllNodes in interface HashtableServerpublic Vector<String> getAllKeys()
getAllKeys in interface HashtableServerpublic String getStats()
getStats in interface HashtableServerpublic void clearStatContainers()
clearStatContainers in interface HashtableServerpublic void loadNodes(Vector<Node> nodes) throws RemoteException
loadNodes in interface HashtableServernodes - RemoteExceptionpublic int getServerId()
throws RemoteException
getServerId in interface HashtableServerRemoteExceptionpublic int getNumServers()
throws RemoteException
getNumServers in interface HashtableServerRemoteExceptionpublic void setNumServers(int n)
throws RemoteException
setNumServers in interface HashtableServerRemoteExceptionpublic ResultObject relocate(int nodeId, String serverName)
relocate in interface HashtableServernodeId - serverName - public void locationChange(int nodeId,
String servername)
locationChange in interface HashtableServernodeId - servername - public ResultObject lock(int nodeId) throws RemoteException
lock in interface HashtableServernodeId - RemoteExceptionpublic void removeLocationTableEntry(String key)
removeLocationTableEntry in interface HashtableServerkey - public ClusterMeasures getClusterMeasures()
getClusterMeasures in interface HashtableServerpublic ResultObject_thrift put_thrift(String key, Node_thrift value)
put_thrift in interface HashtableServer_thrift.Ifacepublic ResultObject_thrift get_thrift(String key, long storageSystemThreadId) throws org.apache.thrift.TException
get_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic ResultObject_thrift getNodeProperties_thrift(NodeData_thrift n) throws org.apache.thrift.TException
getNodeProperties_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic ResultObject_thrift updateNodeProperties_thrift(NodeData_thrift n) throws org.apache.thrift.TException
updateNodeProperties_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic List<ResultObject_thrift> getObjectsProperties_thrift(List<NodeData_thrift> keyList) throws org.apache.thrift.TException
getObjectsProperties_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic List<ResultObject_thrift> updateNodePropertiesParallel_thrift(List<NodeData_thrift> keyList) throws org.apache.thrift.TException
updateNodePropertiesParallel_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic List<ResultObject_thrift> putObjects_thrift(Map<String,Node_thrift> nodeList_thrift) throws org.apache.thrift.TException
putObjects_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic List<ResultObject_thrift> getObjects_thrift(List<String> keyList) throws org.apache.thrift.TException
getObjects_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic List<String> getAllKeys_thrift() throws org.apache.thrift.TException
getAllKeys_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic ResultObject_thrift relocate_thrift(int nodeId, String serverName) throws org.apache.thrift.TException
relocate_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic void locationChange_thrift(int nodeId,
String serverName)
throws org.apache.thrift.TException
locationChange_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TExceptionpublic ResultObject_thrift lock_thrift(int nodeId) throws org.apache.thrift.TException
lock_thrift in interface HashtableServer_thrift.Ifaceorg.apache.thrift.TException