diff options
author | Henning Baldersheim <balder@oath.com> | 2018-04-16 15:39:21 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-04-16 15:39:21 +0200 |
commit | 382951509d1f3b054d9241ef98d1c5a6eac3834c (patch) | |
tree | 41850ad8bb5c7251fd7a98ea6ba65ce9773d5cbd | |
parent | 49d2314efda87f61fd37665ebeac766b06a731fa (diff) |
Remove unused systemstate
23 files changed, 1 insertions, 1194 deletions
diff --git a/documentapi/CMakeLists.txt b/documentapi/CMakeLists.txt index ae2e479e8bf..b03dd66c817 100644 --- a/documentapi/CMakeLists.txt +++ b/documentapi/CMakeLists.txt @@ -20,7 +20,6 @@ vespa_define_module( src/vespa/documentapi/messagebus src/vespa/documentapi/messagebus/messages src/vespa/documentapi/messagebus/policies - src/vespa/documentapi/messagebus/systemstate TEST_DEPENDS messagebus_messagebus-test @@ -34,5 +33,4 @@ vespa_define_module( src/tests/priority src/tests/replymerger src/tests/routablefactory - src/tests/systemstate ) diff --git a/documentapi/src/testlist.txt b/documentapi/src/testlist.txt index 851741bd24a..270cd72f524 100644 --- a/documentapi/src/testlist.txt +++ b/documentapi/src/testlist.txt @@ -4,6 +4,5 @@ tests/policies tests/policyfactory tests/priority tests/routablefactory -tests/systemstate tests/loadtypes tests/replymerger diff --git a/documentapi/src/tests/policies/testframe.cpp b/documentapi/src/tests/policies/testframe.cpp index 024a0c2fdaa..d99d99b9ec0 100644 --- a/documentapi/src/tests/policies/testframe.cpp +++ b/documentapi/src/tests/policies/testframe.cpp @@ -322,13 +322,6 @@ TestFrame::waitSlobrok(const string &pattern, uint32_t cnt) return false; } -SystemStateHandle -TestFrame::getSystemState() -{ - mbus::IProtocol * protocol = _mbus->getProtocol(DocumentProtocol::NAME); - return SystemStateHandle(static_cast<DocumentProtocol&>(*protocol).getSystemState()); -} - void TestFrame::handleReply(mbus::Reply::UP reply) { diff --git a/documentapi/src/tests/policies/testframe.h b/documentapi/src/tests/policies/testframe.h index 15ec61aff7b..cc5101905a1 100644 --- a/documentapi/src/tests/policies/testframe.h +++ b/documentapi/src/tests/policies/testframe.h @@ -2,7 +2,6 @@ #pragma once #include <vespa/documentapi/messagebus/documentprotocol.h> -#include <vespa/documentapi/messagebus/systemstate/systemstatehandle.h> #include <vespa/messagebus/messagebus.h> #include <vespa/messagebus/network/identity.h> #include <vespa/messagebus/network/inetwork.h> @@ -190,12 +189,6 @@ public: */ mbus::Receptor &getReceptor() { return _handler; } - /** - * Returns the system state from contained document protocol. - * - * @return Handle to the system state. - */ - documentapi::SystemStateHandle getSystemState(); void handleReply(mbus::Reply::UP reply) override; }; diff --git a/documentapi/src/tests/systemstate/.gitignore b/documentapi/src/tests/systemstate/.gitignore deleted file mode 100644 index 3f52bc38742..00000000000 --- a/documentapi/src/tests/systemstate/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -systemstate_test -documentapi_systemstate_test_app diff --git a/documentapi/src/tests/systemstate/CMakeLists.txt b/documentapi/src/tests/systemstate/CMakeLists.txt deleted file mode 100644 index b275f2b2fd0..00000000000 --- a/documentapi/src/tests/systemstate/CMakeLists.txt +++ /dev/null @@ -1,8 +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(documentapi_systemstate_test_app TEST - SOURCES - systemstate.cpp - DEPENDS - documentapi -) -vespa_add_test(NAME documentapi_systemstate_test_app COMMAND documentapi_systemstate_test_app) diff --git a/documentapi/src/tests/systemstate/DESC b/documentapi/src/tests/systemstate/DESC deleted file mode 100644 index 19dbc9195f1..00000000000 --- a/documentapi/src/tests/systemstate/DESC +++ /dev/null @@ -1,3 +0,0 @@ -This is a unit test for the system state parser and the corresponding NodeState class. It mirrors the -StateParserTestCase available in the java implementation of message bus. It consists of tests that verify that parsing -works, pathing works, encoding/decoding works, and finally that the NodeState class works as intended. diff --git a/documentapi/src/tests/systemstate/FILES b/documentapi/src/tests/systemstate/FILES deleted file mode 100644 index e1d0e026d31..00000000000 --- a/documentapi/src/tests/systemstate/FILES +++ /dev/null @@ -1 +0,0 @@ -systemstate.cpp diff --git a/documentapi/src/tests/systemstate/systemstate.cpp b/documentapi/src/tests/systemstate/systemstate.cpp deleted file mode 100644 index 3e42c94950a..00000000000 --- a/documentapi/src/tests/systemstate/systemstate.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/documentapi/messagebus/systemstate/systemstate.h> -#include <vespa/documentapi/messagebus/systemstate/nodestate.h> -#include <vespa/documentapi/messagebus/systemstate/systemstatehandle.h> -#include <vespa/vespalib/testkit/testapp.h> - -#include <vespa/log/log.h> -LOG_SETUP("systemstate_test"); - -using namespace documentapi; - -class Test : public vespalib::TestApp { -public: - int Main() override; - void testParser(); - void testPathing(); - void testState(); - void testEncoding(); - void testHandle(); - void testCompact(); - -private: - void assertParser(const string &state, const string &expected = ""); -}; - -TEST_APPHOOK(Test); - -int -Test::Main() -{ - TEST_INIT("systemstate_test"); - - testParser(); TEST_FLUSH(); - testPathing(); TEST_FLUSH(); - testState(); TEST_FLUSH(); - testEncoding(); TEST_FLUSH(); - testHandle(); TEST_FLUSH(); - testCompact(); TEST_FLUSH(); - - TEST_DONE(); - return 0; -} - -void -Test::testParser() -{ - assertParser("storage"); - assertParser("storage?", "ERROR"); - assertParser("storage?a", "ERROR"); - assertParser("storage?a=", "ERROR"); - assertParser("storage?a=1"); - assertParser("storage?a=1&", "ERROR"); - assertParser("storage?a=1&b", "ERROR"); - assertParser("storage?a=1&b=2"); - assertParser("storage?a=1&b=2 search"); - assertParser("storage?a=1&b=2 search?", "ERROR"); - assertParser("storage?a=1&b=2 search?a", "ERROR"); - assertParser("storage?a=1&b=2 search?a=", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1"); - assertParser("storage?a=1&b=2 search?a=1&", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1&b", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1&b=", "ERROR"); - assertParser("storage?a=1&b=2 search?a=1&b=2"); - - assertParser("storage"); - assertParser("storage/"); - assertParser("storage/?", "ERROR"); - assertParser("storage/?a", "ERROR"); - assertParser("storage/?a=", "ERROR"); - assertParser("storage/?a=1"); - assertParser("storage/cluster.storage"); - assertParser("storage/cluster.storage/"); - - assertParser("storage?a=1"); - assertParser("storage/?a=1"); - assertParser("storage/.?a=1"); - assertParser("storage/./?a=1"); - assertParser("storage/./cluster.storage?a=1"); - assertParser("storage/./cluster.storage/?a=1"); - assertParser("storage/./cluster.storage/..?a=1"); - assertParser("storage/./cluster.storage/../?a=1"); - assertParser("storage/./cluster.storage/../storage?a=1"); - assertParser("storage/./cluster.storage/../storage/?a=1"); -} - -void -Test::testPathing() -{ - assertParser("storage?a=1", "storage?a=1"); - assertParser("storage/?a=1", "storage?a=1"); - assertParser("storage/.?a=1", "storage?a=1"); - assertParser("storage/./?a=1", "storage?a=1"); - assertParser("storage/./cluster.storage?a=1", "storage/cluster.storage?a=1"); - assertParser("storage/./cluster.storage/?a=1", "storage/cluster.storage?a=1"); - assertParser("storage/./cluster.storage/..?a=1", "storage?a=1"); - assertParser("storage/./cluster.storage/../?a=1", "storage?a=1"); - assertParser("storage/./cluster.storage/../storage?a=1", "storage/storage?a=1"); - assertParser("storage/./cluster.storage/../storage/?a=1", "storage/storage?a=1"); - - assertParser("a?p1=1 a/b?p2=2 a/b/c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a .?p1=1 ./b?p2=2 ./b/c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a .?p1=1 ./../a/b/ .?p2=2 c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a/./ .?p1=1 ../a/b/c/.. .?p2=2 ./c/../c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - assertParser("a/b/c/d/ ../../ ../ ../a .?p1=1 ./b?p2=2 ./ ../a/b/c?p3=3", "a?p1=1 a/b?p2=2 a/b/c?p3=3"); - - assertParser("a/b/c/d?p1=1 a?p2=2", "a?p2=2 a/b/c/d?p1=1"); - assertParser("a/b/c/d/?p1=1 /a?p2=2", "a?p2=2 a/b/c/d?p1=1"); - assertParser("/a/b/c/d/?p1=1 /a?p2=2", "a?p2=2 a/b/c/d?p1=1"); - - assertParser("a .?p1=1", "a?p1=1"); - assertParser("a/b .?p1=1", "a/b?p1=1"); - assertParser("a/b c?p1=1 d?p2=2", "a/b/c?p1=1 a/b/d?p2=2"); -} - -void -Test::testState() -{ - NodeState state; - state - .addChild("distributor", NodeState() - .setState("n", "27")) - .addChild("storage", NodeState() - .setState("n", "170") - .addChild("2", NodeState() - .setState("s", "d")) - .addChild("13", NodeState() - .setState("s", "r") - .setState("c", "0.0"))); - - EXPECT_EQUAL("27", state.getState("distributor/n")); - EXPECT_EQUAL("170", state.getState("storage/n")); - EXPECT_EQUAL("d", state.getState("storage/2/s")); - EXPECT_EQUAL("r", state.getState("storage/13/s")); - EXPECT_EQUAL("0.0", state.getState("storage/13/c")); - - EXPECT_EQUAL("27", state.getChild("distributor")->getState("n")); - EXPECT_EQUAL("170", state.getChild("storage")->getState("n")); - EXPECT_EQUAL("d", state.getChild("storage")->getChild("2")->getState("s")); - EXPECT_EQUAL("r", state.getChild("storage")->getChild("13")->getState("s")); - EXPECT_EQUAL("0.0", state.getChild("storage")->getChild("13")->getState("c")); -} - -void -Test::testEncoding() -{ - NodeState state; - state.setState("foo", "http://search.yahoo.com/?query=bar"); - LOG(info, "'%s'", state.toString().c_str()); - EXPECT_EQUAL(".?foo=http%3A%2F%2Fsearch.yahoo.com%2F%3Fquery%3Dbar", state.toString()); - assertParser(state.toString(), state.toString()); - - state = NodeState() - .addChild("foo:bar", NodeState() - .setState("foo", "http://search.yahoo.com/?query=bar")); - LOG(info, "'%s'", state.toString().c_str()); - EXPECT_EQUAL("foo%3Abar?foo=http%3A%2F%2Fsearch.yahoo.com%2F%3Fquery%3Dbar", state.toString()); - assertParser(state.toString(), state.toString()); - - state = NodeState() - .addChild("foo/bar", NodeState() - .setState("foo", "http://search.yahoo.com/?query=bar")); - LOG(info, "'%s'", state.toString().c_str()); - EXPECT_EQUAL("foo/bar?foo=http%3A%2F%2Fsearch.yahoo.com%2F%3Fquery%3Dbar", state.toString()); - assertParser(state.toString(), state.toString()); -} - -void -Test::testHandle() -{ - SystemState::UP state(SystemState::newInstance("")); - ASSERT_TRUE(state.get() != NULL); - - SystemStateHandle handle(*state); - ASSERT_TRUE(handle.isValid()); - - SystemStateHandle hoe(std::move(handle)); - ASSERT_TRUE(!handle.isValid()); - ASSERT_TRUE(hoe.isValid()); -} - -void -Test::testCompact() -{ - NodeState state; - state - .setState("a/b0/s", "d") - .setState("a/b0/c0/s", "d") - .setState("a/b0/c1/s", "d") - .setState("a/b1/s", "d") - .setState("a/b1/c0/s", "d") - .setState("a/b1/c1/s", "d"); - EXPECT_EQUAL("a/b0?s=d a/b0/c0?s=d a/b0/c1?s=d a/b1?s=d a/b1/c0?s=d a/b1/c1?s=d", state.toString()); - - state.removeChild("a/b0/c0"); - EXPECT_EQUAL("a/b0?s=d a/b0/c1?s=d a/b1?s=d a/b1/c0?s=d a/b1/c1?s=d", state.toString()); - - state.removeState("a/b0/c1/s"); - EXPECT_EQUAL("a/b0?s=d a/b1?s=d a/b1/c0?s=d a/b1/c1?s=d", state.toString()); - - state.setState("a/b1/c0/s", ""); - EXPECT_EQUAL("a/b0?s=d a/b1?s=d a/b1/c1?s=d", state.toString()); - - state.removeChild("a/b1"); - EXPECT_EQUAL("a/b0?s=d", state.toString()); - - state.removeChild("a"); - EXPECT_EQUAL("", state.toString()); -} - -void -Test::assertParser(const string &state, const string &expected) -{ - SystemState::UP obj = SystemState::newInstance(state); - if (obj.get() == NULL) { - EXPECT_EQUAL("ERROR", expected); - } - else { - SystemStateHandle handle(*obj); - LOG(info, "'%s' => '%s'", state.c_str(), handle.getRoot().toString().c_str()); - if (!expected.empty()) { - EXPECT_EQUAL(expected, handle.getRoot().toString()); - } - } -} - diff --git a/documentapi/src/vespa/documentapi/CMakeLists.txt b/documentapi/src/vespa/documentapi/CMakeLists.txt index 42998182f56..46bc0239834 100644 --- a/documentapi/src/vespa/documentapi/CMakeLists.txt +++ b/documentapi/src/vespa/documentapi/CMakeLists.txt @@ -4,7 +4,6 @@ vespa_add_library(documentapi $<TARGET_OBJECTS:documentapi_documentapimessagebus> $<TARGET_OBJECTS:documentapi_documentapimessages> $<TARGET_OBJECTS:documentapi_documentapipolicies> - $<TARGET_OBJECTS:documentapi_documentapisystemstate> $<TARGET_OBJECTS:documentapi_documentapiloadtypes> INSTALL lib64 DEPENDS diff --git a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp index d92fbdfb941..d2661d0fe6c 100644 --- a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp @@ -28,7 +28,6 @@ DocumentProtocol::DocumentProtocol(const LoadTypeSet& loadTypes, const string &configId) : _routingPolicyRepository(new RoutingPolicyRepository()), _routableRepository(new RoutableRepository(loadTypes)), - _systemState(SystemState::newInstance("")), _repo(repo) { // Prepare config string for routing policy factories. diff --git a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h index 0a6c10ace77..830d7147b4b 100644 --- a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h +++ b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h @@ -1,11 +1,11 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/documentapi/messagebus/systemstate/systemstate.h> #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/iprotocol.h> #include <vespa/messagebus/reply.h> #include <vespa/messagebus/routing/routingcontext.h> +#include <vespa/documentapi/common.h> namespace vespalib { class VersionSpecification; @@ -28,7 +28,6 @@ class DocumentProtocol final : public mbus::IProtocol { private: std::unique_ptr<RoutingPolicyRepository> _routingPolicyRepository; std::unique_ptr<RoutableRepository> _routableRepository; - std::unique_ptr<SystemState> _systemState; std::shared_ptr<const document::DocumentTypeRepo> _repo; public: @@ -301,7 +300,6 @@ public: * * @return The system state. */ - SystemState &getSystemState() { return *_systemState; } const mbus::string &getName() const override { return NAME; } mbus::IRoutingPolicy::UP createPolicy(const mbus::string &name, const mbus::string ¶m) const override; mbus::Blob encode(const vespalib::Version &version, const mbus::Routable &routable) const override; diff --git a/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h b/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h index 05202ad0de9..e2bf5119c58 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h +++ b/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h @@ -2,7 +2,6 @@ #pragma once #include "iroutingpolicyfactory.h" -#include <vespa/documentapi/messagebus/systemstate/systemstate.h> namespace document { class DocumentTypeRepo; } diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/.gitignore b/documentapi/src/vespa/documentapi/messagebus/systemstate/.gitignore deleted file mode 100644 index 5dae353d999..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.depend -Makefile diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/CMakeLists.txt b/documentapi/src/vespa/documentapi/messagebus/systemstate/CMakeLists.txt deleted file mode 100644 index 45ca04e2cb3..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_library(documentapi_documentapisystemstate OBJECT - SOURCES - nodestate.cpp - systemstate.cpp - systemstatehandle.cpp - urlencoder.cpp - DEPENDS -) diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp b/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp deleted file mode 100644 index 42c573ef09e..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "nodestate.h" -#include "urlencoder.h" - -#include <vespa/log/log.h> -LOG_SETUP(".nodestate"); - -using namespace documentapi; - -NodeState::NodeState() : - _parent(NULL), - _id(""), - _children(), - _state() -{ - // empty -} - -NodeState::NodeState(const NodeState &rhs) : - _parent(rhs._parent), - _id(rhs._id), - _children(rhs._children), - _state(rhs._state) -{ - // empty -} - -NodeState::NodeState(StateMap args) : - _parent(NULL), - _id(""), - _children(), - _state(args) -{ - // empty -} - -NodeState::~NodeState() { } - -NodeState & -NodeState::addChild(const string &key, const NodeState &child) -{ - getChild(key, true)->copy(child); - return *this; -} - -NodeState * -NodeState::getChild(const string &key, bool force) -{ - if (key.empty()) { - return this; - } - - // Find first not-self location item. - size_t from = 0, to = key.find('/'); - while (to != string::npos && key.substr(from, to - from) == ".") { - from = to + 1; - to = key.find('/', from); - } - string arr0 = to != string::npos ? key.substr(from, to - from) : key.substr(from); - string arr1 = to != string::npos ? key.substr(to + 1) : ""; - - // Reference this or parent. - if (arr0 == ".") { - return this; - } - if (arr0 == "..") { - if (_parent == NULL) { - LOG(error, "Location string '%s' requests a parent above the top-most node, returning self to avoid crash.", - key.c_str()); - return this; - } - return _parent->getChild(arr1, force); - } - - // Look for child, forcing it if requested. - ChildMap::iterator it = _children.find(arr0); - if (it == _children.end()) { - if (!force) { - return NULL; - } - _children[arr0] = NodeState::SP(new NodeState()); - _children[arr0]->setParent(*this, arr0); - } - if (to != string::npos) { - return _children[arr0]->getChild(arr1, force); - } - return _children[arr0].get(); -} - -const NodeState::ChildMap & -NodeState::getChildren() const -{ - return _children; -} - -NodeState & -NodeState::removeChild(const string &key) -{ - if (key.empty()) { - return *this; - } - size_t pos = key.find_last_of('/'); - if (pos != string::npos) { - NodeState* parent = getChild(key.substr(0, pos), false); - if (parent != NULL) { - return parent->removeChild(key.substr(pos + 1)); - } - } - else { - _children.erase(key); - } - return compact(); -} - -const string -NodeState::getState(const string &key) -{ - if (key.empty()) { - return ""; - } - size_t pos = key.find_last_of('/'); - if (pos != string::npos) { - NodeState* parent = getChild(key.substr(0, pos), false); - return parent != NULL ? parent->getState(key.substr(pos + 1)) : ""; - } - StateMap::iterator it = _state.find(key); - return it != _state.end() ? it->second : ""; -} - -NodeState & -NodeState::setState(const string &key, const string &value) -{ - if (key.empty()) { - return *this; - } - size_t pos = key.find_last_of('/'); - if (pos != string::npos) { - getChild(key.substr(0, pos), true)->setState(key.substr(pos + 1), value); - } - else { - if (value.empty()) { - return removeState(key); - } - else { - _state[key] = value; - } - } - return *this; -} - -NodeState & -NodeState::removeState(const string &key) -{ - if (key.empty()) { - return *this; - } - size_t pos = key.find_last_of('/'); - if (pos != string::npos) { - NodeState* parent = getChild(key.substr(0, pos), false); - if (parent != NULL) { - return parent->removeState(key.substr(pos + 1)); - } - } - else { - _state.erase(key); - } - return compact(); -} - -NodeState & -NodeState::compact() -{ - if (_state.empty() && _children.empty()) { - if (_parent != NULL) { - return _parent->removeChild(_id); - } - } - return *this; -} - -NodeState & -NodeState::copy(const NodeState &node) -{ - for (StateMap::const_iterator it = node._state.begin(); - it != node._state.end(); ++it) { - _state[it->first] = it->second; - } - for (ChildMap::const_iterator it = node._children.begin(); - it != node._children.end(); ++it) { - getChild(it->first, true)->copy(*it->second); - } - return *this; -} - -NodeState & -NodeState::clear() -{ - _state.clear(); - _children.clear(); - return compact(); -} - -NodeState & -NodeState::setParent(NodeState &parent, const string &id) -{ - _parent = &parent; - _id = id; - return *this; -} - -const string -NodeState::toString() const -{ - const std::string ret = toString(""); - size_t pos = ret.find_last_not_of(' '); - return pos != string::npos ? ret.substr(0, pos + 1) : ret; -} - -const string -NodeState::toString(const string &prefix) const -{ - string ret; - if (!_state.empty()) { - string str; - for (StateMap::const_iterator it = _state.begin(); - it != _state.end(); ++it) { - str += it->first + "=" + URLEncoder::encode(it->second) + "&"; - } - ret += (prefix.empty() ? ".?" : prefix + "?") + str.substr(0, str.size() - 1) + " "; - } - string pre = prefix.empty() ? "" : (prefix + "/"); - for (ChildMap::const_iterator it = _children.begin(); - it != _children.end(); ++it) { - ret += it->second->toString(pre + URLEncoder::encode(it->first)); - } - return ret; -} diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h b/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h deleted file mode 100644 index eff684f5bfe..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h +++ /dev/null @@ -1,170 +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/documentapi/common.h> -#include <map> - -namespace documentapi { - -/** - * A node state is a single node in an annotatet tree of such nodes. It contains a reference to its parent - * node, a list of named child nodes, as well as a mapping of (key, value) pairs that constitute the annotated - * state of this node. To create an instance of a node state tree, one can either use the {@link SystemState} - * factory class, or one can programmatically construct each node and use the chaining capabilities of its - * set-methods to compact the necessary code. - */ -class NodeState { -public: - typedef std::unique_ptr<NodeState> UP; - typedef std::shared_ptr<NodeState> SP; - typedef std::map<string, string> StateMap; - typedef std::map<string, NodeState::SP> ChildMap; - -private: - NodeState* _parent; - string _id; - ChildMap _children; - StateMap _state; - - /** - * Compacts the system state tree from this node upwards. This will delete itself if it has a parent, but - * no internal state and no children. - * - * @return This or the first non-null ancestor, to allow chaining. - */ - NodeState &compact(); - - /** - * Returns a string representation of this node state. - * - * @param prefix The prefix to use for this string. - * @return A string representation of this. - */ - const string toString(const string &prefix) const; - -public: - NodeState(NodeState && rhs) = default; - NodeState & operator = (NodeState && rhs) = default; - NodeState & operator = (const NodeState & rhs) = default; - /** - * Creates a node state that no internal content. - */ - NodeState(); - - /** - * Creates a node state as a copy of another. - * - * @param rhs The state to copy. - */ - NodeState(const NodeState &rhs); - - /** - * Creates a node state based on a list of argument objects. These arguments are iterated and added to - * this node's internal state map. - * - * @param args The arguments to use as state. - */ - NodeState(StateMap args); - - ~NodeState(); - - /** - * Adds a child to this node at the given location. The key can be a location string, in which case the - * necessary intermediate node states are created. - * - * @param key The location at which to add the child. - * @param child The child node to add. - * @return This, to allow chaining. - */ - NodeState &addChild(const string &key, const NodeState &child); - - /** - * Returns the child at the given location relative to this. This method can be forced to return a child - * node even if it does not exist, by adding all intermediate nodes and the target node itself. - * - * @param key The location of the child to return. - * @param force Whether or not to force a return value by creating missing nodes. - * @return The child object, null if not found. - */ - NodeState *getChild(const string &key, bool force = false); - - /** - * Returns the map of child nodes for iteration. - * - * @return The internal child map. - */ - const ChildMap &getChildren() const; - - /** - * Removes the named child node from this node, and attempts to compact the system state from this node - * upwards by removing empty nodes. - * - * @param key The child to remove. - * @return The result of invoking {@link #compact} after the remove. - */ - NodeState &removeChild(const string &key); - - /** - * Retrieves some arbitrary state information for a given key. The key can be a location string, in which - * case the necessary intermediate nodes are traversed. If the key is not found, this method returns - * null. This method can not be const because it uses the non-const method {@link #getChild} to resolve a - * pathed key. - * - * @param key The name of the state information to return. - * @return The value of the state key. - */ - const string getState(const string &key); - - /** - * Sets some arbitrary state data in this node. The key can be a location string, in which case the - * necessary intermediate nodes are traversed and even created if missing. - * - * @param key The key to set. - * @param value The value to assign to the key. - * @return This, to allow chaining. - */ - NodeState &setState(const string &key, const string &value); - - /** - * Removes the named (key, value) state pair from this node, and attempts to compact the system state from - * this node upwards by removing empty nodes. - * - * @param key The state variable to clear. - * @return The result of invoking {@link #compact} after the remove. - */ - NodeState &removeState(const string &key); - - /** - * Copies the state content of another node state object into this. - * - * @param node The node state to copy into this. - * @return This, to allow chaining. - */ - NodeState ©(const NodeState &node); - - /** - * Clears both the internal state and child list, then compacts the tree from this node upwards. - * - * @return The result of invoking {@link #compact} after the remove. - */ - NodeState &clear(); - - /** - * Sets the parent of this node. - * - * @param parent The parent node. - * @param id The identifier of this node as seen in the parent. - * @return This, to allow chaining. - */ - NodeState &setParent(NodeState &parent, const string &id); - - /** - * Returns a string representation of this node state. - * - * @return A string representation of this. - */ - const string toString() const; -}; - -} - diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstate.cpp b/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstate.cpp deleted file mode 100644 index 0556e859c42..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstate.cpp +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "systemstate.h" -#include "nodestate.h" -#include <vespa/vespalib/util/sync.h> -#include <vespa/vespalib/util/stringfmt.h> -#include <boost/spirit/include/classic_core.hpp> -#include <boost/spirit/include/classic_parse_tree.hpp> -#include <boost/spirit/include/classic_tree_to_xml.hpp> -#include <boost/spirit/include/classic_chset.hpp> -#include <boost/spirit/include/classic_escape_char.hpp> -#include <boost/spirit/include/classic_grammar_def.hpp> - -#include <vespa/log/log.h> -LOG_SETUP(".systemstate"); - -using namespace documentapi; - -/** - * This class implements a boost::spirit type parser for the system state string. All contained names - * confirm to the boost::spirit naming convention, and care should therefore be taken if one wishes - * to modify any of these. Note that all content is inlined, just as all of boost::spirit, so this is - * therefore contained in the .cpp file instead of a separate .h file. - */ -struct SystemStateGrammar : public boost::spirit::classic::grammar<SystemStateGrammar> { - enum RuleId { - id_hexChar = 1, - id_hexCode, - id_alphaNum, - id_string, - id_argument, - id_argumentList, - id_locationItem, - id_location, - id_systemState - }; - - template <typename Scanner> - struct gram_base { - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_hexChar> > rule_hexChar; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_hexCode> > rule_hexCode; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_alphaNum> > rule_alphaNum; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_string> > rule_string; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_argument> > rule_argument; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_argumentList> > rule_argumentList; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_locationItem> > rule_locationItem; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_location> > rule_location; - typedef typename boost::spirit::classic::rule<Scanner, boost::spirit::classic::parser_tag<id_systemState> > rule_systemState; - typedef boost::spirit::classic::grammar_def<rule_systemState> type; - }; - - template <typename Scanner> - struct definition : gram_base<Scanner>::type { - typename gram_base<Scanner>::rule_hexChar _hexChar; - typename gram_base<Scanner>::rule_hexCode _hexCode; - typename gram_base<Scanner>::rule_alphaNum _alphaNum; - typename gram_base<Scanner>::rule_string _string; - typename gram_base<Scanner>::rule_argument _argument; - typename gram_base<Scanner>::rule_argumentList _argumentList; - typename gram_base<Scanner>::rule_locationItem _locationItem; - typename gram_base<Scanner>::rule_location _location; - typename gram_base<Scanner>::rule_systemState _systemState; - - definition(const SystemStateGrammar &) : - _hexChar(), - _hexCode(), - _alphaNum(), - _string(), - _argument(), - _argumentList(), - _locationItem(), - _location(), - _systemState() { - _hexChar = ( boost::spirit::classic::chset<>("A-Fa-f0-9") ); - _hexCode = ( boost::spirit::classic::ch_p('%') >> _hexChar >> _hexChar); - _alphaNum = ( boost::spirit::classic::chset<>("A-Za-z0-9") | - boost::spirit::classic::ch_p('-') | boost::spirit::classic::ch_p('.') | - boost::spirit::classic::ch_p('_') | boost::spirit::classic::ch_p('~') ); - _string = ( +( boost::spirit::classic::ch_p('+') | _hexCode | _alphaNum ) ); - _argument = ( _string >> boost::spirit::classic::ch_p('=') >> _string ); - _argumentList = ( _argument >> *( boost::spirit::classic::ch_p('&') >> _argument ) ); - _locationItem = ( boost::spirit::classic::str_p("..") | boost::spirit::classic::ch_p('.') | _string ); - _location = ( !boost::spirit::classic::ch_p('/') - >> _locationItem - >> *( boost::spirit::classic::ch_p('/') >> _locationItem ) - >> !boost::spirit::classic::ch_p('/') ); - _systemState = ( +( *boost::spirit::classic::space_p >> - _location >> !( boost::spirit::classic::ch_p('?') >> _argumentList ) ) ); - this->start_parsers(_systemState); - } - }; -}; - -template<typename T> void -debugNode(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node, const string &prefix = "") -{ - std::map<boost::spirit::classic::parser_id, string> names; - names[boost::spirit::classic::parser_id(grammar.id_hexChar)] = "hexChar"; - names[boost::spirit::classic::parser_id(grammar.id_hexCode)] = "hexCode"; - names[boost::spirit::classic::parser_id(grammar.id_alphaNum)] = "alphaNum"; - names[boost::spirit::classic::parser_id(grammar.id_string)] = "string"; - names[boost::spirit::classic::parser_id(grammar.id_argument)] = "argument"; - names[boost::spirit::classic::parser_id(grammar.id_argumentList)] = "argumentList"; - names[boost::spirit::classic::parser_id(grammar.id_locationItem)] = "locationItem"; - names[boost::spirit::classic::parser_id(grammar.id_location)] = "location"; - names[boost::spirit::classic::parser_id(grammar.id_systemState)] = "systemState"; - - std::cout << prefix << names[node.value.id()] << ": " << string(node.value.begin(), node.value.end()) << std::endl; - for (size_t i = 0; i < node.children.size(); i++) { - debugNode(grammar, node.children[i], vespalib::make_string("%s %d.", prefix.c_str(), (int)i)); - } -} - -template<typename T> string -parseHexChar(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node) -{ - assert(node.value.id().to_long() == grammar.id_hexChar); - assert(node.children.size() == 1); - assert(node.children[0].value.id().to_long() == grammar.id_hexChar); - (void) grammar; - return string(node.children[0].value.begin(), node.children[0].value.end()); -} - -template<typename T> char -parseHexCode(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node) -{ - assert(node.value.id().to_long() == grammar.id_hexCode); - assert(node.children.size() == 3); - assert(node.children[0].value.id().to_long() == grammar.id_hexCode); - assert(node.children[1].value.id().to_long() == grammar.id_hexChar); - assert(node.children[2].value.id().to_long() == grammar.id_hexChar); - string enc = parseHexChar(grammar, node.children[1]) + parseHexChar(grammar, node.children[2]); - return (char)strtol(enc.c_str(), NULL, 16); -} - -template<typename T> string -parseAlphaNum(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node) -{ - assert(node.value.id().to_long() == grammar.id_alphaNum); - assert(node.children.size() == 1); - assert(node.children[0].value.id().to_long() == grammar.id_alphaNum); - (void) grammar; - return string(node.children[0].value.begin(), node.children[0].value.end()); -} - -template<typename T> string -parseString(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node) -{ - assert(node.value.id().to_long() == grammar.id_string); - string ret; - for (size_t i = 0; i < node.children.size(); ++i) { - boost::spirit::classic::tree_node<T> &child = node.children[i]; - if (child.value.id().to_long() == grammar.id_string) { - ret += " "; - } - else if (child.value.id().to_long() == grammar.id_alphaNum) { - ret += parseAlphaNum(grammar, child); - } - else if (child.value.id().to_long() == grammar.id_hexCode) { - ret += parseHexCode(grammar, child); - } - } - return ret; -} - -template<typename T> void -parseArgument(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node, - std::map<string, string> &arg) -{ - assert(node.value.id().to_long() == grammar.id_argument); - assert(node.children.size() == 3); - assert(node.children[0].value.id().to_long() == grammar.id_string); - assert(node.children[1].value.id().to_long() == grammar.id_argument); - assert(node.children[2].value.id().to_long() == grammar.id_string); - string key = parseString(grammar, node.children[0]); - string val = parseString(grammar, node.children[2]); - arg[key] = val; -} - -template<typename T> void -parseArgumentList(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node, - std::map<string, string> &arg) -{ - assert(node.value.id().to_long() == grammar.id_argumentList); - for (size_t i = 0; i < node.children.size(); ++i) { - boost::spirit::classic::tree_node<T> &child = node.children[i]; - if (child.value.id().to_long() == grammar.id_argument) { - parseArgument(grammar, child, arg); - } - } -} - -template<typename T> string -parseLocationItem(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node) -{ - assert(node.value.id().to_long() == grammar.id_locationItem); - assert(node.children.size() == 1); - - string ret; - boost::spirit::classic::tree_node<T> &child = node.children[0]; - if (child.value.id().to_long() == grammar.id_locationItem) { - ret = string(child.value.begin(), child.value.end()); - } - else if (child.value.id().to_long() == grammar.id_string) { - ret = parseString(grammar, child); - } - return ret; -} - -template<typename T> string -parseLocation(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node) -{ - assert(node.value.id().to_long() == grammar.id_location); - string ret; - for (size_t i = 0; i < node.children.size(); ++i) { - boost::spirit::classic::tree_node<T> &child = node.children[i]; - if (child.value.id().to_long() == grammar.id_locationItem) { - ret += parseLocationItem(grammar, child) + "/"; - } - } - return ret.substr(0, ret.size() - 1); -} - -template<typename T> NodeState::UP -parseSystemState(SystemStateGrammar &grammar, boost::spirit::classic::tree_node<T> &node) -{ - assert(node.value.id().to_long() == grammar.id_systemState); - NodeState::UP ret(new NodeState()); - string loc, pwd; - std::map<string, string> arg; - for (size_t i = 0; i < node.children.size(); ++i) { - boost::spirit::classic::tree_node<T> &child = node.children[i]; - if (child.value.id().to_long() == grammar.id_systemState) { - if (string(child.value.begin(), child.value.end()) != "?") { - if (!arg.empty()) { - ret->addChild(!loc.empty() ? loc : pwd, NodeState(arg)); - } - else { - pwd = loc; - } - loc.clear(); - arg.clear(); - } - } - else if (child.value.id().to_long() == grammar.id_location) { - if (!pwd.empty()) { - loc = pwd + "/"; - } - loc += parseLocation(grammar, child); - } - else if (child.value.id().to_long() == grammar.id_argumentList) { - parseArgumentList(grammar, child, arg); - } - } - if (!arg.empty()) { - ret->addChild(!loc.empty() ? loc : pwd, NodeState(arg)); - } - return ret; -} - -namespace { - vespalib::Lock _G_parseLock; -} - -SystemState::UP -SystemState::newInstance(const string &state) -{ - if (state.empty()) { - return SystemState::UP(new SystemState(NodeState::UP(new NodeState()))); - } - try { - vespalib::LockGuard guard(_G_parseLock); - SystemStateGrammar grammar; - boost::spirit::classic::tree_parse_info<> info = - boost::spirit::classic::pt_parse(static_cast<const char *>(&*state.begin()), - static_cast<const char *>(&*state.end()), - grammar.use_parser<0>()); - if (!info.full) { - string unexpected(info.stop); - unsigned int position = state.size() - unexpected.size(); - if (unexpected.size() > 10) { - unexpected = unexpected.substr(0, 10); - } - LOG(error, "Unexpected token at position %u ('%s') in query '%s'.", - position, unexpected.c_str(), state.c_str()); - } - else if (info.trees.size() != 1) { - LOG(error, "Parser returned %u trees, expected 1.", - (uint32_t)info.trees.size()); - } - else { - return SystemState::UP(new SystemState(parseSystemState(grammar, info.trees[0]))); - } - } - catch(std::exception& e) { - LOG(fatal, "SystemState::parse() internal error: %s", e.what()); - } - return SystemState::UP(); -} - -SystemState::SystemState(NodeState::UP root) : - _root(std::move(root)), - _lock(std::make_unique<vespalib::Lock>()) -{} - -SystemState::~SystemState() {} diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstate.h b/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstate.h deleted file mode 100644 index 26f1b7fd713..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstate.h +++ /dev/null @@ -1,50 +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/documentapi/common.h> - -namespace vespalib { class Lock; } -namespace documentapi { - -class NodeState; - -/** - * This class is a factory to create a tree of {@link NodeState} objects from a parseable node state - * string. The naming of this class is intended to capture the fact that this annotated service tree actually - * contains the state of each service in the system. - */ -class SystemState { -private: - std::unique_ptr<NodeState> _root; - std::unique_ptr<vespalib::Lock> _lock; - - friend class SystemStateHandle; - - /** - * Constructs a new system state object to encapsulate a given root node state. This method is private; the only way - * to create a new instance is through the {@link #create} method. - * - * @param root The root node state. - */ - SystemState(std::unique_ptr<NodeState> root); - -public: - ~SystemState(); - SystemState(const SystemState &) = delete; - SystemState & operator = (const SystemState &) = delete; - /** - * Convenience typedefs. - */ - typedef std::unique_ptr<SystemState> UP; - - /** - * Creates a system state expression from a system state string. - * - * @param state The string to parse as a system state. - * @return The created node state tree. - * @throws RuntimeException Thrown if the string could not be parsed. - */ - static SystemState::UP newInstance(const string &state); -}; - -} diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstatehandle.cpp b/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstatehandle.cpp deleted file mode 100644 index 9ccaece4511..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstatehandle.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "systemstatehandle.h" - -using namespace documentapi; - -SystemStateHandle::SystemStateHandle(SystemState &state) : - _state(&state), - _guard(*state._lock) -{} - -SystemStateHandle::SystemStateHandle(SystemStateHandle &&rhs) : - _state(rhs._state), - _guard(std::move(rhs._guard)) -{ - rhs._state = nullptr; -} - -SystemStateHandle & -SystemStateHandle::operator=(SystemStateHandle &&rhs) -{ - if (this != &rhs) { - _state = rhs._state; - _guard = std::move(rhs._guard); - rhs._state = nullptr; - } - return *this; -} - -SystemStateHandle::~SystemStateHandle() {} - diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstatehandle.h b/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstatehandle.h deleted file mode 100644 index f0342cfb2de..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/systemstatehandle.h +++ /dev/null @@ -1,52 +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 "systemstate.h" -#include <vespa/vespalib/util/sync.h> - -namespace documentapi { - -/** - * Implements a handle to grant synchronized access to the content of a system state object. - */ -class SystemStateHandle { -private: - SystemState *_state; // The associated system state for which this object is a handler. - vespalib::LockGuard _guard; // The lock guard for the system state's lock. - - SystemStateHandle &operator=(const SystemStateHandle &) = delete; - SystemStateHandle(const SystemStateHandle &) = delete; - -public: - /** - * Creates a new system state handler object that grants access to the content of the supplied system - * state object. This handle is required to make sure that all access to the system state content is - * locked. - */ - SystemStateHandle(SystemState &state); - - /** - * Implements the move constructor. - * - * @param rhs The handle to move to this. - */ - SystemStateHandle(SystemStateHandle &&rhs); - - SystemStateHandle &operator=(SystemStateHandle &&rhs); - /** - * Destructor. Releases the contained lock on the associated system state object. There is no unlock() - * mechanism provided, since this will happen automatically as soon as this handle goes out of scope. - */ - ~SystemStateHandle(); - - /** Returns whether or not this handle is valid. */ - bool isValid() const { return _state != NULL; } - - /** Returns a reference to the root node of the associated system state. */ - NodeState &getRoot() { return *_state->_root; } - - /** Returns a const reference to the root node of the associated system state. */ - const NodeState &getRoot() const { return *_state->_root; } -}; - -} diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/urlencoder.cpp b/documentapi/src/vespa/documentapi/messagebus/systemstate/urlencoder.cpp deleted file mode 100644 index 13bd0750c31..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/urlencoder.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "urlencoder.h" -#include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/stllike/asciistream.h> - -using namespace documentapi; - -const string -URLEncoder::encode(const string &str) -{ - vespalib::asciistream out; - for (size_t i = 0; i < str.size(); i++) { - char c = str[i]; - if ((c >= 48 && c <= 57) || // The range '0'-'9'. - (c >= 65 && c <= 90) || // The range 'A'-'Z'. - (c >= 97 && c <= 122) || // The range 'a'-'z'. - (c == '-' || c == '.' || c == '*' || c == '_')) { - out << c; - } - else if (c == ' ') { - out << '+'; - } - else { - out << "%" << vespalib::make_string("%02X", c & 0xff); - } - } - return out.str(); -} diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/urlencoder.h b/documentapi/src/vespa/documentapi/messagebus/systemstate/urlencoder.h deleted file mode 100644 index 5b09327c0a0..00000000000 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/urlencoder.h +++ /dev/null @@ -1,42 +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/documentapi/common.h> - -namespace documentapi { - -/** - * <p>Utility class for HTML form encoding. This class contains static methods for converting a String to the - * application/x-www-form-urlencoded MIME format. For more information about HTML form encoding, consult the - * HTML specification.</p> - * - * <p>When encoding a String, the following rules apply:</p> - * <ul> - * <li>The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the - * same.</li> - * <li>The special characters ".", "-", "*", and "_" remain the same.</li> - * <li>The space character " " is converted into a plus sign "+".</li> - * <li>All other characters are unsafe and are first converted into one or more bytes using some encoding - * scheme. Then each byte is represented by the 3-character string "%xy", where xy is the two-digit - * hexadecimal representation of the byte. The recommended encoding scheme to use is UTF-8. However, for - * compatibility reasons, if an encoding is not specified, then the default encoding of the platform is - * used.</li> - * </ul> - * - * <p>For example using UTF-8 as the encoding scheme the string "The string �@foo-bar" would get converted to - * "The+string+%C3%BC%40foo-bar" because in UTF-8 the character � is encoded as two bytes C3 (hex) and BC - * (hex), and the character @ is encoded as one byte 40 (hex).</p> - */ -class URLEncoder { -public: - /** - * Translates a string into application/x-www-form-urlencoded format using a UTF-8 encoding. - * - * @param str The string to be translated. - * @return The translated string. - */ - static const string encode(const string &str); -}; - -} - |