Skip to content

Commit

Permalink
Revert "ServerMethods: Add request to get mediaServer memory usage"
Browse files Browse the repository at this point in the history
This reverts commit 0916a7f.

Change-Id: I9df458544f46d57afb3df719f8ef0f1ca328198f
  • Loading branch information
jcaden committed Jun 28, 2016
1 parent 8ea6ec7 commit 4bc4363
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 88 deletions.
34 changes: 1 addition & 33 deletions server/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*
*/

#include "ResourceManager.hpp"
#include <gst/gst.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <KurentoException.hpp>
#include <MediaSet.hpp>
#include "ResourceManager.hpp"

#include <sys/resource.h>

Expand Down Expand Up @@ -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 ()
{
Expand Down Expand Up @@ -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) );
Expand Down
3 changes: 0 additions & 3 deletions server/ResourceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
22 changes: 0 additions & 22 deletions server/ServerMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -820,25 +817,6 @@ ServerMethods::closeSession (const Json::Value &params,
}
}

void
ServerMethods::getUsedMemory (const Json::Value &params,
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()
Expand Down
1 change: 0 additions & 1 deletion server/ServerMethods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class ServerMethods : public Processor
void transaction (const Json::Value &params, Json::Value &response);
void ping (const Json::Value &params, Json::Value &response);
void closeSession (const Json::Value &params, Json::Value &response);
void getUsedMemory (const Json::Value &params, Json::Value &response);

const boost::property_tree::ptree &config;
JsonRpc::Handler handler;
Expand Down
29 changes: 0 additions & 29 deletions test/server_json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
Expand All @@ -58,7 +57,6 @@ class ClientHandler : public F
check_create_pipeline_call();
check_bad_transaction_call();
check_transaction_call();
check_memory_usage();
}
};

Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 4bc4363

Please sign in to comment.