From 1780e269d4ff5df68566d9d4308b2bb4f468e0f4 Mon Sep 17 00:00:00 2001 From: Geir Horn Date: Tue, 2 Jul 2024 21:36:13 +0200 Subject: [PATCH] Added output operator for application state to report state in logging messages --- .vscode/c_cpp_properties.json | 16 ++++++++-------- MetricUpdater.cpp | 1 + MetricUpdater.hpp | 32 +++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 19d5bf0..6cc9639 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -3,16 +3,16 @@ { "name": "Linux", "includePath": [ - "/home/GHo/Documents/Code/NebulOuS/Solvers/", + "${workspaceFolder}/**", + "/usr/include/c++/14/", + "/usr/include/linux/", + "/home/GHo/Documents/Code/NebulOuS/Solver/", "/home/GHo/Documents/Code/Theron++/", "/home/GHo/Documents/Code/CxxOpts/include/", - "/opt/AMPL/amplapi/include", - "${workspaceFolder}/**", - "/usr/include/c++/13/", - "/usr/include/linux/" + "/opt/AMPL/amplapi/include" ], "defines": [], - "cStandard": "gnu23", + "cStandard": "c23", "intelliSenseMode": "linux-gcc-x64", "compilerPath": "/usr/lib64/ccache/g++", "compilerArgs": [ @@ -27,11 +27,11 @@ "configurationProvider": "ms-vscode.makefile-tools", "browse": { "path": [ - "/home/GHo/Documents/Code/NebulOuS/Solvers", + "/home/GHo/Documents/Code/NebulOuS/Solver", "/home/GHo/Documents/Code/Theron++/", "/home/GHo/Documents/Code/CxxOpts/include/", "/opt/AMPL/amplapi/include/", - "/usr/include/c++/13/", + "/usr/include/c++/14/", "/usr/include/linux/" ], "limitSymbolsToIncludedHeaders": false diff --git a/MetricUpdater.cpp b/MetricUpdater.cpp index f455eaa..0cab5e2 100644 --- a/MetricUpdater.cpp +++ b/MetricUpdater.cpp @@ -261,6 +261,7 @@ void MetricUpdater::SLOViolationHandler( { Output << "... failed to forward the application execution context (size: " << MetricValues.size() << "," << " Unset: " << UnsetMetrics + << " Application state: " << ApplicationState << ")" << std::endl; if( MetricValues.empty() ) diff --git a/MetricUpdater.hpp b/MetricUpdater.hpp index 9366bbb..87ab8b7 100644 --- a/MetricUpdater.hpp +++ b/MetricUpdater.hpp @@ -255,7 +255,7 @@ class MetricUpdater Ready, // The application is ready for deployment Deploying, // The application is being deployed or redeployed Running, // The application is running - Failed // The application is in an invalid state + Failed // The application is in an invalid state }; // An arriving lifecycle message indicates a change in state and it is @@ -264,6 +264,36 @@ class MetricUpdater operator State() const; + // There is a need to be able to report the current state of the + // application in textual form, and it is therefore an inverse mapping + // that takes the application state and prints it out as a string to + // the given output stream. + + friend std::ostream & operator << ( std::ostream & Output, + const State ApplicationState ) + { + switch ( ApplicationState ) + { + case State::Deploying : + Output << "Deploying"; + break; + case State::Failed : + Output << "Failed"; + break; + case State::New : + Output << "New"; + break; + case State::Ready : + Output << "Ready"; + break; + case State::Running : + Output << "Running"; + break; + } + + return Output; + } + // Constructors and destructor ApplicationLifecycle( void )