438{
439
440
441
442 std::string tagStr{
tag};
444
445
446
448
450 if (
sc.isFailure()) {
451 ATH_MSG_ERROR (
"Could not get clid for typeName " << typeName);
452 return( StatusCode::FAILURE);
453 }
454
455 try {
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470 bool storeRef = true;
471 bool storeAttrListColl = false;
472 bool needSGaddr=false;
473 if ("AthenaAttributeList" == typeName) {
474 storeRef = false;
475 needSGaddr=false;
476 }
477 if ("CondAttrListCollection" == typeName) {
478 storeRef = false;
479 storeAttrListColl = true;
480 needSGaddr=false;
481 }
482
483
484
485
486
487 IOpaqueAddress* addr=0;
488 std::string
key{spec_key};
489 std::vector<CLID> symlinks;
490 SG::DataProxy*
proxy;
492
493
495 if (!proxy) {
497 return( StatusCode::FAILURE);
498 }
499
500
502
503
504 addr =
proxy->address();
505 } else {
506
508 if (!proxy) {
509 ATH_MSG_ERROR (
"Could not get proxy for clid " << clid <<
" and key " << key);
510 return( StatusCode::FAILURE );
511 }
512
513
514 addr =
proxy->address();
515 }
516 std::string saddr;
517 if (addr) {
518
519 symlinks =
proxy->transientID();
520 auto it = std::find (symlinks.begin(), symlinks.end(), clid);
521 if (it != symlinks.end()) {
522 symlinks.erase (it);
523 }
524
525
526
527 CondAttrListCollAddress* collAddr = dynamic_cast<CondAttrListCollAddress*>(addr);
528 if (collAddr) {
529 storeRef = false;
530 storeAttrListColl = true;
531 }
532
533
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);
539 }
541 } else {
542
543
544
545 if (needSGaddr) {
547 return( StatusCode::FAILURE );
548 } else {
550
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";
555 } else {
557 << typeName);
558 }
559 }
560 }
561
563 << " Storing AttrListCollection: " << storeAttrListColl);
564
565
566
567
568 std::string local_folder;
569 if (""==folderName) {
571 } else {
573 }
575
576
577 cool::IDatabasePtr
db =
m_iov_db->getDatabase(
false);
578 if (!db) {
580 return(StatusCode::FAILURE);
581 }
582
583 const cool::DatabaseId& dbid=
db->databaseId();
584
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));
589
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);
593
594 if (dbidprod) {
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;
598 }
599
600
601 const AthenaAttributeList* attrList = 0;
602 const CondAttrListCollection* attrListColl = 0;
603
604 if (!storeRef) {
605 if ("CondAttrListCollection"==typeName) {
607 retrieve(attrListColl,key)) {
609 << key);
610 return StatusCode::FAILURE;
611 }
612 } else if (storeAttrListColl) {
613
614 if (addr) {
615 CondAttrListCollAddress* attrAddr = dynamic_cast<CondAttrListCollAddress*>(addr);
616 if (attrAddr) {
617
621 << addr << " " << attrAddr << " " << attrListColl);
622 } else {
623 ATH_MSG_ERROR (
"Could not extract ptr for CondAttrListCollAddress ");
624 return StatusCode::FAILURE;
625 }
626 } else {
627 ATH_MSG_ERROR (
"Cannot write out collection of POOLref without streaming them first" );
628 return StatusCode::FAILURE;
629 }
630 } else {
631
632 if (StatusCode::SUCCESS!=
m_detStore->retrieve(attrList,key)) {
634 << key);
635 return StatusCode::FAILURE;
636 }
637 }
638
639 }
640
641
643
644
646
647
648
649
650 bool createFolders = false;
651
652 if(
db->existsFolder(local_folder)) {
653
655
656 if (dbidprod || dbidwriter) {
657 ATH_MSG_FATAL (
"Apparent attempt to delete folder on production COOL schema " << dbid);
658 return StatusCode::FAILURE;
659 }
660
661 ATH_MSG_DEBUG (
" Deleting existing COOL Folder " << local_folder);
662 db->dropNode( local_folder );
663 createFolders = true;
664 }
665 else {
666
668 folder =
db->getFolder(local_folder);
669 }
670
671 }
672 else {
674 << " does not exist - must create it");
675 createFolders = true;
676 }
677
678
679 std::string address_header;
680 std::string address_data;
681
683 if (
sc.isFailure()) {
685 << "addr: " << saddr << "\n"
686 << "hdr: " << address_header << "\n"
687 << "data " << address_data);
688 return( StatusCode::FAILURE);
689 }
690 msg() << MSG::DEBUG <<
"split address: " << saddr <<
endmsg
691 <<
" hdr: " << address_header <<
endmsg
692 <<
" data: " << address_data <<
endmsg;
693
694
695 if(createFolders) {
696
697 if (dbidwriter) {
698 ATH_MSG_FATAL (
"Apparent attempt to create folder using writer account, dbID is: " << dbid);
699 return StatusCode::FAILURE;
700 }
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718 std::string mergedNames;
719
721 mergedNames );
722 if (
sc.isFailure()) {
723 ATH_MSG_ERROR (
"Could not merge towards merged description: "
724 << "typeName: " << typeName);
725 return( StatusCode::FAILURE);
726 }
727
729 mergedNames );
730 if (
sc.isFailure()) {
731 ATH_MSG_ERROR (
"Could not merge towards merged description: "
732 << "addrHeader: " << address_header);
733 return( StatusCode::FAILURE);
734 }
735
736
737
738
739
740
743 if (
sc.isFailure()) {
744 ATH_MSG_ERROR (
"Could not merge towards merged description: "
745 << "key: " << key);
746 return( StatusCode::FAILURE);
747 }
748 }
749
750
751 if (!symlinks.empty()) {
752 std::string symlinkTypes;
753 for (
unsigned int i = 0;
i < symlinks.size(); ++
i) {
756 if (
sc.isFailure()) {
758 << symlinks[i]);
759 return( StatusCode::FAILURE);
760 }
761 else {
763 << symlinks[i] <<
" " <<
type);
764 }
765 if (symlinkTypes.size()) symlinkTypes += ':';
766 symlinkTypes +=
type;
767 }
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] <<
" ";
774 }
776 return( StatusCode::FAILURE);
777 }
778 else {
780 << symlinkTypes << " " << mergedNames);
781 }
782 }
783
784
785
786
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);
800 }
801 bool isTimeStamp = false;
802 if (
start.isTimestamp()) isTimeStamp =
true;
803
804 if (isTimeStamp)
805 {
807 mergedNames );
808 }
809 else
810 {
812 mergedNames );
813 }
814 if (
sc.isFailure()) {
815 ATH_MSG_ERROR (
"Could not merge timeStamp flag towards merged description. ");
816 return( StatusCode::FAILURE);
817 }
818
819 if (storeAttrListColl && attrListColl!=0 &&
820 attrListColl->
name_size()>0) mergedNames+=
"<named/>";
821
823 << " with description " << mergedNames);
824
825
826
828
830 if (storeRef) {
831
832
833
834 payloadSpec.extend(
"PoolRef",cool::StorageType::String4k);
835 }
836 else {
837
838 const coral::AttributeList* atr4spec=0;
839 if (storeAttrListColl) {
840
841
842
843 if (0 == attrListColl) {
845 return( StatusCode::FAILURE);
846 }
847
848 if (0 == attrListColl->
size()) {
850 return( StatusCode::FAILURE);
851 }
852
854 attrListColl->
size());
855
856 atr4spec=&((*attrListColl->
begin()).second);
857 } else {
858
859 atr4spec=attrList;
861 }
863
864 for (coral::AttributeList::const_iterator itr=
865 atr4spec->begin();itr!=atr4spec->end();++itr) {
866
867
870 itr->specification().typeName()));
871 }
872 }
873
874 cool::FolderVersioning::Mode
version=
875 cool::FolderVersioning::MULTI_VERSION;
877 version=cool::FolderVersioning::SINGLE_VERSION;
879 << local_folder);
880 }
883 << local_folder);
884 cool::FolderSpecification
folderSpec(version,payloadSpec,cool::PayloadMode::SEPARATEPAYLOAD);
885 folder =
db->createFolder(local_folder,folderSpec,
886 mergedNames,true);
888 local_folder << " done");
889
890
891 if (storeAttrListColl && attrListColl!=0 &&
894 " channels in " << local_folder);
897 nitr!=attrListColl->
name_end();++nitr) {
898 folder->createChannel(nitr->first,nitr->second);
899 }
900 }
901 }
902
903
904
905 if (storeAttrListColl) {
907 << start << " " << stop << " Note: will be ignored for channels with differnt IOVs " );
908 }
909 else {
910 ATH_MSG_DEBUG (
" Start/stop time " << start <<
" " << stop <<
" ");
911 }
912
913
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();
919 }
920
921
922
923 const cool::RecordSpecification& rspec=
folder->payloadSpecification();
924
925 if (storeAttrListColl) {
926
927
928
929
930
931
932
933 if (storeRef) {
934
935 ATH_MSG_ERROR (
"Trying to store a ref for a CondAttrListCollection. ");
936 return( StatusCode::FAILURE);
937 }
938
939 ATH_MSG_DEBUG (
" --> Storing Object( " << start <<
", " << stop
940 << ", " << tag << " )");
942
946
947
948 const coral::AttributeList&
payload = (*first).second;
949
951
952
953
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();
965 }
966 else {
967 ivStart1 =
range.start().re_time();
968 ivStop1 =
range.stop().re_time();
969 }
971 <<
range.start() <<
" " <<
range.stop() <<
" ");
972 }
973 else {
975 << start << " " << stop << " ");
976 }
977
978
979 cool::Record record(rspec,payload);
983 } else {
984 folder->storeObject( ivStart1,
985 ivStop1,
986 record,
987 chanNum);
988 }
989 }
990 }
991 else {
992
993 cool::Record record(rspec);
994 if (storeRef) {
995
996 record["PoolRef"].setValue<std::string>(address_data);
997 }
998 else {
999
1000 record=cool::Record(rspec,*attrList);
1001 }
1002
1003
1006 folder->storeObject( ivStart,
1007 ivStop,
1009 } else {
1010 folder->storeObject( ivStart,
1011 ivStop,
1012 record,0);
1013 }
1014
1015 ATH_MSG_DEBUG (
" --> Stored Object( " << start <<
", " << stop
1016 << ", " << tag << " )");
1018 }
1019
1021
1022
1024 if ("" == tag) {
1025 ATH_MSG_DEBUG (
" tag is empty - folder is not being tagged ");
1026 }
1027 else {
1028 ATH_MSG_INFO (
" Tagging HEAD of folder " << local_folder <<
1029 " with tag " << tag);
1030 try {
1032 }
1033 catch ( cool::TagExists& e) {
1035 " exists - attempt to delete tag and retag HEAD");
1036
1040 ATH_MSG_ERROR (
"Tag is defined in another folder - tag names must be global");
1041 }
else if (
folder->existsUserTag(tagStr)) {
1042
1043
1045 " is already USER tag - cannot mix tagging modes");
1046 } else {
1047 try {
1048 folder->deleteTag(tagStr);
1051 }
1052 catch ( cool::TagNotFound& e) {
1054 }
1055 }
1056 }
1057 }
1058 }
1059 return StatusCode::SUCCESS;
1060 }
1061
1062 catch (std::exception& e) {
1064
1065
1066 return StatusCode::FAILURE;
1067 }
1068
1069
1070}
#define ATH_MSG_WARNING(x)
uint32_t CLID
The Class ID type.
CondAttrListCollection * attrListColl()
Access to AttributeList.
const_iterator end() const
name_const_iterator name_begin() const
Access to Chan/Name pairs via iterators.
name_size_type name_size() const
number of Chan/Name pairs
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
iov_const_iterator iov_end() const
name_const_iterator name_end() const
size_type size() const
number of Chan/AttributeList pairs
iov_const_iterator chanIOVPair(ChanNum chanNum) const
Access to Chan/IOV pairs via channel number: returns map iterator.
ChanAttrListMap::const_iterator const_iterator
ChanNameMap::const_iterator name_const_iterator
ChanIOVMap::const_iterator iov_const_iterator
Gaudi::Property< bool > m_writeKeyInfo
Gaudi::Property< bool > m_forceGlobalIOV
Gaudi::Property< std::string > m_tagDescription
Gaudi::Property< bool > m_userTagsUH
Gaudi::Property< bool > m_userTags
Gaudi::Property< bool > m_payloadTable
Gaudi::Property< bool > m_svFolder
virtual const InterfaceID & type() const
Service type.
cool::StorageType::TypeId coralToCoolType(const std::string &parname, const std::string &coralName) const
virtual StatusCode buildDescription(std::string_view identifier, std::string_view value, std::string &description) const
Build the folder description field add in front of the description the value with identifier-markups.
StatusCode splitAddress(const std::string &address, std::string &address_header, std::string &address_data) const
Split address in its header and data parts.
std::string find(const std::string &s)
return a remapped string