The Server class that implements the DistributedMap Ice interface. More...
#include <DM_Server.h>
Public Member Functions | |
DM_Server (int num_clients, Server_Helper &) | |
virtual | ~DM_Server () |
void | put (const string &key, const string &val, const Ice::Current &) |
void | set (const string &key, const string &val, const Ice::Current &) |
bool | get (const string &key, string &val, const Ice::Current &) |
bool | remove (const string &, string &, const Ice::Current &) |
void | putNget_async (const AMD_DistributedMap_putNgetPtr &png_cb, const string &word, const string &delta, const Ice::Current &) |
void | waitForAllClients_async (const AMD_DistributedMap_waitForAllClientsPtr &, const Ice::Current &) |
Barrier. Helps clients synchronize. |
The Server class that implements the DistributedMap Ice interface.
It essentially holds a part of the distributed map. Associates a 'key' to a particular 'value'
The implementation abstracts out the semantics. The only accepted key & value types are strings Other types of objects have to be serialized before they can be stored.
It provides the usual get, set & remove operations with the usual semantics.
It also provides accumulator semantics with the put operation. Values stored using a put operation are accumulated instead of being replaced. Note that the semantics of this accumulating is provided by a helper class that implements the Server_Helper interface
There is also a putNget operation which uses AMD to not block dispatch threads. The putNget is also an AMI. More info on AMI in client class. Please look up Ice documentation for more details. This operation puts a value for the given key and returns the result of the accumulate operation.
It also provides a barrier implementation that lets clients synchronize. This is a very simple use of AMD The dispatch threads are released without busy waiting. Only a counter is incremented with every call. Once the counter reaches num_clients registered, a response is sent to all queued up call back objects.
DM_Server::DM_Server | ( | int | num_clients, | |
Server_Helper & | server_helper | |||
) |
The num of clients that will be accessing the DistributedMap This parameter is used to provide a barrier
DM_Server::~DM_Server | ( | ) | [virtual] |
bool DM_Server::get | ( | const string & | key, | |
string & | val, | |||
const Ice::Current & | ||||
) |
The get operation. Sets val with the value of the key and returns true if the key exists. Else does not set val and returns false
void DM_Server::put | ( | const string & | key, | |
const string & | val, | |||
const Ice::Current & | ||||
) |
The put operation. Note the slight difference in semantics This has accumulator semantics. The value is accumulated and not replaced
void DM_Server::putNget_async | ( | const AMD_DistributedMap_putNgetPtr & | png_cb, | |
const string & | word, | |||
const string & | delta, | |||
const Ice::Current & | ||||
) |
The put and get operation. Does a put(word,delta) and returns the updated value png_cb is the AMD call back object
bool DM_Server::remove | ( | const string & | word, | |
string & | counts, | |||
const Ice::Current & | ||||
) |
The remove operation. Removes the key-value pair from the table If the key does not exist, returns false. Else returns true
void DM_Server::set | ( | const string & | key, | |
const string & | val, | |||
const Ice::Current & | ||||
) |
The set operation. The value is replaced if the key already exists
void DM_Server::waitForAllClients_async | ( | const AMD_DistributedMap_waitForAllClientsPtr & | cb, | |
const Ice::Current & | ||||
) |
Barrier. Helps clients synchronize.