diff --git a/definitions/Definitions.vcxproj b/definitions/Definitions.vcxproj index 7e65943b..dd2bbc6f 100644 --- a/definitions/Definitions.vcxproj +++ b/definitions/Definitions.vcxproj @@ -37,9 +37,9 @@ + - @@ -76,6 +76,20 @@ python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --case-convention legacy --keep-empty -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --case-convention legacy --keep-empty -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + $(ProjectDir)../interfaces/json/JMemoryMonitor.h + $(ProjectDir)../interfaces/json/JMemoryMonitor.h + $(ProjectDir)../interfaces/json/JMemoryMonitor.h + $(ProjectDir)../interfaces/json/JMemoryMonitor.h + ClInclude + ClInclude + ClInclude + ClInclude + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force diff --git a/definitions/Definitions.vcxproj.filters b/definitions/Definitions.vcxproj.filters index 9d17a94e..e5058393 100644 --- a/definitions/Definitions.vcxproj.filters +++ b/definitions/Definitions.vcxproj.filters @@ -84,9 +84,6 @@ Generated Files - - Generated Files - Generated Files @@ -144,6 +141,9 @@ Generated Files + + Generated Files + @@ -273,6 +273,9 @@ Interfaces + + Interfaces + Interfaces diff --git a/interfaces/IMemoryMonitor.h b/interfaces/IMemoryMonitor.h new file mode 100644 index 00000000..c805865a --- /dev/null +++ b/interfaces/IMemoryMonitor.h @@ -0,0 +1,109 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2024 Metrological + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#pragma once + +#include "Module.h" + +// @insert + +namespace Thunder { + +namespace Exchange { + + // @json 1.0.0 @text:legacy_lowercase + struct EXTERNAL IMemoryMonitor : virtual public Core::IUnknown { + + enum { ID = ID_MEMORY_MONITOR }; + + struct Restart { + uint8_t limit /* @brief Maximum number or restarts to be attempted (e.g. 3) */; + uint16_t window /* @brief Time period (in seconds) within which failures must happen for the limit to be considered crossed (e.g. 60) */; + }; + + struct Measurement { + uint64_t min /* @brief Minimal value measured (e.g. 0) */; + uint64_t max /* @brief Maximal value measured (e.g. 100) */; + uint64_t average /* @brief Average of all measurements (e.g. 50) */; + uint64_t last /* @brief Last measured value (e.g. 100) */; + }; + + struct Statistics { + Measurement resident /* @brief Resident memory measurement */; + Measurement allocated /* @brief Allocated memory measurement */; + Measurement shared /* @brief Shared memory measurement */; + Measurement process /* @brief Processes measurement */; + bool operational /* @brief Whether the service is up and running (e.g. true) */; + uint32_t count /* @brief Number of measurements (e.g. 100) */; + }; + + using IStringIterator = RPC::IIteratorType; + + // @event + struct EXTERNAL INotification : virtual public Core::IUnknown { + + enum { ID = ID_MEMORY_MONITOR_NOTIFICATION }; + + enum action : uint8_t { + DEACTIVATED, + ACTIVATED, + RESTARTING_STOPPED + }; + + enum reason : uint8_t { + EXCEEDED_MEMORY, + NOT_OPERATIONAL + }; + + // @brief Signals an action taken by the Monitor + // @param callsign: Callsign of the service the Monitor acted upon (e.g. WebServer) + // @param action: Ation executed by the Monitor on a service (e.g. Deactivate) + // @param reason: Mssage describing the reason the action was taken (e.g. EXCEEDED_MEMORY) + virtual void StatusChanged(const string& callsign, const action action, const Core::OptionalType& reason) = 0; + }; + + virtual Core::hresult Register(INotification* const notification) = 0; + virtual Core::hresult Unregister(const INotification* const notification) = 0; + + // @property + // @brief Limits of restarting of a service + // @param callsign: Callsign of the service (e.g. WebServer) + // @param restart: Limits of restarts applying to a given service + virtual Core::hresult RestartingLimits(const string& callsign /* @index */, const Restart& restart) = 0; + virtual Core::hresult RestartingLimits(const string& callsign /* @index */, Restart& restart /* @out */) const = 0; + + // @property + // @brief List of services watched by the Monitor + // @param observables: List of monitored services + virtual Core::hresult Observables(IStringIterator*& observables /* @out */) const = 0; + + // @property + // @brief Memory statistics for a given service + // @param callsign: Callsign of the service (e.g. WebServer) + // @param statistics: Statistics for the requested callsign + virtual Core::hresult MeasurementData(const string& callsign /* @index */, Statistics& statistics /* @out */) const = 0; + + // @brief Resets memory statistics for a given service + // @param callsign: Callsign of the service (e.g. WebServer) + virtual Core::hresult ResetStatistics(const string& callsign) = 0; + }; + +} // namespace Exchange + +} \ No newline at end of file diff --git a/interfaces/Ids.h b/interfaces/Ids.h index df7b9105..d4187ee2 100644 --- a/interfaces/Ids.h +++ b/interfaces/Ids.h @@ -398,7 +398,10 @@ namespace Exchange { ID_SECURITYAGENT = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x550, ID_LOCATIONSYNC = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x560, - ID_LOCATIONSYNC_NOTIFICATION = ID_LOCATIONSYNC + 1 + ID_LOCATIONSYNC_NOTIFICATION = ID_LOCATIONSYNC + 1, + + ID_MEMORY_MONITOR = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x570, + ID_MEMORY_MONITOR_NOTIFICATION = ID_MEMORY_MONITOR + 1 }; } } diff --git a/interfaces/Interfaces.vcxproj b/interfaces/Interfaces.vcxproj index 82c51818..fd1b924e 100644 --- a/interfaces/Interfaces.vcxproj +++ b/interfaces/Interfaces.vcxproj @@ -130,6 +130,7 @@ + diff --git a/interfaces/Interfaces.vcxproj.filters b/interfaces/Interfaces.vcxproj.filters index 0fb7e737..6e81a224 100644 --- a/interfaces/Interfaces.vcxproj.filters +++ b/interfaces/Interfaces.vcxproj.filters @@ -419,6 +419,9 @@ Interface Files + + Interface Files + Interface Files