Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions include/aos/cm/imageprovider.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (C) 2025 EPAM Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef AOS_CM_IMAGEPROVIDER_HPP_
#define AOS_CM_IMAGEPROVIDER_HPP_

#include <aos/common/ocispec/serviceconfig.hpp>
#include <aos/common/types.hpp>

namespace aos::cm::imageprovider {

/** @addtogroup CM ImageProvider
* @{
*/

/**
* Structure providing extended service information.
*/
struct ServiceInfo : public aos::ServiceInfo {
/**
* Remote URL from which the service can be retrieved.
*/
StaticString<cURLLen> mRemoteURL;

/**
* Filesystem path where the service is stored.
*/
StaticString<cFilePathLen> mPath;

/**
* Service installation time.
*/
Time mTimestamp;

/**
* Service state.
*/
ServiceState mState;

/**
* Configuration parameters specific to the service.
*/
oci::ServiceConfig mConfig;

/**
* List of layer digests used by the service.
*/
StaticArray<StaticString<cLayerDigestLen>, cMaxNumLayers> mLayerDigests;

/**
* List of ports exposed by this service.
*/
StaticArray<StaticString<cExposedPortLen>, cMaxNumExposedPorts> mExposedPorts;
};

/**
* Information about a service layer.
*/
struct LayerInfo : public aos::LayerInfo {
/**
* Remote URL to download the layer from.
*/
StaticString<cURLLen> mRemoteURL;

/**
* Local file system path to the layer.
*/
StaticString<cFilePathLen> mPath;

/**
* Timestamp of the layer's last update.
*/
Time mTimestamp;

/**
* Layer state.
*/
LayerState mState;
};

/**
* Listener receiving notifications when services are removed.
*/
class ServiceListenerItf {
public:
/**
* Destructor.
*/
virtual ~ServiceListenerItf() = default;

/**
* Callback triggered when a service is removed.
*
* @param serviceID identifier of the removed service.
*/
virtual void OnServiceRemoved(const String& serviceID) = 0;
};

/**
* Interface that retrieves service information from its image.
*/
class ImageProviderItf {
public:
/**
* Destructor.
*/
virtual ~ImageProviderItf() = default;

/**
* Retrieves information about specified service.
*
* @param serviceID identifier of the service.
* @param[out] serviceInfo service information.
* @return Error.
*/
virtual Error GetServiceInfo(const String& serviceID, ServiceInfo& serviceInfo) = 0;

/**
* Retrieves metadata about an image layer.
*
* @param digest layer digest.
* @param[out] layerInfo layer info.
* @return Error.
*/
virtual Error GetLayerInfo(const String& digest, LayerInfo& layerInfo) = 0;

/**
* Subscribes listener on service information updates.
*
* @param listener service listener.
* @return Error.
*/
virtual Error SubscribeListener(ServiceListenerItf& listener) = 0;

/**
* Unsubscribes service information listener.
*
* @param listener service listener.
* @return Error.
*/
virtual Error UnsubscribeListener(ServiceListenerItf& listener) = 0;
};

/** @}*/

} // namespace aos::cm::imageprovider

#endif
174 changes: 174 additions & 0 deletions include/aos/cm/launcher/nodemanager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
* Copyright (C) 2025 EPAM Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef AOS_CM_LAUNCHER_NODEMANAGER_HPP_
#define AOS_CM_LAUNCHER_NODEMANAGER_HPP_

#include <aos/common/monitoring/monitoring.hpp>
#include <aos/common/types.hpp>

namespace aos::cm::nodemanager {

/** @addtogroup CM NodeManager
* @{
*/

/**
* Represents the status of service instance, extended with its state checksum.
*/
struct InstanceStatus : public aos::InstanceStatus {
/**
* Node identifier.
*/
StaticString<cNodeIDLen> mNodeID;

/**
* Service state checksum.
*/
StaticString<cSHA3_224Size> mStateChecksum;

/**
* Compares instance status.
*
* @param instance status to compare.
* @return bool.
*/
bool operator==(const InstanceStatus& instance) const
{
return static_cast<const aos::InstanceStatus&>(*this) == static_cast<const aos::InstanceStatus&>(instance)
&& mNodeID == instance.mNodeID && mStateChecksum == instance.mStateChecksum;
}

/**
* Compares instance status.
*
* @param instance status to compare.
* @return bool.
*/
bool operator!=(const InstanceStatus& instance) const { return !operator==(instance); }
};

/**
* Represents run status of service instances running on a particular node.
*/
struct NodeRunInstanceStatus {
/**
* Node identifier.
*/
StaticString<cNodeIDLen> mNodeID;

/**
* Node type.
*/
StaticString<cNodeTypeLen> mNodeType;

/**
* List of instance statuses running on this node.
*/
StaticArray<InstanceStatus, cMaxNumInstances> mInstances;

/**
* Compares instance status.
*
* @param instance status to compare.
* @return bool.
*/
bool operator==(const NodeRunInstanceStatus& instance) const
{
return mNodeID == instance.mNodeID && mNodeType == instance.mNodeType && mInstances == instance.mInstances;
}

/**
* Compares instance status.
*
* @param instance status to compare.
* @return bool.
*/
bool operator!=(const NodeRunInstanceStatus& instance) const { return !operator==(instance); }
};

/**
* Interface for receiving status updates about running service instances.
*/
class ServiceStatusListenerItf {
public:
/**
* Destructor.
*/
virtual ~ServiceStatusListenerItf() = default;

/**
* Notifies changes of service instance statuses.
*
* @param status status of service instances.
*/
virtual void OnStatusChanged(const NodeRunInstanceStatus& status) = 0;
};

/**
* Interface to manage service instances.
*/
class NodeManagerItf {
public:
/**
* Destructor.
*/
virtual ~NodeManagerItf() = default;

/**
* Runs service instances on the specified node.
*
* @param nodeID node identifier.
* @param services service list.
* @param layers service layer list.
* @param instances service instance list.
* @param forceRestart force service restart.
* @return Error.
*/
virtual Error StartInstances(const String& nodeID, const Array<ServiceInfo>& services,
const Array<LayerInfo>& layers, const Array<InstanceInfo>& instances, bool forceRestart)
= 0;

/**
* Stops service instances on the specified node.
*
* @param nodeID node identifier.
* @param instances service instance list.
* @return Error.
*/
virtual Error StopInstances(const String& nodeID, const Array<InstanceIdent>& instances) = 0;

/**
* Retrieves average monitoring data for a node.
*
* @param nodeID node identifier.
* @param monitoring average monitoring data.
* @return Error.
*/
virtual Error GetAverageMonitoring(const String& nodeID, monitoring::NodeMonitoringData& monitoring) const = 0;

/**
* Subscribes listener of service statuses.
*
* @param listener service status listener.
* @return Error.
*/
virtual Error SubscribeListener(ServiceStatusListenerItf& listener) = 0;

/**
* Unsubscribes listener of service statuses.
*
* @param listener service status listener.
* @return Error.
*/
virtual Error UnsubscribeListener(ServiceStatusListenerItf& listener) = 0;
};

/** @}*/

} // namespace aos::cm::nodemanager

#endif
Loading
Loading