#include <anna/http/functions.hpp>
#include <anna/comm/functions.hpp>
#include <anna/timex/Engine.hpp>
+#include <anna/timex/Clock.hpp>
#include <anna/diameter/stack/Engine.hpp>
#include <anna/diameter/codec/Engine.hpp>
#include <anna/diameter.comm/OamModule.hpp>
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// COUNTERS RECORD PROCEDURE //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+class MyCounterRecorderClock : public anna::timex::Clock {
+ public:
+ MyCounterRecorderClock(const char *clockName, const anna::Millisecond & timeout) :
+ anna::timex::Clock(clockName, timeout) {;}
+ //virtual ~MyCounterRecorderClock();
+
+ virtual bool tick() throw (RuntimeException) {
+ anna::diameter::comm::OamModule::instantiate().recordCounters();
+ anna::diameter::codec::OamModule::instantiate().recordCounters();
+ return true;
+ }
+};
+
+class MyCounterRecorder : public anna::oam::CounterRecorder {
+
+ // pure virtual definitions:
+ void open() throw(anna::RuntimeException) {;}
+ void apply(const anna::oam::Counter& counter) throw(anna::RuntimeException) {;}
+ void close() throw() {;}
+ std::string asString() const throw() { return "Physical dump not implemented: see memory accumulations writting context (kill -10 <pid>)"; }
+};
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
class MyDiameterEntity : public anna::diameter::comm::Entity {
void eventResponse(const anna::diameter::comm::Response&) throw(anna::RuntimeException);
void eventBreakConnection(Server* server) throw();
};
-
-/*
-class MyCounterRecorder : public anna::oam::CounterRecorder {
-
- // pure virtual definitions:
- void open() throw(anna::RuntimeException) {;}
- void apply(const anna::oam::Counter& counter) throw(anna::RuntimeException) {;}
- void close() throw() {;}
- std::string asString() const throw() { return "Physical dump not implemented: see memory accumulations writting context (kill -10 <pid>)"; }
-};
-*/
-
class Launcher : public anna::comm::Application {
MyCommunicator *a_communicator;
bool a_splitLog, a_detailedLog;
anna::time::Date a_start_time;
anna::timex::Engine* a_timeEngine;
- //MyCounterRecorder *a_counterRecorder;
+ MyCounterRecorder *a_counterRecorder;
+ MyCounterRecorderClock *a_counterRecorderClock;
std::string a_cerPathfile;
std::string a_dwrPathfile;
a_splitLog = false;
a_detailedLog = false;
a_timeEngine = NULL;
- //a_counterRecorder = NULL;
+ a_counterRecorder = NULL;
+ a_counterRecorderClock = NULL;
a_entity = NULL;
a_diameterLocalServer = NULL;
a_cerPathfile = "cer.xml";
// workMode = anna::comm::Communicator::WorkMode::Clone;
a_communicator = new MyCommunicator(workMode);
a_timeEngine = new anna::timex::Engine((anna::Millisecond)300000, (anna::Millisecond)150);
- //a_counterRecorder = new MyCounterRecorder();
+ a_counterRecorder = new MyCounterRecorder();
+ a_counterRecorderClock = new MyCounterRecorderClock("Counters record procedure clock", Millisecond(10000));
+ //a_counterRecorderClock = new MyCounterRecorderClock("Counters record procedure clock", Millisecond(300000));
}
void Launcher::run()
oamDiameterComm.initializeCounterScope(1); // 1000 - 1999
anna::diameter::codec::OamModule & oamDiameterCodec = anna::diameter::codec::OamModule::instantiate();
oamDiameterCodec.initializeCounterScope(2); // 2000 - 2999
+
/////////////////
// COMM MODULE //
/////////////////
oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FailedRuleForCardinalityMoreThanNeeded, "", 17 /*2017*/);
oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FailedGenericAvpRuleForCardinalityFoundDisregardedItem, "", 18 /*2018*/);
oamDiameterCodec.registerCounter(anna::diameter::codec::OamModule::Counter::LevelValidation__FoundDisregardedItemsAndGenericAVPWasNotSpecified, "", 19 /*2019*/);
- //anna::oam::CounterManager& cm = anna::oam::CounterManager::instantiate();
- //cm.setEngine(a_timeEngine);
- //cm.setRecordPeriod(Millisecond(300000));
- ////cm.setCounterRecorder(static_cast<anna::oam::CounterRecorder*>(a_counterRecorder)); ... will be NULL
+
+ /////////////////////////////////
+ // Counter recorder associated //
+ /////////////////////////////////
+ oamDiameterComm.setCounterRecorder(a_counterRecorder);
+ oamDiameterCodec.setCounterRecorder(a_counterRecorder);
+ a_timeEngine->activate(a_counterRecorderClock); // start clock
// Checking command line parameters
if (cl.exists("sessionBasedModelsClientSocketSelection")) {
LOGMETHOD(anna::TraceMethod tttm("anna::oam::Module", "recordCounters", ANNA_FILE_LOCATION));
if(a_counterRecorder == NULL)
- throw RuntimeException("anna::oam::CounterManager has no counter recorder associated", ANNA_FILE_LOCATION);
+ throw RuntimeException("anna::oam::Module has no counter recorder associated", ANNA_FILE_LOCATION);
LOGDEBUG(
std::string msg("Recording counters | ");
cscope = scope(scope_it);
if(cscope == NULL) continue;
- //CounterScope& counterScope(*scope);
- //Guard csGuard(counterScope, "oam::CounterScope from oam::CounterManager::record");
- Guard csGuard(cscope, "oam::CounterScope from oam::CounterManager::record");
+ Guard csGuard(cscope, "oam::CounterScope from oam::Module::record");
for(register int icounter = 0; icounter < CounterScope::MaxCounter; icounter ++) {
Counter* counter = cscope->a_counters [icounter];