From: Adam Dickmeiss Date: Thu, 11 Jun 2009 08:50:53 +0000 (+0200) Subject: Merge branch 'load_balance' X-Git-Tag: v1.0.17~6 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=0a42d22e7e1d240079e47addd39c39500c23d09a;hp=0dcfd01a8fc058f1537af7bf16f29ca901a3e61b;p=metaproxy-moved-to-github.git Merge branch 'load_balance' --- diff --git a/NEWS b/NEWS index 395a520..c8d74bf 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,20 @@ -Implemented facility to change current working directory (-w). +--- 1.0.16 2009/06/10 + +SRU to Z39.50 filter honors x-username and x-password. If only +x-username is given that translates to open authentication (Z39.50v2). If +both x-username and x-password is present that translates to idPass +authentication (Z39.50v3). + +New facility to change current working directory (-w). + +Update to upstream skeleton of init.d script. Should fix bug #2619. + +Filter session_shared now caches records (used to only cache connections +and result sets). + +Filter session_shared now invalidates a Z39.50 session if a server +returns -1 hits. This facility was also part of yazproxy and gets around +a bug in Voyager-based Z39.50 servers. --- 1.0.15 2008/11/18 diff --git a/configure.ac b/configure.ac index b8b447e..edabf5a 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # Autoconf and automake setup AC_PREREQ([2.60]) -AC_INIT([metaproxy],[1.0.15],[metaproxy-help@indexdata.dk]) +AC_INIT([metaproxy],[1.0.16],[metaproxy-help@indexdata.dk]) AC_CONFIG_HEADERS([src/config.hpp]) diff --git a/debian/changelog b/debian/changelog index 4cd4145..701e8b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +metaproxy (1.0.16-1indexdata) unstable; urgency=low + + * Upstream. + + -- Adam Dickmeiss Tue, 09 Jun 2009 15:37:15 +0200 + metaproxy (1.0.15-1indexdata) unstable; urgency=low * Upstream. diff --git a/debian/control b/debian/control index 7cc5213..f6048a1 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: devel Standards-Version: 3.6.2 Maintainer: Adam Dickmeiss Priority: extra -Build-Depends: debhelper (>= 4), libyaz3-dev, libyazpp3-dev (>= 1.1.1), libxslt1-dev, libboost-dev, libboost-thread-dev, libboost-test-dev, libgnutls-dev +Build-Depends: debhelper (>= 4), libyaz3-dev, libyazpp3-dev (>= 1.1.2), libxslt1-dev, libboost-dev, libboost-thread-dev, libboost-test-dev, libgnutls-dev Package: metaproxy Section: net diff --git a/doc/book.xml b/doc/book.xml index 9b641bd..dfa2013 100644 --- a/doc/book.xml +++ b/doc/book.xml @@ -34,7 +34,7 @@ &version; - 2005-2007 + 2005-2009 Index Data ApS diff --git a/src/filter_backend_test.cpp b/src/filter_backend_test.cpp index 3c0aeea..7881e57 100644 --- a/src/filter_backend_test.cpp +++ b/src/filter_backend_test.cpp @@ -232,7 +232,7 @@ void yf::BackendTest::process(Package &package) const Z_InitRequest *req = apdu_req->u.initRequest; Z_InitResponse *resp = apdu_res->u.initResponse; - resp->implementationName = "backend_test"; + resp->implementationName = odr_strdup(odr, "backend_test"); if (ODR_MASK_GET(req->options, Z_Options_namedResultSets)) m_p->m_support_named_result_sets = true; diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index dfd98a0..fea86c1 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -63,15 +63,17 @@ namespace metaproxy_1 { ActiveUrlMap m_active_urls; private: void sru(metaproxy_1::Package &package, Z_GDU *zgdu_req); - bool z3950_build_query(mp::odr &odr_en, Z_Query *z_query, - const Z_SRW_searchRetrieveRequest *req - ) const; - - bool z3950_init_request(mp::Package &package, - mp::odr &odr_en, - std::string zurl, - Z_SRW_PDU *sru_pdu_res, - const Z_SRW_PDU *sru_pdu_req + bool z3950_build_query( + mp::odr &odr_en, Z_Query *z_query, + const Z_SRW_searchRetrieveRequest *req + ) const; + + bool z3950_init_request( + mp::Package &package, + mp::odr &odr_en, + std::string zurl, + Z_SRW_PDU *sru_pdu_res, + const Z_SRW_PDU *sru_pdu_req ) const; bool z3950_close_request(mp::Package &package) const; @@ -81,28 +83,27 @@ namespace metaproxy_1 { mp::odr &odr_en, Z_SRW_PDU *sru_pdu_res, Z_SRW_searchRetrieveRequest const *sr_req, - std::string zurl) const; + std::string zurl + ) const; bool z3950_present_request( mp::Package &package, mp::odr &odr_en, Z_SRW_PDU *sru_pdu_res, - Z_SRW_searchRetrieveRequest const *sr_req) const; - - bool z3950_scan_request(mp::Package &package, - mp::odr &odr_en, - Z_SRW_PDU *sru_pdu_res, - Z_SRW_scanRequest - const *sr_req) const; - - bool z3950_to_srw_diagnostics_ok(mp::odr &odr_en, - Z_SRW_searchRetrieveResponse *srw_res, - Z_Records *records) const; - - int z3950_to_srw_diag(mp::odr &odr_en, - Z_SRW_searchRetrieveResponse *srw_res, - Z_DefaultDiagFormat *ddf) const; - + Z_SRW_searchRetrieveRequest const *sr_req + ) const; + + bool z3950_to_srw_diagnostics_ok( + mp::odr &odr_en, + Z_SRW_searchRetrieveResponse *srw_res, + Z_Records *records + ) const; + + int z3950_to_srw_diag( + mp::odr &odr_en, + Z_SRW_searchRetrieveResponse *srw_res, + Z_DefaultDiagFormat *ddf + ) const; }; } @@ -130,7 +131,8 @@ void yf::SRUtoZ3950::Impl::configure(const xmlNode *confignode) { const xmlNode * dbnode; - for (dbnode = confignode->children; dbnode; dbnode = dbnode->next){ + for (dbnode = confignode->children; dbnode; dbnode = dbnode->next) + { if (dbnode->type != XML_ELEMENT_NODE) continue; @@ -138,14 +140,16 @@ void yf::SRUtoZ3950::Impl::configure(const xmlNode *confignode) mp::xml::check_element_mp(dbnode, "database"); for (struct _xmlAttr *attr = dbnode->properties; - attr; attr = attr->next){ + attr; attr = attr->next) + { mp::xml::check_attribute(attr, "", "name"); database = mp::xml::get_text(attr); const xmlNode *explainnode; for (explainnode = dbnode->children; - explainnode; explainnode = explainnode->next){ + explainnode; explainnode = explainnode->next) + { if (explainnode->type != XML_ELEMENT_NODE) continue; if (explainnode) @@ -174,11 +178,13 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) // assign explain config XML DOM node if database is known const xmlNode *explainnode = 0; - if (idbexp != m_database_explain.end()){ + if (idbexp != m_database_explain.end()) + { explainnode = idbexp->second; } // just moving package if database is not known - else { + else + { package.move(); return; } @@ -191,8 +197,8 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) // filter acts as sink for non-valid SRU requests if (! (sru_pdu_req = mp_util::decode_sru_request(package, odr_de, odr_en, - sru_pdu_res, &soap, - charset, stylesheet))) + sru_pdu_res, &soap, + charset, stylesheet))) { if (soap) { @@ -225,9 +231,10 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) package.origin().set_max_sockets(atoi(arg->value)); } + assert(sru_pdu_req); // filter acts as sink for SRU explain requests - if (sru_pdu_req && sru_pdu_req->which == Z_SRW_explain_request) + if (sru_pdu_req->which == Z_SRW_explain_request) { Z_SRW_explainRequest *er_req = sru_pdu_req->u.explain_request; //mp_util::build_simple_explain(package, odr_en, sru_pdu_res, @@ -235,9 +242,8 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) mp_util::build_sru_explain(package, odr_en, sru_pdu_res, sruinfo, explainnode, er_req); } - else if (sru_pdu_req - && sru_pdu_req->which == Z_SRW_searchRetrieve_request - && sru_pdu_req->u.request) + else if (sru_pdu_req->which == Z_SRW_searchRetrieve_request + && sru_pdu_req->u.request) { // searchRetrieve Z_SRW_searchRetrieveRequest *sr_req = sru_pdu_req->u.request; @@ -267,12 +273,9 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) } // scan - else if (sru_pdu_req - && sru_pdu_req->which == Z_SRW_scan_request + else if (sru_pdu_req->which == Z_SRW_scan_request && sru_pdu_req->u.scan_request) { - Z_SRW_scanRequest *sr_req = sru_pdu_req->u.scan_request; - sru_pdu_res = yaz_srw_get(odr_en, Z_SRW_scan_response); // we do not do scan at the moment, therefore issuing a diagnostic @@ -280,22 +283,15 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) &(sru_pdu_res->u.scan_response->diagnostics), &(sru_pdu_res->u.scan_response->num_diagnostics), YAZ_SRW_UNSUPP_OPERATION, "scan"); - - // to be used when we do scan - if (false && z3950_init_request(package, odr_en, zurl, sru_pdu_res, - sru_pdu_req)) - { - z3950_scan_request(package, odr_en, sru_pdu_res, sr_req); - z3950_close_request(package); - } } else { - //std::cout << "SRU OPERATION NOT SUPPORTED \n"; sru_pdu_res = yaz_srw_get(odr_en, Z_SRW_explain_response); - // TODO: make nice diagnostic return package - return; + yaz_add_srw_diagnostic(odr_en, + &(sru_pdu_res->u.explain_response->diagnostics), + &(sru_pdu_res->u.explain_response->num_diagnostics), + YAZ_SRW_UNSUPP_OPERATION, "unknown"); } // build and send SRU response @@ -309,7 +305,8 @@ void yf::SRUtoZ3950::Impl::process(mp::Package &package) Z_GDU *zgdu_req = package.request().get(); // ignoring all non HTTP_Request packages - if (!zgdu_req || !(zgdu_req->which == Z_GDU_HTTP_Request)){ + if (!zgdu_req || !(zgdu_req->which == Z_GDU_HTTP_Request)) + { package.move(); return; } @@ -366,15 +363,12 @@ yf::SRUtoZ3950::Impl::z3950_init_request(mp::Package &package, Z_IdAuthentication *auth = NULL; if (sru_pdu_req->username && !sru_pdu_req->password) { - yaz_log(YLOG_LOG, "username: %s\n", sru_pdu_req->username); auth = (Z_IdAuthentication *) odr_malloc(odr_en, sizeof(Z_IdAuthentication)); auth->which = Z_IdAuthentication_open; auth->u.open = odr_strdup(odr_en, sru_pdu_req->username); } else if (sru_pdu_req->username && sru_pdu_req->password) { - yaz_log(YLOG_LOG, "username/password: %s/%s\n", - sru_pdu_req->username, sru_pdu_req->password); auth = (Z_IdAuthentication *) odr_malloc(odr_en, sizeof(Z_IdAuthentication)); auth->which = Z_IdAuthentication_idPass; auth->u.idPass = (Z_IdPass *) odr_malloc(odr_en, sizeof(Z_IdPass)); @@ -385,13 +379,6 @@ yf::SRUtoZ3950::Impl::z3950_init_request(mp::Package &package, init_req->idAuthentication = auth; - //TODO: add user name in apdu - //TODO: add user passwd in apdu - //init_req->idAuthentication = org_init->idAuthentication; - //init_req->implementationId = "IDxyz"; - //init_req->implementationName = "NAMExyz"; - //init_req->implementationVersion = "VERSIONxyz"; - ODR_MASK_SET(init_req->options, Z_Options_search); ODR_MASK_SET(init_req->options, Z_Options_present); ODR_MASK_SET(init_req->options, Z_Options_namedResultSets); @@ -415,7 +402,8 @@ yf::SRUtoZ3950::Impl::z3950_init_request(mp::Package &package, z3950_package.move(); // dead Z3950 backend detection - if (z3950_package.session().is_closed()){ + if (z3950_package.session().is_closed()) + { yaz_add_srw_diagnostic(odr_en, &(sru_pdu_res->u.response->diagnostics), &(sru_pdu_res->u.response->num_diagnostics), @@ -459,7 +447,8 @@ yf::SRUtoZ3950::Impl::z3950_close_request(mp::Package &package) const // && z3950_gdu->u.z3950->which == Z_APDU_close) // return true; - if (z3950_package.session().is_closed()){ + if (z3950_package.session().is_closed()) + { return true; } return false; @@ -779,70 +768,6 @@ yf::SRUtoZ3950::Impl::z3950_present_request(mp::Package &package, return true; } -bool -yf::SRUtoZ3950::Impl::z3950_scan_request(mp::Package &package, - mp::odr &odr_en, - Z_SRW_PDU *sru_pdu_res, - Z_SRW_scanRequest const *sr_req) const -{ - assert(sru_pdu_res->u.scan_response); - - Package z3950_package(package.session(), package.origin()); - z3950_package.copy_filter(package); - //mp::odr odr_en(ODR_ENCODE); - Z_APDU *apdu = zget_APDU(odr_en, Z_APDU_scanRequest); - - //TODO: add stuff in apdu - Z_ScanRequest *z_scanRequest = apdu->u.scanRequest; - - // database repackaging - z_scanRequest->num_databaseNames = 1; - z_scanRequest->databaseNames = (char**) - odr_malloc(odr_en, sizeof(char *)); - if (sr_req->database) - z_scanRequest->databaseNames[0] - = odr_strdup(odr_en, const_cast(sr_req->database)); - else - z_scanRequest->databaseNames[0] - = odr_strdup(odr_en, "Default"); - - - // query repackaging - // CQL or XCQL scan is not possible in Z3950, flagging a diagnostic - if (sr_req->query_type != Z_SRW_query_type_pqf) - { - //send_to_srw_client_error(7, "query"); - return false; - } - - // PQF query repackaging - // need to use Z_AttributesPlusTerm structure, not Z_Query - // this can be digget out of a - // Z_query->type1(Z_RPNQuery)->RPNStructure(Z_RPNStructure) - // ->u.simple(Z_Operand)->u.attributesPlusTerm(Z_AttributesPlusTerm ) - - //Z_Query *z_query = (Z_Query *) odr_malloc(odr_en, sizeof(Z_Query)); - //z_searchRequest->query = z_query; - - //if (!z3950_build_query(odr_en, z_query, - // (const SRW_query&)sr_req->query, - // sr_req->query_type)) - //{ - //send_to_srw_client_error(7, "query"); - // return false; - //} - - // TODO: - - z3950_package.request() = apdu; - std::cout << "z3950_scan_request " << *apdu << "\n"; - - z3950_package.move(); - //TODO: check success condition - return true; - return false; -} - bool yf::SRUtoZ3950::Impl::z3950_build_query(mp::odr &odr_en, Z_Query *z_query, const Z_SRW_searchRetrieveRequest *req ) const