summaryrefslogtreecommitdiff
path: root/ndb/src/mgmsrv/Services.cpp
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-11-09 19:39:29 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-11-09 19:39:29 +0000
commit4c26186b4723f8cb9c44b1c9b0314d54d532f826 (patch)
treeedc7c262c8c446aa592557dc15ccb01c2a6d7af5 /ndb/src/mgmsrv/Services.cpp
parent8e8c1a4756f04b582893965af0b780c2d32536f9 (diff)
downloadmariadb-git-4c26186b4723f8cb9c44b1c9b0314d54d532f826.tar.gz
added management function to purge stale sessions in the management server
ndb/include/util/Bitmask.hpp: added bitXORC ndb/include/util/SocketServer.hpp: added method to apply function on each session ndb/src/common/util/SocketServer.cpp: added method to apply function on each session
Diffstat (limited to 'ndb/src/mgmsrv/Services.cpp')
-rw-r--r--ndb/src/mgmsrv/Services.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp
index 2672d8c9d4b..0394c4e80bb 100644
--- a/ndb/src/mgmsrv/Services.cpp
+++ b/ndb/src/mgmsrv/Services.cpp
@@ -242,6 +242,8 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("node", Int, Optional, "Node"),
MGM_ARG("filter", String, Mandatory, "Event category"),
+ MGM_CMD("purge stale sessions", &MgmApiSession::purge_stale_sessions, ""),
+
MGM_END()
};
@@ -1412,6 +1414,46 @@ done:
m_output->println("");
}
+struct PurgeStruct
+{
+ NodeBitmask free_nodes;/* free nodes as reported
+ * by ndbd in apiRegReqConf
+ */
+ BaseString *str;
+};
+
+void
+MgmApiSession::stop_session_if_not_connected(SocketServer::Session *_s, void *data)
+{
+ MgmApiSession *s= (MgmApiSession *)_s;
+ struct PurgeStruct &ps= *(struct PurgeStruct *)data;
+ if (s->m_allocated_resources->is_reserved(ps.free_nodes))
+ {
+ ps.str->appfmt(" %d", s->m_allocated_resources->get_nodeid());
+ s->stopSession();
+ }
+}
+
+void
+MgmApiSession::purge_stale_sessions(Parser_t::Context &ctx,
+ const class Properties &args)
+{
+ struct PurgeStruct ps;
+ BaseString str;
+ ps.str = &str;
+
+ m_mgmsrv.get_connected_nodes(ps.free_nodes);
+ ps.free_nodes.bitXORC(NodeBitmask()); // invert connected_nodes to get free nodes
+
+ m_mgmsrv.get_socket_server()->foreachSession(stop_session_if_not_connected,&ps);
+
+ m_output->println("purge stale sessions reply");
+ if (str.length() > 0)
+ m_output->println("purged:%s",str.c_str());
+ m_output->println("result: Ok");
+ m_output->println("");
+}
+
template class MutexVector<int>;
template class Vector<ParserRow<MgmApiSession> const*>;
template class Vector<unsigned short>;