Skip to content

Commit

Permalink
Merge pull request #50 from IntelLabs/remove_rwlock
Browse files Browse the repository at this point in the history
Remove RWlock in PMGDQueryHandler
  • Loading branch information
luisremis authored Dec 21, 2018
2 parents 34efac9 + cb2aa1f commit 1983062
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 37 deletions.
4 changes: 0 additions & 4 deletions config-vdms.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
"port": 55555, // Default is 55555
"max_simultaneous_clients": 20, // Default is 500

// Tune the number of maximum attempts when acquiring the
// reader writer lock for metadata changes.
"max_lock_attempts": 10,

// Database paths
"pmgd_path": "db/graph", // This will be an IP address in the future
"png_path": "db/images/pngs/",
Expand Down
28 changes: 0 additions & 28 deletions src/PMGDQueryHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "PMGDQueryHandler.h"
#include "util.h" // PMGD util
#include "PMGDIterators.h"
#include "RWLock.h"

// TODO In the complete version of VDMS, this file will live
// within PMGD which would replace the PMGD namespace. Some of
Expand All @@ -43,30 +42,21 @@ using namespace PMGD;
using namespace VDMS;

PMGD::Graph *PMGDQueryHandler::_db;
RWLock *PMGDQueryHandler::_dblock;

void PMGDQueryHandler::init()
{
std::string dbname = VDMSConfig::instance()
->get_string_value("pmgd_path", "db/graph");
unsigned attempts = VDMSConfig::instance()
->get_int_value("max_lock_attempts",
RWLock::MAX_ATTEMPTS);

// Create a db
_db = new PMGD::Graph(dbname.c_str(), PMGD::Graph::Create);

// Create the query handler here assuming database is valid now.
_dblock = new RWLock(attempts);
}

void PMGDQueryHandler::destroy()
{
if (_db) {
delete _db;
delete _dblock;
_db = NULL;
_dblock = NULL;
}
}

Expand All @@ -80,20 +70,6 @@ std::vector<PMGDCmdResponses>

// Assuming one query handler handles one TX at a time.
_readonly = readonly;
try {
if (_readonly)
_dblock->read_lock();
else
_dblock->write_lock();
}
catch (Exception e) {
PMGDCmdResponses &resp_v = responses[0];
PMGDCmdResponse *response = new PMGDCmdResponse();
set_response(response, PMGDCmdResponse::Exception,
e.name + std::string(": ") + e.msg);
resp_v.push_back(response);
return responses;
}

for (const auto cmd : cmds) {
PMGDCmdResponse *response = new PMGDCmdResponse();
Expand All @@ -117,10 +93,6 @@ std::vector<PMGDCmdResponses>
_tx = NULL;
}

if (_readonly)
_dblock->read_unlock();
else
_dblock->write_unlock();
return responses;
}

Expand Down
5 changes: 0 additions & 5 deletions src/PMGDQueryHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ namespace VDMS {
typedef std::vector<PMGDCmd *> PMGDCmds;
typedef std::vector<PMGDCmdResponse *> PMGDCmdResponses;

class RWLock;

class PMGDQueryHandler
{
template <typename T, typename Ti>
Expand All @@ -73,9 +71,6 @@ namespace VDMS {
// Until we have a separate PMGD server this db lives here
static PMGD::Graph *_db;

// Need this lock till we have concurrency support in PMGD
static RWLock *_dblock;

PMGD::Transaction *_tx;
bool _readonly; // Variable changes per TX based on process_queries parameter.

Expand Down

0 comments on commit 1983062

Please sign in to comment.