//------------------------------------------------------ CDB::DAL_ptr CDBProperties::getCDB() { //initialize return value to 0 CDB::DAL_var retVal = 0; // TODO (?): Store the CDB reference in a static field to optimize //use a nice little trick to get at the CDB reference if ((maci::ContainerImpl::getContainer() != 0) && (maci::ContainerImpl::getContainer()->getContainerCORBAProxy() != maci::Container::_nil())) { retVal = maci::ContainerImpl::getContainer()->getService<CDB::DAL>("CDB", 0, true); } else { if (maci::SimpleClient::getInstance() != 0) { retVal = maci::SimpleClient::getInstance()->getContainerServices()->getCDB(); } else { ACS_STATIC_SHORT_LOG((LM_ERROR, "CDBProperties::getCDB", "Container and SimpleClient refs null.")); } } return retVal._retn(); }
//------------------------------------------------------ bool CDBProperties::cdbChannelConfigExists(const std::string& channelName) { //complete name of the channel within the CDB std::string cdbChannelName = "MACI/Channels/" + channelName; //delegate obtaining a reference to the CDB CDB::DAL_var cdbRef = getCDB(); //sanity check if(cdbRef.in()==0) { ACS_STATIC_SHORT_LOG((LM_ERROR, "CDBProperties::cdbChannelConfigExists", "CDB ref null.")); return false; } //try reading the entry from the CDB try { char *joe = 0; joe = cdbRef->get_DAO(cdbChannelName.c_str()); //if the pointer is not null if (joe!=0) { //it's probably OK return true; } else { //something went wrong! return false; } } //DAL throws exceptions if the entry being searched for does not //exist catch(...) { ACS_STATIC_SHORT_LOG((LM_INFO, "CDBProperties::cdbChannelConfigExists", "No CDB entry found for '%s' channel. OK.", cdbChannelName.c_str())); return false; } }
void logBatchUsingMacrosStaticLogger() { std::cout << "Log batch for logger [" << "StaticLogger" << "]. USING ACS MACROS." << std::endl; // Test static logging with audience STATIC_LOG_TO_DEVELOPER(LM_INFO, "STATIC_LOG_TO_DEVELOPER"); STATIC_LOG_TO_OPERATOR(LM_INFO, "STATIC_LOG_TO_OPERATOR"); STATIC_LOG_TO_SCIENCE(LM_INFO, "STATIC_LOG_TO_SCIENCE"); STATIC_LOG_TO_SCILOG(LM_INFO, "STATIC_LOG_TO_SCILOG"); // Static trace ACS_STATIC_TRACE(__PRETTY_FUNCTION__); // static short log ACS_STATIC_SHORT_LOG((LM_INFO, "Test ACS_STATIC_SHORT_LOG with LM_INFO")); // Debug messages ACS_STATIC_DEBUG(__PRETTY_FUNCTION__, "Test of ACS_STATIC_DEBUG macro"); ACS_STATIC_DEBUG_PARAM(__PRETTY_FUNCTION__, "Test of ACS_STATIC_DEBUG_PARAM macro with param: %s", "param2"); } // 8 messages
//----------------------------------------------------------------------------- char* BaseHelper::getNotificationFactoryNameForChannel(CDB::DAL_ptr cdbRef, const char* channelName, const char* domainName) { //sanity check if(CORBA::is_nil(cdbRef)) { ACS_STATIC_SHORT_LOG((LM_DEBUG, "BaseHelper::getNotificationFactoryNameForChannel", "CDB ref null.")); return 0; } std::string cdbChannelsName = "MACI/Channels"; CDB::DAO_var tempDAO; //try reading the entry from the CDB try { tempDAO = cdbRef->get_DAO_Servant(cdbChannelsName.c_str()); //sanity check, should not happen if (tempDAO.in()==0) return 0; //DAL throws exceptions if the entry being searched for does not //exist } catch(...) { ACS_STATIC_SHORT_LOG((LM_DEBUG, "BaseHelper::getNotificationFactoryNameForChannel", "No CDB entry found for '%s' channel. OK.", cdbChannelsName.c_str())); return 0; } // if channel mapping exists take it, wildchars are also supported try { CDB::stringSeq_var channelNameList = tempDAO->get_string_seq("NotificationServiceMapping/Channels_"); for (CORBA::ULong n = 0; n < channelNameList->length(); n++) if (Wildcard::wildcardfit(channelNameList[n], channelName)) return CORBA::string_dup(tempDAO->get_string((std::string("NotificationServiceMapping/Channels_/") + channelNameList[n].in() + "/NotificationService").c_str())); } catch(...) { ACS_STATIC_SHORT_LOG((LM_DEBUG, "BaseHelper::getNotificationFactoryNameForChannel", "No Channel to NotificationService mapping found for channel'%s' channel.", channelName)); } // if domain mapping, if given if (domainName) try { return CORBA::string_dup(tempDAO->get_string((std::string("NotificationServiceMapping/Domains/") + domainName + "/NotificationService").c_str())); } catch(...) { ACS_STATIC_SHORT_LOG((LM_DEBUG, "BaseHelper::getNotificationFactoryNameForChannel", "No Domain to NotificationService mapping found for domain/channel'%s/%s' channel. OK.", domainName, channelName)); } // if default try { return CORBA::string_dup(tempDAO->get_string("NotificationServiceMapping/DefaultNotificationService")); } catch(...) { ACS_STATIC_SHORT_LOG((LM_DEBUG, "BaseHelper::getNotificationFactoryNameForChannel", "No NotificationServiceMapping/DefaultNotificationService attribute found. OK.", domainName, channelName)); } // not found return 0; }
//------------------------------------------------------ CosNotification::AdminProperties CDBProperties::getCDBAdminProps(const std::string& channelName) { CosNotification::AdminProperties retVal; retVal.length(0); //sanity check if (cdbChannelConfigExists(channelName)==false) { ACS_STATIC_SHORT_LOG((LM_INFO, "CDBProperties::getCDBAdminProps", "Channel does not exist.")); return retVal; } //CDB //complete name of the channel within the CDB std::string cdbChannelName = "MACI/Channels/" + channelName; CDB::DAL_var cdbRef = getCDB(); CDB::DAO_var tempDAO = cdbRef->get_DAO_Servant(cdbChannelName.c_str()); //temporary pointer points to the name of the CosNotification //property const char *name_p; //temporary counter unsigned int i = 0U; //MaxQueueLength - TAO 1.1 had a queque of ~5 events. TAO 1.3 allows an // infinite amount of events to be stored. 20 seems like // a reasonable default. { name_p = CosNotification::MaxQueueLength; //allocate one extra element i++; retVal.length(i); retVal[i-1].name = CORBA::string_dup(name_p); retVal[i-1].value <<= tempDAO->get_long(name_p); } //Max consumers/////////////////////////////////////////////////// { name_p = CosNotification::MaxConsumers; //allocate one extra element i++; retVal.length(i); retVal[i-1].name = CORBA::string_dup(name_p); retVal[i-1].value <<= tempDAO->get_long(name_p); } //Max suppliers/////////////////////////////////////////////////// { name_p = CosNotification::MaxSuppliers; //allocate one extra element i++; retVal.length(i); retVal[i-1].name = CORBA::string_dup(name_p); retVal[i-1].value <<= tempDAO->get_long(name_p); } //Reject new events/////////////////////////////////////////////// { name_p = CosNotification::RejectNewEvents; //allocate one extra element i++; retVal.length(i); retVal[i-1].name = CORBA::string_dup(name_p); std::string tString = tempDAO->get_string(name_p); if(tString=="false") { retVal[i-1].value <<= FALSE; } else { retVal[i-1].value <<= TRUE; } } //for debugging purposes only std::string debugMessage = "Length=" + retVal.length(); STATIC_LOG(Logging::BaseLog::LM_DEBUG, "nc::CDBProperties::getCDBAdminProps", debugMessage); return retVal; }