From 60ce47a7101062380a2d05e0433b7d74dd3c1711 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 15 May 2006 13:53:37 +0000 Subject: [PATCH] First work at bug #573: Hide errors for individual servers. For multi, if the element 'hideunavailable' is given, unavablable servers will be ignored. We do not hide 'init rejected' (i.e. any server returning reject will make the multi filter issue a "reject). Not sure if we should hide that at all. Could be done with a new 'hiderejected' config. --- etc/config3.xml | 9 +++++++-- src/filter_multi.cpp | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/etc/config3.xml b/etc/config3.xml index 777422f..d3bd65f 100644 --- a/etc/config3.xml +++ b/etc/config3.xml @@ -1,5 +1,5 @@ - + @@ -18,7 +18,11 @@ db2 - localhost:9998/Slow + localhost:9999/Default + + + db3 + bagel.indexdata.dk:80 gils @@ -43,6 +47,7 @@ M + B diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index fcf3f5b..6cea8f8 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_multi.cpp,v 1.17 2006-05-15 13:22:02 adam Exp $ +/* $Id: filter_multi.cpp,v 1.18 2006-05-15 13:53:37 adam Exp $ Copyright (c) 2005-2006, Index Data. %LICENSE% @@ -95,6 +95,7 @@ namespace metaproxy_1 { friend class Multi; friend struct Frontend; + Rep(); FrontendPtr get_frontend(Package &package); void release_frontend(Package &package); private: @@ -102,10 +103,16 @@ namespace metaproxy_1 { boost::mutex m_mutex; boost::condition m_cond_session_ready; std::map m_clients; + bool m_hide_unavailable; }; } } +yf::Multi::Rep::Rep() +{ + m_hide_unavailable = false; +} + bool yf::Multi::BackendSet::operator < (const BackendSet &k) const { return m_count < k.m_count; @@ -353,7 +360,7 @@ void yf::Multi::Frontend::init(Package &package, Z_GDU *gdu) m_is_multi = true; // create init request - std::list::const_iterator bit; + std::list::iterator bit; for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++) { mp::odr odr; @@ -396,12 +403,20 @@ void yf::Multi::Frontend::init(Package &package, Z_GDU *gdu) ODR_MASK_SET(f_resp->protocolVersion, Z_ProtocolVersion_2); ODR_MASK_SET(f_resp->protocolVersion, Z_ProtocolVersion_3); - for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++) + int no_failed = 0; + int no_succeeded = 0; + for (bit = m_backend_list.begin(); bit != m_backend_list.end(); ) { PackagePtr p = (*bit)->m_package; if (p->session().is_closed()) // if any backend closes, close frontend - package.session().close(); + { + no_failed++; + bit = m_backend_list.erase(bit); + continue; + } + no_succeeded++; + Z_GDU *gdu = p->response().get(); if (gdu && gdu->which == Z_GDU_Z3950 && gdu->u.z3950->which == Z_APDU_initResponse) @@ -431,6 +446,17 @@ void yf::Multi::Frontend::init(Package &package, Z_GDU *gdu) package.response() = p->response(); return; } + bit++; + } + if (m_p->m_hide_unavailable) + { + if (no_succeeded == 0) + package.session().close(); + } + else + { + if (no_failed) + package.session().close(); } package.response() = f_apdu; } @@ -1087,6 +1113,10 @@ void mp::filter::Multi::configure(const xmlNode * ptr) std::cout << "route=" << route << " target=" << target << "\n"; m_p->m_target_route[target] = route; } + else if (!strcmp((const char *) ptr->name, "hideunavailable")) + { + m_p->m_hide_unavailable = true; + } else { throw mp::filter::FilterException -- 1.7.10.4