Preliminary Design - EM driven VSP restart (VUEDPI-3838)

news/2026/1/17 9:52:26/文章来源:https://www.cnblogs.com/Mattcoder/p/19484145
  • Story VUEDPI-3838: Ability to restart specific program container from a specific Splicer/RC
  • Background:
  • Frontend:
  • Backend:
  • Work Breakdown and Estimation
  • Technology options
    • gRpc vs webhook
    • new process / service (Task Manager) hosted by VSC
    • Docker Socket 
  • Example code:
    • Webhook based:
        • Node.js Code to Send Command and Receive Webhook Response
      • Step 2: Setting Up the C++ Service to Handle the Command and Send Webhook
        • C++ Code to Handle Command and Send Webhook (Using cpp-httplib)
    • GRrpc based
      • The Node.js client can connect to this C++ gRPC server using its IP and port, with no need to understand HTTP.
      • C++ : Here’s how a simple gRPC server setup might look in C++, without any explicit HTTP server setup:

 

Story VUEDPI-3838: Ability to restart specific program container from a specific Splicer/RC

Story Summary:  As a DTV operator, I want the ability in the VUE Manager UI to restart specific program container from a specific splicer. Since the splicer works as 1:1 redundancy cluster, this operation should provide me the option to restart the program on specific node or both nodes when triggered. This will be used during troubleshooting when a program is not outputting or not splicing at a VHO. 

Background:

  • Previously in VUEDPI1.0 or later releases,  EM only does pushing the setting such as Mapping, Zones, splicing params and latency etc ,  to Splicer via Redis queue, and the setting will be circulate in all Splicer component without expecting an immediate result. This is the first time related to EM fire a command to Splicer and Splicer need to execute on the it and ideally to return a execution result to the EM.
  • Kumar propose to have a dedicated module / service to host this type of command handler for future extension 

Frontend:

  • Since the VSP restart is base on 2 factors : Program , Splicer and Nodes, UDP mapping UI will be entry point for end user to access to this feature 

image

  • Pop up page goes here, in theory it should support node multi selection within the same splicer (TO BE PROVIDED)

TBD

Backend:

image

image

Work Breakdown and Estimation

UI 2   Emmy
Controller 1   Emmy
VAMS 2   Terry
Task Manager 4 inside VSC Richard
New redis table track docker id/program association  2   Terry
Docker Socket 2   Richard
Platform 2   Moon
Developer Intergration Test 2    
Bug fixes    
QA 2   Stephen

Staffing

3 developers, 1QA

Summary:

Developer:        21 manweeks + 2  (buffer) = 23 manweeks

QA:                   2 manweeks + 1 (buffer) = 3 manweeks

Total:                6 manmonths

Calendar schedule: 

 Development : 2.75 months

 QA:                   0.75 months

 Total:                 3.5 months

 

Technology options

  • gRpc vs webhook

    • Webhook automate communication between application programming interfaces (APIs) and can be used to activate workflows, such as in GitOps environments.,
      • one well known example is with CICD pipeline when Bitbucket (source code repo)is getting new code merged, it will send out notification to Jenkin server to pull Bitbucket’s latest code for other pipelined activities such as complication or deployment. after code change notification. 
      • Pub / Sub api are in different work context, challenges for UI request / response model.
      • Good for use case such as live update of vue server stat / parameter changes to VPS side
      • Example code for webhook goes here.
    • gRpc (Google Remote Process Call)  is created by google in 2016,
      • it support cross platform method invocation and program language agnostic,
      • it leverage HTTP2.0 to transmit payload in binary format and inherently support the request/response model.  with this implementation mainly EM/Controller can fireup a request to Task Manager  process in VSC to execute a task and returns the result in the same call.  
      • It doesn’t requires  the service to have Http Server installed.
      • Security wise we can add secret/passwrod for the authentication. Example code for gRpc goes here.
      • Example code for webhook goes here.
    • Both of them will be new tech set for our future architecture stacks kit.
    • For this requirement, we inclined to use gRpc as it support request / response model most of UI user experience scenario. 
  • new process / service (Task Manager) hosted by VSC

    • Should be C++ base new application / process similar with PM, SM, RM
    • Process Monit should be augmented manage its life cycle and reboot on faulty state similar to other manager processes
  • Docker Socket 

    • Task manager will reuse GetEngineInfo script to query DBSvr to acquire container name given the target program, subsequently it needs the access to docker daemon to execute the container restart.
    • We incline to use docker socket as protocol for its simplicity for Task Manager to query Docker Daemon on existence of target container and proceeding with restart. All Docker commands you run via the CLI (docker run, docker ps, etc.) interact with the Docker daemon through this socket Security is not much of concern since they are co-existed in the same host device.
    • Another option is to use Docker Remote API that is http based but it is different set of syntax so doesn't seems like a better option.

Example code:

Webhook based:

Step 1: Setting Up Node.js to Trigger the C++ Service

In the Node.js app, we would use an HTTP client (like Axios or the built-in http module) to send a command to the C++ service. Additionally, we’d set up a separate HTTP endpoint in Node.js to receive the completion notification from the C++ service.

Node.js Code to Send Command and Receive Webhook Response

const axios = require('axios');
const express = require('express');
const app = express();
 
app.use(express.json());  // Middleware to parse JSON
 
// Webhook endpoint to receive the response from C++ service
app.post('/completion-notification', (req, res) => {
    console.log('Received completion notification:', req.body);
    res.status(200).send('Notification received');
});
 
// Function to send command to C++ service
async function sendCommandToCppService() {
    const cppServiceUrl = 'http://cplusplus-service:8080/execute-command';
     
    try {
        // Sends a command to C++ service, including Node.js webhook URL for callback
        const response = await axios.post(cppServiceUrl, {
            command: 'runTask',
            callbackUrl: 'http://nodejs-service:3000/completion-notification'  // Node.js callback URL
        });
        console.log('Command sent to C++ service:', response.data);
    catch (error) {
        console.error('Error sending command:', error);
    }
}
 
// Start the Node.js server
app.listen(3000, () => {
    console.log('Node.js server listening on port 3000');
    sendCommandToCppService();  // Send the command when server starts
});

 

Step 2: Setting Up the C++ Service to Handle the Command and Send Webhook

The C++ service would need to implement an HTTP server (or use a lightweight HTTP library) to handle incoming requests, process the command, and send an HTTP POST to the Node.js callback URL upon completion.

C++ Code to Handle Command and Send Webhook (Using cpp-httplib)

#include <httplib.h>
#include <iostream>
#include <string>
 
// Function to send webhook notification back to Node.js
void sendWebhookNotification(const std::string& callbackUrl, const std::string& result) {
    httplib::Client cli(callbackUrl.c_str());
    httplib::Params params;
    params.emplace("result", result);
 
    auto res = cli.Post("/", params);
    if (res && res->status == 200) {
        std::cout << "Webhook notification sent successfully." << std::endl;
    else {
        std::cerr << "Failed to send webhook notification." << std::endl;
    }
}
 
int main() {
    httplib::Server svr;
 
    // Endpoint to receive and handle the command from Node.js
    svr.Post("/execute-command", [&](const httplib::Request &req, httplib::Response &res) {
        std::string callbackUrl = req.get_param_value("callbackUrl");
         
        // Process the command (simulating with a print statement)
        std::cout << "Received command to execute task." << std::endl;
 
        // Simulate task completion after processing
        std::string result = "Task completed successfully";
         
        // Send a webhook notification back to Node.js
        sendWebhookNotification(callbackUrl, result);
 
        res.set_content("Command received and processed""text/plain");
    });
 
    std::cout << "C++ server listening on port 8080" << std::endl;
    svr.listen("0.0.0.0", 8080);
 
    return 0;
}

 

GRrpc based

The Node.js client can connect to this C++ gRPC server using its IP and port, with no need to understand HTTP.

const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
 
const packageDefinition = protoLoader.loadSync('my_service.proto', {});
const myServiceProto = grpc.loadPackageDefinition(packageDefinition).myservice;
 
const client = new myServiceProto.MyService('localhost:50051', grpc.credentials.createInsecure());
 
client.DoSomething({ /* request data */ }, (error, response) => {
  if (error) {
    console.error('Error:', error);
  else {
    console.log('Response:', response);
  }
});

C++ : Here’s how a simple gRPC server setup might look in C++, without any explicit HTTP server setup:

#include <grpcpp/grpcpp.h>
#include "my_service.grpc.pb.h"
 
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
using myservice::MyService;
 
// Implement the service method
class MyServiceImpl final : public MyService::Service {
public:
    grpc::Status DoSomething(ServerContext* context, const Request* request, Response* response) override {
        // Handle the request and fill the response
        return grpc::Status::OK;
    }
};
 
void RunServer() {
    std::string server_address("0.0.0.0:50051");
    MyServiceImpl service;
 
    ServerBuilder builder;
    builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
    builder.RegisterService(&service);
    std::unique_ptr<Server> server(builder.BuildAndStart());
    std::cout << "Server listening on " << server_address << std::endl;
 
    server->Wait();
}
 
int main(int argc, char** argv) {
    RunServer();
    return 0;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/1172907.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

YOLO-World:从入门到实战的多模态目标检测全指南

文章目录 从0到1掌握YOLO-World:多模态目标检测入门到实战超详细教程 一、先搞懂“多模态目标检测”和YOLO-World到底是什么 1. 什么是多模态目标检测? 2. YOLO-World:速度与精度的多模态标杆 二、YOLO-World的技术逻辑:从输入到输出的全流程 1. 核心架构:“图像-文本”双…

JavaAPI 工具类

工具类 Math public static int abs (int a) 获取参数绝对值 public static duble ceil (doouble a)向上取整 public static duble floor (doouble a)向下取整 public static int round(float a) 四舍五入 public static int max (int a,int b)获取两个int…

create_deep_agent vs create_agent 的区别

目录 1. create_agent - LangChain 标准函数 2. create_deep_agent - DeepAgents 高级函数 核心区别对比 实际应用对比 工作流程对比 何时使用哪个&#xff1f; 总结 1. create_agent - LangChain 标准函数 来源&#xff1a; langchain.agents 作用&#xff1a; 创建基…

不要让几十万血汗钱打水漂!河北农村自建房必须要了解的7个问题,不懂真的亏大了! - 苏木2025

在河北,从冀北张家口蔚县、承德围场的山地丘陵,到冀中保定清苑、石家庄藁城的平原沃野,再到冀南邯郸永年、邢台宁晋的农耕区,以及冀东唐山滦南、秦皇岛昌黎的沿海村镇,农村自建房始终是家家户户的头等大事。对于大…

基于VUE的高校毕业设计管理系统[VUE]-计算机毕业设计源码+LW文档

摘要&#xff1a;高校毕业设计管理是一项复杂且重要的工作&#xff0c;传统管理方式在效率、准确性等方面存在诸多不足。本文旨在设计并实现基于VUE的高校毕业设计管理系统&#xff0c;以提升管理效能。通过深入的需求分析&#xff0c;明确系统涵盖用户管理、选题管理、任务书管…

变量的定义

变量的定义 1.变量的数据类型:基本数据类型:4类8种整数:byte short int long浮点型:float double字符型:char布尔型:boolean引用数据类型:类 数组 接口 枚举 注释2.概述:在代码的运行中,值会随着不同的情况而随…

南京欧米奇西点西餐学校市场口碑怎么样,学校靠谱排名 - 工业品牌热点

2026年餐饮行业多元化发展趋势下,专业西式餐饮技能已成为年轻人就业创业的热门选择,而优质培训学校的教学质量、口碑评价与创就业支持,直接决定学员的技能竞争力与职业起点。无论是纯正技艺传承、高比例实操机会,还…

idea生成javadoc文件

左上角tools(工具)->generator javadoc(生成javadoc文件)generator javadoc窗口下,在javaDoc scope(javadoc作用域)选择需要的范围选择输出目录并勾选输出内容为避免文档中显示中文乱码,需插入下面俩条语句zh_CN …

2026年上海优秀的RFID智能标签,RFID服装标签,RFID贴纸厂家实力推荐榜 - 品牌鉴赏师

引言在当今数字化飞速发展的时代,RFID(射频识别)技术作为物联网的关键组成部分,在各个领域发挥着越来越重要的作用。RFID智能标签、RFID服装标签、RFID贴纸等产品广泛应用于零售、物流、制造业等众多行业,市场需求…

2026耳塞品牌权威推荐,国际认证与本土适配双重优势品牌盘点 - 品牌鉴赏师

引言在当今快节奏的生活中,噪音干扰成为了影响人们生活质量的一大问题。无论是在睡眠、学习还是工作时,一副优质的耳塞往往能带来极大的帮助。为了给消费者提供更具参考价值的耳塞品牌推荐,我们依据国内相关行业协会…

2026年国内知名的催化燃烧工厂推荐榜单,滤筒除尘器/除尘器/RTO/活性炭箱/催化燃烧/旋风除尘器,催化燃烧厂商推荐 - 品牌推荐师

随着国家“双碳”战略的深入推进及工业废气治理标准的持续升级,催化燃烧技术凭借高效、节能、低排放等优势,成为VOCs(挥发性有机物)治理领域的核心解决方案。然而,市场需求的爆发式增长也催生了大量技术参差不齐的…

短视频开源源码,js函数柯里化 - 云豹科技

短视频开源源码,js函数柯里化函数柯里化维基百科: 柯里化(英语:Currying),又译为卡瑞化或加里化,是把接受多个参数的函数变换成接受一个单一参数(最初函数的第一个参数)的函数,并且返回接受余下的参数而且返…

2026年评价高的武汉隐形车衣,武汉汽车车衣,武汉汽车防爆膜旗舰店采购选型榜单 - 品牌鉴赏师

引言在汽车美容与防护领域,隐形车衣和汽车防爆膜的选择对于车主来说至关重要。尤其是在武汉这样的汽车消费大市场,众多车主都在寻求高品质的汽车贴膜服务。为了给武汉的车主们提供一份客观、公正、实用的采购选型榜单…

聊聊2026年同步带轮厂家哪家好?盖奇同步带轮口碑出众值得选! - 工业品牌热点

本榜单依托全维度市场调研与真实行业口碑,深度筛选出五家同步带轮领域标杆企业,为工业制造、纺织、机床等行业企业选型提供客观依据,助力精准匹配适配的传动产品伙伴。 TOP1 推荐:宁波鄞州盖奇同步带轮有限公司 推…

【2026年精选毕业设计:基于Spring Boot的校园失物招领系统的设计与实现(含论文+源码+PPT+开题报告+任务书+答辩讲解)】 - 指南

【2026年精选毕业设计:基于Spring Boot的校园失物招领系统的设计与实现(含论文+源码+PPT+开题报告+任务书+答辩讲解)】 - 指南pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto…

清远市阳山连山壮族瑶族连南英德连州区英语雅思培训辅导机构推荐,2026权威出国雅思课程中心学校口碑排行榜推荐 - 老周说教育

经全国教育测评联盟认证、雅思备考数据研究院联合发起,基于清远市阳山县、连山壮族瑶族自治县、连南瑶族自治县、英德市、连州市18000+雅思考生专项调研、102家教育机构全方位实测及《2024-2025中国大陆雅思成绩大数据…

学习行为数据挖掘与资源推荐系统毕业设计源码(源码+lw+部署文档+讲解等)

博主介绍&#xff1a;✌ 专注于VUE,小程序&#xff0c;安卓&#xff0c;Java,python,物联网专业&#xff0c;有18年开发经验&#xff0c;长年从事毕业指导&#xff0c;项目实战✌选取一个适合的毕业设计题目很重要。✌关注✌私信我✌具体的问题&#xff0c;我会尽力帮助你。一、…

kubeadm 离线部署 Kubernetes 集群 + 完整测试【20260117】002

文章目录 Kubeadm 离线部署 Kubernetes 集群完整指南 一、环境准备 1.1 机器规划 1.2 系统配置(所有节点执行) 二、离线资源准备 2.1 在有网络的环境中准备离线包 2.2 传输离线包到离线环境 三、安装Docker(所有节点) 3.1 离线安装Docker 四、安装Kubernetes组件 4.1 部署K…

kubeadm 离线部署 Kubernetes 集群 + 完整测试【20260117】001

文章目录 kubeadm 离线部署 Kubernetes 集群 + 完整测试 一、前期准备 1. 环境规划(最小化集群) 2. 所有节点统一基础配置(必须执行) (1)关闭防火墙 (2)关闭 SELinux (3)关闭交换分区 (4)配置内核参数(开启IP转发、加载overlay模块) (5)配置主机名与hosts解析(…