Skip to content
Snippets Groups Projects
Commit f10adc36 authored by Andrea Bignamini's avatar Andrea Bignamini
Browse files

Add remoteSchema and remoteTable

The remoteSchema and remote Table device properties have been added.
The shcema and the table names on the local machine can be different
with respect to the names in the remote machine.
parent 63a8447c
No related branches found
No related tags found
No related merge requests found
......@@ -21,13 +21,15 @@ private:
Configuration(std::string certificateFile,
std::string remoteHost, unsigned int remotePort,
std::string remoteUsername, std::string remotePassword,
std::string remoteSchema, std::string remoteTable,
std::string databaseHost, unsigned int databasePort,
std::string databaseUsername, std::string databasePassword,
std::string databaseSchema, std::string databaseTable,
unsigned int refreshTime, unsigned int timeout) :
m_certificateFile (certificateFile), m_remoteHost(remoteHost),
m_remotePort(remotePort), m_remoteUsername(remoteUsername),
m_remotePassword(remotePassword), m_databaseHost(databaseHost),
m_remotePassword(remotePassword), m_remoteSchema(remoteSchema),
m_remoteTable(remoteTable), m_databaseHost(databaseHost),
m_databasePort(databasePort), m_databaseUsername(databaseUsername),
m_databasePassword(databasePassword), m_databaseSchema(databaseSchema),
m_databaseTable(databaseTable), m_refreshTime(refreshTime),
......@@ -50,13 +52,14 @@ public:
static Configuration::SP create(std::string certificateFile,
std::string remoteHost, unsigned int remotePort,
std::string remoteUsername, std::string remotePassword,
std::string remoteSchema, std::string remoteTable,
std::string databaseHost, unsigned int databasePort,
std::string databaseUsername, std::string databasePassword,
std::string databaseSchema, std::string databaseTable,
unsigned int refreshTime, unsigned int timeout)
{
Configuration::SP c_sp(new Configuration(certificateFile, remoteHost,
remotePort, remoteUsername, remotePassword, databaseHost,
remotePort, remoteUsername, remotePassword, remoteSchema, remoteTable, databaseHost,
databasePort, databaseUsername, databasePassword,
databaseSchema, databaseTable, refreshTime, timeout),
Configuration::Deleter());
......@@ -72,6 +75,8 @@ public:
unsigned int getRemotePort() const { return m_remotePort; }
std::string getRemoteUsername() const { return m_remoteUsername; }
std::string getRemotePassword() const { return m_remotePassword; }
std::string getRemoteSchema() const { return m_remoteSchema; }
std::string getRemoteTable() const { return m_remoteTable; }
std::string getDatabaseHost() const { return m_databaseHost; }
unsigned int getDatabasePort() const { return m_databasePort; }
std::string getDatabaseUsername() const { return m_databaseUsername; }
......@@ -100,6 +105,12 @@ private:
//Metadata exporter remote password
const std::string m_remotePassword;
//Metadata remote database schema
const std::string m_remoteSchema;
//Metadata remote database table
const std::string m_remoteTable;
//Metadata local database host
const std::string m_databaseHost;
......
......@@ -214,6 +214,8 @@ void MetadataImporter::get_device_property()
dev_prop.push_back(Tango::DbDatum("RemotePort"));
dev_prop.push_back(Tango::DbDatum("RemoteUsername"));
dev_prop.push_back(Tango::DbDatum("RemotePassword"));
dev_prop.push_back(Tango::DbDatum("RemoteSchema"));
dev_prop.push_back(Tango::DbDatum("RemoteTable"));
dev_prop.push_back(Tango::DbDatum("EnableSSL"));
dev_prop.push_back(Tango::DbDatum("DatabaseHost"));
dev_prop.push_back(Tango::DbDatum("DatabasePort"));
......@@ -293,6 +295,28 @@ void MetadataImporter::get_device_property()
// And try to extract RemotePassword value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> remotePassword;
// Try to initialize RemoteSchema from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> remoteSchema;
else {
// Try to initialize RemoteSchema from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> remoteSchema;
}
// And try to extract RemoteSchema value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> remoteSchema;
// Try to initialize RemoteTable from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> remoteTable;
else {
// Try to initialize RemoteTable from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> remoteTable;
}
// And try to extract RemoteTable value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> remoteTable;
// Try to initialize EnableSSL from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> enableSSL;
......@@ -421,6 +445,14 @@ void MetadataImporter::get_device_property()
if(remotePassword.empty())
throw(invalid_argument("RemotePassword property is empty or not defined"));
// If remoteSchema is not set, use databaseSchema
if(remoteSchema.empty())
remoteSchema=databaseSchema;
// If remoteTable is not set, use databaseTable
if(remoteTable.empty())
remoteTable=databaseTable;
if(enableSSL)
{
if(certificateFile.empty())
......@@ -454,7 +486,7 @@ void MetadataImporter::get_device_property()
throw(invalid_argument("Timeout property out of range or not defined"));
m_configuration_sp = Configuration::create(certificateFile,
remoteHost, remotePort, remoteUsername, remotePassword, databaseHost,
remoteHost, remotePort, remoteUsername, remotePassword, remoteSchema, remoteTable, databaseHost,
databasePort, databaseUsername, databasePassword, databaseSchema,
databaseTable, refreshTime, timeout);
}
......
......@@ -100,6 +100,10 @@ public:
string remoteUsername;
// RemotePassword: Metadata exporter remote password
string remotePassword;
// RemoteSchema: Metadata remote database schema
string remoteSchema;
// RemoteTable: Metadata remote database table
string remoteTable;
// EnableSSL: Enable or disable SSL connections
Tango::DevBoolean enableSSL;
// DatabaseHost: Metadata local database host
......
......@@ -29,6 +29,14 @@
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="RemoteSchema" description="Metadata remote database schema">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="RemoteTable" description="Metadata remote database table">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="EnableSSL" description="Enable or disable SSL connections">
<type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
......
......@@ -477,6 +477,32 @@ void MetadataImporterClass::set_default_property()
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "RemoteSchema";
prop_desc = "Metadata remote database schema";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "RemoteTable";
prop_desc = "Metadata remote database table";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "DatabaseTable";
......
......@@ -177,13 +177,15 @@ RequestSP ProtocolManager::createValidation() throw(std::runtime_error)
std::string schema = m_configuration_sp->getDatabaseSchema();
std::string table = m_configuration_sp->getDatabaseTable();
std::string rschema = m_configuration_sp->getRemoteSchema();
std::string rtable = m_configuration_sp->getRemoteTable();
INFO_STREAM << "ProtocolManager::createValidation() Send schema "
INFO_STREAM << "ProtocolManager::createValidation() Send local schema "
<< schema << " table " << table << " to " << m_remoteEndpoint << endl;
Request::Validation* validation = request_sp->mutable_validation();
validation->set_schema(schema);
validation->set_table(table);
validation->set_schema(rschema);
validation->set_table(rtable);
DBManager::InformationList informationList =
m_dBManager_sp->retrieveInformation(schema, table);
......@@ -234,6 +236,8 @@ RequestSP ProtocolManager::createMetadata()
std::string schema = m_configuration_sp->getDatabaseSchema();
std::string table = m_configuration_sp->getDatabaseTable();
std::string rschema = m_configuration_sp->getRemoteSchema();
std::string rtable = m_configuration_sp->getRemoteTable();
std::tm tmTimestamp = m_dBManager_sp->retrieveLastTimestamp(schema, table);
......@@ -241,7 +245,7 @@ RequestSP ProtocolManager::createMetadata()
boost::posix_time::ptime_from_tm(tmTimestamp);
INFO_STREAM << "ProtocolManager::createMetadata() Send schema "
<< schema << " table " << table << " timestamp "
<< rschema << " table " << rtable << " timestamp "
<< boost::posix_time::to_simple_string(ptTimestamp)
<< " to " << m_remoteEndpoint << endl;
......@@ -318,10 +322,12 @@ void ProtocolManager::processMetadata(ResponseSP response_sp)
{
std::string schema = m_configuration_sp->getDatabaseSchema();
std::string table = m_configuration_sp->getDatabaseTable();
std::string rschema = m_configuration_sp->getRemoteSchema();
std::string rtable = m_configuration_sp->getRemoteTable();
INFO_STREAM << "ProtocolManager::processMetadata() State ACCEPTED "
<< "status " << metadata.status() << " schema " << schema
<< " table " << table << " from " << m_remoteEndpoint << endl;
<< "status " << metadata.status() << " schema " << rschema
<< " table " << rtable << " from " << m_remoteEndpoint << endl;
if(metadata.rows_size() != 0)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment