VOL-1050 Delay stats collection after connection
Move the state of connectivity and activation to its own file (state)
It handles starting/stopping statistics collection and provides a hook for future actions
Change-Id: If6a7b4015824716ff45781e39f29ca7f06933702
diff --git a/src/server.cc b/src/server.cc
index cfd6f3f..ae2cd56 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -29,6 +29,7 @@
#include "core.h"
#include "indications.h"
#include "stats_collection.h"
+#include "state.h"
#include <grpc++/grpc++.h>
#include <openolt.grpc.pb.h>
@@ -105,17 +106,20 @@
ServerWriter<openolt::Indication>* writer) override {
std::cout << "Connection to Voltha established. Indications enabled"
<< std::endl;
- bool isConnected = true;
- while (isConnected) {
+ state::connect();
+
+ while (state::is_connected) {
auto oltInd = oltIndQ.pop();
- isConnected = writer->Write(oltInd);
+ bool isConnected = writer->Write(oltInd);
if (!isConnected) {
//Lost connectivity to this Voltha instance
//Put the indication back in the queue for next connecting instance
oltIndQ.push(oltInd);
+ state::disconnect();
}
//oltInd.release_olt_ind()
}
+
return Status::OK;
}