From 6c419dc09dae306558ec40453aa03e8cfc3db6c1 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 14 Aug 2014 14:54:01 +0200 Subject: [PATCH] zoom: make retry on failure configurable MP-565 The default and existing behavior is that backend failures (any diagnostic) makes the module re-search once. The behavior may be changed by db parameter 'retry'. If given value '0' disables retry and '1' enables it. If not given, the Torus record may specify with element retryOnFailure (value '0'/'1'). --- etc/config-zoom.xml | 1 + src/filter_zoom.cpp | 19 ++++++++++++++++++- xml/schema/filter_zoom.rnc | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/etc/config-zoom.xml b/etc/config-zoom.xml index 6052fff..09a2612 100644 --- a/etc/config-zoom.xml +++ b/etc/config-zoom.xml @@ -38,6 +38,7 @@ tmarc.xsl http://sever.com?title=${md-title[\s+/+/g]}&parm=1 localhost:9998/Default + 0 heikki/content1 diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index df9fc04..f2d7127 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -80,6 +80,7 @@ namespace metaproxy_1 { std::string sortStrategy; std::string extraArgs; std::string rpn2cql_fname; + std::string retry_on_failure; bool use_turbomarc; bool piggyback; CCL_bibset ccl_bibset; @@ -103,6 +104,7 @@ namespace metaproxy_1 { xmlDoc *explain_doc; std::string m_proxy; cql_transform_t cqlt; + std::string retry_on_failure; public: Backend(); ~Backend(); @@ -489,6 +491,7 @@ yf::Zoom::Searchable::Searchable(CCL_bibset base) piggyback = true; use_turbomarc = true; sortStrategy = "embed"; + retry_on_failure = "1"; // existing default (should have been false) ccl_bibset = ccl_qual_dup(base); } @@ -700,6 +703,11 @@ yf::Zoom::SearchablePtr yf::Zoom::Impl::parse_torus_record(const xmlNode *ptr) } else if (!strcmp((const char *) ptr->name, "rpn2cql")) s->rpn2cql_fname = mp::xml::get_text(ptr); + else if (!strcmp((const char *) ptr->name, + "retryOnFailure")) + { + s->retry_on_failure = mp::xml::get_text(ptr); + } } return s; } @@ -1134,6 +1142,7 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( const char *param_content_user = 0; const char *param_content_password = 0; const char *param_nocproxy = 0; + const char *param_retry = 0; int no_parms = 0; char **names; @@ -1169,6 +1178,8 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( content_proxy = value; else if (!strcmp(name, "nocproxy")) param_nocproxy = value; + else if (!strcmp(name, "retry")) + param_retry = value; else if (!strcmp(name, "proxy")) { char **dstr; @@ -1429,6 +1440,11 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( b->m_frontend_database = database; b->enable_cproxy = param_nocproxy ? false : true; + if (param_retry) + b->retry_on_failure = param_retry; + else + b->retry_on_failure = b->sptr->retry_on_failure; + if (sptr->query_encoding.length()) b->set_option("rpnCharset", sptr->query_encoding); @@ -2150,7 +2166,8 @@ bool yf::Zoom::Frontend::retry(mp::Package &package, error = YAZ_BIB1_PROXY_FAILURE; *addinfo = odr_strdup(odr, b->m_proxy.c_str()); } - else if (same_retries == 0 && proxy_retries == 0) + else if (b && b->retry_on_failure.compare("0") + && same_retries == 0 && proxy_retries == 0) { log_diagnostic(package, error, *addinfo); same_retries++; diff --git a/xml/schema/filter_zoom.rnc b/xml/schema/filter_zoom.rnc index bcd7071..90614eb 100644 --- a/xml/schema/filter_zoom.rnc +++ b/xml/schema/filter_zoom.rnc @@ -49,7 +49,8 @@ filter_zoom = element mp:sortmap_date { xsd:string }?, element mp:sortmap_title { xsd:string }?, element mp:extraArgs { xsd:string }?, - element mp:rpn2cql { xsd:string }? + element mp:rpn2cql { xsd:string }?, + element mp:retryOnFailure { xsd:string }? }* }? }?, -- 1.7.10.4