436 const std::string& spec_key,
437 const std::string& folderName,
438 const std::string& tag,
451 StatusCode
sc =
m_clidSvc->getIDOfTypeName(typeName, clid);
452 if (
sc.isFailure()) {
453 ATH_MSG_ERROR (
"Could not get clid for typeName " << typeName);
454 return( StatusCode::FAILURE);
472 bool storeRef =
true;
473 bool storeAttrListColl =
false;
474 bool needSGaddr=
false;
475 if (
"AthenaAttributeList" == typeName) {
479 if (
"CondAttrListCollection" == typeName) {
481 storeAttrListColl =
true;
489 IOpaqueAddress* addr=0;
490 std::string key = spec_key;
491 std::vector<CLID> symlinks;
499 return( StatusCode::FAILURE);
506 addr = proxy->address();
511 ATH_MSG_ERROR (
"Could not get proxy for clid " << clid <<
" and key " << key);
512 return( StatusCode::FAILURE );
516 addr = proxy->address();
521 symlinks = proxy->transientID();
522 auto it = std::find (symlinks.begin(), symlinks.end(), clid);
523 if (it != symlinks.end()) {
532 storeAttrListColl =
true;
537 if (
sc.isFailure()) {
538 ATH_MSG_WARNING (
"Could not get string from IOpaqueAddress for clid " << clid
539 <<
" is BAD_STORAGE_TYPE: " << (
sc == IConversionSvc::Status::BAD_STORAGE_TYPE));
540 return( StatusCode::FAILURE);
549 return( StatusCode::FAILURE );
553 if (
"AthenaAttributeList" == typeName) {
554 saddr=
"<address_header service_type=\"256\" clid=\"40774348\" /> POOLContainer_AthenaAttributeList][CLID=x";
555 }
else if (
"CondAttrListCollection" == typeName) {
556 saddr=
"<address_header service_type=\"256\" clid=\"1238547719\" /> POOLContainer_CondAttrListCollection][CLID=x";
565 <<
" Storing AttrListCollection: " << storeAttrListColl);
570 std::string local_folder;
571 if (
""==folderName) {
574 local_folder=folderName;
579 cool::IDatabasePtr db =
m_iov_db->getDatabase(
false);
582 return(StatusCode::FAILURE);
585 const cool::DatabaseId& dbid=db->databaseId();
587 bool dbidprod=(dbid.find(
"oracle")!=std::string::npos && (
588 dbid.find(
"ATLAS_COOLONL_")!=std::string::npos ||
589 dbid.find(
"ATLAS_COOLOFL_")!=std::string::npos ||
590 dbid.find(
"ATLAS_COOL_")!=std::string::npos));
592 bool dbidwriter=(dbid.find(
"oracle")!=std::string::npos &&
593 dbid.find(
"_W")!=std::string::npos);
594 ATH_MSG_DEBUG (
"Identified prod/writer " << dbidprod << dbidwriter);
597 ATH_MSG_FATAL (
"Direct update of production Oracle servers from Athena is FORBIDDEN");
598 ATH_MSG_FATAL (
"Please write to SQLite file and then merge with AtlCoolMerge.py");
599 return StatusCode::FAILURE;
607 if (
"CondAttrListCollection"==typeName) {
609 retrieve(attrListColl,key)) {
612 return StatusCode::FAILURE;
614 }
else if (storeAttrListColl) {
623 << addr <<
" " << attrAddr <<
" " << attrListColl);
625 ATH_MSG_ERROR (
"Could not extract ptr for CondAttrListCollAddress ");
626 return StatusCode::FAILURE;
629 ATH_MSG_ERROR (
"Cannot write out collection of POOLref without streaming them first" );
630 return StatusCode::FAILURE;
634 if (StatusCode::SUCCESS!=
m_detStore->retrieve(attrList,key)) {
637 return StatusCode::FAILURE;
647 cool::IFolderPtr folder;
652 bool createFolders =
false;
654 if(db->existsFolder(local_folder)) {
658 if (dbidprod || dbidwriter) {
659 ATH_MSG_FATAL (
"Apparent attempt to delete folder on production COOL schema " << dbid);
660 return StatusCode::FAILURE;
663 ATH_MSG_DEBUG (
" Deleting existing COOL Folder " << local_folder);
664 db->dropNode( local_folder );
665 createFolders =
true;
670 folder = db->getFolder(local_folder);
676 <<
" does not exist - must create it");
677 createFolders =
true;
681 std::string address_header;
682 std::string address_data;
685 if (
sc.isFailure()) {
687 <<
"addr: " << saddr <<
"\n"
688 <<
"hdr: " << address_header <<
"\n"
689 <<
"data " << address_data);
690 return( StatusCode::FAILURE);
692 msg() << MSG::DEBUG <<
"split address: " << saddr <<
endmsg
693 <<
" hdr: " << address_header <<
endmsg
694 <<
" data: " << address_data <<
endmsg;
700 ATH_MSG_FATAL (
"Apparent attempt to create folder using writer account, dbID is: " << dbid);
701 return StatusCode::FAILURE;
720 std::string mergedNames;
724 if (
sc.isFailure()) {
725 ATH_MSG_ERROR (
"Could not merge towards merged description: "
726 <<
"typeName: " << typeName);
727 return( StatusCode::FAILURE);
732 if (
sc.isFailure()) {
733 ATH_MSG_ERROR (
"Could not merge towards merged description: "
734 <<
"addrHeader: " << address_header);
735 return( StatusCode::FAILURE);
745 if (
sc.isFailure()) {
746 ATH_MSG_ERROR (
"Could not merge towards merged description: "
748 return( StatusCode::FAILURE);
753 if (!symlinks.empty()) {
754 std::string symlinkTypes;
755 for (
unsigned int i = 0; i < symlinks.size(); ++i) {
758 if (
sc.isFailure()) {
761 return( StatusCode::FAILURE);
765 << symlinks[i] <<
" " <<
type);
767 if (symlinkTypes.size()) symlinkTypes +=
':';
768 symlinkTypes +=
type;
771 if (
sc.isFailure()) {
772 msg() << MSG::ERROR <<
"Could not merge symlinks to merged description: "
773 <<
"symlink types: ";
774 for (
unsigned int i = 0; i < symlinkTypes.size(); ++i) {
775 msg() << MSG::ERROR << symlinkTypes[i] <<
" ";
778 return( StatusCode::FAILURE);
782 << symlinkTypes <<
" " << mergedNames);
789 if (!start.isValid() ||
791 start.isTimestamp() != stop.isTimestamp() ||
792 start.isRunEvent() != stop.isRunEvent()) {
793 ATH_MSG_ERROR (
"Invalid times: start isValid/isTimeStamp/isRunEvent "
794 <<
"addrHeader: " << address_header
795 << start.isValid() <<
" " << start.isTimestamp() <<
" "
796 << start.isRunEvent());
797 ATH_MSG_ERROR (
"Invalid times: stop isValid/isTimeStamp/isRunEvent "
798 <<
"addrHeader: " << address_header
799 << stop.isValid() <<
" " << stop.isTimestamp() <<
" "
800 << stop.isRunEvent());
801 return( StatusCode::FAILURE);
803 bool isTimeStamp =
false;
804 if (start.isTimestamp()) isTimeStamp =
true;
816 if (
sc.isFailure()) {
817 ATH_MSG_ERROR (
"Could not merge timeStamp flag towards merged description. ");
818 return( StatusCode::FAILURE);
821 if (storeAttrListColl && attrListColl!=0 &&
822 attrListColl->
name_size()>0) mergedNames+=
"<named/>";
825 <<
" with description " << mergedNames);
831 cool::RecordSpecification payloadSpec;
836 payloadSpec.extend(
"PoolRef",cool::StorageType::String4k);
840 const coral::AttributeList* atr4spec=0;
841 if (storeAttrListColl) {
845 if (0 == attrListColl) {
847 return( StatusCode::FAILURE);
850 if (0 == attrListColl->
size()) {
852 return( StatusCode::FAILURE);
856 attrListColl->
size());
858 atr4spec=&((*attrListColl->
begin()).second);
866 for (coral::AttributeList::const_iterator itr=
867 atr4spec->begin();itr!=atr4spec->end();++itr) {
870 payloadSpec.extend(itr->specification().name(),
872 itr->specification().typeName()));
876 cool::FolderVersioning::Mode version=
877 cool::FolderVersioning::MULTI_VERSION;
879 version=cool::FolderVersioning::SINGLE_VERSION;
886 cool::FolderSpecification folderSpec(version,payloadSpec,cool::PayloadMode::SEPARATEPAYLOAD);
887 folder = db->createFolder(local_folder,folderSpec,
890 local_folder <<
" done");
893 if (storeAttrListColl && attrListColl!=0 &&
896 " channels in " << local_folder);
899 nitr!=attrListColl->
name_end();++nitr) {
900 folder->createChannel(nitr->first,nitr->second);
907 if (storeAttrListColl) {
909 << start <<
" " << stop <<
" Note: will be ignored for channels with differnt IOVs " );
912 ATH_MSG_DEBUG (
" Start/stop time " << start <<
" " << stop <<
" ");
916 cool::ValidityKey ivStart = start.re_time();
917 cool::ValidityKey ivStop = stop.re_time();
918 if(start.isTimestamp()) {
919 ivStart = start.timestamp();
920 ivStop = stop.timestamp();
925 const cool::RecordSpecification& rspec=folder->payloadSpecification();
927 if (storeAttrListColl) {
937 ATH_MSG_ERROR (
"Trying to store a ref for a CondAttrListCollection. ");
938 return( StatusCode::FAILURE);
941 ATH_MSG_DEBUG (
" --> Storing Object( " << start <<
", " << stop
942 <<
", " << tag <<
" )");
947 for (; first != last; ++first) {
950 const coral::AttributeList& payload = (*first).second;
956 cool::ValidityKey ivStart1 = ivStart;
957 cool::ValidityKey ivStop1 = ivStop;
959 std::ostringstream attr;
960 payload.toOutputStream( attr );
961 ATH_MSG_DEBUG (
" --> ChanNum: " << chanNum <<
" Payload: " << attr.str());
963 const IOVRange& range = (*iovIt).second;
964 if(range.start().isTimestamp()) {
965 ivStart1 = range.start().timestamp();
966 ivStop1 = range.stop().timestamp();
969 ivStart1 = range.start().re_time();
970 ivStop1 = range.stop().re_time();
973 << range.start() <<
" " << range.stop() <<
" ");
977 << start <<
" " << stop <<
" ");
981 cool::Record record(rspec,payload);
984 folder->storeObject( ivStart1,
989 folder->storeObject( ivStart1,
998 cool::Record record(rspec);
1001 record[
"PoolRef"].setValue<std::string>(address_data);
1005 record=cool::Record(rspec,*attrList);
1011 folder->storeObject( ivStart,
1015 folder->storeObject( ivStart,
1020 ATH_MSG_DEBUG (
" --> Stored Object( " << start <<
", " << stop
1021 <<
", " << tag <<
" )");
1030 ATH_MSG_DEBUG (
" tag is empty - folder is not being tagged ");
1033 ATH_MSG_INFO (
" Tagging HEAD of folder " << local_folder <<
1034 " with tag " << tag);
1038 catch ( cool::TagExists& e) {
1040 " exists - attempt to delete tag and retag HEAD");
1042 std::vector<std::string> taglist=folder->listTags();
1043 if (
find(taglist.begin(),taglist.end(),tag)==
1045 ATH_MSG_ERROR (
"Tag is defined in another folder - tag names must be global");
1046 }
else if (folder->existsUserTag(tag)) {
1050 " is already USER tag - cannot mix tagging modes");
1053 folder->deleteTag(tag);
1057 catch ( cool::TagNotFound& e) {
1064 return StatusCode::SUCCESS;
1067 catch (std::exception& e) {
1071 return StatusCode::FAILURE;
1078 const std::string& parname,
const std::string& coralName)
const {
1080 std::string coralType=coralName;
1085 ATH_MSG_INFO (
"Override default type for attribute " <<
1086 parname <<
" - use " << coralType);
1092 if (coralType==
"bool")
return cool::StorageType::Bool;
1093 if (coralType==
"UChar" || coralType==
"unsigned char")
return cool::StorageType::UChar;
1094 if (coralType==
"Int16")
return cool::StorageType::Int16;
1095 if (coralType==
"UInt16")
return cool::StorageType::UInt16;
1096 if (coralType==
"Int32" || coralType==
"int")
return cool::StorageType::Int32;
1097 if (coralType==
"UInt32" || coralType==
"unsigned int")
return cool::StorageType::UInt32;
1098 if (coralType==
"UInt63" || coralType==
"unsigned long long")
return cool::StorageType::UInt63;
1099 if (coralType==
"Int64" || coralType==
"long long")
return cool::StorageType::Int64;
1100 if (coralType==
"Float" || coralType==
"float")
return cool::StorageType::Float;
1101 if (coralType==
"Double" || coralType==
"double")
return cool::StorageType::Double;
1102 if (coralType==
"String255")
return cool::StorageType::String255;
1103 if (coralType==
"String4k" || coralType==
"string")
return cool::StorageType::String4k;
1104 if (coralType==
"String64k")
return cool::StorageType::String64k;
1105 if (coralType==
"String16M")
return cool::StorageType::String16M;
1106 if (coralType==
"blob" || coralType==
"Blob64k")
1107 return cool::StorageType::Blob64k;
1108 if (coralType==
"Blob16M")
return cool::StorageType::Blob16M;
1111 ATH_MSG_FATAL (
"No COOL mapping defined for CORAL type " << coralName);
1112 throw std::exception();