<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 四、Lars-Reporter Service開發 ## 1) 簡介 負責接收各agent對某modid、cmdid下節點的調用狀態的上報。 > 目前`agent`我們還沒有實現,就可以把agent當成一個普通客戶端就可以。 agent會把代理的host節點的狀態上報給Reporter,Reporter負責存儲在Mysql數據庫中。 **業務**: Reporter服務模型采用了single thread TCP服務器 + 線程池處理請求 * 主線程Reporter負責接收agent請求,并根據請求中攜帶的`modid`和`cmdid`,拼接后進行`murmurHash`(一致性hash),分配到某個線程的MQ上 * Thread 1~N們負責處理請求:把MQ上的請求中的數據同步更新到MySQL數據表 由于agent上報給Reporter的信息是攜帶時間的,且僅作為前臺展示方便查看服務的過載情況,故通信僅有請求沒有響應 于是Reporter服務只要可以高效讀取請求即可,后端寫數據庫的實時性能要求不高。 架構圖如下: ![](https://img.kancloud.cn/a6/1b/a61b823c490255dc61c5d290fa8cd39f_982x661.png) ## 2) 數據庫創建 - 表`ServerCallStatus`: | 字段 | 數據類型 | 是否可以為空 | 主鍵 | 默認 | 附加 | 說明 | | -------- | ---------- | ------------ | ---- | ---- | ---- | ------------ | | modid | int(11) | No | 是 | NULL | | 模塊ID | | modid | int(11) | No | 是 | NULL | | 指令ID | | ip | int(11) | No | 是 | NULL | | 服務器IP地址 | | port | int(11) | No | 是 | NULL | | 服務器端口 | | caller | int(11) | No | 是 | NULL | | 調用者 | | succ_cnt | int(11) | No | | NULL | | 成功次數 | | err_cnt | int(11) | No | | NULL | | 失敗次數 | | ts | bigint(20) | No | | NULL | | 記錄時間 | | overload | char(1) | No | | NULL | | 是否過載 | > Lars/base/sql/lars_dns.sql ```sql DROP TABLE IF EXISTS `ServerCallStatus`; CREATE TABLE `ServerCallStatus` ( `modid` int(11) NOT NULL, `cmdid` int(11) NOT NULL, `ip` int(11) NOT NULL, `port` int(11) NOT NULL, `caller` int(11) NOT NULL, `succ_cnt` int(11) NOT NULL, `err_cnt` int(11) NOT NULL, `ts` bigint(20) NOT NULL, `overload` char(1) NOT NULL, PRIMARY KEY (`modid`,`cmdid`,`ip`,`port`,`caller`), KEY `mlb_index` (`modid`,`cmdid`,`ip`,`port`,`caller`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ``` ## 3) Proto協議定義 > Lars/base/proto/lars.proto ```protobuf syntax = "proto3"; package lars; /* Lars系統的消息ID */ enum MessageId { ID_UNKNOW = 0; //proto3 enum第一個屬性必須是0,用來占位 ID_GetRouteRequest = 1; //向DNS請求Route對應的關系的消息ID ID_GetRouteResponse = 2; //DNS回復的Route信息的消息ID ID_ReportStatusRequest = 3; //上報host調用狀態信息請求消息ID } //一個管理的主機的信息 message HostInfo { int32 ip = 1; int32 port = 2; } //請求lars-dns route信息的消息內容 message GetRouteRequest { int32 modid = 1; int32 cmdid = 2; } //lars-dns 回復的route信息消息內容 message GetRouteResponse { int32 modid = 1; int32 cmdid = 2; repeated HostInfo host = 3; } message HostCallResult { int32 ip = 1; //主機ip int32 port = 2; //主機端口 uint32 succ = 3; //調度成功 uint32 err = 4; //調度失敗 bool overload = 5; //是否過載 } //上報 負載均衡 調度數據 給 lars_reporter 的消息內容 message ReportStatusReq { int32 modid = 1; int32 cmdid = 2; int32 caller = 3; repeated HostCallResult results = 4; uint32 ts = 5; } ``` --- ### 關于作者: 作者:`Aceld(劉丹冰)` mail: [danbing.at@gmail.com](mailto:danbing.at@gmail.com) github: [https://github.com/aceld](https://github.com/aceld) 原創書籍: [http://www.hmoore.net/@aceld](http://www.hmoore.net/@aceld) ![](https://img.kancloud.cn/b0/d1/b0d11a21ba62e96aef1c11d5bfff2cf8_227x227.jpg) >**原創聲明:未經作者允許請勿轉載, 如果轉載請注明出處**
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看