From 06d60cbbb5af11a2cd6994790cf39d8b37b4fe31 Mon Sep 17 00:00:00 2001 From: Eduard Moskalchuk Date: Thu, 23 Jul 2026 08:56:08 +0200 Subject: [PATCH] hmon: Define configuration schema --- .../configuration/health_monitor_config.fbs | 82 +++++++ .../health_monitor_config.schema.json | 223 ++++++++++++++++++ 2 files changed, 305 insertions(+) create mode 100644 score/health_monitor/configuration/health_monitor_config.fbs create mode 100644 score/health_monitor/configuration/health_monitor_config.schema.json diff --git a/score/health_monitor/configuration/health_monitor_config.fbs b/score/health_monitor/configuration/health_monitor_config.fbs new file mode 100644 index 000000000..014d49876 --- /dev/null +++ b/score/health_monitor/configuration/health_monitor_config.fbs @@ -0,0 +1,82 @@ +// ******************************************************************************** +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************** + +namespace score.mw.health.config; + +file_identifier "HMCF"; +file_extension "bin"; + +/// Scheduler policy for the monitoring thread. +enum SchedulerPolicy : byte { + Other = 0, + Fifo = 1, + RoundRobin = 2 +} + +/// Thread parameters for the monitoring thread. +table ThreadParameters { + policy: SchedulerPolicy = null; + priority: int32 = null; + affinity: [uint32]; + stack_size: uint32 = null; +} + +/// A time range with minimum and maximum durations in milliseconds. +table TimeRange { + min_ms: uint32; + max_ms: uint32; +} + +/// A single deadline entry within a deadline monitor. +table DeadlineEntry { + deadline_tag: string (required); + range: TimeRange (required); +} + +/// Configuration for a deadline monitor. +table DeadlineMonitor { + monitor_tag: string (required); + deadlines: [DeadlineEntry] (required); +} + +/// Configuration for a heartbeat monitor. +table HeartbeatMonitor { + monitor_tag: string (required); + range: TimeRange (required); +} + +/// A state and its allowed transitions in a logic monitor. +table StateNode { + state: string (required); + allowed_transitions: [string] (required); +} + +/// Configuration for a logic monitor. +table LogicMonitor { + monitor_tag: string (required); + initial_state: string (required); + states: [StateNode] (required); +} + +/// Root configuration for a HealthMonitor instance. +table HealthMonitorConfig { + schema_version: uint32 = null; + supervisor_api_cycle_ms: uint32; + internal_processing_cycle_ms: uint32; + thread_parameters: ThreadParameters; + deadline_monitors: [DeadlineMonitor]; + heartbeat_monitors: [HeartbeatMonitor]; + logic_monitors: [LogicMonitor]; +} + +root_type HealthMonitorConfig; diff --git a/score/health_monitor/configuration/health_monitor_config.schema.json b/score/health_monitor/configuration/health_monitor_config.schema.json new file mode 100644 index 000000000..dbf2865c4 --- /dev/null +++ b/score/health_monitor/configuration/health_monitor_config.schema.json @@ -0,0 +1,223 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "health_monitor_config.schema.json", + "title": "HealthMonitorConfig", + "description": "Configuration schema for HealthMonitor (compatible with health_monitor_config.fbs)", + "type": "object", + "required": [ + "schema_version", + "supervisor_api_cycle_ms", + "internal_processing_cycle_ms" + ], + "properties": { + "schema_version": { + "type": "integer", + "description": "Schema version", + "enum": [ + 1 + ] + }, + "supervisor_api_cycle_ms": { + "type": "integer", + "minimum": 1, + "description": "Cycle duration in ms for supervisor API notifications" + }, + "internal_processing_cycle_ms": { + "type": "integer", + "minimum": 1, + "description": "Cycle duration in ms for internal deadline checks" + }, + "thread_parameters": { + "$ref": "#/definitions/ThreadParameters" + }, + "deadline_monitors": { + "type": "array", + "items": { + "$ref": "#/definitions/DeadlineMonitor" + }, + "description": "List of deadline monitors" + }, + "heartbeat_monitors": { + "type": "array", + "items": { + "$ref": "#/definitions/HeartbeatMonitor" + }, + "description": "List of heartbeat monitors" + }, + "logic_monitors": { + "type": "array", + "items": { + "$ref": "#/definitions/LogicMonitor" + }, + "description": "List of logic monitors" + } + }, + "additionalProperties": false, + "definitions": { + "SchedulerPolicy": { + "type": "string", + "enum": [ + "POSIX_OTHER", + "POSIX_FIFO", + "POSIX_RR" + ], + "description": "Scheduler policy for the monitoring thread" + }, + "ThreadParameters": { + "type": "object", + "properties": { + "policy": { + "$ref": "#/definitions/SchedulerPolicy", + "description": "Scheduler policy for the monitoring thread" + }, + "priority": { + "type": "integer", + "description": "Thread priority" + }, + "affinity": { + "type": "array", + "items": { + "type": "integer", + "minimum": 0 + }, + "description": "CPU core IDs the thread can run on" + }, + "stack_size": { + "type": "integer", + "minimum": 0, + "description": "Stack size in bytes" + } + }, + "additionalProperties": false + }, + "TimeRange": { + "type": "object", + "required": [ + "min_ms", + "max_ms" + ], + "properties": { + "min_ms": { + "type": "integer", + "minimum": 0, + "description": "Minimum duration in milliseconds" + }, + "max_ms": { + "type": "integer", + "minimum": 0, + "description": "Maximum duration in milliseconds" + } + }, + "additionalProperties": false + }, + "DeadlineEntry": { + "type": "object", + "required": [ + "deadline_tag", + "range" + ], + "properties": { + "deadline_tag": { + "type": "string", + "minLength": 1, + "description": "Unique identifier for the deadline" + }, + "range": { + "$ref": "#/definitions/TimeRange" + } + }, + "additionalProperties": false + }, + "DeadlineMonitor": { + "type": "object", + "required": [ + "monitor_tag", + "deadlines" + ], + "properties": { + "monitor_tag": { + "type": "string", + "minLength": 1, + "description": "Unique identifier for the deadline monitor" + }, + "deadlines": { + "type": "array", + "items": { + "$ref": "#/definitions/DeadlineEntry" + }, + "minItems": 1 + } + }, + "additionalProperties": false + }, + "HeartbeatMonitor": { + "type": "object", + "required": [ + "monitor_tag", + "range" + ], + "properties": { + "monitor_tag": { + "type": "string", + "minLength": 1, + "description": "Unique identifier for the heartbeat monitor" + }, + "range": { + "$ref": "#/definitions/TimeRange" + } + }, + "additionalProperties": false + }, + "StateNode": { + "type": "object", + "required": [ + "state", + "allowed_transitions" + ], + "properties": { + "state": { + "type": "string", + "minLength": 1, + "description": "State identifier" + }, + "allowed_transitions": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "description": "List of states reachable from this state" + } + }, + "additionalProperties": false + }, + "LogicMonitor": { + "type": "object", + "required": [ + "monitor_tag", + "initial_state", + "states" + ], + "properties": { + "monitor_tag": { + "type": "string", + "minLength": 1, + "description": "Unique identifier for the logic monitor" + }, + "initial_state": { + "type": "string", + "minLength": 1, + "description": "Starting state of the logic monitor" + }, + "states": { + "type": "array", + "items": { + "$ref": "#/definitions/StateNode" + }, + "minItems": 1 + } + }, + "additionalProperties": false + } + } +}