From a3b14691ccbdd2b9bfd81902f6e7f1172010930d Mon Sep 17 00:00:00 2001 From: Dinand Vanvelzen Date: Sat, 10 Aug 2024 11:35:32 -0500 Subject: [PATCH] Linux build fixes --- .gitignore | 2 + .../gucefCORE_CTMailboxForSharedCloneables.h | 22 +- platform/gucefKAITAI/ModuleInfo.xml | 6 +- .../src/gucefPUBSUB_CPubSubClientSide.cpp | 150 ++--- .../src/gucefPUBSUB_CPubSubFlowRouter.cpp | 562 +++++++++--------- platform/gucefVFS/src/gucefVFS_CVFS.cpp | 140 ++--- ...ucefWEB_CAsyncHttpServerRequestHandler.cpp | 24 +- .../gucefWEB/src/gucefWEB_CHTTPServer.cpp | 88 +-- .../comcorepluginDBL_CDBLNetworkInterface.cpp | 146 ++--- ...subpluginKAFKA_CKafkaPubSubClientTopic.cpp | 233 ++++---- ...REDISCLUSTER_CRedisClusterPubSubClient.cpp | 80 +-- tools/ProcessMetrics/src/ProcessMetrics.cpp | 88 +-- .../src/redisinfo_CRedisClusterKeyCache.cpp | 56 +- 13 files changed, 800 insertions(+), 797 deletions(-) diff --git a/.gitignore b/.gitignore index 69ea77fa9..cf64f3d04 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ dependencies/android-ndk-r21d/ projects/Android/obj/ projects/Android/libs/ projects/k3s/github/vanvelzen-github-runner-base-latest.tar +projects/k3s/github/github_runner_auth.yaml +projects/k3s/metrics/statsite .vs/slnx.sqlite tools/Kaitai/kaitai-struct-compiler*.deb .vs/ diff --git a/platform/gucefCORE/include/gucefCORE_CTMailboxForSharedCloneables.h b/platform/gucefCORE/include/gucefCORE_CTMailboxForSharedCloneables.h index 95e76644b..872e0e0b6 100644 --- a/platform/gucefCORE/include/gucefCORE_CTMailboxForSharedCloneables.h +++ b/platform/gucefCORE/include/gucefCORE_CTMailboxForSharedCloneables.h @@ -106,7 +106,7 @@ class CTMailboxForSharedCloneables : public MT::CMailboxForCloneables */ bool ReInsertSPtrBulkMail( TMailSPtrList& mailList , bool bestEffortSkipIfNeeded = true ); - + private: CTMailboxForSharedCloneables( const CTMailboxForSharedCloneables& src ); /**< not implemented */ @@ -127,7 +127,7 @@ CTMailboxForSharedCloneables< CloneableType, PtrLockType >::CTMailboxForSharedCl } /*-------------------------------------------------------------------------*/ - + template< typename CloneableType, class PtrLockType > CTMailboxForSharedCloneables< CloneableType, PtrLockType >::~CTMailboxForSharedCloneables() {GUCEF_TRACE; @@ -149,7 +149,7 @@ CTMailboxForSharedCloneables< CloneableType, PtrLockType >::GetMailSPtr( TMailSP mail = TMailSPtr( static_cast< CloneableType* >( m_mailQueue.front() ) ); m_mailQueue.pop_front(); return true; - } + } return false; } @@ -165,9 +165,9 @@ CTMailboxForSharedCloneables< CloneableType, PtrLockType >::GetSPtrBulkMail( TMa if ( m_mailQueue.empty() ) return false; // nothing to read, early out - + // We know how many mail items we will read so lets not perform unnessesary reallocs of the vector's underlying memory - if ( maxMailItems > 0 ) + if ( maxMailItems > 0 ) { size_t itemsToRead = GUCEF_SMALLEST( m_mailQueue.size(), (size_t) maxMailItems ); mailList.reserve( itemsToRead ); @@ -176,7 +176,7 @@ CTMailboxForSharedCloneables< CloneableType, PtrLockType >::GetSPtrBulkMail( TMa { mailList.reserve( m_mailQueue.size() ); } - + Int32 mailItemsRead = 0; while ( mailItemsRead < maxMailItems || maxMailItems < 0 ) { @@ -187,15 +187,15 @@ CTMailboxForSharedCloneables< CloneableType, PtrLockType >::GetSPtrBulkMail( TMa CICloneable* clonable = m_mailQueue.front(); CloneableType* derivedClonable = static_cast< CloneableType* >( clonable ); TMailSPtr objPtr( derivedClonable ); - mailList.push_back( objPtr ); + mailList.push_back( objPtr ); GUCEF_ASSERT( objPtr.GetPointerAlways() == static_cast< CloneableType* >( m_mailQueue.front() ) ); m_mailQueue.pop_front(); #else - - mailList.push_back( TMailSPtr( static_cast< CloneableType* >( m_mailQueue.front() ) ) ); + + mailList.push_back( TMailSPtr( static_cast< CloneableType* >( m_mailQueue.front() ) ) ); m_mailQueue.pop_front(); - + #endif ++mailItemsRead; @@ -220,7 +220,7 @@ CTMailboxForSharedCloneables< CloneableType, PtrLockType >::ReInsertSPtrBulkMail MT::CObjectScopeLock lock( this ); bool errorOccured = false; - TMailSPtrList::iterator i = mailList.begin(); + typename TMailSPtrList::iterator i = mailList.begin(); while ( i != mailList.end() ) { // Note that this only works if the shared pointer holds the last remaining reference diff --git a/platform/gucefKAITAI/ModuleInfo.xml b/platform/gucefKAITAI/ModuleInfo.xml index 77946425e..325a7309f 100644 --- a/platform/gucefKAITAI/ModuleInfo.xml +++ b/platform/gucefKAITAI/ModuleInfo.xml @@ -4,15 +4,15 @@ - + - + - \ No newline at end of file + diff --git a/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubClientSide.cpp b/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubClientSide.cpp index d099102b6..e78506ae9 100644 --- a/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubClientSide.cpp +++ b/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubClientSide.cpp @@ -523,7 +523,7 @@ CPubSubClientSide::OnMetricsTimerCycle( CORE::CNotifier* notifier , {GUCEF_TRACE; MT::CScopeReaderLock lock( m_rwdataLock ); - + } @@ -731,7 +731,7 @@ CPubSubClientSide::OnTopicAccessDestroyed( CORE::CNotifier* notifier , TopicPtrMap::iterator i = m_topicPtrs.find( topicAccess.GetPointerAlways() ); if ( i != m_topicPtrs.end() ) { - TopicLinkPtr topicLink = (*i).second; + TopicLinkPtr topicLink = (*i).second; GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + "):OnTopicAccessDestroyed: Removing topic link info for destroyed topic " + topicAccess->GetTopicName() + @@ -746,7 +746,7 @@ CPubSubClientSide::OnTopicAccessDestroyed( CORE::CNotifier* notifier , GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + "):OnTopicAccessDestroyed: Cannot find topic link info for destroyed topic " + topicAccess->GetTopicName() ); } - + m_topicPtrs.erase( topicAccess.GetPointerAlways() ); } } @@ -770,7 +770,7 @@ CPubSubClientSide::OnTopicsAccessAutoCreated( CORE::CNotifier* notifier , if ( !topicAccess.IsNULL() ) { MT::CScopeWriterLock lock( m_rwdataLock ); - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + "):OnTopicsAccessAutoCreated: Configuring topic link for new auto topic " + topicAccess->GetTopicName() ); @@ -820,11 +820,11 @@ CPubSubClientSide::OnTopicsAccessAutoDestroyed( CORE::CNotifier* notifier , if ( !topicAccess.IsNULL() ) { MT::CScopeWriterLock lock( m_rwdataLock ); - + TopicPtrMap::iterator i = m_topicPtrs.find( topicAccess.GetPointerAlways() ); if ( i != m_topicPtrs.end() ) { - TopicLinkPtr topicLink = (*i).second; + TopicLinkPtr topicLink = (*i).second; GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + "):OnTopicsAccessAutoDestroyed: Removing topic link info for destroyed topic " + topicAccess->GetTopicName() + @@ -834,7 +834,7 @@ CPubSubClientSide::OnTopicsAccessAutoDestroyed( CORE::CNotifier* notifier , // send them to dead letter ? m_topicPtrs.erase( topicAccess.GetPointerAlways() ); - + } else { @@ -926,7 +926,7 @@ CPubSubClientSide::BroadcastPublishMsgsSync( const TMsgCollection& msgs ) {GUCEF_TRACE; MT::CScopeReaderLock readerLock( m_rwdataLock ); - + CORE::UInt32 topicsToPublishOn = 0; CORE::UInt32 topicsPublishedOn = 0; bool totalSuccess = true; @@ -957,7 +957,7 @@ CPubSubClientSide::BroadcastPublishMsgsSync( const TMsgCollection& msgs ) if ( !totalSuccess ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + - "):BroadcastPublishMsgsSync: Failures encountered broadcasting messages to " + CORE::ToString( topicsToPublishOn ) + + "):BroadcastPublishMsgsSync: Failures encountered broadcasting messages to " + CORE::ToString( topicsToPublishOn ) + " successfully broadcast to " + CORE::ToString( topicsPublishedOn ) + " topics" ); } else @@ -981,10 +981,10 @@ CPubSubClientSide::PublishMsgsSync( const TMsgCollection& msgs , try { MT::CScopeReaderLock readerLock( m_rwdataLock ); - + if ( GUCEF_NULL == specificTargetTopic ) { - if ( m_sideSettings.treatPublishWithoutTargetTopicAsBroadcast ) + if ( m_sideSettings->treatPublishWithoutTargetTopicAsBroadcast ) { // No target topic is specific, treat as broadcast to all topics return BroadcastPublishMsgsSync( msgs ); @@ -995,7 +995,7 @@ CPubSubClientSide::PublishMsgsSync( const TMsgCollection& msgs , TopicPtrMap::iterator i = m_topicPtrs.find( specificTargetTopic ); if ( i != m_topicPtrs.end() ) { - TopicLinkPtr topicLink = (*i).second; + TopicLinkPtr topicLink = (*i).second; return topicLink->PublishMsgsSync( msgs ); } else @@ -1052,11 +1052,11 @@ CPubSubClientSide::TopicLink::PublishMsgsSync( const TMsgCollection& msgs ) MT::CScopeMutex lock( m_dataLock ); CORE::CObserverNotificationHold hold( this ); - + if ( GUCEF_NULL == side ) return false; const CPubSubSideChannelSettingsPtr sideSettings = side->GetSideSettings(); - + if ( topic->IsPublishingSupported() ) { currentPublishActionIds.clear(); @@ -1096,7 +1096,7 @@ CPubSubClientSide::TopicLink::PublishMsgsSync( const TMsgCollection& msgs ) /*-------------------------------------------------------------------------*/ -bool +bool CPubSubClientSide::TopicLink::ApplySettings( const CPubSubSideChannelSettingsPtr sideSettings ) {GUCEF_TRACE; @@ -1126,13 +1126,13 @@ CPubSubClientSide::TopicLink::ApplySettings( const CPubSubSideChannelSettingsPtr /*-------------------------------------------------------------------------*/ -void +void CPubSubClientSide::TopicLink::SetTopic( CPubSubClientTopicBasicPtr newTopic ) {GUCEF_TRACE; MT::CScopeMutex lock( m_dataLock ); - UnsubscribeFrom( topic.GetPointerAlways() ); + UnsubscribeFrom( topic.GetPointerAlways() ); topic = newTopic; if ( !topic.IsNULL() ) @@ -1148,7 +1148,7 @@ CPubSubClientSide::TopicLink::SetTopic( CPubSubClientTopicBasicPtr newTopic ) /*-------------------------------------------------------------------------*/ -CPubSubClientTopicBasicPtr +CPubSubClientTopicBasicPtr CPubSubClientSide::TopicLink::GetTopic( void ) const {GUCEF_TRACE; @@ -1157,7 +1157,7 @@ CPubSubClientSide::TopicLink::GetTopic( void ) const /*-------------------------------------------------------------------------*/ -void +void CPubSubClientSide::TopicLink::SetParentSide( CPubSubClientSide* parentSide ) {GUCEF_TRACE; @@ -1167,7 +1167,7 @@ CPubSubClientSide::TopicLink::SetParentSide( CPubSubClientSide* parentSide ) /*-------------------------------------------------------------------------*/ -void +void CPubSubClientSide::TopicLink::SetFlowRouter( CPubSubFlowRouter* router ) {GUCEF_TRACE; @@ -1202,7 +1202,7 @@ CPubSubClientSide::TopicLink::SetPulseGenerator( CORE::PulseGeneratorPtr newPuls /*-------------------------------------------------------------------------*/ -CORE::UInt64 +CORE::UInt64 CPubSubClientSide::TopicLink::GetTotalMsgsInFlight( void ) const {GUCEF_TRACE; @@ -1211,7 +1211,7 @@ CPubSubClientSide::TopicLink::GetTotalMsgsInFlight( void ) const /*-------------------------------------------------------------------------*/ -CORE::CString +CORE::CString CPubSubClientSide::TopicLink::GetMetricFriendlyTopicName( void ) const {GUCEF_TRACE; @@ -1221,7 +1221,7 @@ CPubSubClientSide::TopicLink::GetMetricFriendlyTopicName( void ) const /*-------------------------------------------------------------------------*/ -void +void CPubSubClientSide::TopicLink::SetPubsubBookmarkPersistence( TIPubSubBookmarkPersistenceBasicPtr persistance ) {GUCEF_TRACE; @@ -1231,7 +1231,7 @@ CPubSubClientSide::TopicLink::SetPubsubBookmarkPersistence( TIPubSubBookmarkPers /*-------------------------------------------------------------------------*/ -TIPubSubBookmarkPersistenceBasicPtr +TIPubSubBookmarkPersistenceBasicPtr CPubSubClientSide::TopicLink::GetPubsubBookmarkPersistence( void ) const {GUCEF_TRACE; @@ -1331,7 +1331,7 @@ CPubSubClientSide::PublishMsgs( const CPubSubClientTopic::TPubSubMsgsRefVector& TopicLinkPtr topicLink; { MT::CScopeReaderLock readerLock( m_rwdataLock ); - + TopicPtrMap::iterator i = m_topicPtrs.find( specificTargetTopic ); if ( i != m_topicPtrs.end() ) { @@ -1346,7 +1346,7 @@ CPubSubClientSide::PublishMsgs( const CPubSubClientTopic::TPubSubMsgsRefVector& if ( newTopicObj == specificTargetTopic ) { MT::CScopeWriterLock writeLock( readerLock ); - + // This is a publish on a topic for which we have not received the topic creation event notification yet // in multi-threaded setups the order in which the events arrive vs other event listeners on the same can vary depending // depending on thread timings @@ -1455,7 +1455,7 @@ CPubSubClientSide::TopicLink::OnCheckForTimedOutInFlightMessagesTimerCycle( CORE MT::CScopeMutex lock( m_dataLock ); CORE::CObserverNotificationHold hold( this ); - + CORE::UInt64 totalMsgsInFlightCount = 0; CORE::CDateTime cycleNowDt = CORE::CDateTime::NowUTCDateTime(); @@ -1464,7 +1464,7 @@ CPubSubClientSide::TopicLink::OnCheckForTimedOutInFlightMessagesTimerCycle( CORE if ( !topic.IsNULL() && topic->IsPublishingSupported() && GUCEF_NULL != side ) { const CPubSubSideChannelSettingsPtr sideSettings = side->GetSideSettings(); - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_IMPORTANT, "TopicLink(" + CORE::ToString( this ) + "):OnCheckForTimedOutInFlightMessagesTimerCycle: Topic " + topic->GetTopicName() + " has " + CORE::ToString( inFlightMsgs.size() ) + " messages in flight" ); @@ -1591,12 +1591,12 @@ CPubSubClientSide::ProcessMailbox( void ) if ( m_sideSettings->treatPublishWithoutTargetTopicAsBroadcast ) { MT::CScopeReaderLock readerLock( m_rwdataLock ); - bool totalSuccess = true; + bool totalSuccess = true; if ( m_sideSettings->treatPublishWithoutTargetTopicAsBroadcast ) { UInt64 approxTotalMsgsInFlight = 0; - + TopicPtrMap::iterator i = m_topicPtrs.begin(); while ( i != m_topicPtrs.end() ) { @@ -1629,14 +1629,14 @@ CPubSubClientSide::ProcessMailbox( void ) if ( !m_broadcastMailbox.ReInsertSPtrBulkMail( msgs ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "PubSubClientSide(" + CORE::ToString( this ) + - "):RetryPublishFailedMsgsAndProcessMailbox: Failed to reinsert " + CORE::ToString( msgs.size() ) + + "):RetryPublishFailedMsgsAndProcessMailbox: Failed to reinsert " + CORE::ToString( msgs.size() ) + " messages into the mailbox after an exception occured" ); } } } return totalSuccess; - } - + } + return true; } @@ -1655,11 +1655,11 @@ CPubSubClientSide::TopicLink::RetryPublishFailedMsgs( void ) // We already have the max nr of messages in-flight, dont try to add more right now return true; } - } + } if ( awaitingFailureReport ) { // We are awaiting a failure report, lets not complicate things with more messages in flight - return true; + return true; } MT::CScopeMutex lock( m_dataLock ); @@ -1688,7 +1688,7 @@ CPubSubClientSide::TopicLink::RetryPublishFailedMsgs( void ) "):RetryPublishFailedMsgs: Topic " + topic->GetTopicName() + " has " + CORE::ToString( publishFailedMsgs.size() ) + " messages queued for retry" ); const CPubSubSideChannelSettingsPtr sideSettings = side->GetSideSettings(); - + TopicLink::TUInt64Set inFlightDiscardList; TopicLink::TUInt64Set::iterator n = publishFailedMsgs.begin(); while ( n != publishFailedMsgs.end() ) @@ -1884,7 +1884,7 @@ CPubSubClientSide::TopicLink::PublishMailboxMsgs( void ) {GUCEF_TRACE; MT::CScopeMutex lock( m_dataLock ); - + bool totalSuccess = true; if ( !topic.IsNULL() && GUCEF_NULL != side ) { @@ -1907,7 +1907,7 @@ CPubSubClientSide::TopicLink::PublishMailboxMsgs( void ) bool timeoutOccured = false; try { - + CPubSubClientTopic::TIPubSubMsgSPtrVector::iterator i = msgs.begin(); publishSuccess = PublishMsgsSync< CPubSubClientTopic::TIPubSubMsgSPtrVector >( msgs ); totalSuccess = publishSuccess && totalSuccess; @@ -1927,13 +1927,13 @@ CPubSubClientSide::TopicLink::PublishMailboxMsgs( void ) if ( timeoutOccured ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "TopicLink(" + CORE::ToString( this ) + - "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + + "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + " messages into the mailbox after a timeout exception occured" ); } else { GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "TopicLink(" + CORE::ToString( this ) + - "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + + "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + " messages into the mailbox after a failure to publish occured" ); } } @@ -1941,22 +1941,22 @@ CPubSubClientSide::TopicLink::PublishMailboxMsgs( void ) } } catch ( const timeout_exception& ) - { + { totalSuccess = false; if ( !msgMailbox.ReInsertSPtrBulkMail( msgs ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "TopicLink(" + CORE::ToString( this ) + - "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + + "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + " messages into the mailbox after a timeout exception occured" ); - } + } } catch ( const std::exception& e ) - { + { totalSuccess = false; if ( !msgMailbox.ReInsertSPtrBulkMail( msgs ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "TopicLink(" + CORE::ToString( this ) + - "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + + "):PublishMailboxMsgs: Failed to pop back " + CORE::ToString( msgs.size() ) + " messages into the mailbox after an exception occured" ); } throw e; @@ -2017,7 +2017,7 @@ CPubSubClientSide::TopicLink::DetachFromTopic( void ) return; GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "TopicLink(" + CORE::ToString( this ) + - "):DetachFromTopic: Detaching from topic implementation " + CORE::ToString( topicCopy.GetPointerAlways() ) + + "):DetachFromTopic: Detaching from topic implementation " + CORE::ToString( topicCopy.GetPointerAlways() ) + " for topic \"" + topicCopy->GetTopicName() + "\"" ); // Stop the influx of new event messages into our logic before anything else @@ -2041,7 +2041,7 @@ CPubSubClientSide::TopicLink::UpdateTopicMetrics( void ) {GUCEF_TRACE; MT::CScopeMutex lock( m_dataLock ); - + if ( !metrics.IsNULL() ) { if ( metrics->hasSupportForPublishing ) @@ -2094,7 +2094,7 @@ CPubSubClientSide::TopicLink::OnPubSubTopicMsgsReceived( CORE::CNotifier* notifi "):OnPubSubTopicMsgsReceived: Received " + CORE::ToString( msgs.size() ) + " message(s) from pubsub client on side: " + side->GetSideId() ); MT::CScopeMutex lock( m_dataLock ); - + // We now broadcast the received messages to all other sides which is the purpose of this class if ( GUCEF_NULL != flowRouter ) { @@ -2212,7 +2212,7 @@ CPubSubClientSide::TopicLink::UpdateReceivedMessagesBookmarkAsNeeded( const CIPu return true; // not supported, treat as fyi no-op MT::CScopeMutex lock( m_dataLock ); - + // Check criterea for our generic bookmark persistance const CPubSubSideChannelSettingsPtr sideSettings = side->GetSideSettings(); if ( !pubsubBookmarkPersistence.IsNULL() && @@ -2255,7 +2255,7 @@ CPubSubClientSide::TopicLink::UpdateReceivedMessagesBookmarkAsNeeded( const CIPu {GUCEF_TRACE; MT::CScopeMutex lock( m_dataLock ); - + if ( clientFeatures.supportsBookmarkingConcept ) { // Deriving a bookmark from a message is preferred if supported due to the reduced administrative overhead @@ -2372,7 +2372,7 @@ CPubSubClientSide::TopicLink::ProcessAcknowledgeReceiptsMailbox( void ) {GUCEF_TRACE; MT::CScopeMutex lock( publishAckdMsgsMailbox.GetLock() ); - + CIPubSubMsg::TNoLockSharedPtr msg; while ( publishAckdMsgsMailbox.PeekMail( lock, msg, GUCEF_NULL ) ) { @@ -2388,10 +2388,10 @@ CPubSubClientSide::TopicLink::ProcessAcknowledgeReceiptsMailbox( void ) "):ProcessAcknowledgeReceiptsMailbox: Failed to sync ack receipt of message. " + CPubSubClientSide::GetMsgAttributesForLog( *msg ) ); } } - catch ( const timeout_exception& ) + catch ( const timeout_exception& ) { GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_NORMAL, "TopicLink(" + CORE::ToString( this ) + - "):ProcessAcknowledgeReceiptsMailbox: caught timeout_exception while attempting to ack msg receipt. " + + "):ProcessAcknowledgeReceiptsMailbox: caught timeout_exception while attempting to ack msg receipt. " + CPubSubClientSide::GetMsgAttributesForLog( *msg ) ); break; } @@ -2423,7 +2423,7 @@ CPubSubClientSide::AcknowledgeReceipt( CIPubSubMsg::TNoLockSharedPtr& msg ) else { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + - "):AcknowledgeReceiptSync: Message origin topic is not familiar when trying to ack msg receipt. " + + "):AcknowledgeReceiptSync: Message origin topic is not familiar when trying to ack msg receipt. " + CPubSubClientSide::GetMsgAttributesForLog( *msg ) ); } return false; @@ -2486,7 +2486,7 @@ CPubSubClientSide::TopicLink::OnPubSubTopicMsgsPublished( CORE::CNotifier* notif "):OnPubSubTopicMsgsPublished: Ignoring msg acks from client because we are not tracking msgs for acks" ); return; } - + const CPubSubClientTopic::TMsgsPublishedEventData& eData = *static_cast< CPubSubClientTopic::TMsgsPublishedEventData* >( eventData ); const CPubSubClientTopic::TPublishActionIdVector* publishActionIds = eData; CPubSubClientTopic* topicNotifier = static_cast< CPubSubClientTopic* >( notifier ); @@ -2497,7 +2497,7 @@ CPubSubClientSide::TopicLink::OnPubSubTopicMsgsPublished( CORE::CNotifier* notif MT::CScopeMutex lock( m_dataLock ); CORE::CObserverNotificationHold hold( this ); - + // Here we translate the publish action IDs back into the original messages // Subsequently we use said original messages to ack that to the message origin that we received the message // This is what allows us to provide a garanteed handling garantee since its an explicit handoff all the way through @@ -2654,7 +2654,7 @@ CPubSubClientSide::TopicLink::Clear( void ) {GUCEF_TRACE; MT::CScopeMutex lock( m_dataLock ); - + msgMailbox.Clear(); publishAckdMsgsMailbox.Clear(); @@ -2681,11 +2681,11 @@ CPubSubClientSide::TopicLink::Clear( void ) /*-------------------------------------------------------------------------*/ -void +void CPubSubClientSide::TopicLink::SetJournal( CIPubSubJournalBasicPtr newJournal ) {GUCEF_TRACE; - MT::CScopeMutex lock( m_dataLock ); + MT::CScopeMutex lock( m_dataLock ); journal = newJournal; } @@ -2756,7 +2756,7 @@ CPubSubClientSide::ConfigureTopicLink( CPubSubSideChannelSettingsPtr pubSubSideS } const CORE::CString& topicName = topic->GetTopicName(); - + CPubSubClientTopicConfigPtr topicConfig = pubSubSideSettings->GetTopicConfig( topicName ); if ( topicConfig.IsNULL() ) { @@ -2793,7 +2793,7 @@ CPubSubClientSide::ConfigureTopicLink( CPubSubSideChannelSettingsPtr pubSubSideS { TopicNameMap::iterator t = m_topics.find( topic->GetTopicName() ); if ( t == m_topics.end() ) - { + { topicLink = TopicLink::CreateSharedObj(); if ( !topicLink.IsNULL() ) @@ -2814,15 +2814,15 @@ CPubSubClientSide::ConfigureTopicLink( CPubSubSideChannelSettingsPtr pubSubSideS } else { - topicLink = (*t).second; + topicLink = (*t).second; CPubSubClientTopicBasicPtr originalTopic = topicLink->GetTopic(); - + if ( topic != originalTopic ) - { + { // If we get here we had a pre-existing topic link for a topic of this name. // However the implementation, the topic object, is now different. // This can occur when we perform a swap-out/reset of the underlying implementation - // such as to solve issues like bad state in some backend implementation + // such as to solve issues like bad state in some backend implementation GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + "):ConfigureTopicLink: Found pre-existing topic link for topic with name \"" + topicName + @@ -2838,7 +2838,7 @@ CPubSubClientSide::ConfigureTopicLink( CPubSubSideChannelSettingsPtr pubSubSideS else { // make sure the topic name based index references the latest understanding of the correct topic link - m_topics[ topic->GetTopicName() ] = topicLink; + m_topics[ topic->GetTopicName() ] = topicLink; } // Create and configure the pub-sub bookmark persistence @@ -2856,14 +2856,14 @@ CPubSubClientSide::ConfigureTopicLink( CPubSubSideChannelSettingsPtr pubSubSideS topicLink->SetFlowRouter( m_flowRouter ); topicLink->SetParentSide( this ); - topicLink->SetTopic( topic ); + topicLink->SetTopic( topic ); topicLink->ApplySettings( pubSubSideSettings ); topicLink->SetClientFeatures( m_clientFeatures ); topicLink->SetPubsubBookmarkPersistence( pubsubBookmarkPersistence ); topicLink->SetPubsubBookmarkNamespace( m_bookmarkNamespace ); topicLink->SetJournal( topic->GetJournal() ); - // Set the pulse generator last because we dont want to still be configuring the topic link + // Set the pulse generator last because we dont want to still be configuring the topic link // while the associated thread already starts running updates on the same topicLink->SetPulseGenerator( pulseGenerator ); } @@ -2879,7 +2879,7 @@ CPubSubClientSide::GetLatestBookmark( const CPubSubClientTopic& topic , {GUCEF_TRACE; MT::CScopeReaderLock lock( m_rwdataLock ); - + if ( m_pubsubBookmarkPersistence.IsNULL() || m_pubsubClient.IsNULL() ) return false; @@ -3007,11 +3007,11 @@ CPubSubClientSide::DetachFromClient( CPubSubClientPtr pubsubClient ) "):DetachFromClient: Detaching from underlying pubsub client implementation of type \"" + pubsubClient->GetType() + "\" for side with id " + GetSideId() ); - // If we already had in-flight messages and the like but due to some reason (bad state?) we have to swap out the + // If we already had in-flight messages and the like but due to some reason (bad state?) we have to swap out the // underlying implementation, we need to take care to put things in a defined state, not soley dependent on the timing of the swap // guard against the list changing while we are going through it due to auto cleanup actions - TopicPtrMap topicListCopy = m_topicPtrs; + TopicPtrMap topicListCopy = m_topicPtrs; TopicPtrMap::iterator t = topicListCopy.begin(); while ( t != topicListCopy.end() ) @@ -3065,7 +3065,7 @@ CPubSubClientSide::PerformPubSubClientSetup( bool hardReset ) { DetachFromClient( m_pubsubClient ); } - + // Create and configure the pub-sub client pubSubConfig.pulseGenerator = GetPulseGenerator(); pubSubConfig.metricsPrefix = m_sideSettings->metricsPrefix; @@ -3145,7 +3145,7 @@ CPubSubClientSide::ConnectPubSubClient( bool reset ) if ( !reset && IsConnectedAndSubscribedAsNeeded() ) return true; - + MT::CObjectScopeLock lock( this ); CORE::CObserverNotificationHold hold( this ); @@ -3302,7 +3302,7 @@ CPubSubClientSide::IsPubSubClientInfraReadyToConnect( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CPubSubClientSide::IsConnectedAndSubscribedAsNeeded( void ) const {GUCEF_TRACE; @@ -3501,7 +3501,7 @@ CPubSubClientSide::LoadConfig( const CPubSubSideChannelSettingsPtr sideSettings if ( sideSettings.IsNULL() ) return false; - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubClientSide(" + CORE::ToString( this ) + "):LoadConfig: Loading new side settings for side: " + m_sideId ); diff --git a/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubFlowRouter.cpp b/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubFlowRouter.cpp index a187f1037..115c18fc2 100644 --- a/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubFlowRouter.cpp +++ b/platform/gucefPUBSUB/src/gucefPUBSUB_CPubSubFlowRouter.cpp @@ -87,7 +87,7 @@ CPubSubFlowRouter::CRouteTopicLinks::CRouteTopicLinks( void ) , spilloverTopic( GUCEF_NULL ) , deadletterTopic( GUCEF_NULL ) {GUCEF_TRACE; - + } /*-------------------------------------------------------------------------*/ @@ -101,7 +101,7 @@ CPubSubFlowRouter::CRouteTopicLinks::CRouteTopicLinks( const CRouteTopicLinks& s , spilloverTopic( src.spilloverTopic ) , deadletterTopic( src.deadletterTopic ) {GUCEF_TRACE; - + } /*-------------------------------------------------------------------------*/ @@ -126,9 +126,9 @@ CPubSubFlowRouter::CRouteInfo::CRouteInfo( void ) , deadLetterSideLastHealthStatusChange( CORE::CDateTime::PastMax ) , routeSwitchingTimer( CORE::PulseGeneratorPtr(), 1000 ) , spilloverInfo( GUCEF_NULL ) - , routeConfig( GUCEF_NULL ) + , routeConfig() {GUCEF_TRACE; - + } /*-------------------------------------------------------------------------*/ @@ -155,15 +155,15 @@ CPubSubFlowRouter::CRouteInfo::CRouteInfo( const CRouteInfo& src ) , spilloverInfo( src.spilloverInfo ) , routeConfig( src.routeConfig ) {GUCEF_TRACE; - + } /*-------------------------------------------------------------------------*/ -bool +bool CPubSubFlowRouter::CRouteInfo::IsSpilloverEgressActive( void ) const {GUCEF_TRACE; - + if ( GUCEF_NULL != spilloverInfo ) return spilloverInfo->IsEgressActive(); return false; @@ -171,10 +171,10 @@ CPubSubFlowRouter::CRouteInfo::IsSpilloverEgressActive( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CPubSubFlowRouter::CRouteInfo::IsSpilloverEgressOngoing( void ) const {GUCEF_TRACE; - + if ( GUCEF_NULL != spilloverInfo ) return spilloverInfo->IsEgressOngoing(); return false; @@ -185,7 +185,7 @@ CPubSubFlowRouter::CRouteInfo::IsSpilloverEgressOngoing( void ) const bool CPubSubFlowRouter::CRouteInfo::IsSpilloverIngressOngoing( void ) const {GUCEF_TRACE; - + if ( GUCEF_NULL != spilloverInfo ) return spilloverInfo->IsIngressOngoing(); return false; @@ -199,23 +199,23 @@ CPubSubFlowRouter::CRouteInfo::IsSpilloverInActiveUse( void ) const if ( GUCEF_NULL != spilloverInfo ) return spilloverInfo->IsInActiveUse(); - return false; + return false; } /*-------------------------------------------------------------------------*/ -bool +bool CPubSubFlowRouter::CRouteInfo::DidMsgsFlowIntoSpillover( void ) const {GUCEF_TRACE; if ( GUCEF_NULL != spilloverInfo ) return spilloverInfo->DidMsgsFlowIntoSpillover(); - return false; + return false; } /*-------------------------------------------------------------------------*/ -void +void CPubSubFlowRouter::CRouteInfo::SwitchTopicLinksActiveTopic( RouteType activeSide, CRouteTopicLinks& topicLinks ) {GUCEF_TRACE; @@ -225,7 +225,7 @@ CPubSubFlowRouter::CRouteInfo::SwitchTopicLinksActiveTopic( RouteType activeSide case RouteType::Failover: { topicLinks.activeTopic = topicLinks.failoverTopic; break; } case RouteType::SpilloverBuffer: { topicLinks.activeTopic = topicLinks.spilloverTopic; break; } case RouteType::DeadLetter: { topicLinks.activeTopic = topicLinks.deadletterTopic; break; } - + case RouteType::Disabled: default: { @@ -234,12 +234,12 @@ CPubSubFlowRouter::CRouteInfo::SwitchTopicLinksActiveTopic( RouteType activeSide case RouteType::Active: { break; } } - topicLinks.activeTopicType = activeSide; + topicLinks.activeTopicType = activeSide; } /*-------------------------------------------------------------------------*/ -void +void CPubSubFlowRouter::CRouteInfo::SwitchAllTopicLinksActiveTopic( RouteType activeSide ) {GUCEF_TRACE; @@ -249,39 +249,39 @@ CPubSubFlowRouter::CRouteInfo::SwitchAllTopicLinksActiveTopic( RouteType activeS CRouteTopicLinks& topicLinks = (*i).second; SwitchTopicLinksActiveTopic( activeSide, topicLinks ); ++i; - } + } } /*-------------------------------------------------------------------------*/ -CPubSubFlowRouter::CRouteTopicLinks* -CPubSubFlowRouter::GetTargetTopicLinks( CPubSubClientTopic* fromTopic , +CPubSubFlowRouter::CRouteTopicLinks* +CPubSubFlowRouter::GetTargetTopicLinks( CPubSubClientTopic* fromTopic , CRouteInfo& routeInfo , bool& errorOccured ) {GUCEF_TRACE; errorOccured = false; - TTopicRawPtrToRouteTopicLinksRawPtrMap::iterator t = routeInfo.fromSideTopicLinks.find( fromTopic ); + TTopicRawPtrToRouteTopicLinksRawPtrMap::iterator t = routeInfo.fromSideTopicLinks.find( fromTopic ); if ( t != routeInfo.fromSideTopicLinks.end() ) { - return (*t).second; + return (*t).second; } else { // Check if we need to worry about auto matching topics - if ( fromTopic != GUCEF_NULL && - !routeInfo.routeConfig.IsNULL() && + if ( fromTopic != GUCEF_NULL && + !routeInfo.routeConfig.IsNULL() && routeInfo.routeConfig->IsAnyAutoTopicMatchingNeeded() ) - { + { // We should always have a target topic considering we are auto matching them and not relying on an explicit map - // Due to topic discovery and auto generation this scenario can happen. + // Due to topic discovery and auto generation this scenario can happen. // We will 'lazy init' the mapping now. GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "RouteInfo:GetTargetTopicLinks: topic links not yet found, will lazy init" ); - + MT::CScopeWriterLock lock( m_lock ); - + CORE::PulseGeneratorPtr nullPulseGenerator; if ( routeInfo.MatchTopicRouteConfig( fromTopic, nullPulseGenerator ) ) { @@ -290,10 +290,10 @@ CPubSubFlowRouter::GetTargetTopicLinks( CPubSubClientTopic* fromTopic , t = routeInfo.fromSideTopicLinks.find( fromTopic ); if ( t != routeInfo.fromSideTopicLinks.end() ) { - return (*t).second; - } + return (*t).second; + } } - + errorOccured = true; GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "RouteInfo:GetTargetTopicLinks: Failed to lazy init topic links for topic " + fromTopic->GetTopicName() ); } @@ -305,16 +305,16 @@ CPubSubFlowRouter::GetTargetTopicLinks( CPubSubClientTopic* fromTopic , /*-------------------------------------------------------------------------*/ bool -CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( CPubSubClientTopic* topicAccess , +CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( CPubSubClientTopic* topicAccess , CORE::PulseGeneratorPtr destPulseGenerator ) {GUCEF_TRACE; - if ( topicAccess != GUCEF_NULL && + if ( topicAccess != GUCEF_NULL && topicAccess->GetClient() != GUCEF_NULL ) { CPubSubClientPtr fromSideClient = fromSide->GetCurrentUnderlyingPubSubClient(); if ( !fromSideClient.IsNULL() && topicAccess->GetClient() == fromSideClient.GetPointerAlways() ) - { + { // Seems we want it, lets see if we can support it and if it applies CPubSubClientFeatures supportedFeatures; fromSideClient->GetSupportedFeatures( supportedFeatures ); @@ -333,7 +333,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( CPubSubClientTopic* topicA /*-------------------------------------------------------------------------*/ bool -CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopicConfigPtr topicRouteConfig , +CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopicConfigPtr topicRouteConfig , CORE::PulseGeneratorPtr fromPulseGenerator , CORE::PulseGeneratorPtr destPulseGenerator ) {GUCEF_TRACE; @@ -344,7 +344,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi return true; bool totalSuccess = true; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Applying config for topic association for 'from' topic " + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Applying config for topic association for 'from' topic " + topicRouteConfig->fromSideTopicName ); // refresh destination topic pointers to match config @@ -357,10 +357,10 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi { PUBSUB::CPubSubClientFeatures supportedFeatures; fromSideClient->GetSupportedFeatures( supportedFeatures ); - + // Check if we need to worry about glob pattern topic names - if ( routeConfig->IsAnyAutoTopicMatchingNeeded() && - supportedFeatures.supportsGlobPatternTopicNames && + if ( routeConfig->IsAnyAutoTopicMatchingNeeded() && + supportedFeatures.supportsGlobPatternTopicNames && topicRouteConfig->fromSideTopicName.HasChar( '*' ) >= 0 ) { // Glob pattern topic names are supported by the backend and we actually have a wildcard topic name @@ -371,7 +371,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi topicAccessSet , fromPulseGenerator ) ) { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Obtained access to " + CORE::ToString( topicAccessSet.size() ) + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Obtained access to " + CORE::ToString( topicAccessSet.size() ) + " topics association for pattern matched 'from' topic " + topicRouteConfig->fromSideTopicName + ( fromPulseGenerator.IsNULL() ? "" : ". Requested using pulse generator for thread " + CORE::ToString( fromPulseGenerator->GetPulseDriverThreadId() ) ) ); @@ -393,7 +393,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi if ( !fromPulseGenerator.IsNULL() ) { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Preference given to use 'from' thread for driving destinations as well, will be using pulse generator for thread " + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Preference given to use 'from' thread for driving destinations as well, will be using pulse generator for thread " + CORE::ToString( fromPulseGenerator->GetPulseDriverThreadId() ) ); } else @@ -401,7 +401,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Preference given to use 'from' thread for driving destinations as well, however no suitable pulse generator is available" ); } } - + CPubSubFlowRouteTopicConfigPtr autoTopicRouteConfig = CPubSubFlowRouteTopicConfig::CreateSharedObj(); autoTopicRouteConfig->fromSideTopicName = topicName; @@ -424,17 +424,17 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi autoTopicRouteConfig->deadLetterSideTopicName = topicName; else autoTopicRouteConfig->deadLetterSideTopicName = topicRouteConfig->deadLetterSideTopicName; - - totalSuccess = MatchTopicRouteConfig( autoTopicRouteConfig , - fromPulseGenerator , + + totalSuccess = MatchTopicRouteConfig( autoTopicRouteConfig , + fromPulseGenerator , destPulseGenerator ) && totalSuccess; } else { - // Something went wrong. We should not get back a topic with a topic mame which still + // Something went wrong. We should not get back a topic with a topic mame which still // has wildcards in it. That will confuse this code. The backend should resolve to non wildcard containing names totalSuccess = false; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: glob pattern topic \"" + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: glob pattern topic \"" + topicRouteConfig->fromSideTopicName + "\" for side \"" + fromSide->GetSideId() + "\" was matched by the backend to topic \"" + topicName + "\" which still contains a wildcard. This is not supported." ); } @@ -444,7 +444,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi } else { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Found no relevant topic access for glob pattern topic \"" + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Found no relevant topic access for glob pattern topic \"" + topicRouteConfig->fromSideTopicName + "\" for 'from' side \"" + fromSide->GetSideId() + "\" at this time" ); } } @@ -464,7 +464,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi else { totalSuccess = false; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + topicRouteConfig->fromSideTopicName + "\" for 'from' side \"" + fromSide->GetSideId() + "\"" ); } @@ -477,7 +477,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi if ( !fromPulseGenerator.IsNULL() ) { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Preference given to use 'from' thread for driving destinations as well, will be using pulse generator for thread " + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Preference given to use 'from' thread for driving destinations as well, will be using pulse generator for thread " + CORE::ToString( fromPulseGenerator->GetPulseDriverThreadId() ) ); } else @@ -487,19 +487,19 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi } if ( destPulseGenerator.IsNULL() && routeConfig->preferFromTopicThreadForDestination ) { - destPulseGenerator = fromPulseGenerator; + destPulseGenerator = fromPulseGenerator; } if ( topicLinks.fromTopic != oldFromTopic ) { if ( GUCEF_NULL != oldFromTopic ) { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Erasing map entry for old topic implementation: " + CORE::ToString( oldFromTopic ) ); + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Erasing map entry for old topic implementation: " + CORE::ToString( oldFromTopic ) ); fromSideTopicLinks.erase( oldFromTopic ); } if ( GUCEF_NULL != topicLinks.fromTopic ) - { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Adding map entry for new topic implementation: " + CORE::ToString( topicLinks.fromTopic ) ); + { + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Adding map entry for new topic implementation: " + CORE::ToString( topicLinks.fromTopic ) ); fromSideTopicLinks[ topicLinks.fromTopic ] = &topicLinks; } } @@ -513,7 +513,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi if ( GUCEF_NULL == topicLinks.toTopic ) { totalSuccess = false; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + topicRouteConfig->toSideTopicName + "\" for 'to' side \"" + toSide->GetSideId() + "\"" ); } } @@ -527,7 +527,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi if ( GUCEF_NULL == topicLinks.failoverTopic ) { totalSuccess = false; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + topicRouteConfig->failoverSideTopicName + "\" for 'failover' side \"" + failoverSide->GetSideId() + "\"" ); } } @@ -541,7 +541,7 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi if ( GUCEF_NULL == topicLinks.spilloverTopic ) { totalSuccess = false; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + topicRouteConfig->spilloverSideTopicName + "\" for 'spillover' side \"" + spilloverBufferSide->GetSideId() + "\"" ); } } @@ -555,14 +555,14 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi if ( GUCEF_NULL == topicLinks.deadletterTopic ) { totalSuccess = false; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchTopicRouteConfig: Failed to obtain topic access to topic \"" + topicRouteConfig->deadLetterSideTopicName + "\" for 'dead letter' side \"" + deadLetterSide->GetSideId() + "\"" ); } } } } } - } + } return totalSuccess; } @@ -582,18 +582,18 @@ CPubSubFlowRouter::CRouteInfo::MatchTopicRouteConfig( const CPubSubFlowRouteTopi bool CPubSubFlowRouter::CRouteInfo::MatchAllTopicRouteConfigs( void ) {GUCEF_TRACE; - - if ( GUCEF_NULL == routeConfig ) + + if ( routeConfig.IsNULL() ) return false; - - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchAllTopicRouteConfigs: Applying config for " + + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:RouteInfo:MatchAllTopicRouteConfigs: Applying config for " + CORE::ToString( routeConfig->topicAssociations.size() ) + " topic associations" ); - + bool totalSuccess = true; CPubSubFlowRouteConfig::PubSubFlowRouteTopicConfigVector::const_iterator t = routeConfig->topicAssociations.begin(); - while ( t != routeConfig->topicAssociations.end() ) + while ( t != routeConfig->topicAssociations.end() ) { - totalSuccess = MatchTopicRouteConfig( (*t) ) && totalSuccess; + totalSuccess = MatchTopicRouteConfig( (*t) ) && totalSuccess; ++t; } return totalSuccess; @@ -610,7 +610,7 @@ CPubSubFlowRouter::CSpilloverInfo::CSpilloverInfo( void ) , msgsFlowedIntoSpillover( false ) , route( GUCEF_NULL ) {GUCEF_TRACE; - + } /*-------------------------------------------------------------------------*/ @@ -618,13 +618,13 @@ CPubSubFlowRouter::CSpilloverInfo::CSpilloverInfo( void ) bool CPubSubFlowRouter::CSpilloverInfo::IsEgressActive( void ) const {GUCEF_TRACE; - + // Is the spillover active and in egress mode? if ( GUCEF_NULL != route && route->activeSide == route->spilloverBufferSide && !route->flowingIntoSpillover ) - { + { return true; } - return false; + return false; } /*-------------------------------------------------------------------------*/ @@ -632,10 +632,10 @@ CPubSubFlowRouter::CSpilloverInfo::IsEgressActive( void ) const bool CPubSubFlowRouter::CSpilloverInfo::IsEgressOngoing( void ) const {GUCEF_TRACE; - + // Is the spillover active and in egress mode? if ( GUCEF_NULL != route && route->activeSide == route->spilloverBufferSide && !route->flowingIntoSpillover ) - { + { // did any messages flow into the spillover to begin with? if ( msgsFlowedIntoSpillover || spilloverIngressMsgCount > 0 ) { @@ -651,7 +651,7 @@ CPubSubFlowRouter::CSpilloverInfo::IsEgressOngoing( void ) const { endOfDataEventOccured = client->AreAllSubscriptionsAtEndOfData(); } - } + } return !endOfDataEventOccured; } @@ -659,7 +659,7 @@ CPubSubFlowRouter::CSpilloverInfo::IsEgressOngoing( void ) const return spilloverEgressMsgCount < spilloverIngressMsgCount; } } - return false; + return false; } /*-------------------------------------------------------------------------*/ @@ -696,16 +696,16 @@ CPubSubFlowRouter::CSpilloverInfo::IsInActiveUse( void ) const MT::TLockStatus CPubSubFlowRouter::Lock( UInt32 lockWaitTimeoutInMs ) const {GUCEF_TRACE; - + return MT::CReadWriteLock::RwLockStateToLockStatus( m_lock.WriterStart( lockWaitTimeoutInMs ) ); } /*-------------------------------------------------------------------------*/ -MT::TLockStatus +MT::TLockStatus CPubSubFlowRouter::Unlock( void ) const {GUCEF_TRACE; - + return MT::CReadWriteLock::RwLockStateToLockStatus( m_lock.WriterStop() ); } @@ -714,16 +714,16 @@ CPubSubFlowRouter::Unlock( void ) const MT::TLockStatus CPubSubFlowRouter::ReadOnlyLock( UInt32 lockWaitTimeoutInMs ) const {GUCEF_TRACE; - + return MT::CReadWriteLock::RwLockStateToLockStatus( m_lock.ReaderStart( lockWaitTimeoutInMs ) ); } /*-------------------------------------------------------------------------*/ -MT::TLockStatus +MT::TLockStatus CPubSubFlowRouter::ReadOnlyUnlock( void ) const {GUCEF_TRACE; - + return MT::CReadWriteLock::RwLockStateToLockStatus( m_lock.ReaderStop() ); } @@ -778,16 +778,16 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi {GUCEF_TRACE; normalizedConfig.ackStyle = originalConfig.ackStyle; - + // First we gather all the 'known' sides // If the config says we map to or from anything '*' it still needs to map to an actual side - + CORE::CString::StringSet knownSides; TPubSubClientSidePtrVector::const_iterator i = sides.begin(); while ( i != sides.end() ) { - knownSides.insert( (*i)->GetSideId() ); + knownSides.insert( (*i)->GetSideId() ); ++i; } @@ -814,11 +814,11 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi if ( "*" != (*n)->fromSideId && "*" != (*n)->toSideId ) { explicitRoutes.Set( (*n)->fromSideId, (*n)->toSideId ); - + // Nothing to normalize, just copy to the normalized output normalizedConfig.routes.push_back( (*n) ); - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: We have an explicit route from \"" + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: We have an explicit route from \"" + (*n)->fromSideId + "\" to \"" + (*n)->toSideId + "\" with failover side \"" + (*n)->failoverSideId + "\" and spillover side \"" + (*n)->spilloverBufferSideId + "\" and deadletter side \"" + (*n)->deadLetterSideId + "\"" ); } @@ -826,7 +826,7 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: There are " + CORE::ToString( explicitRoutes.GetValueCount() ) + " explicit routes configured" ); - + // Now that we know about the IDs of all known sides we can populate the '*' as needed for the wildcard side // Note that we intentionally dont handle the * -> * case yet since that is the catch-all applied at the end n = originalConfig.routes.begin(); @@ -850,10 +850,10 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi explicitRoutes.Set( route->fromSideId, route->toSideId ); - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: Generated route from \"" + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: Generated route from \"" + route->fromSideId + "\" to \"" + route->toSideId + "\" with failover side \"" + route->failoverSideId + "\" and spillover side \"" + route->spilloverBufferSideId + "\" and deadletter side \"" + route->deadLetterSideId + "\"" ); - } + } } ++m; } @@ -877,10 +877,10 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi explicitRoutes.Set( route->fromSideId, route->toSideId ); - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: Generated route from \"" + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: Generated route from \"" + route->fromSideId + "\" to \"" + route->toSideId + "\" with failover side \"" + route->failoverSideId + "\" and spillover side \"" + route->spilloverBufferSideId + "\" and deadletter side \"" + route->deadLetterSideId + "\"" ); - } + } } ++m; } @@ -899,7 +899,7 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi if ( !foundCatchAll ) { foundCatchAll = true; - + // Generate a combo for anything that is not yet defined as an explicit route CORE::CString::StringSet::iterator m = knownSides.begin(); while ( m != knownSides.end() ) @@ -920,7 +920,7 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi explicitRoutes.Set( route->fromSideId, route->toSideId ); - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: Generated catch-all route from \"" + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: Generated catch-all route from \"" + route->fromSideId + "\" to \"" + route->toSideId + "\" with failover side \"" + route->failoverSideId + "\" and spillover side \"" + route->spilloverBufferSideId + "\" and deadletter side \"" + route->deadLetterSideId + "\"" ); } @@ -947,7 +947,7 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi CPubSubFlowRouteConfigPtr routeConfig = (*r); CPubSubClientSidePtr fromSide = GetSideWithId( sides, routeConfig->fromSideId ); if ( !fromSide.IsNULL() ) - { + { if ( routeConfig->IsAnyAutoTopicMatchingNeeded() ) { CORE::CString::StringSet fromSideTopicNames; @@ -955,14 +955,14 @@ CPubSubFlowRouter::NormalizeConfig( const CPubSubFlowRouterConfig& originalConfi { CORE::CString::StringSet::iterator t = fromSideTopicNames.begin(); while ( t != fromSideTopicNames.end() ) - { + { const CORE::CString& fromSideTopicName = (*t); - + // Find of create (config permitting) the topic association config - CPubSubFlowRouteTopicConfigPtr topicRouteConfig = routeConfig->FindOrCreateTopicAssociation( fromSideTopicName, false ); + CPubSubFlowRouteTopicConfigPtr topicRouteConfig = routeConfig->FindOrCreateTopicAssociation( fromSideTopicName, false ); if ( topicRouteConfig.IsNULL() ) { - GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: No topic association entry found for side \"" + routeConfig->fromSideId + + GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter:NormalizeConfig: No topic association entry found for side \"" + routeConfig->fromSideId + "\" and from-topic \"" + fromSideTopicName + "\"" ); } ++t; @@ -987,10 +987,10 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , {GUCEF_TRACE; MT::CScopeWriterLock lock( m_lock ); - + // We might get called multiple times so wipe whatever we had first ClearRoutes(); - + // Since we support wildcard based config to reduce config burden we need to normalize the config first CPubSubFlowRouterConfig normalizedConfig; if ( !NormalizeConfig( config, sides, normalizedConfig ) ) @@ -999,7 +999,7 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , return false; } m_normalizedConfig = normalizedConfig; - + // Now we generate the pointer map based on the normalized config UInt32 totalPossibleRoutes = 0; CPubSubFlowRouterConfig::PubSubFlowRouteConfigVector::const_iterator i = m_normalizedConfig.routes.begin(); @@ -1049,20 +1049,20 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , } } ++n; - } + } // The minimum you need is from and to sides, the rest is optional if ( !fromSide.IsNULL() && !toSide.IsNULL() ) { // We found the side combo for which we have a route config - TRouteInfoVector& multiRouteInfo = m_routeMap[ fromSide.GetPointerAlways() ]; + TRouteInfoVector& multiRouteInfo = m_routeMap[ fromSide.GetPointerAlways() ]; multiRouteInfo.push_back( CRouteInfo() ); CRouteInfo& routeInfo = multiRouteInfo.back(); routeInfo.fromSide = fromSide.GetPointerAlways(); routeInfo.toSide = toSide.GetPointerAlways(); routeInfo.failoverSide = failoverSide.GetPointerAlways(); routeInfo.spilloverBufferSide = spilloverSide.GetPointerAlways(); - routeInfo.deadLetterSide = deadletterSide.GetPointerAlways(); + routeInfo.deadLetterSide = deadletterSide.GetPointerAlways(); routeInfo.routeConfig = routeConfig; totalPossibleRoutes += possibleRoutes; @@ -1077,8 +1077,8 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , } GUCEF_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: Routes are now defined for " + - CORE::ToString( m_routeMap.size() ) + " source sides, with a total of " + CORE::ToString( totalPossibleRoutes ) + " possible routes" ); - + CORE::ToString( m_routeMap.size() ) + " source sides, with a total of " + CORE::ToString( totalPossibleRoutes ) + " possible routes" ); + // Validate side capabilities relative to the assigned roles CORE::UInt32 sideClientCapabilityErrors = 0; TSidePtrToRouteInfoVectorMap::iterator r = m_routeMap.begin(); @@ -1103,11 +1103,11 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , if ( !features.supportsPublishing ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: 'to' side's client does not support publishing. This is invalid, disabling route: \"" + - fromSide->GetSideId() + "\" -> \"" + routeInfo.toSide->GetSideId() ); - isValid = false; - ++sideClientCapabilityErrors; + fromSide->GetSideId() + "\" -> \"" + routeInfo.toSide->GetSideId() ); + isValid = false; + ++sideClientCapabilityErrors; } - + if ( !isValid ) routeInfo.toSide = GUCEF_NULL; } @@ -1124,11 +1124,11 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , if ( !features.supportsPublishing ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: 'dead letter' side's client does not support publishing. This is invalid, disabling route: \"" + - fromSide->GetSideId() + "\" -> \"" + routeInfo.deadLetterSide->GetSideId() ); + fromSide->GetSideId() + "\" -> \"" + routeInfo.deadLetterSide->GetSideId() ); isValid = false; ++sideClientCapabilityErrors; } - + if ( !isValid ) routeInfo.deadLetterSide = GUCEF_NULL; } @@ -1145,11 +1145,11 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , if ( !features.supportsPublishing ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: 'failover' side's client does not support publishing. This is invalid, disabling route: \"" + - fromSide->GetSideId() + "\" -> \"" + routeInfo.failoverSide->GetSideId() ); - isValid = false; + fromSide->GetSideId() + "\" -> \"" + routeInfo.failoverSide->GetSideId() ); + isValid = false; ++sideClientCapabilityErrors; } - + if ( !isValid ) routeInfo.failoverSide = GUCEF_NULL; } @@ -1162,25 +1162,25 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , // since its not a final destination in of itself CPubSubClientFeatures features; if ( GUCEF_NULL != routeInfo.toSide || GUCEF_NULL != routeInfo.failoverSide ) - { + { if ( routeInfo.spilloverBufferSide->GetPubSubClientSupportedFeatures( features ) ) { // the 'spill over' side must be capable of: // - receiving messages from the 'from' side and thus for the client that means capable of publishing // - read back messages from the 'spillover' side and thus for the client that means capable of subscribing - + if ( !features.supportsPublishing ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: 'spillover' side's client does not support publishing. This is invalid, disabling route: \"" + - fromSide->GetSideId() + "\" -> \"" + routeInfo.spilloverBufferSide->GetSideId() ); - isValid = false; + fromSide->GetSideId() + "\" -> \"" + routeInfo.spilloverBufferSide->GetSideId() ); + isValid = false; ++sideClientCapabilityErrors; } if ( !features.supportsSubscribing ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: 'spillover' side's client does not support subscribing. This is invalid, disabling route: \"" + - fromSide->GetSideId() + "\" -> \"" + routeInfo.spilloverBufferSide->GetSideId() ); - isValid = false; + fromSide->GetSideId() + "\" -> \"" + routeInfo.spilloverBufferSide->GetSideId() ); + isValid = false; ++sideClientCapabilityErrors; } } @@ -1214,7 +1214,7 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , } else { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: Spillover buffers must be unique to a given route, they cannot be shared. The configuration is invalid for spillover buffer \"" + routeInfo.spilloverBufferSide->GetSideId() + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: Spillover buffers must be unique to a given route, they cannot be shared. The configuration is invalid for spillover buffer \"" + routeInfo.spilloverBufferSide->GetSideId() + "\" with 'from' side \"" + fromSide->GetSideId() + "\". Removing spillover buffer feature from this route as a best-effort fallback" ); isValid = false; } @@ -1230,7 +1230,7 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , GUCEF_NULL == routeInfo.spilloverBufferSide ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter:BuildRoutes: No surviving viable pathways for side " + fromSide->GetSideId() + " post client capability verification" ); - return false; + return false; } ++n; @@ -1263,14 +1263,14 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , if ( GUCEF_NULL != routeInfo.spilloverBufferSide ) { CORE::CString spilloverSideId = routeInfo.spilloverBufferSide->GetSideId(); - + // We found a validated spillover side // now lets make sure we have an egress route for it TSidePtrToRouteInfoVectorMap::iterator r2 = m_routeMap.find( routeInfo.spilloverBufferSide ); if ( r2 != m_routeMap.end() ) { CPubSubClientSide* toSide = GUCEF_NULL != routeInfo.toSide ? routeInfo.toSide : routeInfo.failoverSide; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: Egress route for spillover buffer \"" + spilloverSideId + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: Egress route for spillover buffer \"" + spilloverSideId + "\" to side \"" + toSide->GetSideId() + "\" exists as an explicitly provided configured route. No such route will be auto-generated" ); // Ensure the egress routes are marked as such @@ -1312,11 +1312,11 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , } ++c; } - + if ( !foundSpilloverEgressRouteConfig ) { CPubSubClientSide* toSide = GUCEF_NULL != routeInfo.toSide ? routeInfo.toSide : routeInfo.failoverSide; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: No route config found for egress route from spillover buffer \"" + spilloverSideId + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: No route config found for egress route from spillover buffer \"" + spilloverSideId + "\" to side \"" + toSide->GetSideId() + "\". Auto generating egress route config" ); // We need to add a route config for this auto-generated route @@ -1334,13 +1334,13 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , else { CPubSubClientSide* toSide = GUCEF_NULL != routeInfo.toSide ? routeInfo.toSide : routeInfo.failoverSide; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: No route config found which uses spillover \"" + spilloverSideId + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: No route config found which uses spillover \"" + spilloverSideId + "\" and 'from' side \"" + fromSideId + "\". This should not happen since we have instantiations" ); } - } + } CPubSubClientSide* toSide = GUCEF_NULL != routeInfo.toSide ? routeInfo.toSide : routeInfo.failoverSide; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: Auto-generated egress route for spillover buffer \"" + spilloverSideId + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter:BuildRoutes: Auto-generated egress route for spillover buffer \"" + spilloverSideId + "\" to side \"" + toSide->GetSideId() + "\"" ); } @@ -1416,8 +1416,8 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , ++r; } - - // Now set up all the event handlers + + // Now set up all the event handlers r = m_routeMap.begin(); while ( r != m_routeMap.end() ) { @@ -1436,7 +1436,7 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , UpdatePulseGeneratorUsage(); - // Now connect the routes if desired + // Now connect the routes if desired if ( attemptConnect ) { r = m_routeMap.begin(); @@ -1463,12 +1463,12 @@ CPubSubFlowRouter::BuildRoutes( const CPubSubFlowRouterConfig& config , void CPubSubFlowRouter::RegisterRouteEventHandlers( CRouteInfo& routeInfo ) {GUCEF_TRACE; - + TEventCallback callback( this, &CPubSubFlowRouter::OnRouteSwitchTimerCycle ); SubscribeTo( &routeInfo.routeSwitchingTimer , CORE::CTimer::TimerUpdateEvent , callback ); - + // For efficiency to avoid an additional lookup we use the user data facility // to link back to the parent route info for the timer handler routeInfo.routeSwitchingTimer.SetOpaqueUserData( &routeInfo ); @@ -1490,7 +1490,7 @@ CPubSubFlowRouter::RegisterRouteEventHandlers( CRouteInfo& routeInfo ) void CPubSubFlowRouter::UpdatePulseGeneratorUsage( void ) {GUCEF_TRACE; - + TSidePtrToRouteInfoVectorMap::iterator r = m_routeMap.begin(); while ( r != m_routeMap.end() ) { @@ -1511,7 +1511,7 @@ CPubSubFlowRouter::UpdatePulseGeneratorUsage( void ) void CPubSubFlowRouter::SetPulseGenerator( CORE::PulseGeneratorPtr newPulseGenerator ) {GUCEF_TRACE; - + MT::CScopeWriterLock lock( m_lock ); CORE::CTSGNotifier::SetPulseGenerator( newPulseGenerator ); UpdatePulseGeneratorUsage(); @@ -1547,7 +1547,7 @@ CPubSubFlowRouter::AcknowledgeReceiptForSide( CPubSubClientSide* msgReceiverSide {GUCEF_TRACE; { - // since spillover buffers are unique for a given route, garanteed by route building validation, logically only 1 thread would be + // since spillover buffers are unique for a given route, garanteed by route building validation, logically only 1 thread would be // updating the spillover info, we just need the mapping to remain in existance. // as such a read lock will suffice MT::CScopeReaderLock lock( m_lock ); @@ -1564,9 +1564,9 @@ CPubSubFlowRouter::AcknowledgeReceiptForSide( CPubSubClientSide* msgReceiverSide // If the backend does not support EOD events the message counters will be the only thing to go on if ( !spilloverInfo->endOfDataEventSupported && 0 <= spilloverInfo->spilloverIngressMsgCount ) - { + { // reset the flag to indicate whether any msgs flowed into the spillover - // this flag is used to reduce redundant spillover reconfiguration which takes time + // this flag is used to reduce redundant spillover reconfiguration which takes time spilloverInfo->msgsFlowedIntoSpillover = false; } } @@ -1621,18 +1621,18 @@ CPubSubFlowRouter::AcknowledgeReceiptForSide( CPubSubClientSide* msgReceiverSide "):AcknowledgeReceiptForSide: Unable to ack receipt of message to origin topic since no origin topic was provided on the message. Check your config and backend feature compatibility" ); return false; } - + return false; } /*-------------------------------------------------------------------------*/ -bool -CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide , +bool +CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide , const CPubSubClientTopic::TPubSubMsgsRefVector& msgs , RouteType routeType ) {GUCEF_TRACE; - + // Note that messages in a given batch, as given to the router, are assumed to all come // from the same source topic. Without this assumption we would have to sort all messages which is a big // performance hit @@ -1641,24 +1641,24 @@ CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide { fromTopic = msgs.front()->GetOriginClientTopic().GetPointerAlways(); } - + MT::CScopeReaderLock lock( m_lock ); - + bool publishIstotalSuccess = true; TSidePtrToRouteInfoVectorMap::iterator i = m_routeMap.find( fromSide ); if ( i != m_routeMap.end() ) { - TRouteInfoVector& multiRouteInfo = (*i).second; + TRouteInfoVector& multiRouteInfo = (*i).second; TRouteInfoVector::iterator n = multiRouteInfo.begin(); while ( n != multiRouteInfo.end() ) - { + { bool errorOccured = false; CPubSubClientSide* targetSide = GUCEF_NULL; CPubSubClientTopic* targetTopic = GUCEF_NULL; try - { - + { + CRouteInfo& routeInfo = (*n); // Make sure we are not in spillover egress mode @@ -1667,15 +1667,15 @@ CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide if ( !routeInfo.IsSpilloverEgressActive() ) { CRouteTopicLinks* topicLinks = GetTargetTopicLinks( fromTopic, routeInfo, errorOccured ); - + switch ( routeType ) - { - case RouteType::Active: - { - targetSide = routeInfo.activeSide; + { + case RouteType::Active: + { + targetSide = routeInfo.activeSide; if ( GUCEF_NULL != topicLinks ) { - targetTopic = topicLinks->activeTopic; + targetTopic = topicLinks->activeTopic; if ( GUCEF_NULL == targetTopic ) { // The active destination topic had potentially not yet been determined, set it now lazy init style @@ -1684,31 +1684,31 @@ CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide } } break; - } + } - case RouteType::Primary: - { - targetSide = routeInfo.toSide; + case RouteType::Primary: + { + targetSide = routeInfo.toSide; if ( GUCEF_NULL != topicLinks ) - targetTopic = topicLinks->toTopic; + targetTopic = topicLinks->toTopic; break; } - case RouteType::Failover: - { + case RouteType::Failover: + { targetSide = routeInfo.failoverSide; if ( GUCEF_NULL != topicLinks ) - targetTopic = topicLinks->failoverTopic; + targetTopic = topicLinks->failoverTopic; break; } - case RouteType::SpilloverBuffer: - { + case RouteType::SpilloverBuffer: + { targetSide = routeInfo.spilloverBufferSide; if ( GUCEF_NULL != topicLinks ) - targetTopic = topicLinks->spilloverTopic; + targetTopic = topicLinks->spilloverTopic; break; } - case RouteType::DeadLetter: - { + case RouteType::DeadLetter: + { targetSide = routeInfo.deadLetterSide; if ( GUCEF_NULL != topicLinks ) targetTopic = topicLinks->deadletterTopic; @@ -1719,7 +1719,7 @@ CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide } if ( GUCEF_NULL != targetSide && !errorOccured ) - { + { if ( targetSide->PublishMsgs( msgs, targetTopic ) ) { if ( routeInfo.spilloverBufferSide == targetSide && GUCEF_NULL != routeInfo.spilloverInfo ) @@ -1729,7 +1729,7 @@ CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide { publishIstotalSuccess = false; } - } + } else { publishIstotalSuccess = false; @@ -1775,18 +1775,18 @@ CPubSubFlowRouter::PublishMsgs( CPubSubClientSide* fromSide // no route from this side publishIstotalSuccess = false; } - + return publishIstotalSuccess; } /*-------------------------------------------------------------------------*/ -bool +bool CPubSubFlowRouter::IsTrackingInFlightPublishedMsgsForAcksNeeded( CPubSubClientSide* sideWeAskFor ) const {GUCEF_TRACE; MT::CScopeReaderLock lock( m_lock ); - + TSidePtrToRouteInfoPtrVectorMap::const_iterator i = m_usedInRouteMap.find( sideWeAskFor ); if ( i != m_usedInRouteMap.end() ) { @@ -1795,25 +1795,25 @@ CPubSubFlowRouter::IsTrackingInFlightPublishedMsgsForAcksNeeded( CPubSubClientSi while ( n != multiRouteInfo.end() ) { const CRouteInfo* routeInfo = (*n); - + // We need tracking as soon as 1 side anywhere needs a subscriber ack bool trackingNeeded = IsTrackingInFlightPublishedMsgsForAcksNeededForSide( routeInfo->toSide ) || IsTrackingInFlightPublishedMsgsForAcksNeededForSide( routeInfo->failoverSide ) || IsTrackingInFlightPublishedMsgsForAcksNeededForSide( routeInfo->deadLetterSide ) || IsTrackingInFlightPublishedMsgsForAcksNeededForSide( routeInfo->spilloverBufferSide ); - + if ( trackingNeeded ) return trackingNeeded; ++n; } } - + return false; } /*-------------------------------------------------------------------------*/ -bool +bool CPubSubFlowRouter::IsTrackingInFlightPublishedMsgsForAcksNeededForSide( const CPubSubClientSide* side ) const {GUCEF_TRACE; @@ -1828,14 +1828,14 @@ CPubSubFlowRouter::IsTrackingInFlightPublishedMsgsForAcksNeededForSide( const CP /*-------------------------------------------------------------------------*/ -bool +bool CPubSubFlowRouter::ShouldSideBeConnected( CPubSubClientSide* side ) const {GUCEF_TRACE; if ( GUCEF_NULL != side ) { MT::CScopeReaderLock lock( m_lock ); - + TSidePtrToRouteInfoPtrVectorMap::const_iterator i = m_usedInRouteMap.find( side ); if ( i != m_usedInRouteMap.end() ) { @@ -1851,12 +1851,12 @@ CPubSubFlowRouter::ShouldSideBeConnected( CPubSubClientSide* side ) const "):ShouldSideBeConnected: Determined that side \"" + side->GetSideId() + "\" should not be connected at this time due to lacking an active destination for the route" ); return false; } - + if ( routeInfo->fromSide == side && routeInfo->IsSpilloverInActiveUse() ) - { + { // For destinations we always want to be connected so they are ready for use - // for sources this is usually also true except for when a spillover is used + // for sources this is usually also true except for when a spillover is used // a spillover alters the 'from' of the route dynamically GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + "):ShouldSideBeConnected: Determined that side \"" + side->GetSideId() + "\" should not be connected at this time due to spillover activity" ); @@ -1865,19 +1865,19 @@ CPubSubFlowRouter::ShouldSideBeConnected( CPubSubClientSide* side ) const ++n; } } - + return true; } - return false; + return false; } /*-------------------------------------------------------------------------*/ -void +void CPubSubFlowRouter::RegisterSideEventHandlers( CPubSubClientSide* side ) {GUCEF_TRACE; - if ( GUCEF_NULL != side ) + if ( GUCEF_NULL != side ) { TEventCallback callback( this, &CPubSubFlowRouter::OnSideHealthStatusChange ); SubscribeTo( side , @@ -1888,27 +1888,27 @@ CPubSubFlowRouter::RegisterSideEventHandlers( CPubSubClientSide* side ) SubscribeTo( side , CPubSubClientSide::PubSubClientInstantiationEvent , callback2 ); - + CPubSubClientPtr currentClient = side->GetCurrentUnderlyingPubSubClient(); if ( !currentClient.IsNULL() ) - RegisterSidePubSubClientEventHandlers( currentClient ); + RegisterSidePubSubClientEventHandlers( currentClient ); } } /*-------------------------------------------------------------------------*/ -void +void CPubSubFlowRouter::RegisterSidePubSubClientEventHandlers( CPubSubClientPtr& client ) {GUCEF_TRACE; - if ( !client.IsNULL() ) + if ( !client.IsNULL() ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + "):RegisterSidePubSubClientEventHandlers: Hooking up event handlers for client with implementation type: " + client->GetClassTypeName() ); - + CPubSubClientFeatures clientFeatures; client->GetSupportedFeatures( clientFeatures ); - + // client and topic level subscriptions are currently only used for EOD // if we have another use-case later remove this check if ( clientFeatures.supportsSubscriptionEndOfDataEvent ) @@ -1935,13 +1935,13 @@ void CPubSubFlowRouter::RegisterSidePubSubClientTopicEventHandlers( CPubSubClientTopicBasicPtr topicAccess ) {GUCEF_TRACE; - if ( !topicAccess.IsNULL() ) + if ( !topicAccess.IsNULL() ) { TEventCallback callback( this, &CPubSubFlowRouter::OnSidePubSubClientTopicEndOfData ); SubscribeTo( topicAccess.GetPointerAlways() , CPubSubClientTopic::SubscriptionEndOfDataEvent , callback ); - + // Check init state in case we missed it before we set up the event handler if ( topicAccess->IsSubscriptionAtEndOfData() ) OnSidePubSubClientTopicEndOfData( topicAccess.GetPointerAlways() ); @@ -1954,11 +1954,11 @@ void CPubSubFlowRouter::RegisterSidePubSubClientTopicEventHandlers( CPubSubClientPtr& client ) {GUCEF_TRACE; - if ( !client.IsNULL() ) + if ( !client.IsNULL() ) { CPubSubClient::PubSubClientTopicSet topics; client->GetAllCreatedTopicAccess( topics ); - + CPubSubClient::PubSubClientTopicSet::iterator i = topics.begin(); while ( i != topics.end() ) { @@ -1979,12 +1979,12 @@ CPubSubFlowRouter::ConfigureSpillover( CPubSubClientSide* spilloverSide, bool fl CPubSubSideChannelSettingsPtr sideSettings = CPubSubSideChannelSettings::CreateSharedObjWithParam( *originalSideSettings ); // (Re)Configure for the intended flow direction - if ( flowIntoSpillover ) + if ( flowIntoSpillover ) { // Configure for ingress aka publishing sideSettings->pubsubClientConfig.desiredFeatures.supportsPublishing = true; sideSettings->pubsubClientConfig.desiredFeatures.supportsSubscribing = false; - + CPubSubClientConfig::TPubSubClientTopicConfigPtrVector& topicConfigs = sideSettings->pubsubClientConfig.topics; CPubSubClientConfig::TPubSubClientTopicConfigPtrVector::iterator t = topicConfigs.begin(); while ( t != topicConfigs.end() ) @@ -2043,7 +2043,7 @@ CPubSubFlowRouter::ConnectSide( CPubSubClientSide* sideToConnect ) if ( sideToConnect->ConnectPubSubClient( false ) ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):ConnectSide: side successfully connected: " + sideToConnect->GetSideId() ); + "):ConnectSide: side successfully connected: " + sideToConnect->GetSideId() ); return true; } else @@ -2051,16 +2051,16 @@ CPubSubFlowRouter::ConnectSide( CPubSubClientSide* sideToConnect ) if ( sideToConnect->IsPubSubClientInfraReadyToConnect() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):ConnectSide: side did not connect successfully: " + sideToConnect->GetSideId() ); + "):ConnectSide: side did not connect successfully: " + sideToConnect->GetSideId() ); return false; } else { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):ConnectSide: side is not ready to connect, need to defer for side: " + sideToConnect->GetSideId() ); + "):ConnectSide: side is not ready to connect, need to defer for side: " + sideToConnect->GetSideId() ); return false; } - } + } } return false; } @@ -2073,7 +2073,7 @@ CPubSubFlowRouter::ConnectRoutesForFromSide( CPubSubClientSide* fromSide ) if ( GUCEF_NULL == fromSide ) return false; - + bool allTargetsAreConnected = true; TSidePtrToRouteInfoVectorMap::iterator n = m_routeMap.find( fromSide ); if ( n != m_routeMap.end() ) @@ -2083,11 +2083,11 @@ CPubSubFlowRouter::ConnectRoutesForFromSide( CPubSubClientSide* fromSide ) while ( i != routes.end() ) { CRouteInfo& specificRoute = (*i); - + if ( GUCEF_NULL == specificRoute.activeSide ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):ConnectRoutesForFromSide: A route does not have an active side yet, we will have to determine it first" ); + "):ConnectRoutesForFromSide: A route does not have an active side yet, we will have to determine it first" ); DetermineActiveRouteDestination( specificRoute, true ); } @@ -2123,10 +2123,10 @@ CPubSubFlowRouter::DetermineFirstActiveRoute( CRouteInfo& routeInfo, bool attemp routeInfo.routeSwitchingTimer.SetEnabled( true ); return; } - + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + - "):DetermineFirstActiveRoute: The route has a spillover configured and this is the first active route determination. Commencing spillover egress to ensure there is no data stuck there" ); - + "):DetermineFirstActiveRoute: The route has a spillover configured and this is the first active route determination. Commencing spillover egress to ensure there is no data stuck there" ); + routeInfo.spilloverInfo->msgsFlowedIntoSpillover = true; // init state assuming msgs previously flowed into the spillover routeInfo.flowingIntoSpillover = false; // egress mode if ( !ConfigureSpillover( routeInfo.spilloverBufferSide, false, attemptConnect ) ) @@ -2164,7 +2164,7 @@ CPubSubFlowRouter::DetermineFirstActiveRoute( CRouteInfo& routeInfo, bool attemp GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + "):DetermineFirstActiveRoute: Spillover topic discovery is not supported or not configured to be used. Skipping spillover topic discovery" ); } - + // grab the spillover egress route belonging to this spillover TSidePtrToRouteInfoVectorMap::iterator i = m_routeMap.find( routeInfo.spilloverBufferSide ); if ( i != m_routeMap.end() ) @@ -2178,7 +2178,7 @@ CPubSubFlowRouter::DetermineFirstActiveRoute( CRouteInfo& routeInfo, bool attemp CRouteInfo& spilloverRoute = (*n); if ( GUCEF_NULL == spilloverRoute.activeSide ) DetermineActiveRouteDestination( spilloverRoute, attemptConnect ); - + if ( attemptConnect ) { if ( GUCEF_NULL != spilloverRoute.activeSide ) @@ -2186,8 +2186,8 @@ CPubSubFlowRouter::DetermineFirstActiveRoute( CRouteInfo& routeInfo, bool attemp if ( ConnectSide( spilloverRoute.activeSide ) ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + - "):DetermineFirstActiveRoute: The spillover destination is now connected for route \"" + routeInfo.spilloverBufferSide->GetSideId() + - "\" -> \"" + spilloverRoute.activeSide->GetSideId() + "\" for route with regular 'from' side \"" + routeInfo.fromSide->GetSideId() + "\"" ); + "):DetermineFirstActiveRoute: The spillover destination is now connected for route \"" + routeInfo.spilloverBufferSide->GetSideId() + + "\" -> \"" + spilloverRoute.activeSide->GetSideId() + "\" for route with regular 'from' side \"" + routeInfo.fromSide->GetSideId() + "\"" ); } else { @@ -2210,8 +2210,8 @@ CPubSubFlowRouter::DetermineFirstActiveRoute( CRouteInfo& routeInfo, bool attemp if ( ConnectSide( routeInfo.spilloverBufferSide ) ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + - "):DetermineFirstActiveRoute: The route is now connected and spillover egress thus commencing for spillover \"" + routeInfo.spilloverBufferSide->GetSideId() + - "\" for route with regular 'from' side \"" + routeInfo.fromSide->GetSideId() + "\"" ); + "):DetermineFirstActiveRoute: The route is now connected and spillover egress thus commencing for spillover \"" + routeInfo.spilloverBufferSide->GetSideId() + + "\" for route with regular 'from' side \"" + routeInfo.fromSide->GetSideId() + "\"" ); routeInfo.activeSide = routeInfo.spilloverBufferSide; routeInfo.activeSideType = RouteType::SpilloverBuffer; @@ -2222,7 +2222,7 @@ CPubSubFlowRouter::DetermineFirstActiveRoute( CRouteInfo& routeInfo, bool attemp { // This should not happen, mappings are incorrect GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + - "):DetermineFirstActiveRoute: Egress route for spillover not found" ); + "):DetermineFirstActiveRoute: Egress route for spillover not found" ); } routeInfo.routeSwitchingTimer.SetEnabled( true ); @@ -2235,20 +2235,20 @@ CPubSubFlowRouter::DetermineFirstActiveRoute( CRouteInfo& routeInfo, bool attemp // independently of the parent route if ( !routeInfo.isSpilloverEgressRoute ) { - // This is a regular route without any spillover functionality - + // This is a regular route without any spillover functionality + if ( attemptConnect ) { - // As such we can straightforward connect without special spillover bootstrapping - + // As such we can straightforward connect without special spillover bootstrapping + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + "):DetermineFirstActiveRoute: Commencing first route connectivity attempt for routes from side: " + routeInfo.fromSide->GetSideId() ); if ( ConnectRoutesForFromSide( routeInfo.fromSide ) ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + - "):DetermineFirstActiveRoute: The route is now connected. \"" + routeInfo.fromSide->GetSideId() + - "\" -> \"" + routeInfo.activeSide->GetSideId() + "\"" ); + "):DetermineFirstActiveRoute: The route is now connected. \"" + routeInfo.fromSide->GetSideId() + + "\" -> \"" + routeInfo.activeSide->GetSideId() + "\"" ); } else { @@ -2274,21 +2274,21 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool {GUCEF_TRACE; CORE::UInt64 primarySideHealthDurationInMs = (CORE::UInt64) routeInfo.toSideLastHealthStatusChange.GetTimeDifferenceInMillisecondsToNow(); - + // Try our primary 'to' route first // This is the normal 99% (hopefully) case - if ( GUCEF_NULL != routeInfo.toSide && - routeInfo.toSideIsHealthy && + if ( GUCEF_NULL != routeInfo.toSide && + routeInfo.toSideIsHealthy && primarySideHealthDurationInMs > m_config.minPrimarySideGoodHealthDurationBeforeActivationInMs ) - { + { if ( routeInfo.activeSide != routeInfo.toSide ) - { + { // Before (re)activating the primary route check to make sure we didnt use the spillover // if so need we need to egress those messages first before restoring the normal route if ( !routeInfo.DidMsgsFlowIntoSpillover() ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):DetermineActiveRoute: Switching active route to the Primary side. \"" + routeInfo.fromSide->GetSideId() + + "):DetermineActiveRoute: Switching active route to the Primary side. \"" + routeInfo.fromSide->GetSideId() + "\" -> \"" + routeInfo.toSide->GetSideId() + "\"" ); routeInfo.activeSide = routeInfo.toSide; @@ -2297,7 +2297,7 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool routeInfo.SwitchAllTopicLinksActiveTopic( routeInfo.activeSideType ); } else - { + { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):DetermineActiveRoute: Primary side health is restored but spillover absorbed messages. Commencing spillover egress" ); @@ -2310,7 +2310,7 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool { // rely on timer cycle to try again, nothing we can do GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):DetermineActiveRoute: Primary side health is restored and spillover absorbed messages. Failed to reconfigure spillover for egress" ); + "):DetermineActiveRoute: Primary side health is restored and spillover absorbed messages. Failed to reconfigure spillover for egress" ); routeInfo.routeSwitchingTimer.SetEnabled( true ); } } @@ -2319,7 +2319,7 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool { routeInfo.SwitchAllTopicLinksActiveTopic( routeInfo.activeSideType ); } - } + } else { // Primary 'to' route is not available @@ -2328,12 +2328,12 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool "ms ago" ); if ( primarySideHealthDurationInMs > m_config.minBadHealthDurationBeforeSpilloverInMs ) - { + { CORE::UInt64 failoverSideHealthDurationInMs = (CORE::UInt64) routeInfo.failoverSideLastHealthStatusChange.GetTimeDifferenceInMillisecondsToNow(); - + // Try the failover route if one is available - if ( GUCEF_NULL != routeInfo.failoverSide && - routeInfo.failoverSideIsHealthy && + if ( GUCEF_NULL != routeInfo.failoverSide && + routeInfo.failoverSideIsHealthy && failoverSideHealthDurationInMs > m_config.minFailoverSideGoodHealthDurationBeforeActivationInMs ) { if ( routeInfo.activeSide != routeInfo.failoverSide ) @@ -2344,18 +2344,18 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):DetermineActiveRoute: Switching active route to the Failover side" ); - + routeInfo.activeSide = routeInfo.failoverSide; routeInfo.activeSideType = RouteType::Failover; routeInfo.routeSwitchingTimer.SetEnabled( false ); routeInfo.SwitchAllTopicLinksActiveTopic( routeInfo.activeSideType ); } else - { + { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):DetermineActiveRoute: Failover side health is restored and spillover absorbed messages. Commencing spillover egress" ); - // Switch from ingress to egress + // Switch from ingress to egress if ( ConfigureSpillover( routeInfo.spilloverBufferSide, false, attemptConnect ) ) { routeInfo.flowingIntoSpillover = false; @@ -2375,15 +2375,15 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool } } else - { + { // It seems the primary and failover routes have failed us GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):DetermineActiveRoute: The Primary and Failover sides for the route are not available. Failover health status last changed " + CORE::ToString( failoverSideHealthDurationInMs ) + "ms ago" ); - + // If there is a spillover available we can try using that route as a different type of failover - if ( GUCEF_NULL != routeInfo.spilloverBufferSide && - routeInfo.spilloverBufferSideIsHealthy && + if ( GUCEF_NULL != routeInfo.spilloverBufferSide && + routeInfo.spilloverBufferSideIsHealthy && routeInfo.spilloverBufferSideLastHealthStatusChange.GetTimeDifferenceInMillisecondsToNow() > m_config.minSpilloverSideGoodHealthDurationBeforeActivationInMs ) { // At this point the spillover is healthy and the primary and failover are not @@ -2398,23 +2398,23 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):DetermineActiveRoute: Switching active route to the Spillover buffer side" ); - + routeInfo.activeSide = routeInfo.spilloverBufferSide; routeInfo.activeSideType = RouteType::SpilloverBuffer; routeInfo.routeSwitchingTimer.SetEnabled( false ); routeInfo.SwitchAllTopicLinksActiveTopic( routeInfo.activeSideType ); - // If the spillover is configured for egress instead of ingress we need to either wait of egress to finish + // If the spillover is configured for egress instead of ingress we need to either wait of egress to finish // or if its finished we need to reconfigure for ingress if ( !routeInfo.flowingIntoSpillover ) { CSpilloverInfo& spilloverInfo = m_spilloverInfoMap[ routeInfo.spilloverBufferSide ]; - - // If the spillover is performing egress we need to let it complete first + + // If the spillover is performing egress we need to let it complete first if ( !spilloverInfo.IsEgressOngoing() ) - { + { // reconfigure the spillover for data ingress - // this is an expensive operation + // this is an expensive operation GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):DetermineActiveRoute: Reconfiguring spillover side " + routeInfo.spilloverBufferSide->GetSideId() + " for data ingress" ); @@ -2441,7 +2441,7 @@ CPubSubFlowRouter::DetermineActiveRouteDestination( CRouteInfo& routeInfo, bool } } } - } + } } /*-------------------------------------------------------------------------*/ @@ -2455,7 +2455,7 @@ CPubSubFlowRouter::DetermineActiveRoutes( bool attemptConnect ) if ( !m_busyDeterminingActiveRoutes ) { m_busyDeterminingActiveRoutes = true; - + TSidePtrToRouteInfoVectorMap::iterator r = m_routeMap.begin(); while ( r != m_routeMap.end() ) { @@ -2493,12 +2493,12 @@ CPubSubFlowRouter::DetermineActiveRoute( CRouteInfo& routeInfo, bool attemptConn if ( routeInfo.IsSpilloverEgressOngoing() ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):DetermineActiveRoute: Not changing routes right now and deferring because spillover egress is ongoing" ); + "):DetermineActiveRoute: Not changing routes right now and deferring because spillover egress is ongoing" ); routeInfo.routeSwitchingTimer.SetEnabled( true ); return; } - - DetermineActiveRouteDestination( routeInfo, attemptConnect ); + + DetermineActiveRouteDestination( routeInfo, attemptConnect ); if ( attemptConnect && GUCEF_NULL != routeInfo.activeSide ) { @@ -2546,7 +2546,7 @@ CPubSubFlowRouter::UpdateRoutesBasedOnSideHealthStatus( CPubSubClientSide* side {GUCEF_TRACE; MT::CScopeWriterLock lock( m_lock ); - + TSidePtrToRouteInfoPtrVectorMap::iterator i = m_usedInRouteMap.find( side ); if ( i != m_usedInRouteMap.end() ) { @@ -2557,12 +2557,12 @@ CPubSubFlowRouter::UpdateRoutesBasedOnSideHealthStatus( CPubSubClientSide* side while ( n != multiRouteInfo.end() ) { CRouteInfo* routeInfo = (*n); - + if ( side == routeInfo->toSide ) { if ( routeInfo->toSideIsHealthy != isHealthy ) { - routeInfo->toSideIsHealthy = isHealthy; + routeInfo->toSideIsHealthy = isHealthy; routeInfo->toSideLastHealthStatusChange = CORE::CDateTime::NowUTCDateTime(); ++flagsUpdated; routeInfo->routeSwitchingTimer.SetEnabled( true ); @@ -2572,7 +2572,7 @@ CPubSubFlowRouter::UpdateRoutesBasedOnSideHealthStatus( CPubSubClientSide* side { if ( routeInfo->failoverSideIsHealthy != isHealthy ) { - routeInfo->failoverSideIsHealthy = isHealthy; + routeInfo->failoverSideIsHealthy = isHealthy; routeInfo->failoverSideLastHealthStatusChange = CORE::CDateTime::NowUTCDateTime(); ++flagsUpdated; routeInfo->routeSwitchingTimer.SetEnabled( true ); @@ -2582,7 +2582,7 @@ CPubSubFlowRouter::UpdateRoutesBasedOnSideHealthStatus( CPubSubClientSide* side { if ( routeInfo->deadLetterSideIsHealthy != isHealthy ) { - routeInfo->deadLetterSideIsHealthy = isHealthy; + routeInfo->deadLetterSideIsHealthy = isHealthy; routeInfo->deadLetterSideLastHealthStatusChange = CORE::CDateTime::NowUTCDateTime(); ++flagsUpdated; routeInfo->routeSwitchingTimer.SetEnabled( true ); @@ -2592,7 +2592,7 @@ CPubSubFlowRouter::UpdateRoutesBasedOnSideHealthStatus( CPubSubClientSide* side { if ( routeInfo->spilloverBufferSideIsHealthy != isHealthy ) { - routeInfo->spilloverBufferSideIsHealthy = isHealthy; + routeInfo->spilloverBufferSideIsHealthy = isHealthy; routeInfo->spilloverBufferSideLastHealthStatusChange = CORE::CDateTime::NowUTCDateTime(); ++flagsUpdated; routeInfo->routeSwitchingTimer.SetEnabled( true ); @@ -2605,7 +2605,7 @@ CPubSubFlowRouter::UpdateRoutesBasedOnSideHealthStatus( CPubSubClientSide* side } GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + - "):UpdateRoutesBasedOnSideHealthStatus: Updated " + CORE::ToString( multiRouteInfo.size() ) + " routes that have side \"" + + "):UpdateRoutesBasedOnSideHealthStatus: Updated " + CORE::ToString( multiRouteInfo.size() ) + " routes that have side \"" + side->GetSideId() + "\" for a total of " + CORE::ToString( flagsUpdated ) + " health status updates. Healthy=" + CORE::ToString( isHealthy ) ); } } @@ -2618,7 +2618,7 @@ CPubSubFlowRouter::OnSideHealthStatusChange( CORE::CNotifier* notifier , CORE::CICloneable* eventData ) {GUCEF_TRACE; - CPubSubClientSide* side = static_cast< CPubSubClientSide* >( notifier ); + CPubSubClientSide* side = static_cast< CPubSubClientSide* >( notifier ); CPubSubClientSide::THealthStatusChangeEventData* healthStatus = static_cast< CPubSubClientSide::THealthStatusChangeEventData* >( eventData ); if ( GUCEF_NULL == side || GUCEF_NULL == healthStatus ) @@ -2635,11 +2635,11 @@ CPubSubFlowRouter::OnSidePubSubClientTopicEndOfData( CPubSubClientTopic* topic ) if ( GUCEF_NULL == topic ) return; - + CPubSubClient* client = topic->GetClient(); if ( GUCEF_NULL == client ) return; - + CPubSubClientSide* side = static_cast< CPubSubClientSide* >( client->GetOpaqueUserData() ); if ( GUCEF_NULL == side ) return; @@ -2647,9 +2647,9 @@ CPubSubFlowRouter::OnSidePubSubClientTopicEndOfData( CPubSubClientTopic* topic ) GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):OnSidePubSubClientTopicEndOfData: Side \"" + side->GetSideId() + "\" has client of type \"" + client->GetType() + "\" which notified that topic \"" + topic->GetTopicName() + "\" has observed an 'end of data' event" ); - + MT::CScopeReaderLock readLock( m_lock ); - + // Check if this side is a spillover and in doing so get the spillover info TSidePtrToSpilloverInfoMap::iterator i = m_spilloverInfoMap.find( side ); if ( i != m_spilloverInfoMap.end() ) @@ -2666,20 +2666,20 @@ CPubSubFlowRouter::OnSidePubSubClientTopicEndOfData( CPubSubClientTopic* topic ) CSpilloverInfo& spilloverInfo = (*i).second; spilloverInfo.endOfDataEventOccured = true; - + // reset the flag to indicate whether any msgs flowed into the spillover // this flag is used to reduce redundant spillover reconfiguration which takes time spilloverInfo.msgsFlowedIntoSpillover = false; - + // Flip the spillover to ingress spilloverInfo.route->flowingIntoSpillover = true; // transition our read lock to a write lock // we want to make sure the data references we obtained above do not become invalid - MT::CScopeWriterLock writeLock( readLock ); - + MT::CScopeWriterLock writeLock( readLock ); + // if an entire client and thus a side (since its a 1:1 relationship) has reached EOD - // we check to see if we need to update the active route + // we check to see if we need to update the active route DetermineActiveRoute( *spilloverInfo.route, true ); } } @@ -2693,7 +2693,7 @@ CPubSubFlowRouter::OnSidePubSubClientTopicEndOfData( CORE::CNotifier* notifier CORE::CICloneable* eventData ) {GUCEF_TRACE; - CPubSubClientTopic* topic = static_cast< CPubSubClientTopic* >( notifier ); + CPubSubClientTopic* topic = static_cast< CPubSubClientTopic* >( notifier ); if ( GUCEF_NULL == topic ) return; OnSidePubSubClientTopicEndOfData( topic ); @@ -2707,14 +2707,14 @@ CPubSubFlowRouter::OnSidePubSubClientInstantiation( CORE::CNotifier* notifier CORE::CICloneable* eventData ) {GUCEF_TRACE; - CPubSubClientPtr* pubsubClientPtr = static_cast< CPubSubClientPtr* >( eventData ); + CPubSubClientPtr* pubsubClientPtr = static_cast< CPubSubClientPtr* >( eventData ); if ( GUCEF_NULL == pubsubClientPtr ) return; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):OnSidePubSubClientInstantiation: Adding event handlers for new pubsub client of type " + (*pubsubClientPtr)->GetType() ); - RegisterSidePubSubClientEventHandlers( *pubsubClientPtr ); + RegisterSidePubSubClientEventHandlers( *pubsubClientPtr ); } /*-------------------------------------------------------------------------*/ @@ -2734,9 +2734,9 @@ CPubSubFlowRouter::CreateNewFromTopicAssociationAsNeeded( CPubSubClientTopicBasi CPubSubClientSide* fromSide = static_cast< CPubSubClientSide* >( fromClient->GetOpaqueUserData() ); if ( GUCEF_NULL == fromSide ) return; - + MT::CScopeWriterLock writeLock( m_lock ); - + // look up the routes for which this side is the 'from' side TSidePtrToRouteInfoVectorMap::iterator r = m_routeMap.find( fromSide ); if ( r == m_routeMap.end() ) @@ -2805,23 +2805,23 @@ CPubSubFlowRouter::OnSidePubSubClientTopicCreation( CORE::CNotifier* notifier CORE::CICloneable* eventData ) {GUCEF_TRACE; - CPubSubClient* pubsubClient = static_cast< CPubSubClient* >( notifier ); + CPubSubClient* pubsubClient = static_cast< CPubSubClient* >( notifier ); if ( GUCEF_NULL == pubsubClient || GUCEF_NULL == eventData ) return; CORE::CString topicName = *static_cast< CPubSubClient::TopicAccessCreatedEventData* >( eventData ); CPubSubClientTopicBasicPtr topicAccess = pubsubClient->GetTopicAccess( topicName ); - if ( !topicAccess.IsNULL() ) + if ( !topicAccess.IsNULL() ) { // create the topic association but dont connect yet CreateNewFromTopicAssociationAsNeeded( topicAccess, false ); - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::PointerToString( this ) + "):OnSidePubSubClientTopicCreation: Adding event handlers for new topic " + topicAccess->GetTopicName() ); // hook up the event handlers that will listen to the new topic RegisterSidePubSubClientTopicEventHandlers( topicAccess ); - + // now that everything is set up confirm the active route and connect as needed DetermineActiveRoutes( true ); } @@ -2835,7 +2835,7 @@ CPubSubFlowRouter::OnSidePubSubClientTopicsAutoCreation( CORE::CNotifier* notifi CORE::CICloneable* eventData ) {GUCEF_TRACE; - CPubSubClient* pubsubClient = static_cast< CPubSubClient* >( notifier ); + CPubSubClient* pubsubClient = static_cast< CPubSubClient* >( notifier ); if ( GUCEF_NULL == pubsubClient || GUCEF_NULL == eventData ) return; @@ -2850,7 +2850,7 @@ CPubSubFlowRouter::OnSidePubSubClientTopicsAutoCreation( CORE::CNotifier* notifi { // create the topic association but dont connect yet CreateNewFromTopicAssociationAsNeeded( (*i), false ); - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "PubSubFlowRouter(" + CORE::ToString( this ) + "):OnSidePubSubClientTopicsAutoCreation: Adding event handlers for new auto created topic " + (*i)->GetTopicName() ); @@ -2867,7 +2867,7 @@ CPubSubFlowRouter::OnSidePubSubClientTopicsAutoCreation( CORE::CNotifier* notifi /*-------------------------------------------------------------------------*/ -const CString& +const CString& CPubSubFlowRouter::GetClassTypeName( void ) const {GUCEF_TRACE; diff --git a/platform/gucefVFS/src/gucefVFS_CVFS.cpp b/platform/gucefVFS/src/gucefVFS_CVFS.cpp index 6dab1b7e1..09b218fb0 100644 --- a/platform/gucefVFS/src/gucefVFS_CVFS.cpp +++ b/platform/gucefVFS/src/gucefVFS_CVFS.cpp @@ -196,7 +196,7 @@ CVFS::~CVFS() {GUCEF_TRACE; MT::CScopeWriterLock lock( m_rwdataLock ); - + UnmountAllArchives(); UnregisterAllArchiveFactories(); SignalUpcomingDestruction(); @@ -234,12 +234,12 @@ CVFS::UnmountAllArchives( void ) while ( !m_mountList.empty() ) { TMountEntry& mountEntry = *m_mountList.begin(); - TArchiveUnmountedEventData eData( mountEntry.mountPath ); + TArchiveUnmountedEventData eData( mountEntry.mountPath ); if ( mountEntry.archive->UnloadArchive() ) { m_archivePtrToMountEntryLookup.erase( mountEntry.archive.GetPointerAlways() ); m_mountList.erase( m_mountList.begin() ); - NotifyObservers( ArchiveUnmountedEvent, &eData ); + NotifyObservers( ArchiveUnmountedEvent, &eData ); } } } @@ -333,7 +333,7 @@ CVFS::OnArchiveDirectoryWatcherEvent( CORE::CNotifier* notifier , {GUCEF_TRACE; VFS::CArchive* archive = static_cast< VFS::CArchive* >( notifier ); - + if ( IsDirectoryWatcherDirEvent( eventid ) ) { MT::CScopeReaderLock lock( m_rwdataLock ); @@ -354,7 +354,7 @@ CVFS::OnArchiveDirectoryWatcherEvent( CORE::CNotifier* notifier , vfsAdjusted.GetData().newDirName = ConformVfsDirPath( vfsAdjusted.GetData().newDirName ); vfsAdjusted.GetData().oldDirName = ConformVfsDirPath( vfsAdjusted.GetData().oldDirName ); NotifyObservers( eventid, &vfsAdjusted ); - } + } } else { @@ -372,12 +372,12 @@ CVFS::OnArchiveDirectoryWatcherEvent( CORE::CNotifier* notifier , if ( IsDirectoryWatcherFileEvent( eventid ) ) { MT::CScopeReaderLock lock( m_rwdataLock ); - + TArchivePtrToMountEntryMap::iterator i = m_archivePtrToMountEntryLookup.find( archive ); if ( i != m_archivePtrToMountEntryLookup.end() ) - { + { TMountEntry* mountEntry = (*i).second; - + if ( eventid == CORE::CDirectoryWatcherEvents::FileRenamedEvent ) { CORE::CDirectoryWatcherEvents::TFileRenamedEventData* fileRenameInfo = static_cast< CORE::CDirectoryWatcherEvents::TFileRenamedEventData* >( eventdata ); @@ -399,7 +399,7 @@ CVFS::OnArchiveDirectoryWatcherEvent( CORE::CNotifier* notifier , CORE::TCloneableString vfsPath( mountEntry->mountPath + '/' + *filePath ); vfsPath = ConformVfsFilePath( vfsPath ); NotifyObservers( eventid, &vfsPath ); - } + } } } } @@ -448,7 +448,7 @@ CVFS::IsConnected( void ) const {GUCEF_TRACE; MT::CScopeReaderLock lock( m_rwdataLock ); - + bool isConnectedOverall = true; TMountVector::const_iterator i = m_mountList.begin(); while ( i != m_mountList.end() ) @@ -461,7 +461,7 @@ CVFS::IsConnected( void ) const } ++i; } - + return isConnectedOverall; } @@ -472,7 +472,7 @@ CVFS::IsHealthy( void ) const {GUCEF_TRACE; MT::CObjectScopeLock lock( this ); - + bool isHealthyOverall = true; TMountVector::const_iterator i = m_mountList.begin(); while ( i != m_mountList.end() ) @@ -485,7 +485,7 @@ CVFS::IsHealthy( void ) const } ++i; } - + return isHealthyOverall; } @@ -521,7 +521,7 @@ CVFS::MountAllDelayMountedArchives( void ) m_delayMountedArchiveSettings.erase( i ); } m_delayedArchiveMountingIsComplete = true; - + lock.EarlyUnlock(); NotifyObservers( DelayedArchiveMountingCompletedEvent ); @@ -536,20 +536,20 @@ CVFS::OnGlobalConfigLoadFinished( CORE::CNotifier* notifier , {GUCEF_TRACE; MountAllDelayMountedArchives(); - + NotifyObservers( VfsInitializationCompletedEvent ); } /*-------------------------------------------------------------------------*/ -void +void CVFS::OnAppShutdownCompleted( CORE::CNotifier* notifier , const CORE::CEvent& eventid , CORE::CICloneable* eventdata ) {GUCEF_TRACE; MT::CScopeWriterLock lock( m_rwdataLock ); - + UnmountAllArchives(); UnregisterAllArchiveFactories(); } @@ -598,18 +598,18 @@ CVFS::MoveFile( const CString& oldFilePath , CString oldPath = ConformVfsFilePath( oldFilePath ); CString newPath = ConformVfsFilePath( newFilePath ); - + if ( oldPath == newPath ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "VFS:MoveFile: old and new path are the same. No action taken. Path= " + oldPath ); return true; - } - + } + MT::CScopeReaderLock lock( m_rwdataLock ); // Get lists of all eligable mounts TConstMountLinkVector oldPathMountLinks; - GetEligableMounts( oldPath, false, oldPathMountLinks ); + GetEligableMounts( oldPath, false, oldPathMountLinks ); TConstMountLinkVector newPathMountLinks; GetEligableMounts( newPath, false, newPathMountLinks ); @@ -619,15 +619,15 @@ CVFS::MoveFile( const CString& oldFilePath , TConstMountLink& oldMountLink = (*i); TConstMountLinkVector::iterator n = newPathMountLinks.begin(); while ( n != newPathMountLinks.end() ) - { + { TConstMountLink& newMountLink = (*n); if ( oldMountLink.mountEntry == newMountLink.mountEntry ) { // Found a match where both old and new path are available via the same archive // this takes priority over any cross-archive logical 'moves' TArchivePtr archive = newMountLink.mountEntry->archive; - return archive->MoveFile( oldMountLink.remainder , - newMountLink.remainder , + return archive->MoveFile( oldMountLink.remainder , + newMountLink.remainder , overwrite ); } ++n; @@ -695,9 +695,9 @@ CVFS::CopyFileContent( const CORE::CString& originalFilepath , GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFileContent: original and target path cannot be the same: " + originalFilepath ); return false; } - + TBasicVfsResourcePtr originalFile = GetFile( originalFilepath, "rb", overwrite ); - if ( !originalFile || GUCEF_NULL == originalFile->GetAccess() || !originalFile->GetAccess()->IsValid() ) + if ( originalFile.IsNULL() || originalFile->GetAccess().IsNULL() || !originalFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFileContent: Cannot obtain original file: " + originalFilepath ); return false; @@ -705,7 +705,7 @@ CVFS::CopyFileContent( const CORE::CString& originalFilepath , UInt64 origSize = originalFile->GetAccess()->GetSize(); TBasicVfsResourcePtr targetFile = GetFile( copyFilepath, "wb", overwrite ); - if ( !targetFile || GUCEF_NULL == targetFile->GetAccess() || !targetFile->GetAccess()->IsValid() ) + if ( targetFile.IsNULL() || targetFile->GetAccess().IsNULL() || !targetFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFileContent: Cannot obtain access to output file: " + copyFilepath ); return false; @@ -728,7 +728,7 @@ CVFS::CopyFileContent( const CORE::CString& originalFilepath , } return false; } - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFileContent: Successfully copied file \"" + originalFilepath + "\" to \"" + copyFilepath + "\"" ); return true; @@ -789,9 +789,9 @@ CVFS::CopyFile( const CORE::CString& originalFilepath , GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFile: Cannot obtain meta-data on original file: " + originalFilepath ); return false; } - + TBasicVfsResourcePtr originalFile = GetFile( originalFilepath, "rb", overwrite ); - if ( !originalFile || GUCEF_NULL == originalFile->GetAccess() || !originalFile->GetAccess()->IsValid() ) + if ( originalFile.IsNULL() || originalFile->GetAccess().IsNULL() || !originalFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFile: Cannot obtain original file: " + originalFilepath ); return false; @@ -801,13 +801,13 @@ CVFS::CopyFile( const CORE::CString& originalFilepath , // where the file is created without the meta-data and then the meta-data is applied afterwards // However not all backend implementations support this so we fall back to applying the meta-data afterwards TBasicVfsResourcePtr targetFile = GetFileAs( copyFilepath, metaData, "wb", overwrite ); - if ( !targetFile || GUCEF_NULL == targetFile->GetAccess() || !targetFile->GetAccess()->IsValid() ) + if ( targetFile.IsNULL() || targetFile->GetAccess().IsNULL() || !targetFile->GetAccess()->IsValid() ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFile: Cannot obtain access to output file using source metadata as a constraint: " + copyFilepath ); // Try again without the meta-data constraint targetFile = GetFile( copyFilepath, "wb", overwrite ); - if ( !targetFile || GUCEF_NULL == targetFile->GetAccess() || !targetFile->GetAccess()->IsValid() ) + if ( targetFile.IsNULL() || targetFile->GetAccess().IsNULL() || !targetFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFile: Cannot obtain access to output file: " + copyFilepath ); return false; @@ -844,7 +844,7 @@ CVFS::CopyFile( const CORE::CString& originalFilepath , GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFile: Could not apply meta-data to copied file \"" + copyFilepath + "\" using info from \"" + originalFilepath + "\". File content is copied but meta-data will differ" ); } - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "VFS:CopyFile: Successfully copied file \"" + originalFilepath + "\" to \"" + copyFilepath + "\"" ); return true; @@ -910,14 +910,14 @@ CVFS::EncodeFile( const CORE::CString& originalFilepath , } TBasicVfsResourcePtr originalFile = GetFile( originalFilepath, "rb", overwrite ); - if ( !originalFile || GUCEF_NULL == originalFile->GetAccess() || !originalFile->GetAccess()->IsValid() ) + if ( originalFile.IsNULL() || originalFile->GetAccess().IsNULL() || !originalFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:EncodeFile: Cannot obtain original file: " + originalFilepath ); return false; } TBasicVfsResourcePtr targetFile = GetFile( encodedFilepath, "wb", overwrite ); - if ( !targetFile || GUCEF_NULL == targetFile->GetAccess() || !targetFile->GetAccess()->IsValid() ) + if ( targetFile.IsNULL() || targetFile->GetAccess().IsNULL() || !targetFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:EncodeFile: Cannot obtain access to output file: " + encodedFilepath ); return false; @@ -993,7 +993,7 @@ CVFS::DecodeAsFile( CORE::CDynamicBuffer& decodedOutput , } TBasicVfsResourcePtr sourceFile = GetFile( encodedFilePath, "rb", false ); - if ( !sourceFile || GUCEF_NULL == sourceFile->GetAccess() || !sourceFile->GetAccess()->IsValid() ) + if ( sourceFile.IsNULL() || sourceFile->GetAccess().IsNULL() || !sourceFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:DecodeAsFile: Cannot obtain access to output file: " + encodedFilePath ); return false; @@ -1041,7 +1041,7 @@ CVFS::EncodeAsFile( const CORE::CDynamicBuffer& data , } TBasicVfsResourcePtr targetFile = GetFile( encodedFilepath, "wb", overwrite ); - if ( !targetFile || GUCEF_NULL == targetFile->GetAccess() || !targetFile->GetAccess()->IsValid() ) + if ( targetFile.IsNULL() || targetFile->GetAccess().IsNULL() || !targetFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:EncodeAsFile: Cannot obtain access to output file: " + encodedFilepath ); return false; @@ -1061,7 +1061,7 @@ CVFS::EncodeAsFile( const CORE::CDynamicBuffer& data , GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "VFS:DecodeFile: Successfully encoded buffer using codec \"" + encodeCodec + "\" from codec family \"" + codecFamily + "\"" ); - + return true; } @@ -1170,14 +1170,14 @@ CVFS::DecodeFile( const CORE::CString& originalFilepath , } TBasicVfsResourcePtr originalFile = GetFile( originalFilepath, "rb", overwrite ); - if ( !originalFile || GUCEF_NULL == originalFile->GetAccess() || !originalFile->GetAccess()->IsValid() ) + if ( originalFile.IsNULL() || originalFile->GetAccess().IsNULL() || !originalFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:DecodeFile: Cannot obtain original file: " + originalFilepath ); return false; } TBasicVfsResourcePtr targetFile = GetFile( decodedFilepath, "wb", overwrite ); - if ( !targetFile || GUCEF_NULL == targetFile->GetAccess() || !targetFile->GetAccess()->IsValid() ) + if ( targetFile.IsNULL() || targetFile->GetAccess().IsNULL() || !targetFile->GetAccess()->IsValid() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:DecodeFile: Cannot obtain access to output file: " + decodedFilepath ); return false; @@ -1401,7 +1401,7 @@ CVFS::LoadFile( CORE::CDynamicBuffer& destinationBuffer , // First load the file as a VFS reference as usual TBasicVfsResourcePtr fileReference = GetFile( filePath, mode, false ); - if ( fileReference.IsNULL() || GUCEF_NULL == fileReference->GetAccess() ) + if ( fileReference.IsNULL() || fileReference->GetAccess().IsNULL() ) return false; // load the data from whatever abstracted vfs medium into memory @@ -1419,10 +1419,10 @@ CVFS::LoadFile( CORE::CDataNode& destination , const CORE::CString& codecToUse ) {GUCEF_TRACE; - + CORE::CString actualCodecToUse = codecToUse; if ( actualCodecToUse.IsNULLOrEmpty() ) - actualCodecToUse = CORE::ExtractFileExtention( filePath ); + actualCodecToUse = CORE::ExtractFileExtention( filePath ); if ( actualCodecToUse.IsNULLOrEmpty() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "Vfs:LoadFile: No codec type name or file extension provided for file: " + filePath ); @@ -1431,9 +1431,9 @@ CVFS::LoadFile( CORE::CDataNode& destination , // First load the file as a VFS reference as usual TBasicVfsResourcePtr fileReference = GetFile( filePath, "rb", false ); - if ( !fileReference || GUCEF_NULL == fileReference->GetAccess() ) + if ( fileReference.IsNULL() || fileReference->GetAccess().IsNULL() ) return false; - + // Now obtain the codec CORE::CDStoreCodecRegistry& codecRegistry = CORE::CCoreGlobal::Instance()->GetDStoreCodecRegistry(); CORE::CDStoreCodecRegistry::TDStoreCodecPtr codec; @@ -1441,7 +1441,7 @@ CVFS::LoadFile( CORE::CDataNode& destination , { // Now pass the I/O access to the codec CORE::IOAccessPtr accessPtr = fileReference->GetAccess(); - if ( codec->BuildDataTree( &destination, accessPtr.GetPointerAlways() ) ) + if ( codec->BuildDataTree( &destination, accessPtr.GetPointerAlways() ) ) { return true; } @@ -1636,7 +1636,7 @@ CVFS::MountArchive( const CArchiveSettings& settings ) } else { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:MountArchive: Failed to load archive of type \"" + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VFS:MountArchive: Failed to load archive of type \"" + settings.GetArchiveType() + "\" which was to be mounted at path: " + updatedSettings.GetMountPath() ); } } @@ -1805,7 +1805,7 @@ CVFS::GetActualFilePath( const CString& file , {GUCEF_TRACE; CString filePath = ConformVfsFilePath( file ); - + MT::CScopeReaderLock lock( m_rwdataLock ); // Get a list of all eligable mounts @@ -1871,7 +1871,7 @@ CVFS::GetVfsPathForAbsolutePath( const CString& absolutePath , /*-------------------------------------------------------------------------*/ -bool +bool CVFS::DirExists( const CString& dirPath ) const {GUCEF_TRACE; @@ -1967,13 +1967,13 @@ CVFS::UnmountArchiveByName( const CString& archiveName ) { if ( mountEntry.archive->UnloadArchive() ) { - TArchiveUnmountedEventData eData( mountEntry.mountPath ); + TArchiveUnmountedEventData eData( mountEntry.mountPath ); m_archivePtrToMountEntryLookup.erase( mountEntry.archive.GetPointerAlways() ); m_mountList.erase( i ); lock.EarlyUnlock(); - NotifyObservers( ArchiveUnmountedEvent, &eData ); + NotifyObservers( ArchiveUnmountedEvent, &eData ); return true; } return false; @@ -2083,10 +2083,10 @@ CVFS::LoadVfsSystemConfig( const CORE::CDataNode& cfg ) m_maxmemloadsize = cfg.GetAttributeValueOrChildValueByName( "maxmemload" ).AsUInt32( m_maxmemloadsize, true ); m_asyncOpsThreadpool = cfg.GetAttributeValueOrChildValueByName( "asyncOpsThreadpool" ).AsString( m_asyncOpsThreadpool, true ); - m_asyncOpsMinWorkerThreads = cfg.GetAttributeValueOrChildValueByName( "asyncOpsMinWorkerThreads" ).AsUInt32( m_asyncOpsMinWorkerThreads, true ); + m_asyncOpsMinWorkerThreads = cfg.GetAttributeValueOrChildValueByName( "asyncOpsMinWorkerThreads" ).AsUInt32( m_asyncOpsMinWorkerThreads, true ); CORE::ThreadPoolPtr threadPool = CORE::CCoreGlobal::Instance()->GetTaskManager().GetOrCreateThreadPool( m_asyncOpsThreadpool ); - threadPool->SetDesiredMinNrOfWorkerThreads( m_asyncOpsMinWorkerThreads ); + threadPool->SetDesiredMinNrOfWorkerThreads( m_asyncOpsMinWorkerThreads ); return true; } @@ -2098,7 +2098,7 @@ CVFS::LoadConfig( const CORE::CDataNode& tree ) {GUCEF_TRACE; MT::CScopeWriterLock lock( m_rwdataLock ); - + bool globalConfigLoadInProgress = IsGlobalConfigLoadInProgress(); const CORE::CDataNode* n = tree.Search( "GUCEF%VFS%CVFS" , '%' , @@ -2107,7 +2107,7 @@ CVFS::LoadConfig( const CORE::CDataNode& tree ) if ( GUCEF_NULL != n ) { LoadVfsSystemConfig( *n ); - + CORE::CDataNode::TConstDataNodeSet rootNodeList = n->FindChildrenOfType( "VfsRoot" ); CORE::CDataNode::TConstDataNodeSet::iterator i = rootNodeList.begin(); while( i != rootNodeList.end() ) @@ -2129,7 +2129,7 @@ CVFS::LoadConfig( const CORE::CDataNode& tree ) if ( GUCEF_NULL != n ) { LoadVfsSystemConfig( *n ); - + CORE::CDataNode::TConstDataNodeSet rootNodeList = n->FindChildrenOfType( "ArchiveSettings", false, false ); CORE::CDataNode::TConstDataNodeSet::iterator i = rootNodeList.begin(); while( i != rootNodeList.end() ) @@ -2210,7 +2210,7 @@ CVFS::FilterValidation( const CORE::CString& filename , } return true; } - + // no filter passed means no filtering should be applied return true; } @@ -2226,7 +2226,7 @@ CVFS::FilterValidation( const CORE::CString& filename , { CORE::CString::StringSet::const_iterator i = filters.begin(); while ( i != filters.end() ) - { + { // we just need to match 1 of the filters passed if ( FilterValidation( filename, (*i) ) ) return true; @@ -2235,7 +2235,7 @@ CVFS::FilterValidation( const CORE::CString& filename , } return false; } - + // no filters passed means no filtering should be applied return true; } @@ -2308,7 +2308,7 @@ CVFS::GetEligableMounts( const CString& location , bool CVFS::GetFileList( TStringVector& outputList , - const CString& location , + const CString& location , bool recursive , bool includePathInFilename , const CString& nameFilter , @@ -2319,7 +2319,7 @@ CVFS::GetFileList( TStringVector& outputList , if ( !nameFilter.IsNULLOrEmpty() ) filters.insert( nameFilter ); - return GetFileList( outputList , + return GetFileList( outputList , location , recursive , includePathInFilename , @@ -2331,7 +2331,7 @@ CVFS::GetFileList( TStringVector& outputList , bool CVFS::GetFileList( TStringVector& outputList , - const CString& location , + const CString& location , bool recursive , bool includePathInFilename , const CString::StringSet& nameFilters , @@ -2340,7 +2340,7 @@ CVFS::GetFileList( TStringVector& outputList , bool totalSuccess = true; CString path = ConformVfsDirPath( location ); - + MT::CScopeReaderLock lock( m_rwdataLock ); // Get a list of all eligable mounts @@ -2379,7 +2379,7 @@ CVFS::GetDirList( TStringVector& outputList , CORE::CString::StringSet filters; filters.insert( nameFilter ); - return GetDirList( outputList , + return GetDirList( outputList , location , recursive , includePathInFilename , @@ -2660,7 +2660,7 @@ CVFS::AddDirToWatch( const CString& dirToWatch , totalSuccess = false; ++i; } - + return totalSuccess; } @@ -2690,7 +2690,7 @@ CVFS::RemoveDirToWatch( const CString& dirToWatch ) totalSuccess = false; ++i; } - + return totalSuccess; } @@ -2701,7 +2701,7 @@ CVFS::RemoveAllWatches( void ) {GUCEF_TRACE; MT::CScopeReaderLock lock( m_rwdataLock ); - + bool totalSuccess = true; TMountVector::iterator i = m_mountList.begin(); while ( i != m_mountList.end() ) @@ -2711,7 +2711,7 @@ CVFS::RemoveAllWatches( void ) totalSuccess = false; ++i; } - + return totalSuccess; } @@ -2722,7 +2722,7 @@ CVFS::GetAllWatchedDirs( CString::StringSet& dirs ) const {GUCEF_TRACE; MT::CScopeReaderLock lock( m_rwdataLock ); - + bool totalSuccess = true; TMountVector::const_iterator i = m_mountList.begin(); while ( i != m_mountList.end() ) @@ -2745,7 +2745,7 @@ CVFS::GetAllWatchedDirs( CString::StringSet& dirs ) const totalSuccess = false; ++i; } - + return totalSuccess; } diff --git a/platform/gucefWEB/src/gucefWEB_CAsyncHttpServerRequestHandler.cpp b/platform/gucefWEB/src/gucefWEB_CAsyncHttpServerRequestHandler.cpp index 31666140e..21090a0b8 100644 --- a/platform/gucefWEB/src/gucefWEB_CAsyncHttpServerRequestHandler.cpp +++ b/platform/gucefWEB/src/gucefWEB_CAsyncHttpServerRequestHandler.cpp @@ -1,5 +1,5 @@ /* - * gucefWEB: GUCEF module providing Web application functionality + * gucefWEB: GUCEF module providing Web application functionality * for standardized protocols * * Copyright (C) 1998 - 2020. Dinand Vanvelzen @@ -24,7 +24,7 @@ //-------------------------------------------------------------------------*/ #include -#include +#include #ifndef GUCEF_CORE_CTASKMANAGER_H #include "gucefCORE_CTaskManager.h" @@ -101,8 +101,8 @@ CAsyncHttpRequestData::~CAsyncHttpRequestData() /*-------------------------------------------------------------------------*/ -CORE::CICloneable* -CAsyncHttpRequestData::Clone( void ) const +CORE::CICloneable* +CAsyncHttpRequestData::Clone( void ) const {GUCEF_TRACE; return GUCEF_NEW CAsyncHttpRequestData( *this ); @@ -110,7 +110,7 @@ CAsyncHttpRequestData::Clone( void ) const /*-------------------------------------------------------------------------*/ -void +void CAsyncHttpServerRequestHandler::RegisterEvents( void ) {GUCEF_TRACE; @@ -120,7 +120,7 @@ CAsyncHttpServerRequestHandler::RegisterEvents( void ) /*-------------------------------------------------------------------------*/ CAsyncHttpServerRequestHandler::CAsyncHttpServerRequestHandler( void ) - : CORE::CTaskConsumer() + : CORE::CTaskConsumer() , m_requestHandler() {GUCEF_TRACE; @@ -187,7 +187,7 @@ CAsyncHttpServerRequestHandler::OnTaskCycle( CORE::CICloneable* taskData ) return true; } - if ( GUCEF_NULL == m_requestHandler ) + if ( m_requestHandler.IsNULL() ) { m_requestHandler = httpRequestData->httpServer->GetRequestHandlerFactory()->Create(); if ( m_requestHandler.IsNULL() ) @@ -196,11 +196,11 @@ CAsyncHttpServerRequestHandler::OnTaskCycle( CORE::CICloneable* taskData ) CAsyncHttpResponseData* response = GUCEF_NEW CAsyncHttpResponseData( httpRequestData ); m_requestHandler->OnRequest( *httpRequestData, *response ); - - if ( !CORE::CCoreGlobal::Instance()->GetTaskManager().GetThreadPool()->QueueTask( CAsyncHttpServerResponseHandler::TaskType, - response, - GUCEF_NULL, - GUCEF_NULL, + + if ( !CORE::CCoreGlobal::Instance()->GetTaskManager().GetThreadPool()->QueueTask( CAsyncHttpServerResponseHandler::TaskType, + response, + GUCEF_NULL, + GUCEF_NULL, true ) ) { // Failed to queue task to send the response to the client diff --git a/platform/gucefWEB/src/gucefWEB_CHTTPServer.cpp b/platform/gucefWEB/src/gucefWEB_CHTTPServer.cpp index a66d939c4..a12960111 100644 --- a/platform/gucefWEB/src/gucefWEB_CHTTPServer.cpp +++ b/platform/gucefWEB/src/gucefWEB_CHTTPServer.cpp @@ -1,5 +1,5 @@ /* - * gucefWEB: GUCEF module providing Web application functionality + * gucefWEB: GUCEF module providing Web application functionality * for standardized protocols * * Copyright (C) 1998 - 2020. Dinand Vanvelzen @@ -125,7 +125,7 @@ CHttpServerSettings::CHttpServerSettings( const CHttpServerSettings& src ) /*-------------------------------------------------------------------------*/ -CHttpServerSettings& +CHttpServerSettings& CHttpServerSettings::operator=( const CHttpServerSettings& src ) {GUCEF_TRACE; @@ -146,19 +146,19 @@ CHttpServerSettings::~CHttpServerSettings() {GUCEF_TRACE; } - + /*-------------------------------------------------------------------------*/ bool CHttpServerSettings::SaveConfig( CORE::CDataNode& cfg ) const {GUCEF_TRACE; - bool totalSuccess = true; + bool totalSuccess = true; totalSuccess = cfg.SetAttribute( "maxClientConnections", maxClientConnections ) && totalSuccess; totalSuccess = cfg.SetAttribute( "keepAliveConnections", keepAliveConnections ) && totalSuccess; totalSuccess = cfg.SetAttribute( "processRequestsAsync", processRequestsAsync ) && totalSuccess; totalSuccess = cfg.SetAttribute( "allowWebSocketUpgrades", allowWebSocketUpgrades ) && totalSuccess; - return totalSuccess; + return totalSuccess; } /*-------------------------------------------------------------------------*/ @@ -167,8 +167,8 @@ bool CHttpServerSettings::LoadConfig( const CORE::CDataNode& cfg ) {GUCEF_TRACE; - maxClientConnections = cfg.GetAttributeValueOrChildValueByName( "maxClientConnections" ).AsUInt32( maxClientConnections, true ); - keepAliveConnections = cfg.GetAttributeValueOrChildValueByName( "keepAliveConnections" ).AsBool( keepAliveConnections, true ); + maxClientConnections = cfg.GetAttributeValueOrChildValueByName( "maxClientConnections" ).AsUInt32( maxClientConnections, true ); + keepAliveConnections = cfg.GetAttributeValueOrChildValueByName( "keepAliveConnections" ).AsBool( keepAliveConnections, true ); processRequestsAsync = cfg.GetAttributeValueOrChildValueByName( "processRequestsAsync" ).AsBool( processRequestsAsync, true ); allowWebSocketUpgrades = cfg.GetAttributeValueOrChildValueByName( "allowWebSocketUpgrades" ).AsBool( allowWebSocketUpgrades, true ); @@ -177,7 +177,7 @@ CHttpServerSettings::LoadConfig( const CORE::CDataNode& cfg ) /*-------------------------------------------------------------------------*/ -const CString& +const CString& CHttpServerSettings::GetClassTypeName( void ) const {GUCEF_TRACE; @@ -188,7 +188,7 @@ CHttpServerSettings::GetClassTypeName( void ) const CHTTPServer::CHTTPServer( THttpServerRequestHandlerFactory* requestHandlerFactory /* = GUCEF_NULL */ , const CHttpServerSettings* settings /* = GUCEF_NULL */ ) - : CORE::CObservingNotifier() + : CORE::CObservingNotifier() , m_tcpServerSocket( false, GUCEF_NULL != settings ? settings->maxClientConnections : 100 ) , m_requestHandler() , m_requestHandlerFactory( requestHandlerFactory ) @@ -216,8 +216,8 @@ CHTTPServer::CHTTPServer( THttpServerRequestHandlerFactory* requestHandlerFactor CHTTPServer::CHTTPServer( const CORE::PulseGeneratorPtr& pulsGenerator , THttpServerRequestHandlerFactory* requestHandlerFactory /* = GUCEF_NULL */ , const CHttpServerSettings* settings /* = GUCEF_NULL */ ) - : CORE::CObservingNotifier() - , m_tcpServerSocket( pulsGenerator, false, GUCEF_NULL != settings ? settings->maxClientConnections : 100 ) + : CORE::CObservingNotifier() + , m_tcpServerSocket( pulsGenerator, false, GUCEF_NULL != settings ? settings->maxClientConnections : 100 ) , m_requestHandler() , m_requestHandlerFactory( requestHandlerFactory ) , m_settings() @@ -245,7 +245,7 @@ CHTTPServer::~CHTTPServer() {GUCEF_TRACE; MT::CScopeMutex lock( m_lock ); - + SignalUpcomingObserverDestruction(); m_requestHandler.Unlink(); } @@ -294,7 +294,7 @@ CHTTPServer::GetRequestHandler( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CHTTPServer::IsActive( void ) const {GUCEF_TRACE; @@ -312,7 +312,7 @@ CHTTPServer::ListenOnPort( const UInt16 port ) /*-------------------------------------------------------------------------*/ -bool +bool CHTTPServer::Listen( void ) {GUCEF_TRACE; @@ -330,10 +330,10 @@ CHTTPServer::Close( void ) /*-------------------------------------------------------------------------*/ -bool +bool CHTTPServer::SetPort( UInt16 port ) {GUCEF_TRACE; - + return m_tcpServerSocket.SetPort( port ); } @@ -449,7 +449,7 @@ CHTTPServer::InitSha1CodecLink( void ) if ( m_sha1Codec.IsNULL() ) { CORE::CCodecRegistry& codecRegistry = CORE::CCoreGlobal::Instance()->GetCodecRegistry(); - + // First obtain the registery specific to compression codecs CORE::CCodecRegistry::TCodecFamilyRegistryPtr codecFamilyRegistry; if ( codecRegistry.TryLookup( CORE::CoreCodecTypes::CryptographicHashCodec, codecFamilyRegistry, false ) && codecFamilyRegistry ) @@ -480,7 +480,7 @@ CHTTPServer::GenerateWebSocketResponseKey( const CORE::CString& clientKey ) if ( !m_sha1Codec.IsNULL() ) { CORE::CString sanityCheckKey = clientKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - CORE::CDynamicBuffer inBuffer; inBuffer.LinkTo( sanityCheckKey ); + CORE::CDynamicBuffer inBuffer; inBuffer.LinkTo( sanityCheckKey ); CORE::CDynamicBufferAccess inBufferAccess( inBuffer ); CORE::CDynamicBuffer outBuffer( true ); @@ -505,20 +505,20 @@ CHTTPServer::OnWebSocketUpgrade( COMCORE::CTCPServerConnection* connection , { CHttpResponseData response; response.statusCode = 403; // Forbidden - + CORE::CDynamicBuffer responseBuffer; response.Serialize( responseBuffer ); connection->Send( responseBuffer ); connection->Close(); - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "HttpServer(" + CORE::ToString( this ) + "):OnWebSocketUpgrade: Client attempted websocket upgrade. This feature is disabled" ); return; - } - + } + CHttpRequestData::TStringMap::const_iterator versionHeader = requestData.otherHeaders.find( "sec-websocket-version" ); CHttpRequestData::TStringMap::const_iterator connectionHeader = requestData.otherHeaders.find( "connection" ); CHttpRequestData::TStringMap::const_iterator sanityCheckKeyHeader = requestData.otherHeaders.find( "sec-websocket-key" ); - + // In the case of a websocket upgrade request perform additional sanity check // We want a well formed request if ( versionHeader == requestData.otherHeaders.end() || @@ -527,12 +527,12 @@ CHTTPServer::OnWebSocketUpgrade( COMCORE::CTCPServerConnection* connection , { CHttpResponseData response; response.statusCode = 400; // Bad Request - missing headers - + CORE::CDynamicBuffer responseBuffer; response.Serialize( responseBuffer ); connection->Send( responseBuffer ); connection->Close(); - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "HttpServer(" + CORE::ToString( this ) + "):OnWebSocketUpgrade: Client attempted websocket upgrade without all the mandatory headers" ); return; } @@ -541,7 +541,7 @@ CHTTPServer::OnWebSocketUpgrade( COMCORE::CTCPServerConnection* connection , { CHttpResponseData response; response.statusCode = 400; // Bad Request - malformed, mandatory partner header - + CORE::CDynamicBuffer responseBuffer; response.Serialize( responseBuffer ); connection->Send( responseBuffer ); @@ -583,7 +583,7 @@ CHTTPServer::OnWebSocketUpgrade( COMCORE::CTCPServerConnection* connection , GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "HttpServer(" + CORE::ToString( this ) + "):OnWebSocketUpgrade: Cannot perform websocket upgrade: No SHA1 codec is available" ); return; } - + // We are accepting the web socket upgrade. Notify as such CHttpResponseData response; response.statusCode = 101; // Switching Protocols @@ -616,7 +616,7 @@ CHTTPServer::ASyncProcessReceivedData( COMCORE::CTCPServerConnection* connection OnWebSocketUpgrade( connection, requestData ); return; } - + requestData.clientConnectionId = connection->GetConnectionIndex(); requestData.remoteClientAddress = connection->GetRemoteHostAddress().GetFirstIPv4Address(); requestData.keepConnectionsAlive = m_settings.keepAliveConnections; @@ -634,7 +634,7 @@ CHTTPServer::ASyncProcessReceivedData( COMCORE::CTCPServerConnection* connection // directly GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPServer(" + CORE::PointerToString( this ) + "): Unable to ASync queue the request processing (QueueTask failed). As such will respond with 503" ); - + CHttpResponseData returnData; returnData.statusCode = 503; // Send 'Server too busy' because this is per configured capacity constraints @@ -656,7 +656,7 @@ CHTTPServer::SyncProcessReceivedData( COMCORE::CTCPServerConnection* connection try { - CHttpRequestData requestData; + CHttpRequestData requestData; if ( !ParseRequest( inputBuffer, requestData ) ) return; @@ -674,17 +674,17 @@ CHTTPServer::SyncProcessReceivedData( COMCORE::CTCPServerConnection* connection connection->Send( outputBuffer ); if ( !m_settings.keepAliveConnections ) - connection->Close(); + connection->Close(); } catch ( const std::exception& e ) { GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPServer(" + CORE::PointerToString( this ) + "): Exception sync processing received data: " + CORE::CString( e.what() ) ); - + try { // Inform the client we ran into an internal server error so they are not just sitting there waiting for a response CHttpResponseData returnData; - returnData.statusCode = 500; + returnData.statusCode = 500; CORE::CDynamicBuffer outputBuffer; returnData.Serialize( outputBuffer ); @@ -692,7 +692,7 @@ CHTTPServer::SyncProcessReceivedData( COMCORE::CTCPServerConnection* connection if ( !m_settings.keepAliveConnections ) { - try + try { connection->Close(); } @@ -833,7 +833,7 @@ CHTTPServer::ParseRequest( const CORE::CDynamicBuffer& inputBuffer , request.requestUriParams = request.requestUri.SubstrToChar( '?', false, true ); temp = temp.CutChars( request.requestUri.Length()+1, true ); if ( !request.requestUriParams.IsNULLOrEmpty() ) - request.requestUri = request.requestUri.CutChars( request.requestUriParams.Length()+1, false, 0 ); + request.requestUri = request.requestUri.CutChars( request.requestUriParams.Length()+1, false, 0 ); // Parse the request protocol and its version request.requestProtocol = temp.SubstrToChar( '/', true ); @@ -894,7 +894,7 @@ CHTTPServer::ParseRequest( const CORE::CDynamicBuffer& inputBuffer , if ( headerName == "upgrade" ) { request.isWebSocketUpgrade = "websocket" == headerValue; - } + } else { request.otherHeaders[ headerName ] = headerValue; @@ -919,30 +919,30 @@ CHTTPServer::ParseRequest( const CORE::CDynamicBuffer& inputBuffer , } /*-------------------------------------------------------------------------*/ - + MT::TLockStatus CHTTPServer::Lock( UInt32 lockWaitTimeoutInMs ) const {GUCEF_TRACE; - + return m_lock.Lock( lockWaitTimeoutInMs ); } /*-------------------------------------------------------------------------*/ - + MT::TLockStatus CHTTPServer::Unlock( void ) const {GUCEF_TRACE; - + return m_lock.Unlock(); } /*-------------------------------------------------------------------------*/ -CIHTTPServerRouterController* +CIHTTPServerRouterController* CHTTPServer::GetRouterController( void ) const {GUCEF_TRACE; - if ( GUCEF_NULL != m_requestHandler ) + if ( !m_requestHandler.IsNULL() ) { return m_requestHandler->GetRouterController(); } @@ -960,13 +960,13 @@ CHTTPServer::GetRequestHandlerFactory( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CHTTPServer::SendResponseASync( UInt32 connectionId , const CORE::CDynamicBuffer& response , const COMCORE::CIPv4Address& remoteIP ) {GUCEF_TRACE; - return m_tcpServerSocket.SendToConnection( connectionId , + return m_tcpServerSocket.SendToConnection( connectionId , response.GetConstBufferPtr() , response.GetDataSize() , &remoteIP ); diff --git a/plugins/COMCORE/comcorepluginDBL/src/comcorepluginDBL_CDBLNetworkInterface.cpp b/plugins/COMCORE/comcorepluginDBL/src/comcorepluginDBL_CDBLNetworkInterface.cpp index e4b67e524..94f6d7a68 100644 --- a/plugins/COMCORE/comcorepluginDBL/src/comcorepluginDBL_CDBLNetworkInterface.cpp +++ b/plugins/COMCORE/comcorepluginDBL/src/comcorepluginDBL_CDBLNetworkInterface.cpp @@ -71,7 +71,7 @@ namespace DBL { //-------------------------------------------------------------------------*/ bool -CDBLNetworkInterface::SetupAdapterInfo( void* pAdaptInfoVoid ) +CDBLNetworkInterface::SetupAdapterInfo( void* pAdaptInfoVoid ) { @@ -80,9 +80,9 @@ CDBLNetworkInterface::SetupAdapterInfo( void* pAdaptInfoVoid ) /*-------------------------------------------------------------------------*/ -bool -CDBLNetworkInterface::EnumNetworkAdapters( TINetworkInterfacePtrVector& interfaces ) -{ +bool +CDBLNetworkInterface::EnumNetworkAdapters( TINetworkInterfacePtrVector& interfaces ) +{ return true; } @@ -93,11 +93,11 @@ CDBLNetworkInterface::CDBLNetworkInterface( void ) : CINetworkInterface() , m_dataLock() {GUCEF_TRACE; - + } /*-------------------------------------------------------------------------*/ - + CDBLNetworkInterface::~CDBLNetworkInterface() {GUCEF_TRACE; @@ -109,12 +109,12 @@ const CORE::CString& CDBLNetworkInterface::GetClassTypeName( void ) const {GUCEF_TRACE; - static const CORE::CString classTypeName = "GUCEF::COMCOREPLUGIN::DBL::::CDBLNetworkInterface"; + static const CORE::CString classTypeName = "GUCEF::COMCOREPLUGIN::DBL::::CDBLNetworkInterface"; return classTypeName; } /*-------------------------------------------------------------------------*/ - + CORE::CString CDBLNetworkInterface::GetCommunicationInterfaceType( void ) const {GUCEF_TRACE; @@ -124,7 +124,7 @@ CDBLNetworkInterface::GetCommunicationInterfaceType( void ) const /*-------------------------------------------------------------------------*/ -CORE::CString +CORE::CString CDBLNetworkInterface::GetAdapterName( void ) const {GUCEF_TRACE; @@ -134,7 +134,7 @@ CDBLNetworkInterface::GetAdapterName( void ) const /*-------------------------------------------------------------------------*/ -CORE::CString +CORE::CString CDBLNetworkInterface::GetAdapterDescription( void ) const {GUCEF_TRACE; @@ -144,7 +144,7 @@ CDBLNetworkInterface::GetAdapterDescription( void ) const /*-------------------------------------------------------------------------*/ -UInt32 +UInt32 CDBLNetworkInterface::GetNrOfDnsAddresses( void ) const {GUCEF_TRACE; @@ -153,8 +153,8 @@ CDBLNetworkInterface::GetNrOfDnsAddresses( void ) const } /*-------------------------------------------------------------------------*/ - -bool + +bool CDBLNetworkInterface::GetDnsAddresses( THostAddressVector& dnsAddresses ) {GUCEF_TRACE; @@ -164,7 +164,7 @@ CDBLNetworkInterface::GetDnsAddresses( THostAddressVector& dnsAddresses ) /*-------------------------------------------------------------------------*/ -UInt32 +UInt32 CDBLNetworkInterface::GetNrOfIPAddresses( void ) const {GUCEF_TRACE; @@ -174,7 +174,7 @@ CDBLNetworkInterface::GetNrOfIPAddresses( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CDBLNetworkInterface::GetIPInfo( TIPInfoVector& ipInfo, bool includeUninitialized ) const {GUCEF_TRACE; @@ -183,8 +183,8 @@ CDBLNetworkInterface::GetIPInfo( TIPInfoVector& ipInfo, bool includeUninitialize } /*-------------------------------------------------------------------------*/ - -bool + +bool CDBLNetworkInterface::IsDhcpUsed( void ) const {GUCEF_TRACE; @@ -194,7 +194,7 @@ CDBLNetworkInterface::IsDhcpUsed( void ) const /*-------------------------------------------------------------------------*/ -CORE::CDateTime +CORE::CDateTime CDBLNetworkInterface::GetDhcpLeaseObtainedTime( void ) const {GUCEF_TRACE; @@ -205,7 +205,7 @@ CDBLNetworkInterface::GetDhcpLeaseObtainedTime( void ) const /*-------------------------------------------------------------------------*/ -CORE::CDateTime +CORE::CDateTime CDBLNetworkInterface::GetDhcpLeaseExpirationTime( void ) const {GUCEF_TRACE; @@ -216,7 +216,7 @@ CDBLNetworkInterface::GetDhcpLeaseExpirationTime( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CDBLNetworkInterface::ReleaseAddress( void ) {GUCEF_TRACE; @@ -226,7 +226,7 @@ CDBLNetworkInterface::ReleaseAddress( void ) /*-------------------------------------------------------------------------*/ -bool +bool CDBLNetworkInterface::RenewAddress( void ) {GUCEF_TRACE; @@ -236,7 +236,7 @@ CDBLNetworkInterface::RenewAddress( void ) /*-------------------------------------------------------------------------*/ -bool +bool CDBLNetworkInterface::IsWinsUsed( void ) const {GUCEF_TRACE; @@ -256,7 +256,7 @@ CDBLNetworkInterface::GetPrimaryWinsServer( void ) const /*-------------------------------------------------------------------------*/ -COMCORE::CIPv4Address +COMCORE::CIPv4Address CDBLNetworkInterface::GetSecondaryWinsServer( void ) const {GUCEF_TRACE; @@ -266,7 +266,7 @@ CDBLNetworkInterface::GetSecondaryWinsServer( void ) const /*-------------------------------------------------------------------------*/ -UInt32 +UInt32 CDBLNetworkInterface::GetOsAdapterIndex( void ) const {GUCEF_TRACE; @@ -276,7 +276,7 @@ CDBLNetworkInterface::GetOsAdapterIndex( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) const {GUCEF_TRACE; @@ -290,7 +290,7 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c int32_t productLookupResult = dblwrapper_mal_translate_to_product( nicIndex, &productIdPartA, &productIdPartB ); if ( 0 != productLookupResult ) { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Couldn't find board " + CORE::ToString( nicIndex ) ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Couldn't find board " + CORE::ToString( (Int64)nicIndex ) ); return false; } @@ -298,26 +298,26 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c int64_t v8 = 0; int32_t optionFlags = v8 & 0xFFFFFFFFFFFFFF00 | productIdPartA; void* deviceContext = GUCEF_NULL; - int32_t openResult = dblwrapper_mal_open( productIdPartB, - 0xffffffff, - &deviceContext, - optionFlags, + int32_t openResult = dblwrapper_mal_open( productIdPartB, + 0xffffffff, + &deviceContext, + optionFlags, productIdPartB ); if ( 0 != openResult ) { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Cannot open board " + CORE::ToString( nicIndex ) ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Cannot open board " + CORE::ToString( (Int64)nicIndex ) ); return false; } // Query the numeric NIC ID first as a sanity check to check our access int32_t driverId = productIdPartB; // <- on input we need to give the product id for the board we are asking for - int32_t queryResult = dblwrapper_mal_ioctl( deviceContext, - MAL_IOCTL_INFOTYPEID_NIC, - &driverId, + int32_t queryResult = dblwrapper_mal_ioctl( deviceContext, + MAL_IOCTL_INFOTYPEID_NIC, + &driverId, MAL_IOCTL_PROPERTYID_INT32_ID ); if ( 0 != queryResult ) { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to get driver id for board " + CORE::ToString( nicIndex ) ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to get driver id for board " + CORE::ToString( (Int64)nicIndex ) ); dblwrapper_mal_close( deviceContext ); return false; } @@ -329,14 +329,14 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c // Query how many ports the NIC has, it can have multiple ports on a single card int32_t boardPortCount = productIdPartB; // <- on input we need to give the product id for the board we are asking for - queryResult = dblwrapper_mal_ioctl( deviceContext, - MAL_IOCTL_INFOTYPEID_PORTS, - &boardPortCount, + queryResult = dblwrapper_mal_ioctl( deviceContext, + MAL_IOCTL_INFOTYPEID_PORTS, + &boardPortCount, MAL_IOCTL_PROPERTYID_INT32_COUNT ); if ( 0 != queryResult ) { // we wont count this as a fatal error. log but keep going - GUCEF_WARNING_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Cannot get port count for board " + CORE::ToString( nicIndex ) ); + GUCEF_WARNING_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Cannot get port count for board " + CORE::ToString( (Int64)nicIndex ) ); } GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "DBLNetworkInterface: Board NIC ID string is \"" + CORE::ToString( idStr ) + @@ -344,13 +344,13 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c // Query how many counter stats are available, we will need to allocate sufficient storage for them int32_t nrOfCounterStats = productIdPartB; // <- on input we need to give the product id for the board we are asking for - queryResult = dblwrapper_mal_ioctl( deviceContext, - MAL_IOCTL_INFOTYPEID_COUNTERS_METADATA, - &nrOfCounterStats, + queryResult = dblwrapper_mal_ioctl( deviceContext, + MAL_IOCTL_INFOTYPEID_COUNTERS_METADATA, + &nrOfCounterStats, MAL_IOCTL_PROPERTYID_INT32_COUNT ); if ( 0 != queryResult ) { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to get nr of counter stats for board " + CORE::ToString( nicIndex ) ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to get nr of counter stats for board " + CORE::ToString( (Int64)nicIndex ) ); dblwrapper_mal_close( deviceContext ); return false; } @@ -370,20 +370,20 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c GUCEF_NULL == counters2 || GUCEF_NULL == counters3 ) { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to allocate memory to store counter stats for board " + CORE::ToString( nicIndex ) ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to allocate memory to store counter stats for board " + CORE::ToString( (Int64)nicIndex ) ); dblwrapper_mal_close( deviceContext ); return false; } // Query the counter strings counterStrsBuffer.AsType< int32_t >() = productIdPartB; // <- on input we need to give the product id for the board we are asking for - queryResult = dblwrapper_mal_ioctl( deviceContext, - MAL_IOCTL_INFOTYPEID_COUNTERS_STRINGS, - counterStrs, + queryResult = dblwrapper_mal_ioctl( deviceContext, + MAL_IOCTL_INFOTYPEID_COUNTERS_STRINGS, + counterStrs, MAL_IOCTL_PROPERTYID_INT32_COUNT ); // <- ??? if ( 0 != queryResult ) { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to get nr of counter stats for board " + CORE::ToString( nicIndex ) ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "DBLNetworkInterface: Failed to get nr of counter stats for board " + CORE::ToString( (Int64)nicIndex ) ); dblwrapper_mal_close( deviceContext ); return false; } @@ -394,14 +394,14 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c counters2Buffer.AsType< int32_t >() = productIdPartB; // <- on input we need to give the product id for the board we are asking for int32_t counterQueryType = 0; queryResult = dblwrapper_mal_ioctl( deviceContext, 2236563, counters2, MAL_IOCTL_PROPERTYID_INT32_COUNT ); - if( (uint32_t)queryResult == 0 ) + if( (uint32_t)queryResult == 0 ) { *v14 = productIdPartB; v18 = 1; v19 = v14; counterQueryType = MAL_IOCTL_INFOTYPEID_COUNTERS; - } - else + } + else { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "DBLNetworkInterface: no classes support" ); *v13 = productIdPartB; @@ -416,44 +416,44 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c queryResult = dblwrapper_mal_ioctl( deviceContext, counterQueryType, v19, MAL_IOCTL_PROPERTYID_INT32_COUNT ); - if( (uint32_t)queryResult != 0 ) + if( (uint32_t)queryResult != 0 ) { _ErrMsg = "Cannot get counters values"; - } - else + } + else { - if( local_0x90 != 0 ) + if( local_0x90 != 0 ) { v22 = local_0x90; v23 = v13; - while( 1 ) + while( 1 ) { - if( local_0x74 < 2 ) + if( local_0x74 < 2 ) { v25 = strstr( _Str, "(Port 1)" ); - if( v25 == 0 ) + if( v25 == 0 ) { goto node_244; } - } - else + } + else { node_244: - if( (int32_t)v18 == 0 ) + if( (int32_t)v18 == 0 ) { - if( ((int32_t)v3 == 0 || (int32_t)v18 != *v23) && ((int32_t)v2 != 0 || (uint32_t)*(v15 - v13 + v23) == 0) ) + if( ((int32_t)v3 == 0 || (int32_t)v18 != *v23) && ((int32_t)v2 != 0 || (uint32_t)*(v15 - v13 + v23) == 0) ) { v24 = ntohl( *v23 ); printf( "%34s: %10u\n", _Str, v24 ); } - } - else - if( ((int32_t)v3 == 0 || *v14 != 0) && ((int32_t)v2 != 0 || (uint32_t)*(v15 - v13 + v23) == 0) ) + } + else + if( ((int32_t)v3 == 0 || *v14 != 0) && ((int32_t)v2 != 0 || (uint32_t)*(v15 - v13 + v23) == 0) ) { printf( "%34s: %20llu\n", _Str, *v14 ); } } - if( v22 == 1 ) + if( v22 == 1 ) { break; } @@ -463,27 +463,27 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c (uint8_t *)v23 += 4; } } - if( local_0x78 != 0 ) + if( local_0x78 != 0 ) { local_0x70 = local_0x98; queryResult = dblwrapper_mal_ioctl( deviceContext, MAL_IOCTL_INFOTYPEID_IRQ, &local_0x70, 16 ); - if( (uint32_t)queryResult == 0 ) + if( (uint32_t)queryResult == 0 ) { printf( "Host irq info: %10u intr, %10u events, %10u intr w/o event\n", local_0x6C, local_0x68, local_0x64 ); - } - else + } + else { perror( "Cannot get interrupt counters -- try enabling MAL_DEBUG in the kernel?" ); } } - if( local_0x80 == 0 ) + if( local_0x80 == 0 ) { dblwrapper_mal_close( deviceContext ); __security_check_cookie( local_0x30 ^ &v1 ); return 0; } queryResult = dblwrapper_mal_ioctl( deviceContext, MAL_IOCTL_INFOTYPEID_CLEAR_COUNTERS, &local_0x98, 4 ); - if( (uint32_t)queryResult == 0 ) + if( (uint32_t)queryResult == 0 ) { dblwrapper_mal_close( local_0x88 ); __security_check_cookie( local_0x30 ^ &v1 ); @@ -499,7 +499,7 @@ CDBLNetworkInterface::GetMetrics( COMCORE::CNetworkInterfaceMetrics& metrics ) c /*-------------------------------------------------------------------------*/ -const MT::CILockable* +const MT::CILockable* CDBLNetworkInterface::AsLockable( void ) const {GUCEF_TRACE; diff --git a/plugins/PUBSUB/pubsubpluginKAFKA/src/pubsubpluginKAFKA_CKafkaPubSubClientTopic.cpp b/plugins/PUBSUB/pubsubpluginKAFKA/src/pubsubpluginKAFKA_CKafkaPubSubClientTopic.cpp index fbf4ff36f..5a08f8e20 100644 --- a/plugins/PUBSUB/pubsubpluginKAFKA/src/pubsubpluginKAFKA_CKafkaPubSubClientTopic.cpp +++ b/plugins/PUBSUB/pubsubpluginKAFKA/src/pubsubpluginKAFKA_CKafkaPubSubClientTopic.cpp @@ -23,6 +23,7 @@ //-------------------------------------------------------------------------*/ #include +#include #ifndef GUCEF_MT_CSCOPEMUTEX_H #include "gucefMT_CScopeMutex.h" @@ -143,7 +144,7 @@ CKafkaPubSubClientTopic::Shutdown( void ) MT::CScopeMutex lock( m_lock ); m_client = GUCEF_NULL; - + Disconnect(); Clear(); SignalUpcomingDestruction(); @@ -165,7 +166,7 @@ CKafkaPubSubClientTopic::Clear( void ) {GUCEF_TRACE; MT::CScopeMutex lock( m_lock ); - + GUCEF_DELETE m_metricsTimer; m_metricsTimer = GUCEF_NULL; @@ -438,9 +439,9 @@ CKafkaPubSubClientTopic::RdKafkaStatsCallback( rd_kafka_t *rk , /*-------------------------------------------------------------------------*/ void -CKafkaPubSubClientTopic::RdKafkaLogCallback( const rd_kafka_t *rk , +CKafkaPubSubClientTopic::RdKafkaLogCallback( const rd_kafka_t *rk , int level , - const char *fac , + const char *fac , const char *buf ) {GUCEF_TRACE; @@ -528,7 +529,7 @@ CKafkaPubSubClientTopic::SetupBasedOnConfig( void ) kafkaConf->set( "rebalance_cb", static_cast< RdKafka::RebalanceCb* >( this ), errStr ); kafkaConf->set( "offset_commit_cb", static_cast< RdKafka::OffsetCommitCb* >( this ), errStr ); - rd_kafka_conf_set_log_cb( kafkaConf->c_ptr_global(), &RdKafkaLogCallback ); + rd_kafka_conf_set_log_cb( kafkaConf->c_ptr_global(), &RdKafkaLogCallback ); if ( m_maxTotalMsgsInFlight > 0 ) { @@ -714,7 +715,7 @@ CKafkaPubSubClientTopic::SetupBasedOnConfig( void ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic:LoadConfig: Failed to resolve macros in consumerGroupName" ); } - + if ( RdKafka::Conf::CONF_OK == m_kafkaConsumerConf->set( "group.id", consumerGroupName, errStr ) ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:LoadConfig: Set Kafka group.id to \"" + @@ -766,7 +767,7 @@ CKafkaPubSubClientTopic::SetupBasedOnConfig( void ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic:LoadConfig: consumerName is mandatory but not configured. check the config" ); } - } + } RdKafka::KafkaConsumer* consumer = RdKafka::KafkaConsumer::create( m_kafkaConsumerConf, errStr ); if ( consumer == GUCEF_NULL ) @@ -786,7 +787,7 @@ CKafkaPubSubClientTopic::SetupBasedOnConfig( void ) if ( m_maxTotalMsgsInFlight > 0 ) PrepStorageForReadMsgs( (UInt32) m_maxTotalMsgsInFlight ); - + return true; } @@ -801,7 +802,7 @@ CKafkaPubSubClientTopic::PrepStorageForReadMsgs( CORE::UInt32 msgCount ) // Add extra slots m_rdKafkaMsgs.resize( msgCount ); } - + if ( msgCount > m_pubsubMsgs.size() ) { // Add extra slots @@ -966,13 +967,13 @@ CKafkaPubSubClientTopic::Subscribe( void ) if ( !IsConnected() ) if ( !SetupBasedOnConfig() ) return false; - + if ( GUCEF_NULL != m_kafkaConsumer ) { // First obtain the currently commited offsets if possible // this is optional but desired as it helps with troubleshooting and helps init the stats earlier RetrieveKafkaCommitedOffsets(); - + // Perform the actual subscribe std::vector< std::string > topics; topics.push_back( m_config.topicName ); @@ -1078,9 +1079,9 @@ CKafkaPubSubClientTopic::SubscribeStartingAtTopicIndex( const CORE::CVariant& in RdKafka::ErrorCode response; MT::CScopeMutex lock( m_lock ); - + m_shouldBeConnected = true; - + // First we need to set up RdKafka with the relevant internal stuctures for our topics std::vector< std::string > topics; topics.push_back( m_config.topicName ); @@ -1221,9 +1222,9 @@ CKafkaPubSubClientTopic::SubscribeStartingAtMsgDateTime( const CORE::CDateTime& {GUCEF_TRACE; MT::CScopeMutex lock( m_lock ); - + m_shouldBeConnected = true; - + std::string errStr; RdKafka::ErrorCode response = RdKafka::ERR_NO_ERROR; CORE::UInt64 ticksSinceEpoch = msgDtBookmark.ToUnixEpochBasedTicksInMillisecs(); @@ -1489,10 +1490,10 @@ CKafkaPubSubClientTopic::IsConnected( void ) const { MT::CScopeMutex lock( m_lock ); - + // note that connected is a very relative term here, more like prepared to connect as needed if you are a producer if ( m_config.needPublishSupport ) - if ( GUCEF_NULL == m_kafkaProducer ) + if ( GUCEF_NULL == m_kafkaProducer ) return false; if ( m_config.needSubscribeSupport ) @@ -1504,7 +1505,7 @@ CKafkaPubSubClientTopic::IsConnected( void ) const /*-------------------------------------------------------------------------*/ -bool +bool CKafkaPubSubClientTopic::IsSubscribed( void ) const {GUCEF_TRACE; @@ -1545,15 +1546,15 @@ CKafkaPubSubClientTopic::IsHealthy( void ) const } else { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:IsHealthy: Topic " + m_config.topicName + " is now unhealthy" ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:IsHealthy: Topic " + m_config.topicName + " is now unhealthy" ); } - THealthStatusChangeEventData eData( newHealthyState ); - NotifyObservers( HealthStatusChangeEvent, &eData ); + THealthStatusChangeEventData eData( newHealthyState ); + NotifyObservers( HealthStatusChangeEvent, &eData ); } return newHealthyState; -} +} /*-------------------------------------------------------------------------*/ @@ -1684,7 +1685,7 @@ CKafkaPubSubClientTopic::UpdateKafkaMsgsReceiveLag( void ) {GUCEF_TRACE; bool totalSuccess = true; - + m_metrics.hasKafkaMessagesReceiveLag = false; m_metrics.kafkaMessagesReceiveLagAvg = 0; m_metrics.kafkaMessagesReceiveLagMin = 0; @@ -1695,22 +1696,22 @@ CKafkaPubSubClientTopic::UpdateKafkaMsgsReceiveLag( void ) m_metrics.kafkaMessagesReceiveCommitLagMax = 0; if ( GUCEF_NULL != m_kafkaConsumer ) - { + { RdKafka::ErrorCode response = RdKafka::ERR_NO_ERROR; TRdKafkaTopicPartitionPtrVector kafkaPartitions; - response = m_kafkaConsumer->assignment( kafkaPartitions ); + response = m_kafkaConsumer->assignment( kafkaPartitions ); if ( response != RdKafka::ERR_NO_ERROR ) return false; if ( !kafkaPartitions.empty() ) { CORE::Int64 minLag = GUCEF_INT64MAX; - CORE::Int64 maxLag = GUCEF_INT64MIN; + CORE::Int64 maxLag = GUCEF_INT64MIN; CORE::Int64 lag = 0; - + CORE::Int64 commitMinLag = GUCEF_INT64MAX; - CORE::Int64 commitMaxLag = GUCEF_INT64MIN; + CORE::Int64 commitMaxLag = GUCEF_INT64MIN; CORE::Int64 commitLag = 0; TRdKafkaTopicPartitionPtrVector::iterator i = kafkaPartitions.begin(); @@ -1719,16 +1720,16 @@ CKafkaPubSubClientTopic::UpdateKafkaMsgsReceiveLag( void ) RdKafka::TopicPartition* partition = (*i); if ( GUCEF_NULL != partition ) { - CORE::Int64 lowOffset = 0; - CORE::Int64 highOffset = 0; + int64_t lowOffset = 0; + int64_t highOffset = 0; response = m_kafkaConsumer->get_watermark_offsets( partition->topic(), partition->partition(), &lowOffset, &highOffset ); if ( response == RdKafka::ERR_NO_ERROR ) { if ( RdKafka::Topic::OFFSET_INVALID != highOffset ) { - // We use the ack'd minimum offsets known to the topic as the earliest most up-to-date carat of where we + // We use the ack'd minimum offsets known to the topic as the earliest most up-to-date carat of where we // are reading wise which can be a little ahead of the read position that was actually commited to Kafka - + TInt32ToInt64Map::iterator n = m_consumerReadOffsets.find( partition->partition() ); if ( n != m_consumerReadOffsets.end() ) { @@ -1738,8 +1739,8 @@ CKafkaPubSubClientTopic::UpdateKafkaMsgsReceiveLag( void ) if ( currentReadCursorLag < minLag ) minLag = currentReadCursorLag; if ( currentReadCursorLag > maxLag ) - maxLag = currentReadCursorLag; - + maxLag = currentReadCursorLag; + lag += currentReadCursorLag; TInt32ToInt64Map::iterator m = m_kafkaCommitedConsumerOffsets.find( partition->partition() ); @@ -1753,7 +1754,7 @@ CKafkaPubSubClientTopic::UpdateKafkaMsgsReceiveLag( void ) if ( currentReadCursorCommitedOffsetLag < commitMinLag ) commitMinLag = currentReadCursorCommitedOffsetLag; if ( currentReadCursorCommitedOffsetLag > commitMaxLag ) - commitMaxLag = currentReadCursorCommitedOffsetLag; + commitMaxLag = currentReadCursorCommitedOffsetLag; commitLag += currentReadCursorCommitedOffsetLag; } @@ -1951,7 +1952,7 @@ CKafkaPubSubClientTopic::ConvertKafkaConsumerStartOffset( CORE::Int64 startOffse if ( RdKafka::ERR_NO_ERROR != err ) { ++m_kafkaErrorReplies; - + std::string errStr = RdKafka::err2str( err ); GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Failed to convert offset description \"STORED\" into offset for partition " + CORE::Int32ToString( partitionId ) + ". Cannot obtain partition assignment. ErrorCode : " + errStr ); @@ -1962,7 +1963,7 @@ CKafkaPubSubClientTopic::ConvertKafkaConsumerStartOffset( CORE::Int64 startOffse if ( RdKafka::ERR_NO_ERROR != err ) { ++m_kafkaErrorReplies; - + std::string errStr = RdKafka::err2str( err ); GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Failed to convert offset description \"STORED\" into offset for partition " + CORE::Int32ToString( partitionId ) + ". Cannot obtain commited offsets . ErrorCode : " + errStr ); @@ -2025,7 +2026,7 @@ CKafkaPubSubClientTopic::GetConsumerConfigSetting( const CORE::CString& keyName, /*-------------------------------------------------------------------------*/ -Int64 +Int64 CKafkaPubSubClientTopic::GetConsumerConfigSettingAsInt64( const CORE::CString& keyName, Int64 defaultValue ) const {GUCEF_TRACE; @@ -2056,7 +2057,7 @@ CKafkaPubSubClientTopic::offset_commit_cb( RdKafka::ErrorCode err commitInfo += "Topic \"" + partitions[ i ]->topic() + "\" is at partition \"" + CORE::Int32ToString( partitions[ i ]->partition() ).STL_String() + "\" at offset \"" + ConvertKafkaConsumerStartOffset( partitions[ i ]->offset() ).STL_String() + "\". "; } GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, commitInfo ); - } + } else { #ifdef GUCEF_DEBUG_MODE @@ -2072,14 +2073,14 @@ CKafkaPubSubClientTopic::offset_commit_cb( RdKafka::ErrorCode err if ( RdKafka::ERR__NO_OFFSET == err ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: No offsets are stored server-side for this client id. If this is unexpected check your offset storage health and retention policies. Will switch to using a default initial setting" ); - + // check our config to see how we want to handle this scenario Int64 requestTimeout = GetConsumerConfigSettingAsInt64( "request.timeout.ms", 3000 ); - CORE::CString offsetResetSetting = GetConsumerConfigSetting( "auto.offset.reset", DefaultOffsetResetValue ); + CORE::CString offsetResetSetting = GetConsumerConfigSetting( "auto.offset.reset", DefaultOffsetResetValue ); if ( offsetResetSetting.Lowercase() == "stored" ) { - GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic: The \"auto.offset.reset\" setting is set to \"" + offsetResetSetting + " which is not correct for an invalid/no offset scenario. Overruling to " + DefaultOffsetResetValue ); - offsetResetSetting = DefaultOffsetResetValue; + GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic: The \"auto.offset.reset\" setting is set to \"" + offsetResetSetting + " which is not correct for an invalid/no offset scenario. Overruling to " + DefaultOffsetResetValue ); + offsetResetSetting = DefaultOffsetResetValue; } GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic: Using offset reset setting of \"" + offsetResetSetting + "\" with request timeout of " + CORE::ToString( requestTimeout ) ); @@ -2087,7 +2088,7 @@ CKafkaPubSubClientTopic::offset_commit_cb( RdKafka::ErrorCode err for ( unsigned int i=0; ioffset(); - if ( RdKafka::Topic::OFFSET_INVALID == partitionOffset || + if ( RdKafka::Topic::OFFSET_INVALID == partitionOffset || RdKafka::Topic::OFFSET_INVALID == m_kafkaCommitedConsumerOffsets[ partitions[ i ]->partition() ] ) { Int64 newPartitionOffset = ConvertKafkaConsumerStartOffset( offsetResetSetting, partitions[ i ]->partition(), (Int32) requestTimeout ); @@ -2114,12 +2115,12 @@ CKafkaPubSubClientTopic::offset_commit_cb( RdKafka::ErrorCode err int64_t partitionOffset = partitions[ i ]->offset(); if ( 0 <= partitionOffset ) { - m_kafkaCommitedConsumerOffsets[ partitions[ i ]->partition() ] = partitionOffset; + m_kafkaCommitedConsumerOffsets[ partitions[ i ]->partition() ] = partitionOffset; } - + } } - } + } } /*-------------------------------------------------------------------------*/ @@ -2135,12 +2136,12 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Assigning partitions" ); RdKafka::ErrorCode assignSuccess = consumer->assign( partitions ); - + // Check if we can use the newly assigned partition's offsets bool hasInvalidOffsets = false; for ( unsigned int i=0; ioffset(); + Int64 paritionOffset = partitions[ i ]->offset(); if ( RdKafka::Topic::OFFSET_INVALID == paritionOffset ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: We were given OFFSET_INVALID for topic \"" + m_config.topicName + "\"" ); @@ -2153,18 +2154,18 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer // in such a case no need for an extra call to Kafka bool updatedKafkaCommitedConsumerOffsets = false; if ( !hasInvalidOffsets ) - { + { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: We were given offsets for topic \"" + m_config.topicName + "\". Will use those as the new 'commited' offsets" ); - + m_kafkaCommitedConsumerOffsets.clear(); for ( unsigned int i=0; ipartition(); - Int64 paritionOffset = partitions[ i ]->offset(); + Int64 paritionOffset = partitions[ i ]->offset(); m_kafkaCommitedConsumerOffsets[ partitionId ] = paritionOffset; m_consumerAckdOffsets[ partitionId ] = paritionOffset; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: partition " + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: partition " + CORE::ToString( partitionId ) + " is now at offset " + CORE::ToString( paritionOffset ) ); } updatedKafkaCommitedConsumerOffsets = true; @@ -2182,16 +2183,16 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer for ( unsigned int i=0; ipartition(); - Int64 paritionOffset = partitions[ i ]->offset(); + Int64 paritionOffset = partitions[ i ]->offset(); TInt32ToInt64Map::iterator c = m_kafkaCommitedConsumerOffsets.find( partitionId ); if ( c != m_kafkaCommitedConsumerOffsets.end() ) { Int64 comittedOffset = (*c).second; partitions[ i ]->set_offset( comittedOffset ); - m_consumerAckdOffsets[ partitionId ] = comittedOffset; + m_consumerAckdOffsets[ partitionId ] = comittedOffset; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Changing offset for partition " + CORE::ToString( partitionId ) + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Changing offset for partition " + CORE::ToString( partitionId ) + " from " + CORE::ToString( paritionOffset ) + " to committed value " + CORE::ToString( comittedOffset ) ); } else @@ -2199,7 +2200,7 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer // this should never happen hasInvalidOffsets = true; partitions[ i ]->set_offset( RdKafka::Topic::OFFSET_INVALID ); - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Offset for partition " + CORE::ToString( partitionId ) + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Offset for partition " + CORE::ToString( partitionId ) + " with value " + CORE::ToString( paritionOffset ) + " could not be updated to a committed value since the partition is not available as part of the commited set" ); } } @@ -2219,26 +2220,26 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer for ( unsigned int i=0; ipartition(); - Int64 paritionOffset = partitions[ i ]->offset(); + Int64 paritionOffset = partitions[ i ]->offset(); int64_t high = 0; int64_t low = 0; RdKafka::ErrorCode err = m_kafkaConsumer->get_watermark_offsets( m_config.topicName, partitionId, &low, &high ); if ( RdKafka::ERR_NO_ERROR == err ) - { + { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: The watermark offsets for topic \"" + m_config.topicName + - "\" and partition " + CORE::ToString( partitionId ) + " are: Low=" + CORE::ToString( low ) + ", High=" + CORE::ToString( high ) ); - + "\" and partition " + CORE::ToString( partitionId ) + " are: Low=" + CORE::ToString( (Int64)low ) + ", High=" + CORE::ToString( (Int64)high ) ); + // Does the offset for this partition need fixing? Some may already be Ok if ( RdKafka::Topic::OFFSET_INVALID == paritionOffset ) { // Try using the locally available in ram 'last ack'd' offsets - TInt32ToInt64Map::iterator a = m_consumerAckdOffsets.find( partitionId ); + TInt32ToInt64Map::iterator a = m_consumerAckdOffsets.find( partitionId ); if ( a != m_consumerAckdOffsets.end() ) { // We have last ack'd offsets in memory on our end for this partition // in this case its safe to use the last ack'd offsets as long as they are within watermark range. This limits replay volume due to commit lag Int64 lastAckdOffset = (*a).second; - + if ( RdKafka::Topic::OFFSET_INVALID != lastAckdOffset && lastAckdOffset >= low && lastAckdOffset <= high ) { // Great! The offset is in range and thus can be used as a substitute @@ -2260,7 +2261,7 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer } } else - { + { ++m_kafkaErrorReplies; GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic:rebalance_cb: Unable to obtain low and high watermarks for topic \"" + m_config.topicName + "\" and partition " + CORE::ToString( partitionId ) + ". Without this information our only option is a full reset" ); @@ -2270,14 +2271,14 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer // Any luck yet? If not fall back to a reset to default offset values, starting from scratch if ( hasInvalidOffsets || m_kafkaCommitedConsumerOffsets.empty() ) - { + { Int64 requestTimeout = GetConsumerConfigSettingAsInt64( "request.timeout.ms", 3000 ); hasInvalidOffsets = false; for ( unsigned int i=0; ipartition(); - Int64 paritionOffset = partitions[ i ]->offset(); + Int64 paritionOffset = partitions[ i ]->offset(); CORE::Int64 startOffset = (CORE::Int64) RdKafka::Topic::OFFSET_INVALID; // Does the offset for this partition need fixing? Some may already be Ok @@ -2288,19 +2289,19 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer { partitions[ i ]->set_offset( startOffset ); m_kafkaCommitedConsumerOffsets[ partitionId ] = startOffset; - m_consumerAckdOffsets[ partitionId ] = startOffset; + m_consumerAckdOffsets[ partitionId ] = startOffset; m_receivedMsgAcks[ partitionId ].clear(); updatedKafkaCommitedConsumerOffsets = true; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Changing offset for partition " + CORE::ToString( partitionId ) + - " from " + CORE::ToString( paritionOffset ) + " to reset value " + CORE::ToString( startOffset ) ); + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Changing offset for partition " + CORE::ToString( partitionId ) + + " from " + CORE::ToString( paritionOffset ) + " to reset value " + CORE::ToString( startOffset ) ); } else { // This should not happen hasInvalidOffsets = true; - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Offset for partition " + CORE::ToString( partitionId ) + - " with offset " + CORE::ToString( paritionOffset ) + " cannot be updated to a reset value since the reset value is invalid: " + CORE::ToString( startOffset ) ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: Offset for partition " + CORE::ToString( partitionId ) + + " with offset " + CORE::ToString( paritionOffset ) + " cannot be updated to a reset value since the reset value is invalid: " + CORE::ToString( startOffset ) ); } } } @@ -2312,7 +2313,7 @@ CKafkaPubSubClientTopic::rebalance_cb( RdKafka::KafkaConsumer* consumer for ( unsigned int i=0; ipartition(); - Int64 paritionOffset = partitions[ i ]->offset(); + Int64 paritionOffset = partitions[ i ]->offset(); if ( RdKafka::Topic::OFFSET_INVALID == paritionOffset ) { GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:rebalance_cb: We still have OFFSET_INVALID for partition " + CORE::ToString( partitionId ) + " of topic \"" + m_config.topicName + "\"" ); @@ -2385,7 +2386,7 @@ CKafkaPubSubClientTopic::UpdateIsHealthyStatus( bool newStatus ) // the caller might only know about one aspect of health // The IsHealthy check itself will update the status and perform eventing if needed newStatus = IsHealthy(); - } + } } /*-------------------------------------------------------------------------*/ @@ -2500,7 +2501,7 @@ CKafkaPubSubClientTopic::IsSubscriptionAtEndOfData( void ) const if ( m_isSubscribed ) return m_isSubscriptionAtEndOfData; - + bool isSubscriptionAtEndOfData = m_isSubscriptionAtEndOfData; if ( QueryKafkaIfSubscriptionIsAtEndOfData( isSubscriptionAtEndOfData ) ) return isSubscriptionAtEndOfData; @@ -2513,9 +2514,9 @@ CKafkaPubSubClientTopic::IsSubscriptionAtEndOfData( void ) const bool CKafkaPubSubClientTopic::QueryKafkaIfSubscriptionIsAtEndOfData( bool& isSubscriptionAtEndOfData ) const {GUCEF_TRACE; - + MT::CScopeMutex lock( m_lock ); - + if ( GUCEF_NULL == m_kafkaConsumer ) return false; @@ -2523,12 +2524,12 @@ CKafkaPubSubClientTopic::QueryKafkaIfSubscriptionIsAtEndOfData( bool& isSubscrip { TInt32ToInt64Map::const_iterator i = m_consumerReadOffsets.begin(); while ( i != m_consumerReadOffsets.end() ) - { + { CORE::Int32 partitionId = (*i).first; CORE::Int64 readPosition = (*i).second; - - CORE::Int64 lowOffset = 0; - CORE::Int64 highOffset = 0; + + int64_t lowOffset = 0; + int64_t highOffset = 0; RdKafka::ErrorCode response = m_kafkaConsumer->get_watermark_offsets( m_config.topicName, partitionId, &lowOffset, &highOffset ); if ( response == RdKafka::ERR_NO_ERROR ) { @@ -2557,8 +2558,8 @@ CKafkaPubSubClientTopic::QueryKafkaIfSubscriptionIsAtEndOfData( bool& isSubscrip /*-------------------------------------------------------------------------*/ bool -CKafkaPubSubClientTopic::ProcessRdKafkaMessage( RdKafka::Message& message , - CORE::UInt32 msgIndex , +CKafkaPubSubClientTopic::ProcessRdKafkaMessage( RdKafka::Message& message , + CORE::UInt32 msgIndex , bool& isFiltered ) {GUCEF_TRACE; @@ -2642,11 +2643,11 @@ CKafkaPubSubClientTopic::ProcessRdKafkaMessage( RdKafka::Message& message , m_msgsAckdSinceLastOffsetCommit = true; // Since something was recieved we want to set the flag to ensure we start commiting offsets again } } - + LinkReceivedMsg( message, msgIndex ); success = true; } - + // We will consider the ability to receive and process messages as healthy UpdateIsHealthyStatus( true ); break; @@ -2662,7 +2663,7 @@ CKafkaPubSubClientTopic::ProcessRdKafkaMessage( RdKafka::Message& message , // The signal from Kafka merely triggers a more hollistic check if ( IsSubscriptionAtEndOfData() ) { - if ( !NotifyObservers( SubscriptionEndOfDataEvent ) ) + if ( !NotifyObservers( SubscriptionEndOfDataEvent ) ) return success; } } @@ -2672,7 +2673,7 @@ CKafkaPubSubClientTopic::ProcessRdKafkaMessage( RdKafka::Message& message , case RdKafka::ERR__UNKNOWN_PARTITION: { ++m_kafkaErrorReplies; - + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Kafka consume error: UNKNOWN_PARTITION: " + message.errstr() ); UpdateIsHealthyStatus( false ); break; @@ -2680,7 +2681,7 @@ CKafkaPubSubClientTopic::ProcessRdKafkaMessage( RdKafka::Message& message , case RdKafka::ERR__UNKNOWN_TOPIC: { ++m_kafkaErrorReplies; - + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Kafka consume error: UNKNOWN_TOPIC: " + message.errstr() ); UpdateIsHealthyStatus( false ); break; @@ -2688,14 +2689,14 @@ CKafkaPubSubClientTopic::ProcessRdKafkaMessage( RdKafka::Message& message , case RdKafka::ERR__MAX_POLL_EXCEEDED: { ++m_kafkaErrorReplies; - + GUCEF_WARNING_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Kafka consume error: MAX_POLL_EXCEEDED: " + message.errstr() ); break; } default: { ++m_kafkaErrorReplies; - + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Kafka consume error: " + message.errstr() ); UpdateIsHealthyStatus( false ); break; @@ -2729,7 +2730,7 @@ CKafkaPubSubClientTopic::event_cb( RdKafka::Event& event ) { ++m_kafkaErrorReplies; ++m_kafkaConnectionErrors; - + // Per GitHub comment from edenhill on Dec 18, 2018 for issue #2159: // "It will re-resolve the address on each re-connect attempt, but it will not log equal sub-sequent errors." GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:event_cb: Unable to resolve Kafka broker DNS for Kafka topic \"" + m_config.topicName + @@ -2739,13 +2740,13 @@ CKafkaPubSubClientTopic::event_cb( RdKafka::Event& event ) break; } case RdKafka::ERR__TRANSPORT: - { + { ++m_kafkaErrorReplies; ++m_kafkaConnectionErrors; // Per GitHub comment from edenhill on Dec 18, 2018 for issue #2159: // "It will re-resolve the address on each re-connect attempt, but it will not log equal sub-sequent errors." - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:event_cb: Unable to establish or retain connection to Kafka brokers for Kafka topic \"" + m_config.topicName + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:event_cb: Unable to establish or retain connection to Kafka brokers for Kafka topic \"" + m_config.topicName + "\". event msg=\"" + event.str() + "\". error as string =\"" + RdKafka::err2str( event.err() ) + "\"" ); if ( !NotifyObservers( ConnectionErrorEvent ) ) return; UpdateIsHealthyStatus( false ); @@ -2930,27 +2931,27 @@ CKafkaPubSubClientTopic::CommitConsumerOffsets( bool useAsyncCommit ) // Match the current Topic objects with our simplistic bookkeeping and sync them std::vector::iterator p = partitions.begin(); while ( p != partitions.end() ) - { + { CORE::Int32 partitionId = (*p)->partition(); CORE::Int64 partitionOffset = (*p)->offset(); - + // try to find ackd offsets for the given partition // note that if no messages have been recieved and/or ackd yet then this will not yield anything - + TInt32ToInt64Map::iterator o = m_consumerAckdOffsets.find( partitionId ); if ( o != m_consumerAckdOffsets.end() ) { CORE::Int64 ackdOffset = (*o).second; - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:CommitConsumerOffsets: Ackd offsets are available for partition " + CORE::ToString( partitionId ) + ". Current offset is " + CORE::ToString( partitionOffset ) + ". Ackd offset is " + CORE::ToString( ackdOffset ) ); (*p)->set_offset( ackdOffset ); } else - { + { // We dont have any acks for this partition we can use to update the offset - // as such fall back to the commited offsets collection + // as such fall back to the commited offsets collection TInt32ToInt64Map::iterator o2 = m_kafkaCommitedConsumerOffsets.find( partitionId ); if ( o2 != m_kafkaCommitedConsumerOffsets.end() ) { @@ -2958,7 +2959,7 @@ CKafkaPubSubClientTopic::CommitConsumerOffsets( bool useAsyncCommit ) GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "KafkaPubSubClientTopic:CommitConsumerOffsets: No ackd offsets are available for partition " + CORE::ToString( partitionId ) + ". Current offset is " + CORE::ToString( partitionOffset ) + ". falling back to local copy of commited offset " + CORE::ToString( commitedOffset ) ); - + (*p)->set_offset( commitedOffset ); } else @@ -3095,7 +3096,7 @@ CKafkaPubSubClientTopic::ProcessMsgAcks( void ) if ( p == m_consumerAckdOffsets.end() ) { CORE::Int64 commitedOffset = 0; - TInt32ToInt64Map::iterator k = m_kafkaCommitedConsumerOffsets.find( partitionId ); + TInt32ToInt64Map::iterator k = m_kafkaCommitedConsumerOffsets.find( partitionId ); if ( k == m_kafkaCommitedConsumerOffsets.end() ) { if ( RetrieveKafkaCommitedOffsets() ) @@ -3109,8 +3110,8 @@ CKafkaPubSubClientTopic::ProcessMsgAcks( void ) GUCEF_DEBUG_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: No ackd offset found for partition " + CORE::ToString( partitionId ) + " using Kafka commited offset as the new ack starting position: " + CORE::ToString( commitedOffset ) ); - - m_consumerAckdOffsets[ partitionId ] = commitedOffset; + + m_consumerAckdOffsets[ partitionId ] = commitedOffset; p = m_consumerAckdOffsets.find( partitionId ); } else @@ -3127,7 +3128,7 @@ CKafkaPubSubClientTopic::ProcessMsgAcks( void ) if ( p != m_consumerAckdOffsets.end() ) { CORE::Int64& currentOffset = (*p).second; - + TInt64Set::iterator a = ackdOffsets.begin(); CORE::Int64 ackdOffset = (*a); if ( currentOffset == ackdOffset || currentOffset+1 == ackdOffset ) @@ -3142,19 +3143,19 @@ CKafkaPubSubClientTopic::ProcessMsgAcks( void ) ackdOffset = nextAckdOffset; else break; - + ++a; } // Now we move the consumer offset to the new position - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Moving ackd commit offset from " + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Moving ackd commit offset from " + CORE::ToString( currentOffset ) + " to " + CORE::ToString( ackdOffset ) + " for partition " + CORE::ToString( partitionId ) ); currentOffset = ackdOffset; offsetsChanged = true; } else { - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Ackd offset " + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_IMPORTANT, "KafkaPubSubClientTopic: Ackd offset " + CORE::ToString( ackdOffset ) + " is too far from current offset " + CORE::ToString( currentOffset ) + " for partition " + CORE::ToString( partitionId ) ); } } @@ -3186,7 +3187,7 @@ CKafkaPubSubClientTopic::CleanupMsgAcks( void ) { CORE::Int64 ackdOffset = *(ackdOffsets.begin()); if ( ackdOffset <= currentOffset ) - ackdOffsets.erase( ackdOffsets.begin() ); + ackdOffsets.erase( ackdOffsets.begin() ); else break; } @@ -3241,16 +3242,16 @@ CKafkaPubSubClientTopic::OnPulseCycle( CORE::CNotifier* notifier , if ( GUCEF_NULL != m_kafkaConsumer && m_isSubscribed ) { - if ( m_requestedConsumeDelayInMs == 0 || + if ( m_requestedConsumeDelayInMs == 0 || m_requestedConsumeDelayInMs <= GetPulseGenerator()->GetTimeSinceTickCountInMilliSecs( m_tickCountAtConsumeDelayRequest ) ) - { + { m_requestedConsumeDelayInMs = 0; - + UInt32 maxMsgsToRead = 100; if ( m_maxTotalMsgsInFlight > 0 ) { maxMsgsToRead = (UInt32) m_maxTotalMsgsInFlight; - PrepStorageForReadMsgs( maxMsgsToRead ); + PrepStorageForReadMsgs( maxMsgsToRead ); } // Try to fetch a bunch of messages in one go @@ -3274,7 +3275,7 @@ CKafkaPubSubClientTopic::OnPulseCycle( CORE::CNotifier* notifier , { m_isSubscriptionAtEndOfData = true; if ( GUCEF_NULL != m_client ) - { + { if ( m_client->GetConfig().desiredFeatures.supportsSubscriptionEndOfDataEvent ) { if ( !NotifyObservers( SubscriptionEndOfDataEvent ) ) @@ -3290,7 +3291,7 @@ CKafkaPubSubClientTopic::OnPulseCycle( CORE::CNotifier* notifier , if ( ProcessRdKafkaMessage( *msg, msgRead+1, isFiltered ) && !isFiltered ) { ++msgRead; - m_rdKafkaMsgs[ msgRead ] = msg; + m_rdKafkaMsgs[ msgRead ] = msg; } } @@ -3300,11 +3301,11 @@ CKafkaPubSubClientTopic::OnPulseCycle( CORE::CNotifier* notifier , { if ( !NotifyObservers( MsgsRecievedEvent, &m_pubsubMsgsRefs ) ) return; - + m_pubsubMsgsRefs.clear(); } - // Cleanup all the messages we received from RdKafka + // Cleanup all the messages we received from RdKafka for ( CORE::Int32 i=0; i<=msgRead; ++i ) { RdKafka::Message* msg = m_rdKafkaMsgs[ i ]; @@ -3361,7 +3362,7 @@ CKafkaPubSubClientTopic::DeriveBookmarkFromMsg( const PUBSUB::CIPubSubMsg& msg, /*-------------------------------------------------------------------------*/ -const CORE::CString& +const CORE::CString& CKafkaPubSubClientTopic::GetClassTypeName( void ) const {GUCEF_TRACE; diff --git a/plugins/PUBSUB/pubsubpluginREDISCLUSTER/src/pubsubpluginREDISCLUSTER_CRedisClusterPubSubClient.cpp b/plugins/PUBSUB/pubsubpluginREDISCLUSTER/src/pubsubpluginREDISCLUSTER_CRedisClusterPubSubClient.cpp index 6bd6e6e6f..7ba91699c 100644 --- a/plugins/PUBSUB/pubsubpluginREDISCLUSTER/src/pubsubpluginREDISCLUSTER_CRedisClusterPubSubClient.cpp +++ b/plugins/PUBSUB/pubsubpluginREDISCLUSTER/src/pubsubpluginREDISCLUSTER_CRedisClusterPubSubClient.cpp @@ -55,7 +55,7 @@ // // //-------------------------------------------------------------------------*/ -using namespace GUCEF::REDISINFO; +using namespace GUCEF::REDISINFO; namespace GUCEF { namespace PUBSUBPLUGIN { @@ -125,11 +125,11 @@ CRedisClusterPubSubClient::CRedisClusterPubSubClient( const PUBSUB::CPubSubClien m_config.metricsPrefix += "redis."; if ( config.desiredFeatures.supportsSubscribing ) - m_threadPool = CORE::CCoreGlobal::Instance()->GetTaskManager().GetOrCreateThreadPool( - "RedisClusterPubSubClient(" + CORE::ToString( this ) + ")", - m_config.pulseGenerator, + m_threadPool = CORE::CCoreGlobal::Instance()->GetTaskManager().GetOrCreateThreadPool( + "RedisClusterPubSubClient(" + CORE::ToString( this ) + ")", + m_config.pulseGenerator, true ); - + RegisterEventHandlers(); if ( !m_journal.IsNULL() ) @@ -142,7 +142,7 @@ CRedisClusterPubSubClient::~CRedisClusterPubSubClient() {GUCEF_TRACE; MT::CScopeMutex lock( m_lock ); - + if ( !m_threadPool.IsNULL() ) { m_threadPool->RequestAllThreadsToStop( true, false ); @@ -193,10 +193,10 @@ CRedisClusterPubSubClient::SetPulseGenerator( CORE::PulseGeneratorPtr newPulseGe {GUCEF_TRACE; MT::CScopeMutex lock( m_lock ); - + CORE::CTSGNotifier::SetPulseGenerator( newPulseGenerator ); m_config.pulseGenerator = newPulseGenerator; - + if ( GUCEF_NULL != m_metricsTimer ) { m_metricsTimer->SetPulseGenerator( newPulseGenerator ); @@ -247,7 +247,7 @@ CRedisClusterPubSubClient::GetThreadPool( void ) /*-------------------------------------------------------------------------*/ -bool +bool CRedisClusterPubSubClient::IsTrackingAcksNeeded( void ) const {GUCEF_TRACE; @@ -257,7 +257,7 @@ CRedisClusterPubSubClient::IsTrackingAcksNeeded( void ) const /*-------------------------------------------------------------------------*/ bool -CRedisClusterPubSubClient::GetSupportedFeatures( PUBSUB::CPubSubClientFeatures& features ) const +CRedisClusterPubSubClient::GetSupportedFeatures( PUBSUB::CPubSubClientFeatures& features ) const {GUCEF_TRACE; features.supportsBinaryPayloads = true; // Redis strings are binary safe so yes redis natively supports binary data @@ -289,9 +289,9 @@ CRedisClusterPubSubClient::GetSupportedFeatures( PUBSUB::CPubSubClientFeatures& features.supportsDerivingBookmarkFromMsg = true; // The Redis auto-generated msgId acts as a topic index and as such we can derive a bookmark from a message features.supportsDiscoveryOfAvailableTopics = true; // we support scanning for available Redis streams features.supportsGlobPatternTopicNames = true; // we support glob pattern matching the scan of available Redis streams - features.supportsPatternBasedAggregateTopic = false; // @TODO: Look into supporting this with + features.supportsPatternBasedAggregateTopic = false; // @TODO: Look into supporting this with features.supportsSubscriptionMsgArrivalDelayRequests = true; // we support delaying the redis read thread on a per read cycle basis - + // the following features we enable based on expresed desired functionality, we support either features.supportsSubscriptionEndOfDataEvent = m_config.desiredFeatures.supportsSubscriptionEndOfDataEvent; return true; @@ -367,10 +367,10 @@ CRedisClusterPubSubClient::GetTopicAccess( const CORE::CString& topicName ) /*-------------------------------------------------------------------------*/ -void +void CRedisClusterPubSubClient::GetAllCreatedTopicAccess( PubSubClientTopicSet& topicAccess ) {GUCEF_TRACE; - + MT::CObjectScopeLock lock( this ); TTopicMap::iterator i = m_topicMap.begin(); @@ -453,7 +453,7 @@ CRedisClusterPubSubClient::AutoCreateMultiTopicAccess( const TTopicConfigPtrToSt while ( m != topicsToCreate.end() ) { PUBSUB::CPubSubClientTopicConfigPtr templateTopicConfig( ((*m).first) ); - if ( !templateTopicConfig.IsNULL() ) + if ( !templateTopicConfig.IsNULL() ) { const CORE::CString::StringSet& topicNameList = (*m).second; @@ -461,7 +461,7 @@ CRedisClusterPubSubClient::AutoCreateMultiTopicAccess( const TTopicConfigPtrToSt while ( i != topicNameList.end() ) { CRedisClusterPubSubClientTopicConfigPtr topicConfig = CRedisClusterPubSubClientTopicConfig::CreateSharedObj(); - topicConfig->LoadConfig( *templateTopicConfig.GetPointerAlways() ); + topicConfig->LoadConfig( *templateTopicConfig.GetPointerAlways() ); topicConfig->topicName = (*i); CRedisClusterPubSubClientTopicPtr tAccess; @@ -471,7 +471,7 @@ CRedisClusterPubSubClient::AutoCreateMultiTopicAccess( const TTopicConfigPtrToSt tAccess = ( GUCEF_NEW CRedisClusterPubSubClientTopic( this ) )->CreateSharedPtr(); if ( tAccess->LoadConfig( *topicConfig ) ) { - m_topicMap[ topicConfig->topicName ] = tAccess; + m_topicMap[ topicConfig->topicName ] = tAccess; topicAccess.insert( tAccess ); m_config.topics.push_back( topicConfig ); ++newTopicAccessCount; @@ -626,7 +626,7 @@ CRedisClusterPubSubClient::AutoDestroyTopicAccess( const CORE::CString::StringSe PUBSUB::CPubSubClientTopicBasicPtr tAccess = (*t); CORE::CString topicName = tAccess->GetTopicName(); - m_topicMap.erase( topicName ); + m_topicMap.erase( topicName ); { CRedisClusterPubSubClientTopicBasicPtr topicAccess = tAccess.StaticCast< CRedisClusterPubSubClientTopic >(); topicAccess->Shutdown(); @@ -677,16 +677,16 @@ CRedisClusterPubSubClient::GetTopicConfig( const CORE::CString& topicName ) /*-------------------------------------------------------------------------*/ -PUBSUB::CPubSubClientTopicConfigPtr +PUBSUB::CPubSubClientTopicConfigPtr CRedisClusterPubSubClient::GetOrCreateTopicConfig( const CORE::CString& topicName ) {GUCEF_TRACE; MT::CScopeMutex lock( m_lock ); - + PUBSUB::CPubSubClientTopicConfigPtr preExistingConfig = GetTopicConfig( topicName ); if ( !preExistingConfig.IsNULL() ) return preExistingConfig; - + if ( !m_config.defaultTopicConfig.IsNULL() ) { CRedisClusterPubSubClientTopicConfigPtr newTopicConfig = CRedisClusterPubSubClientTopicConfig::CreateSharedObj(); @@ -763,11 +763,11 @@ CRedisClusterPubSubClient::DetermineIfTrackingAcksIsNeeded( void ) const PUBSUB::CPubSubClientFeatures features; GetSupportedFeatures( features ); - + // Whether we need to track successfull message handoff (garanteed handling) depends both on whether we want that extra reliability per the config // (optional since nothing is free and this likely degrades performance a bit) but also whether the backend even supports it. // If the backend doesnt support it all we will be able to do between the sides is fire-and-forget - + bool doWeWantIt = ( m_config.desiredFeatures.supportsSubscribing && // <- does it apply in this context ? ( m_config.desiredFeatures.supportsSubscriberMsgReceivedAck || // <- do we want it? m_config.desiredFeatures.supportsSubscribingUsingBookmark ) @@ -779,8 +779,8 @@ CRedisClusterPubSubClient::DetermineIfTrackingAcksIsNeeded( void ) const bool canWeNotWantIt = features.supportsAbsentMsgReceivedAck && // <- Is it even an option to not do it regardless of desired features ( !features.supportsBookmarkingConcept || // <- if we need to perform client-side bookmarking then its not really an option to forgo acks if you want a reliable handoff and thus bookmark progression features.supportsBookmarkingConcept && features.supportsSubscribingUsingBookmark && features.supportsServerSideBookmarkPersistance ); - - bool acksNeeded = ( doWeWantIt && isItSupported ) || + + bool acksNeeded = ( doWeWantIt && isItSupported ) || ( !canWeNotWantIt && isItSupported ); return acksNeeded; @@ -1036,7 +1036,7 @@ CRedisClusterPubSubClient::Connect( bool reset ) if ( !reset && IsConnected() ) return true; - + if ( !Disconnect() ) return false; @@ -1071,7 +1071,7 @@ CRedisClusterPubSubClient::Connect( bool reset ) if ( !m_config.desiredFeatures.supportsPublishing ) { clientRole = sw::redis::Role::SLAVE; - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterPubSubClient(" + CORE::ToString( this ) + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterPubSubClient(" + CORE::ToString( this ) + "):Connect: Since there is no desire to publish data we will signal a willingness to use read-only replica nodes" ); } @@ -1086,7 +1086,7 @@ CRedisClusterPubSubClient::Connect( bool reset ) { if ( 0 == strcmp( e.what(), "no slave node available" ) ) { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterPubSubClient(" + CORE::ToString( this ) + + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterPubSubClient(" + CORE::ToString( this ) + "):Connect: Since there are no slave nodes available we will adapt to connect to primary nodes only" ); clientRole = sw::redis::Role::MASTER; @@ -1153,7 +1153,7 @@ CRedisClusterPubSubClient::IsHealthy( void ) const {GUCEF_TRACE; MT::CScopeMutex lock( m_lock ); - + if ( !m_topicMap.empty() ) { // Aggregate the health status of all topics @@ -1168,7 +1168,7 @@ CRedisClusterPubSubClient::IsHealthy( void ) const // Notify if there was a change in status if ( allHealthy != m_isHealthy ) { - m_isHealthy = allHealthy; + m_isHealthy = allHealthy; if ( m_isHealthy ) { @@ -1176,12 +1176,12 @@ CRedisClusterPubSubClient::IsHealthy( void ) const } else { - GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterPubSubClient:IsHealthy: overall health status is now unhealthy" ); + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterPubSubClient:IsHealthy: overall health status is now unhealthy" ); } lock.EarlyUnlock(); - THealthStatusChangeEventData eData( allHealthy ); - NotifyObservers( HealthStatusChangeEvent, &eData ); + THealthStatusChangeEventData eData( allHealthy ); + NotifyObservers( HealthStatusChangeEvent, &eData ); } return allHealthy; @@ -1201,7 +1201,7 @@ CRedisClusterPubSubClient::IsInitialized( void ) const /*-------------------------------------------------------------------------*/ -void +void CRedisClusterPubSubClient::RegisterTopicEventHandlers( PUBSUB::CPubSubClientTopic* topic ) {GUCEF_TRACE; @@ -1294,7 +1294,7 @@ CRedisClusterPubSubClient::OnMetricsTimerCycle( CORE::CNotifier* notifier , GUCEF_METRIC_COUNT( topicMetricsPrefix + ".redisErrorReplies", topicMetrics.redisErrorReplies, 1.0f ); GUCEF_METRIC_COUNT( topicMetricsPrefix + ".redisTimeouts", topicMetrics.redisTimeouts, 1.0f ); GUCEF_METRIC_COUNT( topicMetricsPrefix + ".msgsInFlight", topicMetrics.msgsInFlight, 1.0f ); - + if ( topicConfig.needSubscribeSupport ) { GUCEF_METRIC_COUNT( topicMetricsPrefix + ".msgsReceived", topicMetrics.msgsReceived, 1.0f ); @@ -1475,7 +1475,7 @@ CRedisClusterPubSubClient::OnRedisKeyCacheUpdate( CORE::CNotifier* notifier , { if ( !NotifyObservers( TopicDiscoveryEvent, &updateInfo->newKeys ) ) return; } - + // Build a bulk creation map linking template config to stream names // This allows for better batch processing down the line, reducing overhead TTopicConfigPtrToStringSetMap bulkCreationMap; @@ -1483,7 +1483,7 @@ CRedisClusterPubSubClient::OnRedisKeyCacheUpdate( CORE::CNotifier* notifier , while ( n != updateInfo->newKeys.end() ) { const PUBSUB::CPubSubClientTopicConfigPtr templateConfig = FindTemplateConfigForTopicName( (*n) ); - if ( GUCEF_NULL != templateConfig ) + if ( !templateConfig.IsNULL() ) { bulkCreationMap[ templateConfig ].insert( (*n) ); } @@ -1515,7 +1515,7 @@ CRedisClusterPubSubClient::Lock( UInt32 lockWaitTimeoutInMs ) const /*-------------------------------------------------------------------------*/ MT::TLockStatus -CRedisClusterPubSubClient::Unlock( void ) const +CRedisClusterPubSubClient::Unlock( void ) const {GUCEF_TRACE; return m_lock.Unlock(); @@ -1523,7 +1523,7 @@ CRedisClusterPubSubClient::Unlock( void ) const /*-------------------------------------------------------------------------*/ -const CORE::CString& +const CORE::CString& CRedisClusterPubSubClient::GetClassTypeName( void ) const {GUCEF_TRACE; @@ -1543,7 +1543,7 @@ CRedisClusterPubSubClient::SetJournal( PUBSUB::CIPubSubJournalBasicPtr journal ) /*-------------------------------------------------------------------------*/ -PUBSUB::CIPubSubJournalBasicPtr +PUBSUB::CIPubSubJournalBasicPtr CRedisClusterPubSubClient::GetJournal( void ) const {GUCEF_TRACE; diff --git a/tools/ProcessMetrics/src/ProcessMetrics.cpp b/tools/ProcessMetrics/src/ProcessMetrics.cpp index 634ec36fe..f371e4379 100644 --- a/tools/ProcessMetrics/src/ProcessMetrics.cpp +++ b/tools/ProcessMetrics/src/ProcessMetrics.cpp @@ -291,14 +291,14 @@ ProcessMetrics::CProcInfo::Clear( void ) /*-------------------------------------------------------------------------*/ -ProcessMetrics::CProcInfo& +ProcessMetrics::CProcInfo& ProcessMetrics::CProcInfo::operator=( const CProcInfo& src ) {GUCEF_TRACE; if ( this != &src ) { Clear(); - + pid = CORE::CopyProcessId( src.pid ); previousProcCpuDataDataPoint = CORE::CopyProcCpuDataPoint( previousProcCpuDataDataPoint, pid ); processInformation = src.processInformation; @@ -309,11 +309,11 @@ ProcessMetrics::CProcInfo::operator=( const CProcInfo& src ) restartIfStopsRunning = src.restartIfStopsRunning; } return *this; -} +} /*-------------------------------------------------------------------------*/ -bool +bool ProcessMetrics::CProcInfo::IsProcessStillActive( void ) {GUCEF_TRACE; @@ -334,20 +334,20 @@ ProcessMetrics::CProcInfo::IsProcessStillActive( void ) { if ( lastUptimeInMs > cpuUseInfo.uptimeInMs ) { - GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Proc \"" + exeName + "\" : Uptime went down even though the OS claims the proc is still alive. lastUptime=" + + GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Proc \"" + exeName + "\" : Uptime went down even though the OS claims the proc is still alive. lastUptime=" + CORE::ToString( lastUptimeInMs ) + " -> uptime=" + CORE::ToString( cpuUseInfo.uptimeInMs ) ); - + lastUptimeInMs = cpuUseInfo.uptimeInMs; // If the up time went down then the process cannot possibly have been the same one that persisted // Since things don't add up we will report this proc as dead since the context is that in this app it will cause - // us to refresh all relevant information + // us to refresh all relevant information return false; } lastUptimeInMs = cpuUseInfo.uptimeInMs; } } - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Proc \"" + exeName + "\" is still alive" ); return true; } @@ -385,7 +385,7 @@ ProcessMetrics::CProcInfo::Unlink( void ) /*-------------------------------------------------------------------------*/ -bool +bool ProcessMetrics::CProcInfo::RefreshPID( void ) {GUCEF_TRACE; @@ -403,7 +403,7 @@ ProcessMetrics::CProcInfo::RefreshPID( void ) /*-------------------------------------------------------------------------*/ -bool +bool ProcessMetrics::CProcInfo::RefreshPID( CORE::TProcessId* procIds, CORE::UInt32 procIdCount ) {GUCEF_TRACE; @@ -428,14 +428,14 @@ ProcessMetrics::CProcInfo::RefreshPID( CORE::TProcessId* procIds, CORE::UInt32 p } } } - + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: No running proc match found for \"" + exeName + "\"" ); return success; } /*-------------------------------------------------------------------------*/ -bool +bool ProcessMetrics::CProcInfo::RefreshPID( CORE::TProcessId* newProcId ) {GUCEF_TRACE; @@ -444,14 +444,14 @@ ProcessMetrics::CProcInfo::RefreshPID( CORE::TProcessId* newProcId ) CORE::FreeProcessId( pid ); pid = GUCEF_NULL; GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Refreshing pre-existing PID for \"" + exeName + "\"" ); - } + } else { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Applying PID for \"" + exeName + "\"" ); } - + pid = CORE::CopyProcessId( newProcId ); - + if ( CORE::CProcessInformation::TryGetProcessInformation( pid, processInformation ) ) { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Obtained process information for \"" + exeName + "\"" ); @@ -469,7 +469,7 @@ ProcessMetrics::CProcInfo::RefreshPID( CORE::TProcessId* newProcId ) } else { - previousProcCpuDataDataPoint = CORE::CreateProcCpuDataPoint( pid ); + previousProcCpuDataDataPoint = CORE::CreateProcCpuDataPoint( pid ); } return true; @@ -573,11 +573,11 @@ ProcessMetrics::RegisterEventHandlers( void ) SubscribeTo( &m_metricsTimer , CORE::CTimer::TimerUpdateEvent , callback ); - + TEventCallback callback2( this, &ProcessMetrics::OnProcScanTimerCycle ); SubscribeTo( &m_procIndexTimer , CORE::CTimer::TimerUpdateEvent , - callback2 ); + callback2 ); } /*-------------------------------------------------------------------------*/ @@ -588,7 +588,7 @@ ProcessMetrics::RefreshPIDs( const CORE::CString::StringSet& refreshExeNames ) if ( refreshExeNames.empty() ) return; - + GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Refresing PID administration for " + CORE::ToString( refreshExeNames.size() ) + " items" ); CORE::UInt32 procIdCount = 0; @@ -634,7 +634,7 @@ ProcessMetrics::LaunchProcs( const CORE::CString::StringSet& procsToLaunch ) {GUCEF_TRACE; GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Attempting to launch " + CORE::ToString( procsToLaunch.size() ) + " proc(s)" ); - + bool totalSuccess = true; CORE::CString::StringSet::const_iterator i = procsToLaunch.begin(); while ( i != procsToLaunch.end() ) @@ -677,7 +677,7 @@ ProcessMetrics::LaunchProcs( const CORE::CString::StringSet& procsToLaunch ) } else { - GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Launched process \"" + procInfo.exeName + + GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Launched process \"" + procInfo.exeName + "\" using only its name and command line \"" + cmdLine + "\" but unable to get its meta-data" ); } } @@ -724,11 +724,11 @@ ProcessMetrics::SetupPubSubClient( const CORE::CDataNode& cfg ) if ( !topicNameList.empty() ) { m_thresholdNotificationPublishTopic = m_pubSubClient->GetTopicAccess( *topicNameList.begin() ); - if ( GUCEF_NULL == m_thresholdNotificationPublishTopic ) + if ( m_thresholdNotificationPublishTopic.IsNULL() ) { m_thresholdNotificationPublishTopic = m_pubSubClient->CreateTopicAccess( *topicNameList.begin() ); } - if ( GUCEF_NULL != m_thresholdNotificationPublishTopic ) + if ( !m_thresholdNotificationPublishTopic.IsNULL() ) { GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics:SetupPubSubClient: Successfully obtained access to topic with name: " + *topicNameList.begin() ); return true; @@ -769,7 +769,7 @@ ProcessMetrics::PublishMetricThresholdExceeded( const CORE::CVariant& metricValu const MetricThreshold& threshold ) {GUCEF_TRACE; - if ( m_pubSubClient.IsNULL() || GUCEF_NULL == m_thresholdNotificationPublishTopic ) + if ( m_pubSubClient.IsNULL() || m_thresholdNotificationPublishTopic.IsNULL() ) return; PUBSUB::CBasicPubSubMsg msg; @@ -886,7 +886,7 @@ ProcessMetrics::OnProcScanTimerCycle( CORE::CNotifier* notifier , UInt32 lockedOnProcs = 0; TProcessIdMap::iterator m = m_exeProcsToWatch.begin(); while ( m != m_exeProcsToWatch.end() ) - { + { // We don't just check that we found the proc, we also revalidate that its still alive CProcInfo& procInfo = (*m).second; if ( procInfo.IsProcessStillActive() ) @@ -897,14 +897,14 @@ ProcessMetrics::OnProcScanTimerCycle( CORE::CNotifier* notifier , { nonLockedOnProcs.insert( procInfo.exeName ); - if ( procInfo.startIfNotRunning && + if ( procInfo.startIfNotRunning && ( GUCEF_NULL == procInfo.pid && 0 == procInfo.lastUptimeInMs ) ) { // this proc is not running and has not run before to the best of our knowledge procsToLaunch.insert( procInfo.exeName ); } else - if ( procInfo.restartIfStopsRunning && + if ( procInfo.restartIfStopsRunning && ( GUCEF_NULL != procInfo.pid || 0 != procInfo.lastUptimeInMs ) ) { // this proc was running and is requested to be auto-restarted @@ -918,7 +918,7 @@ ProcessMetrics::OnProcScanTimerCycle( CORE::CNotifier* notifier , // negative number means always match everything if ( m_exeMatchPidMatchThreshold > 0 && lockedOnProcs >= (UInt32) m_exeMatchPidMatchThreshold ) { - GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Locked onto " + CORE::ToString( lockedOnProcs ) + + GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Locked onto " + CORE::ToString( lockedOnProcs ) + " procs out of a minimum match total of " + CORE::ToString( m_exeMatchPidMatchThreshold ) + ", skipping proc scan" ); return; } @@ -938,7 +938,7 @@ ProcessMetrics::RefreshPIDs( void ) UInt32 lockedOnProcs = 0; TProcessIdMap::iterator m = m_exeProcsToWatch.begin(); while ( m != m_exeProcsToWatch.end() ) - { + { // We don't just check that we found the proc, we also revalidate that its still alive CProcInfo& procInfo = (*m).second; if ( procInfo.IsProcessStillActive() ) @@ -966,13 +966,13 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , TStringSet failedProcs; if ( m_gatherMemStats ) - { + { TProcessIdMap::iterator m = m_exeProcsToWatch.begin(); while ( m != m_exeProcsToWatch.end() ) { CProcInfo& procInfo = (*m).second; if ( procInfo.gatherMetrics ) - { + { CORE::TProcessMemoryUsageInfo memUseInfo; if ( OSWRAP_TRUE == CORE::GetProcessMemoryUsage( procInfo.pid, &memUseInfo ) ) { @@ -1031,7 +1031,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , { static const CORE::CString metricName = "CpuUsePercentage"; GUCEF_METRIC_GAUGE( lCpuMetricPrefix + metricName, cpuStats->cpuUsePercentage, 1.0f ); - ValidateMetricThresholds( CORE::CVariant( cpuStats->cpuUsePercentage ), metricName, CORE::CString::Empty ); + ValidateMetricThresholds( CORE::CVariant( cpuStats->cpuUsePercentage ), metricName, CORE::CString::Empty ); } for ( CORE::UInt32 i=0; ilogicalCpuCount; ++i ) @@ -1088,7 +1088,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , { static const CORE::CString metricName = "CpuUsePercentage"; GUCEF_METRIC_GAUGE( lCpuMetricPrefix + metricName, lCpuStats->cpuUsePercentage, 1.0f ); - ValidateMetricThresholds( CORE::CVariant( lCpuStats->cpuUsePercentage ), metricName, CORE::CString::Empty ); + ValidateMetricThresholds( CORE::CVariant( lCpuStats->cpuUsePercentage ), metricName, CORE::CString::Empty ); } } } @@ -1101,7 +1101,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , { CProcInfo& procInfo = (*m).second; if ( procInfo.gatherMetrics ) - { + { CORE::TProcessCpuUsageInfo cpuUseInfo; if ( OSWRAP_TRUE == CORE::GetProcessCpuUsage( procInfo.pid, procInfo.previousProcCpuDataDataPoint, &cpuUseInfo ) ) { @@ -1109,7 +1109,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , // this is used as an extra sanity check on whether the process's lifecycle was interrupted procInfo.lastUptimeInMs = cpuUseInfo.uptimeInMs; - const CORE::CString& procName = (*m).first; + const CORE::CString& procName = (*m).first; CORE::CString metricPrefix = "ProcessMetrics." + procName + '.'; if ( m_gatherProcCpuUptime ) @@ -1198,7 +1198,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , if ( m_gatherGlobalNetworkStats ) { COMCORE::CCom& comms = COMCORE::CComCoreGlobal::Instance()->GetCom(); - + COMCORE::CCom::TINetworkInterfacePtrVector nics; if ( comms.GetAllNetworkInterfaces( nics ) ) { @@ -1317,7 +1317,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , CORE::CString nicMetricName = nicMetricNamePrefix + nic->GetAdapterName() + "ReceiveLinkSpeedBitsPerSec"; GUCEF_METRIC_GAUGE( nicMetricName, nicMetrics.receiveLinkSpeedBitsPerSec, 1.0f ); ValidateMetricThresholds( CORE::CVariant( nicMetrics.receiveLinkSpeedBitsPerSec ), nicMetricName, CORE::CString::Empty ); - } + } } ++i; } @@ -1331,7 +1331,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Fetching storage volume list" ); if ( CORE::GetAllFileSystemStorageVolumes( m_storageVolumeIds ) ) { - GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Successfully obtained a list of " + CORE::ToString( m_storageVolumeIds.size() ) + " storage volumes" ); + GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "ProcessMetrics: Successfully obtained a list of " + CORE::ToString( m_storageVolumeIds.size() ) + " storage volumes" ); } else { @@ -1367,11 +1367,11 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , ++i; } } - } + } } static const CORE::CString storageMetricNamePrefix = "ProcessMetrics.Storage."; - + CORE::CString::StringSet::iterator i = m_storageVolumeIds.begin(); while ( i != m_storageVolumeIds.end() ) { @@ -1386,7 +1386,7 @@ ProcessMetrics::OnMetricsTimerCycle( CORE::CNotifier* notifier , metricStrToUse = &storagePath; CORE::CString metricsStorageVolumeId = GenerateMetricsFriendlyString( *metricStrToUse ); - + if ( m_gatherGlobalStorageVolumeBytesAvailableToCaller ) { CORE::CString storageMetricName = storageMetricNamePrefix + metricsStorageVolumeId + ".FreeBytesAvailableToCaller"; @@ -1490,7 +1490,7 @@ ProcessMetrics::SetStandbyMode( bool newModeIsStandby ) TProcessIdMap::iterator m = m_exeProcsToWatch.begin(); while ( m != m_exeProcsToWatch.end() ) { - CProcInfo& procInfo = (*m).second; + CProcInfo& procInfo = (*m).second; procInfo.Unlink(); ++m; } @@ -1551,7 +1551,7 @@ ProcessMetrics::LoadConfig( const CORE::CValueList& appConfig , m_gatherGlobalCpuSpecMaxFrequencyInMhz = appConfig.GetValueAlways( "gatherGlobalCpuSpecMaxFrequencyInMhz", m_gatherGlobalCpuSpecMaxFrequencyInMhz ).AsBool( m_gatherGlobalCpuSpecMaxFrequencyInMhz, true ); m_gatherGlobalCpuMaxFrequencyInMhz = appConfig.GetValueAlways( "gatherGlobalCpuMaxFrequencyInMhz", m_gatherGlobalCpuMaxFrequencyInMhz ).AsBool( m_gatherGlobalCpuMaxFrequencyInMhz, true ); m_gatherGlobalCpuOverallPercentage = appConfig.GetValueAlways( "gatherGlobalCpuOverallPercentage", m_gatherGlobalCpuOverallPercentage ).AsBool( m_gatherGlobalCpuOverallPercentage, true ); - m_gatherGlobalCpuOverallPercentagePerCore = appConfig.GetValueAlways( "gatherGlobalCpuOverallPercentagePerCore", m_gatherGlobalCpuOverallPercentagePerCore ).AsBool( m_gatherGlobalCpuOverallPercentagePerCore, true ); + m_gatherGlobalCpuOverallPercentagePerCore = appConfig.GetValueAlways( "gatherGlobalCpuOverallPercentagePerCore", m_gatherGlobalCpuOverallPercentagePerCore ).AsBool( m_gatherGlobalCpuOverallPercentagePerCore, true ); m_gatherGlobalNetworkStats = appConfig.GetValueAlways( "gatherGlobalNetworkStats", m_gatherGlobalNetworkStats ).AsBool( m_gatherGlobalNetworkStats, true ); m_gatherGlobalNetworkStatInboundOctets = appConfig.GetValueAlways( "gatherGlobalNetworkStatInboundOctets", m_gatherGlobalNetworkStatInboundOctets ).AsBool( m_gatherGlobalNetworkStatInboundOctets, true ); @@ -1563,7 +1563,7 @@ ProcessMetrics::LoadConfig( const CORE::CValueList& appConfig , m_gatherGlobalNetworkStatOutboundUnicastOctets = appConfig.GetValueAlways( "gatherGlobalNetworkStatOutboundUnicastOctets", m_gatherGlobalNetworkStatOutboundUnicastOctets ).AsBool( m_gatherGlobalNetworkStatOutboundUnicastOctets, true ); m_gatherGlobalNetworkStatOutboundUnicastPackets = appConfig.GetValueAlways( "gatherGlobalNetworkStatOutboundUnicastPackets", m_gatherGlobalNetworkStatOutboundUnicastPackets ).AsBool( m_gatherGlobalNetworkStatOutboundUnicastPackets, true ); m_gatherGlobalNetworkStatOutboundErroredPackets = appConfig.GetValueAlways( "gatherGlobalNetworkStatOutboundErroredPackets", m_gatherGlobalNetworkStatOutboundErroredPackets ).AsBool( m_gatherGlobalNetworkStatOutboundErroredPackets, true ); - m_gatherGlobalNetworkStatOutboundDiscardedPackets = appConfig.GetValueAlways( "gatherGlobalNetworkStatOutboundDiscardedPackets", m_gatherGlobalNetworkStatOutboundDiscardedPackets ).AsBool( m_gatherGlobalNetworkStatOutboundDiscardedPackets, true ); + m_gatherGlobalNetworkStatOutboundDiscardedPackets = appConfig.GetValueAlways( "gatherGlobalNetworkStatOutboundDiscardedPackets", m_gatherGlobalNetworkStatOutboundDiscardedPackets ).AsBool( m_gatherGlobalNetworkStatOutboundDiscardedPackets, true ); m_gatherGlobalNetworkStatInboundMulticastOctets = appConfig.GetValueAlways( "gatherGlobalNetworkStatInboundMulticastOctets", m_gatherGlobalNetworkStatInboundMulticastOctets ).AsBool( m_gatherGlobalNetworkStatInboundMulticastOctets, true ); m_gatherGlobalNetworkStatOutboundMulticastOctets = appConfig.GetValueAlways( "gatherGlobalNetworkStatOutboundMulticastOctets", m_gatherGlobalNetworkStatOutboundMulticastOctets ).AsBool( m_gatherGlobalNetworkStatOutboundMulticastOctets, true ); m_gatherGlobalNetworkStatInboundBroadcastOctets = appConfig.GetValueAlways( "gatherGlobalNetworkStatInboundBroadcastOctets", m_gatherGlobalNetworkStatInboundBroadcastOctets ).AsBool( m_gatherGlobalNetworkStatInboundBroadcastOctets, true ); diff --git a/tools/redisinfo/src/redisinfo_CRedisClusterKeyCache.cpp b/tools/redisinfo/src/redisinfo_CRedisClusterKeyCache.cpp index a4a715837..bf08054e4 100644 --- a/tools/redisinfo/src/redisinfo_CRedisClusterKeyCache.cpp +++ b/tools/redisinfo/src/redisinfo_CRedisClusterKeyCache.cpp @@ -75,7 +75,7 @@ namespace REDISINFO { //-------------------------------------------------------------------------*/ const CORE::CEvent CRedisClusterKeyCache::CacheUpdateEvent = "GUCEF::PUBSUBPLUGIN::REDISCLUSTER::CRedisClusterKeyCache::CacheUpdateEvent"; -#define GUCEF_DEFAULT_SCAN_COUNT_SIZE 5000 +#define GUCEF_DEFAULT_SCAN_COUNT_SIZE 5000 #define GUCEF_DEFAULT_CACHE_UPDATE_TIMER_INTERVAL ( 5 * 60 * 1000 ) // 5mins MT::CReadWriteLock CRedisClusterKeyCache::g_dataLock( true ); @@ -153,7 +153,7 @@ CRedisClusterKeyCache::CRedisClusterKeyCache( void ) {GUCEF_TRACE; MT::CScopeWriterLock lock( g_dataLock ); - + if ( !m_threadPool.IsNULL() ) m_threadPool->RequestAllThreadsToStop( true, false ); m_threadPool.Unlink(); @@ -223,7 +223,7 @@ CRedisClusterKeyCache::SetRedisScanInterationCountSize( UInt32 countSize ) /*-------------------------------------------------------------------------*/ -UInt32 +UInt32 CRedisClusterKeyCache::GetRedisScanInterationCountSize( void ) const {GUCEF_TRACE; @@ -263,22 +263,22 @@ CRedisClusterKeyCache::GetRedisKeys( RedisClusterPtr redisCluster return false; CORE::UInt64 resultOffset = page * (CORE::UInt64) maxResults; - + MT::CScopeReaderLock lock( g_dataLock ); - + TStringToStringSetMap& keyMap = m_cache[ redisCluster ]; - CORE::CString::StringSet& cachedKeys = keyMap[ keyType ]; + CORE::CString::StringSet& cachedKeys = keyMap[ keyType ]; if ( globPatternsToMatch.empty() ) { // No pattern matching, return everything - + // first sanity check if ( resultOffset + maxResults > cachedKeys.size() ) { if ( resultOffset > cachedKeys.size() ) return true; // empty result set since we are past the max - + // cap the values CORE::UInt64 remnant = cachedKeys.size() - resultOffset; if ( remnant < maxResults ) @@ -294,12 +294,12 @@ CRedisClusterKeyCache::GetRedisKeys( RedisClusterPtr redisCluster else break; } - + // copy the specified subset CORE::UInt32 resultEntries = 0; while ( i != cachedKeys.end() && resultEntries < maxResults ) { - keys.insert( (*i) ); + keys.insert( (*i) ); ++i; ++resultEntries; } @@ -311,7 +311,7 @@ CRedisClusterKeyCache::GetRedisKeys( RedisClusterPtr redisCluster CORE::CString::StringSet::iterator i = cachedKeys.begin(); while ( i != cachedKeys.end() ) { - const CORE::CString& key = (*i); + const CORE::CString& key = (*i); CORE::CString::StringSet::iterator g = globPatternsToMatch.begin(); while ( g != globPatternsToMatch.end() ) { @@ -368,7 +368,7 @@ CRedisClusterKeyCache::GetRedisKeys( RedisClusterPtr redisCluster keys.Clear(); keys.SetName( keyType ); keys.SetNodeType( GUCEF_DATATYPE_ARRAY ); - + CORE::CString::StringSet flatIndexOfKeys; if ( GetRedisKeys( redisCluster, flatIndexOfKeys, keyType, globPatternsToMatch ) ) { @@ -377,7 +377,7 @@ CRedisClusterKeyCache::GetRedisKeys( RedisClusterPtr redisCluster { keys.AddValueAsChild( (*i) ); ++i; - } + } return true; } return false; @@ -385,7 +385,7 @@ CRedisClusterKeyCache::GetRedisKeys( RedisClusterPtr redisCluster /*-------------------------------------------------------------------------*/ -void +void CRedisClusterKeyCache::StopUpdatesForCluster( RedisClusterPtr redisCluster ) {GUCEF_TRACE; @@ -396,14 +396,14 @@ CRedisClusterKeyCache::StopUpdatesForCluster( RedisClusterPtr redisCluster ) /*-------------------------------------------------------------------------*/ // Only intended to be used by the closely coupled task class -bool +bool CRedisClusterKeyCache::GetRedisClusterAccess( RedisClusterPtrSet& set ) {GUCEF_TRACE; try { MT::CScopeReaderLock lock( g_dataLock ); - + TRedisClusterPtrToTypeKeysMap::iterator i = m_cache.begin(); while ( i != m_cache.end() ) { @@ -421,7 +421,7 @@ CRedisClusterKeyCache::GetRedisClusterAccess( RedisClusterPtrSet& set ) /*-------------------------------------------------------------------------*/ // Only intended to be used by the closely coupled task class -bool +bool CRedisClusterKeyCache::GetRedisKeyCache( RedisClusterPtr& redisCluster , const CORE::CString& keyType , CORE::CString::StringSet** keys ) @@ -432,7 +432,7 @@ CRedisClusterKeyCache::GetRedisKeyCache( RedisClusterPtr& redisCluster , TStringToStringSetMap& keyMap = m_cache[ redisCluster ]; CORE::CString::StringSet& cachedKeys = keyMap[ keyType ]; - + *keys = &cachedKeys; return true; } @@ -440,7 +440,7 @@ CRedisClusterKeyCache::GetRedisKeyCache( RedisClusterPtr& redisCluster , /*-------------------------------------------------------------------------*/ // Only intended to be used by the closely coupled task class -bool +bool CRedisClusterKeyCache::ApplyKeyDelta( CacheUpdateInfo& updateInfo ) {GUCEF_TRACE; @@ -455,7 +455,7 @@ CRedisClusterKeyCache::ApplyKeyDelta( CacheUpdateInfo& updateInfo ) MT::CScopeWriterLock lock( g_dataLock ); TStringToStringSetMap& keyMap = m_cache[ updateInfo.redisCluster ]; - CORE::CString::StringSet& cachedKeys = keyMap[ updateInfo.keyType ]; + CORE::CString::StringSet& cachedKeys = keyMap[ updateInfo.keyType ]; // delete the deleted keys CORE::CString::StringSet::iterator i = updateInfo.deletedKeys.begin(); @@ -474,7 +474,7 @@ CRedisClusterKeyCache::ApplyKeyDelta( CacheUpdateInfo& updateInfo ) } } - // Now that the changes have been applied and the write lock released we + // Now that the changes have been applied and the write lock released we // notify of the changes NotifyObservers( CacheUpdateEvent, &updateInfo ); } @@ -482,7 +482,7 @@ CRedisClusterKeyCache::ApplyKeyDelta( CacheUpdateInfo& updateInfo ) { return false; } - return true; + return true; } /*-------------------------------------------------------------------------*/ @@ -524,11 +524,11 @@ CRedisClusterKeyCache::SetPersistKeyCacheSnapshotCodec( const CORE::CString& sna /*-------------------------------------------------------------------------*/ bool -CRedisClusterKeyCache::SaveDocTo( const CORE::CDataNode& doc , - const CORE::CString& codecName , +CRedisClusterKeyCache::SaveDocTo( const CORE::CDataNode& doc , + const CORE::CString& codecName , const CORE::CString& vfsPath ) const {GUCEF_TRACE; - + VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs(); if ( !vfs.IsInitialized() ) { @@ -536,16 +536,16 @@ CRedisClusterKeyCache::SaveDocTo( const CORE::CDataNode& doc , return false; } - CORE::CDStoreCodecRegistry::TDStoreCodecPtr codec; + CORE::CDStoreCodecRegistry::TDStoreCodecPtr codec; CORE::CCoreGlobal::Instance()->GetDStoreCodecRegistry().TryLookup( codecName, codec, false ); if ( !codec ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterKeyCache:SaveDocTo: Could not obtain codec for codecName : " + codecName ); - return false; + return false; } VFS::TBasicVfsResourcePtr file = vfs.GetFile( vfsPath, "wb", true ); - if ( file.IsNULL() || GUCEF_NULL == file->GetAccess() ) + if ( file.IsNULL() || file->GetAccess().IsNULL() ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "RedisClusterKeyCache:SaveDocTo: VFS could not provide access to file at path: " + vfsPath ); return false;