Commit 18f43cda authored by Jonas Nylund's avatar Jonas Nylund

SEV No limit in long attribute names anymore

parent 58cca3fd
......@@ -318,73 +318,6 @@ int sev_server::send_itemlist( qcom_sQid tgt)
}
return 1;
}
/*
int sev_server::send_itemlist( qcom_sQid tgt)
{
int item_cnt = 0;
qcom_sPut put;
pwr_tStatus sts, lsts;
int size;
for ( unsigned int i = 0; i < m_db->m_items.size(); i++) {
if ( m_db->m_items[i].deleted)
continue;
item_cnt++;
}
if ( !item_cnt)
return 1;
size = sizeof(sev_sMsgHistItems) + (item_cnt - 1) * sizeof(sev_sHistItem);
put.size = size;
put.data = qcom_Alloc(&lsts, put.size);
((sev_sMsgHistItems *)put.data)->Type = sev_eMsgType_HistItems;
((sev_sMsgHistItems *)put.data)->NumItems = item_cnt;
int idx = 0;
for ( unsigned int i = 0; i < m_db->m_items.size(); i++) {
if ( m_db->m_items[i].deleted)
continue;
((sev_sMsgHistItems *)put.data)->Items[idx].oid = m_db->m_items[i].oid;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].oname, m_db->m_items[i].oname);
((sev_sMsgHistItems *)put.data)->Items[idx].storagetime =
net_DeltaTimeToNetTime(&m_db->m_items[i].storagetime);
((sev_sMsgHistItems *)put.data)->Items[idx].creatime =
net_TimeToNetTime( &m_db->m_items[i].creatime);
((sev_sMsgHistItems *)put.data)->Items[idx].modtime =
net_TimeToNetTime( &m_db->m_items[i].modtime);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].description, m_db->m_items[i].description);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].aname, m_db->m_items[i].attr[0].aname);
((sev_sMsgHistItems *)put.data)->Items[idx].attrnum = m_db->m_items[i].attrnum;
((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].type = m_db->m_items[i].attr[0].type;
((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].size = m_db->m_items[i].attr[0].size;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].unit, m_db->m_items[i].attr[0].unit);
((sev_sMsgHistItems *)put.data)->Items[idx].scantime = m_db->m_items[i].scantime;
((sev_sMsgHistItems *)put.data)->Items[idx].deadband = m_db->m_items[i].deadband;
((sev_sMsgHistItems *)put.data)->Items[idx].options = m_db->m_items[i].options;
idx++;
}
if ( !item_cnt)
((sev_sMsgHistItems *)put.data)->Status = SEV__NOITEMS;
else
((sev_sMsgHistItems *)put.data)->Status = SEV__SUCCESS;
put.reply.nid = m_nodes[0].nid;
put.reply.qix = sev_eProcSevServer;
put.type.b = (qcom_eBtype) sev_cMsgClass;
put.type.s = (qcom_eStype) sev_eMsgType_HistItems;
put.msg_id = m_msg_id++;
if ( !qcom_Put( &sts, &tgt, &put)) {
qcom_Free( &sts, put.data);
return 0;
}
return 1;
}
*/
int sev_server::send_server_status( qcom_sQid tgt)
{
......@@ -584,7 +517,7 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
attributeName[0] = '\0';
storagetime = net_NetTimeToDeltaTime( &buffP->storagetime );
sprintf( tablename, "obj_%s", m_db->oid_to_table( buffP->oid, attributeName) );
sprintf( tablename, "HiaHia"); //Dummy-name, real name created in add_objectitem
bool newobject = false;
if ( !m_db->check_objectitem( &m_sts,
tablename,
......@@ -650,7 +583,6 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
//rename the table to something and create a new one.
//this is the only way to do this without hanging the server for several minutes
m_db->handle_objectchange(&m_sts, tablename, idx, newobject);
}
//If node is coming up again we do not want deadband to be active due to init of old_value
......@@ -700,6 +632,7 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
msg->Items[i].deadband, msg->Items[i].options, &idx);
if ( EVEN(m_sts)) return m_sts;
}
if ( ODD(m_sts) ) {
//Create space for the old values used if we have deadband active
if ( m_db->m_items[idx].old_value != 0 ) {
......@@ -788,10 +721,8 @@ int sev_server::send_histdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *rmsg,
starttime = net_NetTimeToTime( &rmsg->StartTime);
endtime = net_NetTimeToTime( &rmsg->EndTime);
sev_item item;
char tablename[500];
strcpy( tablename, m_db->oid_to_table( rmsg->Oid, rmsg->AName) );
m_db->get_item(&m_sts, &item, tablename);
m_db->get_item(&m_sts, &item, rmsg->Oid, rmsg->AName);
if(ODD(m_sts)) {
m_db->get_values( &m_sts, rmsg->Oid, item.options, item.deadband,
rmsg->AName, item.attr[0].type, item.attr[0].size,
......@@ -848,10 +779,8 @@ int sev_server::send_objecthistdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *
starttime = net_NetTimeToTime( &rmsg->StartTime);
endtime = net_NetTimeToTime( &rmsg->EndTime);
sev_item item;
char tablename[500];
sprintf( tablename, "obj_%s", m_db->oid_to_table( rmsg->Oid, rmsg->AName) );
m_db->get_objectitem(&m_sts, &item, tablename);
m_db->get_objectitem(&m_sts, &item, rmsg->Oid, rmsg->AName);
if(ODD(m_sts)) {
m_db->get_objectvalues(&m_sts, &item, item.value_size, &starttime, &endtime, rmsg->NumPoints, &tbuf, &vbuf, &rows);
}
......@@ -959,7 +888,7 @@ void sev_server::garbage_item( int idx)
m_db->m_items[idx].options, limit);
}
else {
m_db->delete_old_data( &m_sts, m_db->m_items[idx].oid, m_db->m_items[idx].attr[0].aname,
m_db->delete_old_data( &m_sts, m_db->m_items[idx].tablename,
m_db->m_items[idx].options, limit);
}
}
......
......@@ -92,7 +92,7 @@ class sev_db {
pwr_tTime *endtime, int maxsize, pwr_tTime **tbuf, void **vbuf,
unsigned int *bsize) { return 0;}
virtual int get_items( pwr_tStatus *sts) { return 0;}
virtual int delete_old_data( pwr_tStatus *sts, pwr_tOid oid, char *aname,
virtual int delete_old_data( pwr_tStatus *sts, char *tablename,
pwr_tMask options, pwr_tTime limit) { return 0;}
virtual char *oid_to_table( pwr_tOid oid, char *aname) { return 0;}
......@@ -106,8 +106,8 @@ class sev_db {
pwr_tFloat32 deadband, pwr_tMask options, unsigned int *idx) { return 0;}
virtual int store_objectitem( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, char *description, pwr_tFloat32 scantime, pwr_tFloat32 deadband, pwr_tMask options) { return 0;}
virtual int get_item( pwr_tStatus *sts, sev_item *item, char *tablename) { return 0;}
virtual int get_objectitem( pwr_tStatus *sts, sev_item *item, char *tablename) { return 0;}
virtual int get_item( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename) { return 0;}
virtual int get_objectitem( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename) { return 0;}
virtual int get_objectitems( pwr_tStatus *sts) { return 0;}
virtual int check_objectitemattr( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *aname, char *oname,
pwr_eType type, unsigned int size, unsigned int *idx) { return 0;}
......
This diff is collapsed.
......@@ -103,6 +103,8 @@ class sev_dbms_env
class sev_dbms : public sev_db {
public:
static const unsigned int constMaxColNameLength = 64;
sev_dbms_env *m_env;
sev_dbms( sev_dbms_env *env) : m_env(env) {}
......@@ -122,14 +124,14 @@ class sev_dbms : public sev_db {
pwr_eType type, unsigned int size, pwr_tFloat32 scantime, pwr_tTime *creatime,
pwr_tTime *starttime,
pwr_tTime *endtime, int maxsize, pwr_tTime **tbuf, void **vbuf, unsigned int *bsize);
int delete_old_data( pwr_tStatus *sts, pwr_tOid oid, char *aname,
int delete_old_data( pwr_tStatus *sts, char *tablename,
pwr_tMask options, pwr_tTime limit);
int delete_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
int get_items( pwr_tStatus *sts);
int create_table( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type, unsigned int size,
int create_table( pwr_tStatus *sts, char *tablename, pwr_eType type, unsigned int size,
pwr_tMask options, float deadband);
int delete_table( pwr_tStatus *sts, pwr_tOid oid, char *aname);
int delete_table( pwr_tStatus *sts, char *tablename);
int store_item( pwr_tStatus *sts, char *tabelname, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, pwr_eType vtype, unsigned int vsize,
char *description, char *unit, pwr_tFloat32 scantime,
......@@ -152,8 +154,8 @@ class sev_dbms : public sev_db {
int create_objecttable( pwr_tStatus *sts, char *tablename, pwr_tMask options, float deadband);
int store_objectvalue( pwr_tStatus *sts, int item_idx, int attr_idx,
pwr_tTime time, void *buf, void *oldbuf, unsigned int size);
int get_item( pwr_tStatus *sts, sev_item *item, char *tablename);
int get_objectitem( pwr_tStatus *sts, sev_item *item, char *tablename);
int get_item( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename);
int get_objectitem( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename);
int get_objectitems( pwr_tStatus *sts);
int get_objectitemattributes( pwr_tStatus *sts, sev_item *item, char *tablename);
int check_objectitemattr( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *aname, char *oname,
......@@ -165,8 +167,19 @@ class sev_dbms : public sev_db {
int maxsize, pwr_tTime **tbuf, void **vbuf, unsigned int *bsize);
pwr_tUInt64 get_minFromIntegerColumn( char *tablename, char *colname );
pwr_tUInt64 get_maxFromIntegerColumn( char *tablename, char *colname );
pwr_tUInt64 get_nextAutoIncrement( char *tablename );
int handle_itemchange(pwr_tStatus *sts, char *tablename, unsigned int item_idx);
int handle_objectchange(pwr_tStatus *sts, char *tablename, unsigned int item_idx, bool newObject);
inline char* create_colName(unsigned int index, char *attributename) {
static char colName[constMaxColNameLength];
strncpy(colName, attributename, constMaxColNameLength);
if(strlen(attributename) > constMaxColNameLength)
{
colName[constMaxColNameLength-5] = 0;
snprintf(&colName[strlen(colName)], 5, "_%d", index);
}
return colName;
}
};
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment