00001 #include "CondCore/DBCommon/interface/ConfigSessionFromParameterSet.h"
00002 #include "CondCore/DBCommon/interface/DBSession.h"
00003 #include "CondCore/DBCommon/interface/SessionConfiguration.h"
00004 #include "CondCore/DBCommon/interface/ConnectionConfiguration.h"
00005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00006
00007
00008 cond::ConfigSessionFromParameterSet::ConfigSessionFromParameterSet(
00009 cond::DBSession& session,
00010 const edm::ParameterSet& connectionPset ){
00011 std::string xmlauthName=connectionPset.getUntrackedParameter<std::string>("authenticationPath","");
00012 int messageLevel=connectionPset.getUntrackedParameter<int>("messageLevel",0);
00013 bool enableConnectionSharing=connectionPset.getUntrackedParameter<bool>("enableConnectionSharing",true);
00014 int connectionTimeOut=connectionPset.getUntrackedParameter<int>("connectionTimeOut",600);
00015 bool enableReadOnlySessionOnUpdateConnection=connectionPset.getUntrackedParameter<bool>("enableReadOnlySessionOnUpdateConnection",true);
00016 int connectionRetrialPeriod=connectionPset.getUntrackedParameter<int>("connectionRetrialPeriod",30);
00017 int connectionRetrialTimeOut=connectionPset.getUntrackedParameter<int>("connectionRetrialTimeOut",180);
00018 bool enablePoolAutomaticCleanUp=connectionPset.getUntrackedParameter<bool>("enablePoolAutomaticCleanUp",false);
00019 int idleConnectionCleanupPeriod=connectionPset.getUntrackedParameter<int>("idleConnectionCleanupPeriod",300);
00020 if( xmlauthName.empty() ){
00021 session.configuration().setAuthenticationMethod(cond::Env);
00022 }else{
00023 session.configuration().setAuthenticationMethod(cond::XML);
00024 session.configuration().setAuthenticationPath(xmlauthName);
00025 }
00026 switch (messageLevel) {
00027 case 0 :
00028 session.configuration().setMessageLevel( cond::Error );
00029 break;
00030 case 1:
00031 session.configuration().setMessageLevel( cond::Warning );
00032 break;
00033 case 2:
00034 session.configuration().setMessageLevel( cond::Info );
00035 break;
00036 case 3:
00037 session.configuration().setMessageLevel( cond::Debug );
00038 break;
00039 default:
00040 session.configuration().setMessageLevel( cond::Error );
00041 }
00042 if(enableConnectionSharing){
00043 session.configuration().connectionConfiguration()->enableConnectionSharing();
00044 }else{
00045 session.configuration().connectionConfiguration()->disableConnectionSharing();
00046 }
00047 session.configuration().connectionConfiguration()->setConnectionTimeOut(connectionTimeOut);
00048 if(enableReadOnlySessionOnUpdateConnection){
00049 session.configuration().connectionConfiguration()->enableReadOnlySessionOnUpdateConnections();
00050 }else{
00051 session.configuration().connectionConfiguration()->disableReadOnlySessionOnUpdateConnections();
00052 }
00053 if( enablePoolAutomaticCleanUp ){
00054 session.configuration().connectionConfiguration()->enablePoolAutomaticCleanUp();
00055 }else{
00056 session.configuration().connectionConfiguration()->disablePoolAutomaticCleanUp();
00057 session.configuration().connectionConfiguration()->setIdleConnectionCleanupPeriod(idleConnectionCleanupPeriod);
00058 }
00059 session.configuration().connectionConfiguration()->setConnectionRetrialPeriod(connectionRetrialPeriod);
00060 session.configuration().connectionConfiguration()->setConnectionRetrialTimeOut(connectionRetrialTimeOut);
00061 }