mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
新增获取poller监听fd个数方法
This commit is contained in:
parent
654dc198dd
commit
652ac9fe82
@ -1 +1 @@
|
|||||||
Subproject commit 1b7d6fc47ca4f13deab56de0241d3a9ac380e2d6
|
Subproject commit 7c0f9b41c1346e31892924320fb8b6cc67cf88ef
|
||||||
@ -748,6 +748,26 @@ void addStreamPusherProxy(const string &schema,
|
|||||||
pusher->publish(url);
|
pusher->publish(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getThreadsLoad(TaskExecutorGetterImp &getter, API_ARGS_MAP_ASYNC) {
|
||||||
|
getter.getExecutorDelay([&getter, invoker, headerOut](const vector<int> &vecDelay) {
|
||||||
|
Value val;
|
||||||
|
auto vec = getter.getExecutorLoad();
|
||||||
|
std::vector<EventPoller::Ptr> pollers;
|
||||||
|
getter.for_each([&](const TaskExecutor::Ptr &exe) { pollers.emplace_back(std::static_pointer_cast<EventPoller>(exe)); });
|
||||||
|
int i = API::Success;
|
||||||
|
for (auto load : vec) {
|
||||||
|
Value obj(objectValue);
|
||||||
|
obj["load"] = load;
|
||||||
|
auto &poller = pollers[i];
|
||||||
|
obj["name"] = poller->getThreadName();
|
||||||
|
obj["fd_count"] = static_cast<Json::UInt64>(poller->fdCount());
|
||||||
|
obj["delay"] = vecDelay[i++];
|
||||||
|
val["data"].append(obj);
|
||||||
|
}
|
||||||
|
val["code"] = API::Success;
|
||||||
|
invoker(200, headerOut, val.toStyledString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装api接口
|
* 安装api接口
|
||||||
@ -769,19 +789,7 @@ void installWebApi() {
|
|||||||
// Test url http://127.0.0.1/index/api/getThreadsLoad
|
// Test url http://127.0.0.1/index/api/getThreadsLoad
|
||||||
api_regist("/index/api/getThreadsLoad", [](API_ARGS_MAP_ASYNC) {
|
api_regist("/index/api/getThreadsLoad", [](API_ARGS_MAP_ASYNC) {
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
EventPollerPool::Instance().getExecutorDelay([invoker, headerOut](const vector<int> &vecDelay) {
|
getThreadsLoad(EventPollerPool::Instance(), API_ARGS_VALUE, invoker);
|
||||||
Value val;
|
|
||||||
auto vec = EventPollerPool::Instance().getExecutorLoad();
|
|
||||||
int i = API::Success;
|
|
||||||
for (auto load : vec) {
|
|
||||||
Value obj(objectValue);
|
|
||||||
obj["load"] = load;
|
|
||||||
obj["delay"] = vecDelay[i++];
|
|
||||||
val["data"].append(obj);
|
|
||||||
}
|
|
||||||
val["code"] = API::Success;
|
|
||||||
invoker(200, headerOut, val.toStyledString());
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取后台工作线程负载 [AUTO-TRANSLATED:6166e265]
|
// 获取后台工作线程负载 [AUTO-TRANSLATED:6166e265]
|
||||||
@ -790,19 +798,7 @@ void installWebApi() {
|
|||||||
// Test url http://127.0.0.1/index/api/getWorkThreadsLoad
|
// Test url http://127.0.0.1/index/api/getWorkThreadsLoad
|
||||||
api_regist("/index/api/getWorkThreadsLoad", [](API_ARGS_MAP_ASYNC) {
|
api_regist("/index/api/getWorkThreadsLoad", [](API_ARGS_MAP_ASYNC) {
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
WorkThreadPool::Instance().getExecutorDelay([invoker, headerOut](const vector<int> &vecDelay) {
|
getThreadsLoad(WorkThreadPool::Instance(), API_ARGS_VALUE, invoker);
|
||||||
Value val;
|
|
||||||
auto vec = WorkThreadPool::Instance().getExecutorLoad();
|
|
||||||
int i = 0;
|
|
||||||
for (auto load : vec) {
|
|
||||||
Value obj(objectValue);
|
|
||||||
obj["load"] = load;
|
|
||||||
obj["delay"] = vecDelay[i++];
|
|
||||||
val["data"].append(obj);
|
|
||||||
}
|
|
||||||
val["code"] = API::Success;
|
|
||||||
invoker(200, headerOut, val.toStyledString());
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取服务器配置 [AUTO-TRANSLATED:7dd2f3da]
|
// 获取服务器配置 [AUTO-TRANSLATED:7dd2f3da]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user