From c6748b2816f578f766e9c02c785f047bc840d0c1 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 25 Oct 2013 21:11:20 +0200 Subject: [PATCH] feature #1678: Drop logic moved to Information Manager. Always drop the host --- src/host/HostPool.cc | 10 +++---- src/im/InformationManager.cc | 10 ++++--- src/im/InformationManagerDriver.cc | 44 ++++++++++++++++++------------ src/rm/RequestManagerDelete.cc | 15 ++-------- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/host/HostPool.cc b/src/host/HostPool.cc index 22f9c9e0e7..30da51da49 100644 --- a/src/host/HostPool.cc +++ b/src/host/HostPool.cc @@ -235,10 +235,8 @@ error_common: int HostPool::drop(int hid, string& error_msg) { - Nebula& nd = Nebula::instance(); Host * host; - ClusterPool * clpool; host = get(hid,true); @@ -250,8 +248,6 @@ int HostPool::drop(int hid, string& error_msg) return -1; } - clpool = nd.get_clpool(); - int cluster_id = host->get_cluster_id(); int rc = drop(host, error_msg); @@ -260,7 +256,10 @@ int HostPool::drop(int hid, string& error_msg) if ( cluster_id != ClusterPool::NONE_CLUSTER_ID && rc == 0 ) { - Cluster * cluster = clpool->get(cluster_id, true); + Nebula& nd = Nebula::instance(); + + ClusterPool * clpool = nd.get_clpool(); + Cluster * cluster = clpool->get(cluster_id, true); if( cluster != 0 ) { @@ -281,7 +280,6 @@ int HostPool::drop(int hid, string& error_msg) return rc; } - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/im/InformationManager.cc b/src/im/InformationManager.cc index a12b9dbd6f..8cb2ab2801 100644 --- a/src/im/InformationManager.cc +++ b/src/im/InformationManager.cc @@ -133,6 +133,7 @@ void InformationManager::trigger(Actions action, int _hid) break; default: + delete hid; return; } @@ -183,11 +184,8 @@ void InformationManager::stop_monitor(int hid) host = hpool->get(hid,true); - if (host == 0) + if (host == 0) //Already deleted silently return { - oss.str(""); - oss << "Could get host " << hid; - NebulaLog::log("InM",Log::ERROR,oss); return; } @@ -203,8 +201,12 @@ void InformationManager::stop_monitor(int hid) return; } + host->disable(); + imd->stop_monitor(hid, host->get_name()); + hpool->update(host); + host->unlock(); } diff --git a/src/im/InformationManagerDriver.cc b/src/im/InformationManagerDriver.cc index aff1a12f53..3509e3b368 100644 --- a/src/im/InformationManagerDriver.cc +++ b/src/im/InformationManagerDriver.cc @@ -292,32 +292,40 @@ void InformationManagerDriver::protocol(const string& message) const } else if (action == "STOPMONITOR") { + int rc; + string error; + + host = hpool->get(id,true); + + if ( host == 0 ) + { + goto error_host; + } + if (result != "SUCCESS") { - host = hpool->get(id,true); + ostringstream oss; + string info; - if ( host == 0 ) - { - goto error_host; - } + getline (is, info); - host->set_error(); - hpool->update(host); - host->unlock(); + oss << "Could not stop monitor on host " << id << " " << info; + NebulaLog::log("InM", Log::ERROR, oss.str()); } - else - { - string error_message; - int rc = hpool->drop(id, error_message); - if (rc != 0) - { - ostringstream oss; - oss << "Could not delete host " << id << " " << error_message; - NebulaLog::log("InM",Log::ERROR,oss.str()); - } + rc = hpool->drop(id, error); + + host->unlock(); + + if (rc != 0) + { + ostringstream oss; + + oss << "Could not delete host " << id << " " << error; + NebulaLog::log("InM",Log::ERROR,oss.str()); } } + return; error_host: diff --git a/src/rm/RequestManagerDelete.cc b/src/rm/RequestManagerDelete.cc index 3113283898..a419f2ce86 100644 --- a/src/rm/RequestManagerDelete.cc +++ b/src/rm/RequestManagerDelete.cc @@ -146,19 +146,10 @@ int RequestManagerDelete::drop( int HostDelete::drop(int oid, PoolObjectSQL * object, string& error_msg) { - Nebula& nd = Nebula::instance(); + Nebula& nd = Nebula::instance(); + InformationManager * im = nd.get_im(); - - InformationManager * im = nd.get_im(); - HostPool * hpool = nd.get_hpool(); - - Host * host = static_cast(object); - - host->disable(); - hpool->update(host); - host->unlock(); - - im->trigger(InformationManager::STOPMONITOR,oid); + im->trigger(InformationManager::STOPMONITOR, oid); return 0; }