Commit e2563981 authored by aorlati's avatar aorlati
Browse files

fix #180: ACS team changed the way the logging service is registered in the...

fix #180: ACS team changed the way the logging service is registered in the naming service. Some tuning done
parent 3bbce95b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -106,4 +106,8 @@
	<Member name="ThreadName" type="string" description="Name of the thread" />
</ErrorCode>  

<ErrorCode name="ACSService" shortDescription="ACS service is not available" description="">
	<Member name="ServiceName" type="string" description="Name of the Service" />
</ErrorCode>

</Type>
+11 −2
Original line number Diff line number Diff line
@@ -108,8 +108,8 @@ class CustomLoggerImpl: public virtual baci::CharacteristicComponentImpl,
        nc::SimpleSupplier *m_loggingSupplier;
        CosNaming::NamingContext_var namingContext_m;
        CosNotifyChannelAdmin::EventChannel_var ec_;
        CosNotifyChannelAdmin::InterFilterGroupOperator ifgop_;
        CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin_;
        //CosNotifyChannelAdmin::InterFilterGroupOperator ifgop_;
        CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin_; //*
        CustomStructuredPushConsumer* consumer_;
	/**
	* Filter the log records.
@@ -151,6 +151,15 @@ class CustomLoggerImpl: public virtual baci::CharacteristicComponentImpl,
         */
        void addToLoggingQueue(LogRecord_sp log_record);
        /**@}*/
        /**
         *
        */
        void createConsumerAdmin();
        /**
         * get the reference to notification channel
         * @throw ComponentErrors::CORBAProblemExImpl
        */
        void resolveNotifyChannel(const char *channel_binding_name) throw (ComponentErrors::CORBAProblemExImpl);
};

/**
+73 −33
Original line number Diff line number Diff line
@@ -116,29 +116,43 @@ CustomLoggerImpl::initialize() throw (ACSErr::ACSbaseExImpl)
{
	ACS::Time _timestamp;
	setLogging(false);
    CosNaming::Name name(1);
    name.length(1);
    name[0].id = CORBA::string_dup(CUSTOM_LOGGING_CHANNEL);
    name[0].kind = LOGGING_CHANNEL_KIND;
    ifgop_ = CosNotifyChannelAdmin::OR_OP;
    //CosNaming::Name name(1);
    //name.length(1);
    //name[0].id = CORBA::string_dup(CUSTOM_LOGGING_CHANNEL);
    //name[0].kind = LOGGING_CHANNEL_KIND;
    //ifgop_ = CosNotifyChannelAdmin::OR_OP;
	m_nevents_sp->getDevIO()->write((long)0, _timestamp);
    ACS_SHORT_LOG((LM_DEBUG, "CutomLoggerImpl : resolving name service"));
	ACS_SHORT_LOG((LM_DEBUG,"Resolving the name service"));
	try {
		namingContext_m = maci::ContainerImpl::getContainer()->getService<CosNaming::NamingContext>(acscommon::NAMING_SERVICE_NAME, 0, true);
	}
	catch (maciErrType::CannotGetServiceExImpl& ex) {
		_ADD_BACKTRACE(ComponentErrors::ACSServiceExImpl,impl,ex,"CustomLoggerImpl::initialize");
		impl.setServiceName(acscommon::NAMING_SERVICE_NAME);
		throw impl;
	}
	if(CORBA::is_nil(namingContext_m))
   {
   	_EXCPT(ComponentErrors::CORBAProblemExImpl, _dummy,"CustomLoggerImpl::initialize");
     //CUSTOM_EXCPT_LOG(_dummy);
     throw _dummy;
   }
    ACS_SHORT_LOG((LM_DEBUG, "CutomLoggerImpl : resolving logging channel name"));
    CORBA::Object_var obj = namingContext_m -> resolve(name);  
    ec_ = CosNotifyChannelAdmin::EventChannel::_narrow(obj.in());
    ACS_SHORT_LOG((LM_DEBUG, "CutomLoggerImpl : subscribing to the logging channel"));
    CosNotifyChannelAdmin::AdminID adminid;
    consumer_admin_ = ec_->new_for_consumers(ifgop_, adminid);
    ACE_ASSERT(!CORBA::is_nil(consumer_admin_.in()));
   ACS_SHORT_LOG((LM_DEBUG,"Resolving logging channel name"));
   // this should be the name of the logging channel as it should be registered in the name service
	std::string channelName=BaseHelper::combineChannelAndDomainName(acscommon::LOGGING_CHANNEL_XML_NAME,acscommon::ACS_NC_DOMAIN_LOGGING);    
    //CORBA::Object_var obj = namingContext_m -> resolve(name);  
    //ec_ = CosNotifyChannelAdmin::EventChannel::_narrow(obj.in());
	resolveNotifyChannel(channelName.c_str());  // throw (ComponentErrors::CORBAProblemExImpl)    
   // now subscribe to the channel...... 
   ACS_SHORT_LOG((LM_DEBUG,"Subscribing to the logging channel"));
    //CosNotifyChannelAdmin::AdminID adminid;
    //consumer_admin_ = ec_->new_for_consumers(ifgop_, adminid);
    //ACE_ASSERT(!CORBA::is_nil(consumer_admin_.in()));
	createConsumerAdmin();
	// creating a new consumer.....
	consumer_=new CustomStructuredPushConsumer (this);
	consumer_->connect(consumer_admin_.in());
 	// Setup the CA to receive event_type
	CosNotification::EventTypeSeq added(1);
	CosNotification::EventTypeSeq removed (0);
	added.length(1);
@@ -149,7 +163,7 @@ CustomLoggerImpl::initialize() throw (ACSErr::ACSbaseExImpl)

    /* LOGGING INITIALIZATION
     ========================*/
    ACS_SHORT_LOG((LM_DEBUG, "CutomLoggerImpl : Initializing EXPAT for xml parsing"));
    ACS_SHORT_LOG((LM_DEBUG, "Initializing EXPAT for xml parsing"));
    log_parser = init_log_parsing();
     long _a_age;
     if(IRA::CIRATools::getDBValue(getContainerServices(), "LogMaxAgeMillis", _a_age))
@@ -548,6 +562,32 @@ CustomLoggerImpl::handle_xml_error()
    _writer->resume();
};

void CustomLoggerImpl::createConsumerAdmin()
{
	CosNotifyChannelAdmin::AdminID adminid;
	CosNotifyChannelAdmin::InterFilterGroupOperator ifgop=CosNotifyChannelAdmin::OR_OP;
	consumer_admin_=ec_->new_for_consumers(ifgop,adminid);
	ACE_ASSERT(!CORBA::is_nil(consumer_admin_.in()));  
}

void CustomLoggerImpl::resolveNotifyChannel(const char *channel_binding_name) throw (ComponentErrors::CORBAProblemExImpl)
{
	CORBA::Object_var obj;
	CosNaming::Name name(1);
	name.length(1);
	name[0].id=CORBA::string_dup(channel_binding_name);
	name[0].kind=acscommon::NC_KIND;
	try {
		obj=namingContext_m->resolve(name);
		ec_=CosNotifyChannelAdmin::EventChannel::_narrow(obj.in());
	}
	catch (...) {
		_EXCPT(ComponentErrors::CORBAProblemExImpl, _dummy,"CustomLoggerImpl::resolveNotifyChannel");
      throw _dummy;
	}
	
}

CustomStructuredPushConsumer::CustomStructuredPushConsumer(CustomLoggerImpl* logger) : 
    logger_(logger)
{
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,10 @@ IDL_FILES =
TAO_IDLFLAGS =
USER_IDL =

SCRIPTS_L         = emitErrorLogTest

PY_SCRIPTS_L = emitLogMessage

#
# list of all possible C-sources (used to create automatic dependencies)
# ------------------------------
+6 −0
Original line number Diff line number Diff line
#! /bin/bash
. acsstartupLogging.sh


ACS_LOG_ERROR "emitErrorLog" "Test Error log......."
Loading