diff --git a/server/ResourceManager.cpp b/server/ResourceManager.cpp index b3eca8b03..73f9c688e 100644 --- a/server/ResourceManager.cpp +++ b/server/ResourceManager.cpp @@ -15,6 +15,7 @@ * */ +#include "ResourceManager.hpp" #include #include #include @@ -22,7 +23,6 @@ #include #include #include -#include "ResourceManager.hpp" #include @@ -56,26 +56,6 @@ get_int (std::string &str, char sep, int nToken) return 0; } -static int64_t -get_int64 (std::string &str, char sep, int nToken) -{ - size_t start = str.find_first_not_of (sep), end; - int count = 0; - - while (start != std::string::npos) { - end = str.find (sep, start); - - if (count++ == nToken) { - str[end] = '\0'; - return atol (&str.c_str() [start]); - } - - start = str.find_first_not_of (sep, end); - } - - return 0; -} - static int getNumberOfThreads () { @@ -179,18 +159,6 @@ void killServerOnLowResources (float limit_percent) }); } -int64_t -getUsedMemory () -{ - std::string stat; - std::ifstream stat_file ("/proc/self/stat"); - - std::getline (stat_file, stat); - stat_file.close(); - - return get_int64 (stat, ' ', 22) / 1024; -} - } /* kurento */ static void init_debug (void) __attribute__ ( (constructor) ); diff --git a/server/ResourceManager.hpp b/server/ResourceManager.hpp index db29bbadc..e2f6be125 100644 --- a/server/ResourceManager.hpp +++ b/server/ResourceManager.hpp @@ -27,9 +27,6 @@ void checkResources (float limit_percent); void killServerOnLowResources (float limit_percent); -/* Returns the virtual memory size in KiB */ -int64_t getUsedMemory (); - } /* kurento */ #endif /* __RESOURCE_MANAGER_H__ */ diff --git a/server/ServerMethods.cpp b/server/ServerMethods.cpp index 761978be7..a1692260b 100644 --- a/server/ServerMethods.cpp +++ b/server/ServerMethods.cpp @@ -162,9 +162,6 @@ ServerMethods::ServerMethods (const boost::property_tree::ptree &config) : handler.addMethod ("closeSession", std::bind (&ServerMethods::closeSession, this, std::placeholders::_1, std::placeholders::_2) ); - handler.addMethod ("getUsedMemory", std::bind (&ServerMethods::getUsedMemory, - this, - std::placeholders::_1, std::placeholders::_2) ); } ServerMethods::~ServerMethods() @@ -820,25 +817,6 @@ ServerMethods::closeSession (const Json::Value ¶ms, } } -void -ServerMethods::getUsedMemory (const Json::Value ¶ms, - Json::Value &response) -{ - std::string sessionId; - - try { - JsonRpc::getValue (params, SESSION_ID, sessionId); - response [SESSION_ID] = sessionId; - } catch (JsonRpc::CallException e) { - } - - JsonSerializer s (true); - - int64_t value = kurento::getUsedMemory(); - s.SerializeNVP (value); - response = s.JsonValue; -} - ServerMethods::StaticConstructor ServerMethods::staticConstructor; ServerMethods::StaticConstructor::StaticConstructor() diff --git a/server/ServerMethods.hpp b/server/ServerMethods.hpp index a60491386..9079af6dd 100644 --- a/server/ServerMethods.hpp +++ b/server/ServerMethods.hpp @@ -78,7 +78,6 @@ class ServerMethods : public Processor void transaction (const Json::Value ¶ms, Json::Value &response); void ping (const Json::Value ¶ms, Json::Value &response); void closeSession (const Json::Value ¶ms, Json::Value &response); - void getUsedMemory (const Json::Value ¶ms, Json::Value &response); const boost::property_tree::ptree &config; JsonRpc::Handler handler; diff --git a/test/server_json_test.cpp b/test/server_json_test.cpp index dbb0825dd..7e21f9b1a 100644 --- a/test/server_json_test.cpp +++ b/test/server_json_test.cpp @@ -47,7 +47,6 @@ class ClientHandler : public F void check_connect_call (); void check_bad_transaction_call (); void check_transaction_call (); - void check_memory_usage(); void runTests () { @@ -58,7 +57,6 @@ class ClientHandler : public F check_create_pipeline_call(); check_bad_transaction_call(); check_transaction_call(); - check_memory_usage(); } }; @@ -328,33 +326,6 @@ ClientHandler::check_create_pipeline_call() BOOST_CHECK (response["result"]["sessionId"].asString () == sessionId ); } -void -ClientHandler::check_memory_usage() -{ - Json::Value request; - Json::Value response; - std::string pipeId; - std::string objId; - - Json::Value params; - Json::Value constructorParams; - Json::Value operationParams; - - request["jsonrpc"] = "2.0"; - request["id"] = getId(); - request["method"] = "getUsedMemory"; - params["sessionId"] = "12345"; - request["params"] = params; - - response = sendRequest (request); - - BOOST_CHECK (!response.isMember ("error") ); - BOOST_CHECK (response.isMember ("result") ); - BOOST_CHECK (response["result"].isObject() ); - BOOST_CHECK (response["result"].isMember ("value") ); - BOOST_CHECK (response["result"]["value"].isInt() ); -} - BOOST_FIXTURE_TEST_SUITE ( server_json_test, ClientHandler) BOOST_AUTO_TEST_CASE ( server_json_test )