Skip to content
Snippets Groups Projects
Commit 9e009b3c authored by Auke Klazema's avatar Auke Klazema
Browse files

SW-596: Added port to the configuration reading code. And added additional exception handling.

parent 6318e78f
No related branches found
No related tags found
No related merge requests found
...@@ -252,17 +252,69 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& ...@@ -252,17 +252,69 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface&
// Try to connect to the SAS database. // Try to connect to the SAS database.
ParameterSet* pParamSet = globalParameterSet(); ParameterSet* pParamSet = globalParameterSet();
string username = pParamSet->getString("OTDBusername"); try
string DBname = pParamSet->getString("OTDBdatabasename"); {
string password = pParamSet->getString("OTDBpassword"); string username = pParamSet->getString("OTDBusername");
string hostname = pParamSet->getString("OTDBhostname"); }
catch(LOFAR::APSException& ex)
{
LOG_ERROR_STR("MACScheduler code caught an exception while trying to "
"read the OTDB database user name from its configuration file: "
<< ex.what());
throw(ex);
}
try
{
string DBname = pParamSet->getString("OTDBdatabasename");
}
catch(LOFAR::APSException& ex)
{
LOG_ERROR_STR("MACScheduler code caught an exception while trying to "
"read the OTDB database name from its configuration file: "
<< ex.what());
throw(ex);
}
try
{
string password = pParamSet->getString("OTDBpassword");
}
catch(LOFAR::APSException& ex)
{
LOG_ERROR_STR("MACScheduler code caught an exception while trying to "
"read the OTDB database password from its configuration file: "
<< ex.what());
throw(ex);
}
try
{
string hostname = pParamSet->getString("OTDBhostname");
}
catch(LOFAR::APSException& ex)
{
LOG_ERROR_STR("MACScheduler code caught an exception while trying to "
"read the OTDB database server host name from its configuration file: "
<< ex.what());
throw(ex);
}
try
{
string port = pParamSet->getString("OTDBport");
}
catch(LOFAR::APSException& ex)
{
LOG_ERROR_STR("MACScheduler code caught an exception while trying to "
"read the OTDB database server port from its configuration file: "
<< ex.what());
throw(ex);
}
LOG_INFO_STR ("Trying to connect to the OTDB on " << hostname); LOG_INFO_STR ("Trying to connect to the OTDB on " << hostname);
itsOTDBconnection= new OTDBconnection(username, password, DBname, hostname); itsOTDBconnection= new OTDBconnection(username, password, DBname, hostname, port);
ASSERTSTR (itsOTDBconnection, "Memory allocation error (OTDB)"); ASSERTSTR (itsOTDBconnection, "Memory allocation error (OTDB)");
ASSERTSTR (itsOTDBconnection->connect(), ASSERTSTR (itsOTDBconnection->connect(),
"Unable to connect to database " << DBname << " on " << hostname << "Unable to connect to database " << DBname << " on " << hostname <<
" using " << username << "," << password); " port: " << port <<
" using " << username << "," << password);
LOG_INFO ("Connected to the OTDB"); LOG_INFO ("Connected to the OTDB");
itsPropertySet->setValue(PN_MS_OTDB_CONNECTED, GCFPVBool(true)); itsPropertySet->setValue(PN_MS_OTDB_CONNECTED, GCFPVBool(true));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment