Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

架构调整 #1

Open
16 of 18 tasks
ImHype opened this issue Nov 23, 2018 · 1 comment
Open
16 of 18 tasks

架构调整 #1

ImHype opened this issue Nov 23, 2018 · 1 comment

Comments

@ImHype
Copy link
Member

ImHype commented Nov 23, 2018

  • 建立 Leader 与 Follower 的进程,使用 TCP 进程间通信;
    • 每个启动的进程抢占成为 Supervisor 的宿主进程,只有一个进程能够抢占成功;
    • 抢占成为 Supervisor 的宿主进程,开始 fork Supervisor 进程;
    • Supervisor 进程负责 fork Leader 进程,并守护 Leader 的重启;
    • Leader 进程启动成功后,以 net 模块去监听一个端口(这个端口在第一步就确定了);
    • Follower 进程在启动成功后,便不断尝试连接 Leader,直至连接完成;
    • Leader 进程与 Follower 建立连接后,生成 Request 对象,将其存入 requestPool,用于 broadcast;
    • Follower 断开连接时,Leader 将其对应的 Request 对象 从 requestPool 中移除;
    • Leader Crash 后会自动重启,Follower 断开连接后不断重试(每秒一次),期间出现 sendToLeader 的需求时,等待重连后再发送;
    • Follower 与 Leader 建立连接后,获取初始化的一些信息,如采集频率;
    • kagent 提供采集基础方法 guage/timer/histogram/meter/counter;
    • Follower 在采集间隔达到时进行采集(执行 Guage 函数,汇总其他数据),并将采集结果,发送给 Leader;
    • Leader 与 WebSocketAgent 模块交互,将采集结果汇总,并等待与服务端的连接建立完毕后,发送给服务端,完成上报;
    • Follower 与 Leader 建立连接后,Leader 可以向 Follower 分发一些可执行命令,执行完成后重新返回给 Follower;
  • 新增 WebSocketAgent
    • 首次连接,传递基础信息(包含 appid, secret, hostname)到服务端进行认证,服务端决定是否创建集群/节点,并将信息存储在 socket 结构上;
    • 如果不存在 session 信息,或是 session 信息失效了,以事件通知客户端,使其重新认证;
    • 接收 / 执行远程端命令
    • 日志上报
    • 连接断开时,Leader 进程会重启(socket.io)
ImHype referenced this issue in kaola-fed/kagent Nov 27, 2018
ImHype referenced this issue in kaola-fed/kagent Nov 27, 2018
@ImHype ImHype changed the title kagent v1.0.0 架构调整 Nov 28, 2018
@ImHype ImHype transferred this issue from kaola-fed/kagent Dec 14, 2018
@ImHype
Copy link
Member Author

ImHype commented Jan 8, 2019

console-agent 001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant