diff options
author | Henning Baldersheim <balder@oath.com> | 2018-04-16 15:38:19 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-04-16 15:38:19 +0200 |
commit | db68de6f457386b0c8d02926489df8a0f784a8e1 (patch) | |
tree | 309d25d56e137b2df59893093bbfb77e019f59b7 /vespaclient/src | |
parent | 96c808b99545c027e68c54f0e1fa8ac8425e192f (diff) |
Remove unused doclocator
Diffstat (limited to 'vespaclient/src')
7 files changed, 0 insertions, 352 deletions
diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/.gitignore b/vespaclient/src/vespa/vespaclient/vespadoclocator/.gitignore deleted file mode 100644 index 52e1033ec5b..00000000000 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -vespa-doclocator -vespa-doclocator-bin diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/CMakeLists.txt b/vespaclient/src/vespa/vespaclient/vespadoclocator/CMakeLists.txt deleted file mode 100644 index 69bffc28092..00000000000 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespaclient_vespadoclocator_app - SOURCES - application.cpp - locator.cpp - main.cpp - OUTPUT_NAME vespa-doclocator-bin - INSTALL bin - DEPENDS -) -vespa_add_target_system_dependency(vespaclient_vespadoclocator_app boost boost_program_options${VESPA_BOOST_LIB_SUFFIX}) diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.cpp b/vespaclient/src/vespa/vespaclient/vespadoclocator/application.cpp deleted file mode 100644 index 1d7d84e2b01..00000000000 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "application.h" -#include <boost/program_options.hpp> -#include <vespa/vespalib/util/exceptions.h> -#include <vespa/config/common/exceptions.h> -#include <vespa/document/base/idstringexception.h> -#include <iostream> - -#include <vespa/log/log.h> -LOG_SETUP("vespadoclocator"); - - -bool -Application::printDocumentLocation(Locator &locator, const std::string &docIdStr) -{ - try { - document::DocumentId docId(docIdStr); - std::cout << "DocumentId(" << docIdStr << ") " - << "BucketId(" << locator.getBucketId(docId).getId() << ") " - << "SearchColumn(" << locator.getSearchColumn(docId) << ")" - << std::endl; - } catch (document::IdParseException &e) { - std::cerr << e.getMessage() << std::endl; - return false; - } catch (vespalib::IllegalArgumentException &e) { - std::cerr << e.getMessage() << std::endl; - return false; - } - return true; -} - -int -Application::Main() -{ - // Configure locator object. - using namespace boost::program_options; - - uint32_t numColumns = 0; - std::string configId; - std::string clusterName; - std::vector<std::string> docIds; - - options_description desc("This is a tool for resolving the target column number of a document." - "\n\n" - "The options are"); - desc.add_options() - ( "config-id,i", - value<std::string>(&configId)->default_value("client"), - "The identifier to use when subscribing to configuration." ) - - ( "cluster-name,c", - value<std::string>(&clusterName), - "The name of the search cluster in which to resolve document location." ) - - ( "document-id,d", - value< std::vector<std::string> >(&docIds), - "The identifiers of the documents to locate. " - "These can also be passed as arguments without the option prefix. " - "If none is given, this tool parses identifiers from standard in." ) - - ( "help,h", - "Shows this help page." ) - - ( "num-columns,n", - value<uint32_t>(&numColumns), - "The number of columns in the search cluster. By providing this, no configuration " - "is required, meaning you can run this tool outside of a vespa cluster." ); - - positional_options_description pos; - pos.add("document-id", -1); - - variables_map vm; - try { - store(command_line_parser(_argc, _argv).options(desc).positional(pos).run(), vm); - notify(vm); - } catch (unknown_option &e) { - std::cout << e.what() << std::endl; - return EXIT_FAILURE; - } - - if (vm.count("help") != 0) { - std::cout << desc << std::endl; - return EXIT_SUCCESS; - } - - Locator locator(numColumns); - if (vm.count("num-columns") == 0) { - try { - locator.configure(configId, clusterName); - } catch (config::InvalidConfigException &e) { - std::cerr << e.getMessage() << std::endl; - return EXIT_FAILURE; - } - } - - // Locate the documents provided. - if (docIds.empty()) { - char buf[4096]; - while (!std::cin.getline(buf, 4096).eof()) { - std::string in(buf); - if (!printDocumentLocation(locator, in)) { - return EXIT_FAILURE; - } - } - } else { - for (std::vector<std::string>::iterator it = docIds.begin(); - it != docIds.end(); ++it) - { - if (!printDocumentLocation(locator, *it)) { - return EXIT_FAILURE; - } - } - } - return EXIT_SUCCESS; -} diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.h b/vespaclient/src/vespa/vespaclient/vespadoclocator/application.h deleted file mode 100644 index 58104ec407c..00000000000 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include "locator.h" -#include <vespa/fastos/app.h> - -class Application : public FastOS_Application { -private: - /** - * Locates and outputs the whereabouts of the given document id. If there is a problem parsing the given - * document identifier, this method returns false. - * - * @param locator The locator to use. - * @param docId The document to locate. - * @return True if the document was located. - */ - bool printDocumentLocation(Locator &locator, const std::string &docId); - -public: - int Main() override; -}; - diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.cpp b/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.cpp deleted file mode 100644 index 638c83ca456..00000000000 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "locator.h" -#include <vespa/documentapi/messagebus/documentprotocol.h> -#include <vespa/messagebus/configagent.h> -#include <vespa/messagebus/iconfighandler.h> -#include <vespa/messagebus/routing/routingspec.h> -#include <vespa/vdslib/bucketdistribution.h> -#include <vespa/vespalib/util/stringfmt.h> -#include <vespa/config/helper/configgetter.hpp> -#include <vespa/config/common/exceptions.h> -#include <vespa/config/subscription/configuri.h> -#include <boost/tokenizer.hpp> - -typedef std::map<std::string, uint32_t> ClusterMap; -using namespace config; - -namespace { - - void - processHop(const mbus::HopSpec &hop, ClusterMap &clusters) - { - typedef boost::char_separator<char> CharSeparator; - typedef boost::tokenizer<CharSeparator> Tokenizer; - - int colIdx = -1; - for (uint32_t r = 0, len = hop.getNumRecipients(); r < len; ++r) { - Tokenizer tokens(hop.getRecipient(r), CharSeparator("/")); - Tokenizer::iterator token = tokens.begin(); - for (uint32_t t = 0; t < 2 && token != tokens.end(); ++t, ++token) { - // empty - } - if (token != tokens.end()) { - colIdx = std::max(colIdx, atoi(&token->c_str()[1])); - } - } - if (colIdx < 0) { - throw config::InvalidConfigException(vespalib::make_string("Failed to process cluster '%s'.", - hop.getName().c_str())); - } - clusters.insert(ClusterMap::value_type(hop.getName().substr(15), colIdx + 1)); - } - - void - processTable(const mbus::RoutingTableSpec &table, ClusterMap &clusters) - { - clusters.clear(); - for (uint32_t i = 0, len = table.getNumHops(); i < len; ++i) { - const mbus::HopSpec &hop = table.getHop(i); - if (hop.getName().find("search/cluster.") == 0) { - processHop(hop, clusters); - } - } - if (clusters.empty()) { - throw config::InvalidConfigException("No search clusters found to resolve document location for."); - } - } - - void - processRouting(const mbus::RoutingSpec &routing, ClusterMap &clusters) - { - const mbus::RoutingTableSpec *table = NULL; - for (uint32_t i = 0, len = routing.getNumTables(); i < len; ++i) { - const mbus::RoutingTableSpec &ref = routing.getTable(i); - if (ref.getProtocol() == documentapi::DocumentProtocol::NAME) { - table = &ref; - break; - } - } - if (table == NULL) { - throw config::InvalidConfigException("No routing table available to derive config from."); - } - processTable(*table, clusters); - } - - uint32_t - getNumColumns(const mbus::RoutingSpec &routing, const std::string &clusterName) - { - ClusterMap clusters; - processRouting(routing, clusters); - - if (clusterName.empty() && clusters.size() == 1) { - return clusters.begin()->second; - } - - ClusterMap::iterator it = clusters.find(clusterName); - if (it == clusters.end()) { - std::string str = "Cluster name must be one of "; - int i = 0, len = clusters.size(); - for (it = clusters.begin(); it != clusters.end(); ++it, ++i) - { - str.append("'").append(it->first).append("'"); - if (i < len - 2) { - str.append(", "); - } else if (i == len - 2) { - str.append(" or "); - } - } - str.append("."); - throw config::InvalidConfigException(str); - } - - return it->second; - } -} - -Locator::Locator(uint32_t numColumns) : - _factory(), - _numColumns(numColumns) -{ - // empty -} - -void -Locator::configure(const std::string &configId, const std::string &clusterName) -{ - config::ConfigUri configUri(configId); - // Configure by inspecting routing config. - struct MyCB : public mbus::IConfigHandler { - mbus::RoutingSpec mySpec; - MyCB() : mySpec() {} - bool setupRouting(const mbus::RoutingSpec &spec) override { - mySpec = spec; - return true; - } - } myCB; - mbus::ConfigAgent agent(myCB); - agent.configure(ConfigGetter<messagebus::MessagebusConfig>::getConfig(configUri.getConfigId(), configUri.getContext())); - _numColumns = getNumColumns(myCB.mySpec, clusterName); -} - -document::BucketId -Locator::getBucketId(document::DocumentId &docId) -{ - return _factory.getBucketId(docId); -} - -uint32_t -Locator::getSearchColumn(document::DocumentId &docId) -{ - vdslib::BucketDistribution dist(_numColumns, 16u); - return dist.getColumn(getBucketId(docId)); -} diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.h b/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.h deleted file mode 100644 index 02df3a9916f..00000000000 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <vespa/document/base/documentid.h> -#include <vespa/document/bucket/bucketidfactory.h> - -class Locator { -private: - document::BucketIdFactory _factory; - uint32_t _numColumns; - -public: - /** - * Constructs a new locator object. - */ - Locator(uint32_t numColumns = 0); - - /** - * Configures this locator using the supplied configuration id and cluster name. This method will - * subscribe to some known config and attempt to retrieve the number of columns of the given search - * cluster from that. - * - * This method throws an exception if it could not be configured. - * - * @param configId The config identifier to subscribe to. - * @param clusterName The name of the search cluster to resolve locations in. - */ - void configure(const std::string &configId, - const std::string &clusterName); - - /** - * Returns the bucket id to which a document id belongs. - * - * @param docId The document id to resolve. - * @return The corresponding bucket id. - */ - document::BucketId getBucketId(document::DocumentId &docId); - - /** - * Returns the column in which the given document id belongs. - * - * @param docId The document id to resolve. - * @return The corresponding column. - */ - uint32_t getSearchColumn(document::DocumentId &docId); -}; - diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/main.cpp b/vespaclient/src/vespa/vespaclient/vespadoclocator/main.cpp deleted file mode 100644 index da20eb5c283..00000000000 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "application.h" - -int -main(int argc, char **argv) -{ - Application app; - return app.Entry(argc, argv); -} |