433 std::string_view spec_key,
434 std::string_view folderName,
435 std::string_view tag,
442 std::string tagStr{tag};
449 StatusCode
sc =
m_clidSvc->getIDOfTypeName(std::string{typeName}, clid);
450 if (
sc.isFailure()) {
451 ATH_MSG_ERROR (
"Could not get clid for typeName " << typeName);
452 return( StatusCode::FAILURE);
470 bool storeRef =
true;
471 bool storeAttrListColl =
false;
472 bool needSGaddr=
false;
473 if (
"AthenaAttributeList" == typeName) {
477 if (
"CondAttrListCollection" == typeName) {
479 storeAttrListColl =
true;
487 IOpaqueAddress* addr=0;
488 std::string key{spec_key};
489 std::vector<CLID> symlinks;
497 return( StatusCode::FAILURE);
504 addr = proxy->address();
509 ATH_MSG_ERROR (
"Could not get proxy for clid " << clid <<
" and key " << key);
510 return( StatusCode::FAILURE );
514 addr = proxy->address();
519 symlinks = proxy->transientID();
520 auto it = std::find (symlinks.begin(), symlinks.end(), clid);
521 if (it != symlinks.end()) {
530 storeAttrListColl =
true;
535 if (
sc.isFailure()) {
536 ATH_MSG_WARNING (
"Could not get string from IOpaqueAddress for clid " << clid
537 <<
" is BAD_STORAGE_TYPE: " << (
sc == IConversionSvc::Status::BAD_STORAGE_TYPE));
538 return( StatusCode::FAILURE);
547 return( StatusCode::FAILURE );
551 if (
"AthenaAttributeList" == typeName) {
552 saddr=
"<address_header service_type=\"256\" clid=\"40774348\" /> POOLContainer_AthenaAttributeList][CLID=x";
553 }
else if (
"CondAttrListCollection" == typeName) {
554 saddr=
"<address_header service_type=\"256\" clid=\"1238547719\" /> POOLContainer_CondAttrListCollection][CLID=x";
563 <<
" Storing AttrListCollection: " << storeAttrListColl);
568 std::string local_folder;
569 if (
""==folderName) {
572 local_folder=folderName;
577 cool::IDatabasePtr db =
m_iov_db->getDatabase(
false);
580 return(StatusCode::FAILURE);
583 const cool::DatabaseId& dbid=db->databaseId();
585 bool dbidprod=(dbid.find(
"oracle")!=std::string::npos && (
586 dbid.find(
"ATLAS_COOLONL_")!=std::string::npos ||
587 dbid.find(
"ATLAS_COOLOFL_")!=std::string::npos ||
588 dbid.find(
"ATLAS_COOL_")!=std::string::npos));
590 bool dbidwriter=(dbid.find(
"oracle")!=std::string::npos &&
591 dbid.find(
"_W")!=std::string::npos);
592 ATH_MSG_DEBUG (
"Identified prod/writer " << dbidprod << dbidwriter);
595 ATH_MSG_FATAL (
"Direct update of production Oracle servers from Athena is FORBIDDEN");
596 ATH_MSG_FATAL (
"Please write to SQLite file and then merge with AtlCoolMerge.py");
597 return StatusCode::FAILURE;
605 if (
"CondAttrListCollection"==typeName) {
607 retrieve(attrListColl,key)) {
610 return StatusCode::FAILURE;
612 }
else if (storeAttrListColl) {
621 << addr <<
" " << attrAddr <<
" " << attrListColl);
623 ATH_MSG_ERROR (
"Could not extract ptr for CondAttrListCollAddress ");
624 return StatusCode::FAILURE;
627 ATH_MSG_ERROR (
"Cannot write out collection of POOLref without streaming them first" );
628 return StatusCode::FAILURE;
632 if (StatusCode::SUCCESS!=
m_detStore->retrieve(attrList,key)) {
635 return StatusCode::FAILURE;
645 cool::IFolderPtr folder;
650 bool createFolders =
false;
652 if(db->existsFolder(local_folder)) {
656 if (dbidprod || dbidwriter) {
657 ATH_MSG_FATAL (
"Apparent attempt to delete folder on production COOL schema " << dbid);
658 return StatusCode::FAILURE;
661 ATH_MSG_DEBUG (
" Deleting existing COOL Folder " << local_folder);
662 db->dropNode( local_folder );
663 createFolders =
true;
668 folder = db->getFolder(local_folder);
674 <<
" does not exist - must create it");
675 createFolders =
true;
679 std::string address_header;
680 std::string address_data;
683 if (
sc.isFailure()) {
685 <<
"addr: " << saddr <<
"\n"
686 <<
"hdr: " << address_header <<
"\n"
687 <<
"data " << address_data);
688 return( StatusCode::FAILURE);
690 msg() << MSG::DEBUG <<
"split address: " << saddr <<
endmsg
691 <<
" hdr: " << address_header <<
endmsg
692 <<
" data: " << address_data <<
endmsg;
698 ATH_MSG_FATAL (
"Apparent attempt to create folder using writer account, dbID is: " << dbid);
699 return StatusCode::FAILURE;
718 std::string mergedNames;
722 if (
sc.isFailure()) {
723 ATH_MSG_ERROR (
"Could not merge towards merged description: "
724 <<
"typeName: " << typeName);
725 return( StatusCode::FAILURE);
730 if (
sc.isFailure()) {
731 ATH_MSG_ERROR (
"Could not merge towards merged description: "
732 <<
"addrHeader: " << address_header);
733 return( StatusCode::FAILURE);
743 if (
sc.isFailure()) {
744 ATH_MSG_ERROR (
"Could not merge towards merged description: "
746 return( StatusCode::FAILURE);
751 if (!symlinks.empty()) {
752 std::string symlinkTypes;
753 for (
unsigned int i = 0; i < symlinks.size(); ++i) {
756 if (
sc.isFailure()) {
759 return( StatusCode::FAILURE);
763 << symlinks[i] <<
" " <<
type);
765 if (symlinkTypes.size()) symlinkTypes +=
':';
766 symlinkTypes +=
type;
769 if (
sc.isFailure()) {
770 msg() << MSG::ERROR <<
"Could not merge symlinks to merged description: "
771 <<
"symlink types: ";
772 for (
unsigned int i = 0; i < symlinkTypes.size(); ++i) {
773 msg() << MSG::ERROR << symlinkTypes[i] <<
" ";
776 return( StatusCode::FAILURE);
780 << symlinkTypes <<
" " << mergedNames);
787 if (!start.isValid() ||
789 start.isTimestamp() != stop.isTimestamp() ||
790 start.isRunEvent() != stop.isRunEvent()) {
791 ATH_MSG_ERROR (
"Invalid times: start isValid/isTimeStamp/isRunEvent "
792 <<
"addrHeader: " << address_header
793 << start.isValid() <<
" " << start.isTimestamp() <<
" "
794 << start.isRunEvent());
795 ATH_MSG_ERROR (
"Invalid times: stop isValid/isTimeStamp/isRunEvent "
796 <<
"addrHeader: " << address_header
797 << stop.isValid() <<
" " << stop.isTimestamp() <<
" "
798 << stop.isRunEvent());
799 return( StatusCode::FAILURE);
801 bool isTimeStamp =
false;
802 if (start.isTimestamp()) isTimeStamp =
true;
814 if (
sc.isFailure()) {
815 ATH_MSG_ERROR (
"Could not merge timeStamp flag towards merged description. ");
816 return( StatusCode::FAILURE);
819 if (storeAttrListColl && attrListColl!=0 &&
820 attrListColl->
name_size()>0) mergedNames+=
"<named/>";
823 <<
" with description " << mergedNames);
829 cool::RecordSpecification payloadSpec;
834 payloadSpec.extend(
"PoolRef",cool::StorageType::String4k);
838 const coral::AttributeList* atr4spec=0;
839 if (storeAttrListColl) {
843 if (0 == attrListColl) {
845 return( StatusCode::FAILURE);
848 if (0 == attrListColl->
size()) {
850 return( StatusCode::FAILURE);
854 attrListColl->
size());
856 atr4spec=&((*attrListColl->
begin()).second);
864 for (coral::AttributeList::const_iterator itr=
865 atr4spec->begin();itr!=atr4spec->end();++itr) {
868 payloadSpec.extend(itr->specification().name(),
870 itr->specification().typeName()));
874 cool::FolderVersioning::Mode version=
875 cool::FolderVersioning::MULTI_VERSION;
877 version=cool::FolderVersioning::SINGLE_VERSION;
884 cool::FolderSpecification folderSpec(version,payloadSpec,cool::PayloadMode::SEPARATEPAYLOAD);
885 folder = db->createFolder(local_folder,folderSpec,
888 local_folder <<
" done");
891 if (storeAttrListColl && attrListColl!=0 &&
894 " channels in " << local_folder);
897 nitr!=attrListColl->
name_end();++nitr) {
898 folder->createChannel(nitr->first,nitr->second);
905 if (storeAttrListColl) {
907 << start <<
" " << stop <<
" Note: will be ignored for channels with differnt IOVs " );
910 ATH_MSG_DEBUG (
" Start/stop time " << start <<
" " << stop <<
" ");
914 cool::ValidityKey ivStart = start.re_time();
915 cool::ValidityKey ivStop = stop.re_time();
916 if(start.isTimestamp()) {
917 ivStart = start.timestamp();
918 ivStop = stop.timestamp();
923 const cool::RecordSpecification& rspec=folder->payloadSpecification();
925 if (storeAttrListColl) {
935 ATH_MSG_ERROR (
"Trying to store a ref for a CondAttrListCollection. ");
936 return( StatusCode::FAILURE);
939 ATH_MSG_DEBUG (
" --> Storing Object( " << start <<
", " << stop
940 <<
", " << tag <<
" )");
945 for (; first != last; ++first) {
948 const coral::AttributeList& payload = (*first).second;
954 cool::ValidityKey ivStart1 = ivStart;
955 cool::ValidityKey ivStop1 = ivStop;
957 std::ostringstream attr;
958 payload.toOutputStream( attr );
959 ATH_MSG_DEBUG (
" --> ChanNum: " << chanNum <<
" Payload: " << attr.str());
961 const IOVRange& range = (*iovIt).second;
962 if(range.start().isTimestamp()) {
963 ivStart1 = range.start().timestamp();
964 ivStop1 = range.stop().timestamp();
967 ivStart1 = range.start().re_time();
968 ivStop1 = range.stop().re_time();
971 << range.start() <<
" " << range.stop() <<
" ");
975 << start <<
" " << stop <<
" ");
979 cool::Record record(rspec,payload);
982 folder->storeObject( ivStart1, ivStop1, record, chanNum, tagStr,!
m_userTagsUH);
984 folder->storeObject( ivStart1,
993 cool::Record record(rspec);
996 record[
"PoolRef"].setValue<std::string>(address_data);
1000 record=cool::Record(rspec,*attrList);
1006 folder->storeObject( ivStart,
1010 folder->storeObject( ivStart,
1015 ATH_MSG_DEBUG (
" --> Stored Object( " << start <<
", " << stop
1016 <<
", " << tag <<
" )");
1025 ATH_MSG_DEBUG (
" tag is empty - folder is not being tagged ");
1028 ATH_MSG_INFO (
" Tagging HEAD of folder " << local_folder <<
1029 " with tag " << tag);
1033 catch ( cool::TagExists& e) {
1035 " exists - attempt to delete tag and retag HEAD");
1037 std::vector<std::string> taglist=folder->listTags();
1038 if (
find(taglist.begin(),taglist.end(),tag)==
1040 ATH_MSG_ERROR (
"Tag is defined in another folder - tag names must be global");
1041 }
else if (folder->existsUserTag(tagStr)) {
1045 " is already USER tag - cannot mix tagging modes");
1048 folder->deleteTag(tagStr);
1052 catch ( cool::TagNotFound& e) {
1059 return StatusCode::SUCCESS;
1062 catch (std::exception& e) {
1066 return StatusCode::FAILURE;
1073 const std::string& parname,
const std::string& coralName)
const {
1075 std::string coralType=coralName;
1080 ATH_MSG_INFO (
"Override default type for attribute " <<
1081 parname <<
" - use " << coralType);
1087 if (coralType==
"bool")
return cool::StorageType::Bool;
1088 if (coralType==
"UChar" || coralType==
"unsigned char")
return cool::StorageType::UChar;
1089 if (coralType==
"Int16")
return cool::StorageType::Int16;
1090 if (coralType==
"UInt16")
return cool::StorageType::UInt16;
1091 if (coralType==
"Int32" || coralType==
"int")
return cool::StorageType::Int32;
1092 if (coralType==
"UInt32" || coralType==
"unsigned int")
return cool::StorageType::UInt32;
1093 if (coralType==
"UInt63" || coralType==
"unsigned long long")
return cool::StorageType::UInt63;
1094 if (coralType==
"Int64" || coralType==
"long long")
return cool::StorageType::Int64;
1095 if (coralType==
"Float" || coralType==
"float")
return cool::StorageType::Float;
1096 if (coralType==
"Double" || coralType==
"double")
return cool::StorageType::Double;
1097 if (coralType==
"String255")
return cool::StorageType::String255;
1098 if (coralType==
"String4k" || coralType==
"string")
return cool::StorageType::String4k;
1099 if (coralType==
"String64k")
return cool::StorageType::String64k;
1100 if (coralType==
"String16M")
return cool::StorageType::String16M;
1101 if (coralType==
"blob" || coralType==
"Blob64k")
1102 return cool::StorageType::Blob64k;
1103 if (coralType==
"Blob16M")
return cool::StorageType::Blob16M;
1106 ATH_MSG_FATAL (
"No COOL mapping defined for CORAL type " << coralName);
1107 throw std::exception();