1 |
//============================================================================ |
//============================================================================ |
2 |
// $Id: PacketUser.cpp,v 1.12 2009/12/30 14:49:51 mocchiut Exp $ |
// $Id: PacketUser.cpp,v 1.16 2010/02/02 15:26:09 mocchiut Exp $ |
3 |
// Description : |
// Description : |
4 |
//============================================================================ |
//============================================================================ |
5 |
#include "PacketUser.h" |
#include "PacketUser.h" |
31 |
//marco_new_31: |
//marco_new_31: |
32 |
extern char* db_user; |
extern char* db_user; |
33 |
extern char* db_pwd; |
extern char* db_pwd; |
34 |
extern char* connection; |
extern char* pelosconnection; |
35 |
|
|
36 |
//per tenere conto reset obt |
//per tenere conto reset obt |
37 |
extern unsigned long int max_pkt_obt; |
extern unsigned long int max_pkt_obt; |
457 |
//if(!table){table=Table_GL_RESURS_OFFSET} |
//if(!table){table=Table_GL_RESURS_OFFSET} |
458 |
|
|
459 |
if (!single_connection) { |
if (!single_connection) { |
460 |
OpenDBConnection(table);//Nota qui ho deciso di lockare solo questa tabella e non tutte |
OpenDBConnection(NULL);// no, locak tutto Nota qui ho deciso di lockare solo questa tabella e non tutte |
461 |
} |
} |
462 |
|
|
463 |
UInt_t t0 = 0;//toffset |
UInt_t t0 = 0;//toffset |
632 |
msg = err.str(); |
msg = err.str(); |
633 |
mainLogUtil->logInfo(msg); |
mainLogUtil->logInfo(msg); |
634 |
|
|
635 |
TString qu = Form("select ID_N from ROOT_TABLE_BAD order by INSERT_TIME desc limit 1;"); |
// TString qu = Form("select ID_N from ROOT_TABLE_BAD order by INSERT_TIME desc limit 1;"); // <========================= |
636 |
|
TString qu = Form("select ID_N from ROOT_TABLE_BAD where FILE_NAME='%s' and PKT_NUMBER_INIT=%i and INSERTED_BY='%s';",filename,pkt_number_init,tag_value); // <========================= |
637 |
TSQLResult *result = sqlServer->Query(qu.Data()); |
TSQLResult *result = sqlServer->Query(qu.Data()); |
638 |
TSQLRow *row = result->Next(); |
TSQLRow *row = result->Next(); |
639 |
Int_t eid = -1; |
Int_t eid = -1; |
648 |
} |
} |
649 |
|
|
650 |
CleanDisk(); |
CleanDisk(); |
651 |
if (!single_connection) { |
// if (!single_connection) { |
652 |
CloseDBConnection(); |
// CloseDBConnection(); |
653 |
} |
// } |
654 |
return; |
// return; // commented here... |
655 |
|
|
656 |
}; |
}; |
657 |
} |
} |
658 |
|
|
659 |
if ( real_time_init || real_time_last) { |
if ( real_time_init || real_time_last) { |
660 |
//saves info in DB in table Table_ROOT |
//saves info in DB in table Table_ROOT |
661 |
if (boot_number == 0) |
if (boot_number == 0) |
662 |
boot_number = boot_number_prevvalue; |
boot_number = boot_number_prevvalue; |
|
|
|
|
if (saveROOT_DB( |
|
|
Table_ROOT_Good, |
|
|
outDir, // here outDir is good, no expand EMI |
|
|
filename, pkt_number_init, pkt_number_last, obt_init, obt_last, obt_time_sync, last_time_sync_info, |
|
|
real_time_init, real_time_last, boot_number, timeOffset, bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, |
|
|
numPKTSaved, fni, time_is_estimated) == true) { |
|
|
oss.str() = ""; |
|
|
oss << "Saved information regarding file: " << filename << " in table " << Table_ROOT_Good << " id= " << my_id; |
|
|
msg = oss.str(); |
|
|
mainLogUtil->logInfo(msg); |
|
663 |
|
|
664 |
if (tryMerge) { |
if (saveROOT_DB( |
665 |
merge_ROOTfiles(); |
Table_ROOT_Good, |
666 |
} |
outDir, // here outDir is good, no expand EMI |
667 |
} else { |
filename, pkt_number_init, pkt_number_last, obt_init, obt_last, obt_time_sync, last_time_sync_info, |
668 |
|
real_time_init, real_time_last, boot_number, timeOffset, bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, |
669 |
|
numPKTSaved, fni, time_is_estimated) == true) { |
670 |
|
oss.str() = ""; |
671 |
|
oss << "Saved information regarding file: " << filename << " in table " << Table_ROOT_Good << " id= " << my_id; |
672 |
|
msg = oss.str(); |
673 |
|
mainLogUtil->logInfo(msg); |
674 |
|
|
675 |
|
if (tryMerge) { |
676 |
|
merge_ROOTfiles(); |
677 |
|
} |
678 |
|
} else { |
679 |
oss.str() = ""; |
oss.str() = ""; |
680 |
oss << "Problem storing information in DB regarding file: " << filename; |
oss << "Problem storing information in DB regarding file: " << filename; |
681 |
msg = oss.str(); |
msg = oss.str(); |
682 |
mainLogUtil->logError(msg); |
mainLogUtil->logError(msg); |
683 |
} |
} |
684 |
}; |
}; |
685 |
|
|
686 |
// if dbinfo is not empty than |
// if dbinfo is not empty than |
832 |
|
|
833 |
}//pRun |
}//pRun |
834 |
} |
} |
835 |
|
|
836 |
|
|
837 |
void PacketUser::CleanDisk(){ |
void PacketUser::CleanDisk(){ |
838 |
if ( !candelete ) return; |
if ( !candelete ) return; |
1388 |
TSQLResult* res = NULL; |
TSQLResult* res = NULL; |
1389 |
stringstream oss; |
stringstream oss; |
1390 |
oss.str(""); |
oss.str(""); |
1391 |
if (!tableTobeLocked) |
// if (!tableTobeLocked) |
1392 |
oss << "lock table " << Table_ROOT_Good << " write, " << Table_ROOT_Bad << " write, " << Table_GL_RESURS_OFFSET |
oss << "lock table " << Table_ROOT_Good << " write, " << Table_ROOT_Bad << " write, " << Table_GL_RESURS_OFFSET |
1393 |
<< " write, " << Table_ROOT_Merging << " write;"; |
<< " write, " << Table_ROOT_Merging << " write;"; |
1394 |
else |
// else |
1395 |
oss << "lock table " << tableTobeLocked << " write; "; |
// oss << "lock table " << tableTobeLocked << " write; "; |
1396 |
|
|
1397 |
string msg = oss.str(); |
string msg = oss.str(); |
1398 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
1462 |
if (do_cont_check) { |
if (do_cont_check) { |
1463 |
//controllo che non sia gia' aperta |
//controllo che non sia gia' aperta |
1464 |
if (!sqlServer) { |
if (!sqlServer) { |
1465 |
sqlServer = TSQLServer::Connect(connection, db_user, db_pwd); |
sqlServer = TSQLServer::Connect(pelosconnection, db_user, db_pwd); |
1466 |
if ((!sqlServer) || (!(sqlServer->IsConnected()))) { |
if ((!sqlServer) || (!(sqlServer->IsConnected()))) { |
1467 |
cout << "Can not connect with MYSQL sever" << endl; |
cout << "Can not connect with MYSQL sever" << endl; |
1468 |
} |
} |