From d593d1b4a18375475af9a685a9181023aa8e2642 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 21 Oct 2016 14:18:08 +0000 Subject: We only need one vtag --- fastos/src/vespa/fastos/CMakeLists.txt | 1 - fastos/src/vespa/fastos/vtag.cpp | 23 -- fastos/src/vespa/fastos/vtag.h | 15 -- fnet/src/vespa/fnet/CMakeLists.txt | 1 - fnet/src/vespa/fnet/fnet.h | 5 +- fnet/src/vespa/fnet/info.cpp | 2 +- fnet/src/vespa/fnet/vtag.cpp | 21 -- fnet/src/vespa/fnet/vtag.h | 13 -- logd/src/logd/CMakeLists.txt | 1 - logd/src/logd/forward.cpp | 13 +- logd/src/logd/service.h | 1 + logd/src/logd/vtag.cpp | 18 -- logd/src/logd/vtag.h | 13 -- messagebus/src/apps/printversion/printversion.cpp | 17 +- messagebus/src/tests/routing/routing.cpp | 10 +- .../src/tests/simpleprotocol/simpleprotocol.cpp | 10 +- messagebus/src/tests/targetpool/targetpool.cpp | 7 +- messagebus/src/vespa/messagebus/CMakeLists.txt | 1 - .../src/vespa/messagebus/network/rpcnetwork.cpp | 10 +- .../src/vespa/messagebus/testlib/testserver.cpp | 10 +- messagebus/src/vespa/messagebus/vtag.cpp | 81 ------- messagebus/src/vespa/messagebus/vtag.h | 23 -- slobrok/src/vespa/slobrok/server/CMakeLists.txt | 2 +- slobrok/src/vespa/slobrok/server/named_service.h | 10 +- slobrok/src/vespa/slobrok/server/rpchooks.cpp | 17 +- slobrok/src/vespa/slobrok/server/rpcmirror.cpp | 216 +++++++++++++++++ slobrok/src/vespa/slobrok/server/rpcmirror.h | 256 ++------------------- slobrok/src/vespa/slobrok/server/visible_map.h | 3 +- slobrok/src/vespa/slobrok/server/vtag.cpp | 21 -- slobrok/src/vespa/slobrok/server/vtag.h | 15 -- storage/src/vespa/storage/common/CMakeLists.txt | 1 - .../common/hostreporter/versionreporter.cpp | 5 +- storage/src/vespa/storage/common/vtag.cpp | 81 ------- storage/src/vespa/storage/common/vtag.h | 24 -- .../frameworkimpl/status/statuswebserver.cpp | 3 +- .../src/vespa/vespalib/component/CMakeLists.txt | 1 + vespalib/src/vespa/vespalib/component/vtag.cpp | 80 +++++++ vespalib/src/vespa/vespalib/component/vtag.h | 22 ++ 38 files changed, 394 insertions(+), 659 deletions(-) delete mode 100644 fastos/src/vespa/fastos/vtag.cpp delete mode 100644 fastos/src/vespa/fastos/vtag.h delete mode 100644 fnet/src/vespa/fnet/vtag.cpp delete mode 100644 fnet/src/vespa/fnet/vtag.h delete mode 100644 logd/src/logd/vtag.cpp delete mode 100644 logd/src/logd/vtag.h delete mode 100644 messagebus/src/vespa/messagebus/vtag.cpp delete mode 100644 messagebus/src/vespa/messagebus/vtag.h create mode 100644 slobrok/src/vespa/slobrok/server/rpcmirror.cpp delete mode 100644 slobrok/src/vespa/slobrok/server/vtag.cpp delete mode 100644 slobrok/src/vespa/slobrok/server/vtag.h delete mode 100644 storage/src/vespa/storage/common/vtag.cpp delete mode 100644 storage/src/vespa/storage/common/vtag.h create mode 100644 vespalib/src/vespa/vespalib/component/vtag.cpp create mode 100644 vespalib/src/vespa/vespalib/component/vtag.h diff --git a/fastos/src/vespa/fastos/CMakeLists.txt b/fastos/src/vespa/fastos/CMakeLists.txt index 5e5eb6cf139..efa1bcb0c13 100644 --- a/fastos/src/vespa/fastos/CMakeLists.txt +++ b/fastos/src/vespa/fastos/CMakeLists.txt @@ -21,7 +21,6 @@ vespa_add_library(fastos unix_socket.cpp unix_thread.cpp unix_time.cpp - vtag.cpp INSTALL lib64 DEPENDS ${CMAKE_DL_LIBS} diff --git a/fastos/src/vespa/fastos/vtag.cpp b/fastos/src/vespa/fastos/vtag.cpp deleted file mode 100644 index a9f00820224..00000000000 --- a/fastos/src/vespa/fastos/vtag.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include "vtag.h" - -#ifndef V_TAG -#define V_TAG "NOTAG" -#define V_TAG_TYPE "NOTAG" -#define V_TAG_VALUE "NOTAG" -#define V_TAG_DATE "NOTAG" -#define V_TAG_SYSTEM "NOTAG" -#define V_TAG_SYSTEM_REV "NOTAG" -#define V_TAG_BUILDER "NOTAG" -#endif - -namespace fastos { - -char VersionTag[] = V_TAG; -char VersionTagDate[] = V_TAG_DATE; -char VersionTagSystem[] = V_TAG_SYSTEM; -char VersionTagSystemRev[] = V_TAG_SYSTEM_REV; -char VersionTagBuilder[] = V_TAG_BUILDER; - -} // namespace fastos diff --git a/fastos/src/vespa/fastos/vtag.h b/fastos/src/vespa/fastos/vtag.h deleted file mode 100644 index ee5c065ef1c..00000000000 --- a/fastos/src/vespa/fastos/vtag.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -namespace fastos { - -extern char VersionTag[]; -extern char VersionTagType[]; -extern char VersionTagValue[]; -extern char VersionTagDate[]; -extern char VersionTagSystem[]; -extern char VersionTagSystemRev[]; -extern char VersionTagBuilder[]; - -} // namespace fastos - diff --git a/fnet/src/vespa/fnet/CMakeLists.txt b/fnet/src/vespa/fnet/CMakeLists.txt index 2df853b2893..556cb69a988 100644 --- a/fnet/src/vespa/fnet/CMakeLists.txt +++ b/fnet/src/vespa/fnet/CMakeLists.txt @@ -22,7 +22,6 @@ vespa_add_library(fnet task.cpp transport.cpp transport_thread.cpp - vtag.cpp $ INSTALL lib64 DEPENDS diff --git a/fnet/src/vespa/fnet/fnet.h b/fnet/src/vespa/fnet/fnet.h index b4ca0d95599..85f4f3e750e 100644 --- a/fnet/src/vespa/fnet/fnet.h +++ b/fnet/src/vespa/fnet/fnet.h @@ -3,15 +3,12 @@ #pragma once #include +#include // FEATURES #include "features.h" -// VTAG - -#include "vtag.h" - // DEFINES #define FNET_NOID ((uint32_t)-1) diff --git a/fnet/src/vespa/fnet/info.cpp b/fnet/src/vespa/fnet/info.cpp index c345fc2e28c..1ad3dbb784a 100644 --- a/fnet/src/vespa/fnet/info.cpp +++ b/fnet/src/vespa/fnet/info.cpp @@ -61,7 +61,7 @@ FNET_Info::FNET_Info() const char* FNET_Info::GetFNETVersion() { - return fnet::VersionTag; + return vespalib::VersionTag; } diff --git a/fnet/src/vespa/fnet/vtag.cpp b/fnet/src/vespa/fnet/vtag.cpp deleted file mode 100644 index e2f280dee5b..00000000000 --- a/fnet/src/vespa/fnet/vtag.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include - -#ifndef V_TAG -#define V_TAG "NOTAG" -#define V_TAG_DATE "NOTAG" -#define V_TAG_SYSTEM "NOTAG" -#define V_TAG_SYSTEM_REV "NOTAG" -#define V_TAG_BUILDER "NOTAG" -#endif - -namespace fnet { - -char VersionTag[] = V_TAG; -char VersionTagDate[] = V_TAG_DATE; -char VersionTagSystem[] = V_TAG_SYSTEM; -char VersionTagSystemRev[] = V_TAG_SYSTEM_REV; -char VersionTagBuilder[] = V_TAG_BUILDER; - -} // namespace fnet diff --git a/fnet/src/vespa/fnet/vtag.h b/fnet/src/vespa/fnet/vtag.h deleted file mode 100644 index 28b3164e9fc..00000000000 --- a/fnet/src/vespa/fnet/vtag.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -namespace fnet { - -extern char VersionTag[]; -extern char VersionTagDate[]; -extern char VersionTagSystem[]; -extern char VersionTagSystemRev[]; -extern char VersionTagBuilder[]; - -} // namespace fnet - diff --git a/logd/src/logd/CMakeLists.txt b/logd/src/logd/CMakeLists.txt index 3c0f7bacd33..81aa64641b2 100644 --- a/logd/src/logd/CMakeLists.txt +++ b/logd/src/logd/CMakeLists.txt @@ -9,7 +9,6 @@ vespa_add_library(logd STATIC cmdbuf.cpp perform.cpp sigterm.cpp - vtag.cpp DEPENDS ) vespa_generate_config(logd ../main/resources/configdefinitions/logd.def) diff --git a/logd/src/logd/forward.cpp b/logd/src/logd/forward.cpp index 373f95ab742..e4c86583fc0 100644 --- a/logd/src/logd/forward.cpp +++ b/logd/src/logd/forward.cpp @@ -7,15 +7,14 @@ #include #include #include - -#include -LOG_SETUP(""); -LOG_RCSID("$Id$"); - #include "errhandle.h" #include "service.h" #include "forward.h" -#include "vtag.h" +#include +#include + +LOG_SETUP(""); +LOG_RCSID("$Id$"); namespace logdemon { @@ -40,7 +39,7 @@ void Forwarder::sendMode() { char buf[1024]; - snprintf(buf, 1024, "mode logd %s\n", VersionTag); + snprintf(buf, 1024, "mode logd %s\n", vespalib::VersionTag); int len = strlen(buf); if (len < 100) { forwardText(buf, len); diff --git a/logd/src/logd/service.h b/logd/src/logd/service.h index a6d6ca4ff60..700ab85fe27 100644 --- a/logd/src/logd/service.h +++ b/logd/src/logd/service.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace logdemon { diff --git a/logd/src/logd/vtag.cpp b/logd/src/logd/vtag.cpp deleted file mode 100644 index 17b677d4662..00000000000 --- a/logd/src/logd/vtag.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace logdemon { - -#ifndef V_TAG -#define V_TAG "NOTAG" -#define V_TAG_DATE "NOTAG" -#define V_TAG_SYSTEM "NOTAG" -#define V_TAG_SYSTEM_REV "NOTAG" -#define V_TAG_BUILDER "NOTAG" -#endif - -char VersionTag[] = V_TAG; -char VersionTagDate[] = V_TAG_DATE; -char VersionTagSystem[] = V_TAG_SYSTEM; -char VersionTagSystemRev[] = V_TAG_SYSTEM_REV; -char VersionTagBuilder[] = V_TAG_BUILDER; - -} // namespace logdemon diff --git a/logd/src/logd/vtag.h b/logd/src/logd/vtag.h deleted file mode 100644 index 7c78914829e..00000000000 --- a/logd/src/logd/vtag.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -namespace logdemon { - -extern char VersionTag[]; -extern char VersionTagDate[]; -extern char VersionTagSystem[]; -extern char VersionTagSystemRev[]; -extern char VersionTagBuilder[]; - -} - diff --git a/messagebus/src/apps/printversion/printversion.cpp b/messagebus/src/apps/printversion/printversion.cpp index 8401653fc51..d616394ef80 100644 --- a/messagebus/src/apps/printversion/printversion.cpp +++ b/messagebus/src/apps/printversion/printversion.cpp @@ -1,19 +1,18 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include +#include #include -#include int main(int, char **) { - printf("version tag: %s\n", mbus::VersionTag); - printf("version tag date: %s\n", mbus::VersionTagDate); - printf("version tag system: %s\n", mbus::VersionTagSystem); - printf("version tag system rev: %s\n", mbus::VersionTagSystemRev); - printf("version tag builder: %s\n", mbus::VersionTagBuilder); + printf("version tag: %s\n", vespalib::VersionTag); + printf("version tag date: %s\n", vespalib::VersionTagDate); + printf("version tag system: %s\n", vespalib::VersionTagSystem); + printf("version tag system rev: %s\n", vespalib::VersionTagSystemRev); + printf("version tag builder: %s\n", vespalib::VersionTagBuilder); printf("nice version:\n\t"); - mbus::Vtag::printVersionNice(); + vespalib::Vtag::printVersionNice(); printf("\n"); - printf("currentVersion object: %s\n", mbus::Vtag::currentVersion.toString().c_str()); + printf("currentVersion object: %s\n", vespalib::Vtag::currentVersion.toString().c_str()); return 0; } diff --git a/messagebus/src/tests/routing/routing.cpp b/messagebus/src/tests/routing/routing.cpp index b9c673263b5..23698279137 100644 --- a/messagebus/src/tests/routing/routing.cpp +++ b/messagebus/src/tests/routing/routing.cpp @@ -1,8 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include -LOG_SETUP("routing_test"); - #include #include #include @@ -16,8 +13,11 @@ LOG_SETUP("routing_test"); #include #include #include -#include +#include #include +#include + +LOG_SETUP("routing_test"); using namespace mbus; @@ -650,7 +650,7 @@ Test::testTrace(TestData &data, const std::vector &expected) bool Test::testTrace(const std::vector &expected, const Trace &trace) { - string version = Vtag::currentVersion.toString(); + string version = vespalib::Vtag::currentVersion.toString(); string actual = trace.toString(); size_t pos = 0; for (uint32_t i = 0; i < expected.size(); ++i) { diff --git a/messagebus/src/tests/simpleprotocol/simpleprotocol.cpp b/messagebus/src/tests/simpleprotocol/simpleprotocol.cpp index eaf609a2be1..c4268e5108d 100644 --- a/messagebus/src/tests/simpleprotocol/simpleprotocol.cpp +++ b/messagebus/src/tests/simpleprotocol/simpleprotocol.cpp @@ -1,9 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include -LOG_SETUP("simpleprotocol_test"); - #include +#include #include #include #include @@ -14,7 +12,9 @@ LOG_SETUP("simpleprotocol_test"); #include #include #include -#include +#include + +LOG_SETUP("simpleprotocol_test"); using namespace mbus; @@ -25,7 +25,7 @@ Test::Main() { TEST_INIT("simpleprotocol_test"); - vespalib::Version version = Vtag::currentVersion; + vespalib::Version version = vespalib::Vtag::currentVersion; SimpleProtocol protocol; EXPECT_TRUE(protocol.getName() == "Simple"); diff --git a/messagebus/src/tests/targetpool/targetpool.cpp b/messagebus/src/tests/targetpool/targetpool.cpp index 0e63be19547..855784ec557 100644 --- a/messagebus/src/tests/targetpool/targetpool.cpp +++ b/messagebus/src/tests/targetpool/targetpool.cpp @@ -1,13 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include -LOG_SETUP("targetpool_test"); - -#include #include #include #include #include +#include + +LOG_SETUP("targetpool_test"); using namespace mbus; diff --git a/messagebus/src/vespa/messagebus/CMakeLists.txt b/messagebus/src/vespa/messagebus/CMakeLists.txt index 81b86d8e0dc..01526e0dd59 100644 --- a/messagebus/src/vespa/messagebus/CMakeLists.txt +++ b/messagebus/src/vespa/messagebus/CMakeLists.txt @@ -31,7 +31,6 @@ vespa_add_library(messagebus sourcesessionparams.cpp staticthrottlepolicy.cpp systemtimer.cpp - vtag.cpp $ $ INSTALL lib64 diff --git a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp index 434cdb0e3c3..8ec6794919b 100644 --- a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp +++ b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp @@ -1,19 +1,19 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include -LOG_SETUP(".rpcnetwork"); - #include #include #include #include -#include #include #include #include "inetworkowner.h" #include "rpcnetwork.h" #include "rpcsendv1.h" #include "rpcservice.h" +#include + +LOG_SETUP(".rpcnetwork"); + namespace { @@ -160,7 +160,7 @@ RPCNetwork::flushTargetPool() const vespalib::Version & RPCNetwork::getVersion() const { - return Vtag::currentVersion; + return vespalib::Vtag::currentVersion; } void diff --git a/messagebus/src/vespa/messagebus/testlib/testserver.cpp b/messagebus/src/vespa/messagebus/testlib/testserver.cpp index c0ef5f9fbf9..cdc7325c508 100644 --- a/messagebus/src/vespa/messagebus/testlib/testserver.cpp +++ b/messagebus/src/vespa/messagebus/testlib/testserver.cpp @@ -1,22 +1,22 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include -LOG_SETUP(".testserver"); - +#include #include #include -#include #include "oosstate.h" #include "simpleprotocol.h" #include "slobrok.h" #include "slobrokstate.h" #include "testserver.h" +#include + +LOG_SETUP(".testserver"); namespace mbus { VersionedRPCNetwork::VersionedRPCNetwork(const RPCNetworkParams ¶ms) : RPCNetwork(params), - _version(Vtag::currentVersion) + _version(vespalib::Vtag::currentVersion) { // empty } diff --git a/messagebus/src/vespa/messagebus/vtag.cpp b/messagebus/src/vespa/messagebus/vtag.cpp deleted file mode 100644 index 0a42b5e6ec0..00000000000 --- a/messagebus/src/vespa/messagebus/vtag.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -#include -#include "vtag.h" -#include - -#ifndef V_TAG -#define V_TAG "NOTAG" -#define V_TAG_DATE "NOTAG" -#define V_TAG_SYSTEM "NOTAG" -#define V_TAG_SYSTEM_REV "NOTAG" -#define V_TAG_BUILDER "NOTAG" -#define V_TAG_VERSION "0" -#define V_TAG_ARCH "NOTAG" -#endif - -namespace mbus { - -char VersionTag[] = V_TAG; -char VersionTagDate[] = V_TAG_DATE; -char VersionTagSystem[] = V_TAG_SYSTEM; -char VersionTagSystemRev[] = V_TAG_SYSTEM_REV; -char VersionTagBuilder[] = V_TAG_BUILDER; -char VersionTagPkg[] = V_TAG_PKG; -char VersionTagComponent[] = V_TAG_COMPONENT; -char VersionTagArch[] = V_TAG_ARCH; - -vespalib::Version Vtag::currentVersion(VersionTagComponent); - -void -Vtag::printVersionNice() -{ - char *s = VersionTag; - bool needdate = true; - if (strncmp(VersionTag, "V_", 2) == 0) { - s += 2; - do { - while (strchr("0123456789", *s) != NULL) { - printf("%c", *s++); - } - if (strncmp(s, "_RELEASE", 8) == 0) { - needdate = false; - break; - } - if (strncmp(s, "_RC", 3) == 0) { - char *e = strchr(s, '-'); - if (e == NULL) { - printf("%s", s); - } else { - printf("%.*s", (int)(e-s), s); - } - needdate = false; - break; - } - if (*s == '_' && strchr("0123456789", *++s)) { - printf("."); - } else { - break; - } - } while (*s && *s != '-'); - } else { - char *e = strchr(s, '-'); - if (e == NULL) { - printf("%s", s); - } else { - printf("%.*s", (int)(e-s), s); - } - } - if (needdate) { - s = VersionTagDate; - char *e = strchr(s, '-'); - if (e == NULL) { - printf("-%s", s); - } else { - printf("-%.*s", (int)(e-s), s); - } - } -} - -} // namespace mbus diff --git a/messagebus/src/vespa/messagebus/vtag.h b/messagebus/src/vespa/messagebus/vtag.h deleted file mode 100644 index 505ffb42161..00000000000 --- a/messagebus/src/vespa/messagebus/vtag.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -namespace vespalib { -class Version; -} - -namespace mbus { - -extern char VersionTag[]; -extern char VersionTagDate[]; -extern char VersionTagSystem[]; -extern char VersionTagSystemRev[]; -extern char VersionTagBuilder[]; - -class Vtag { -public: - static vespalib::Version currentVersion; - static void printVersionNice(); -}; - -} // namespace messagebus - diff --git a/slobrok/src/vespa/slobrok/server/CMakeLists.txt b/slobrok/src/vespa/slobrok/server/CMakeLists.txt index da337624ce3..2ac6b28a8b2 100644 --- a/slobrok/src/vespa/slobrok/server/CMakeLists.txt +++ b/slobrok/src/vespa/slobrok/server/CMakeLists.txt @@ -15,11 +15,11 @@ vespa_add_library(slobrok_slobrokserver rpc_server_manager.cpp rpc_server_map.cpp rpchooks.cpp + rpcmirror.cpp sbenv.cpp selfcheck.cpp slobrokserver.cpp visible_map.cpp - vtag.cpp metrics_producer.cpp INSTALL lib64 DEPENDS diff --git a/slobrok/src/vespa/slobrok/server/named_service.h b/slobrok/src/vespa/slobrok/server/named_service.h index f5221b75657..9d04475573a 100644 --- a/slobrok/src/vespa/slobrok/server/named_service.h +++ b/slobrok/src/vespa/slobrok/server/named_service.h @@ -18,17 +18,15 @@ namespace slobrok { class NamedService { -private: - NamedService(const NamedService &); // Not used - NamedService &operator=(const NamedService &); // Not used - protected: std::string _name; std::string _spec; public: - NamedService(const char *name, - const char *spec); + NamedService(const NamedService &) = delete; + NamedService &operator=(const NamedService &) = delete; + + NamedService(const char *name, const char *spec); virtual ~NamedService(); const char *getName() const { return _name.c_str(); } diff --git a/slobrok/src/vespa/slobrok/server/rpchooks.cpp b/slobrok/src/vespa/slobrok/server/rpchooks.cpp index 5f610ae2e45..5e7f2c401bd 100644 --- a/slobrok/src/vespa/slobrok/server/rpchooks.cpp +++ b/slobrok/src/vespa/slobrok/server/rpchooks.cpp @@ -1,12 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include "vtag.h" - -#include -LOG_SETUP(".rpchooks"); - +#include #include - #include "rpchooks.h" #include "ok_state.h" #include "named_service.h" @@ -17,6 +12,10 @@ LOG_SETUP(".rpchooks"); #include "visible_map.h" #include "rpcmirror.h" +#include + +LOG_SETUP(".rpchooks"); + namespace slobrok { namespace { @@ -558,9 +557,9 @@ RPCHooks::rpc_version(FRT_RPCRequest *req) _cnts.adminReqs++; std::string ver; - char *s = VersionTag; + char *s = vespalib::VersionTag; bool needdate = true; - if (strncmp(VersionTag, "V_", 2) == 0) { + if (strncmp(vespalib::VersionTag, "V_", 2) == 0) { s += 2; do { while (strchr("0123456789", *s) != NULL) { @@ -596,7 +595,7 @@ RPCHooks::rpc_version(FRT_RPCRequest *req) } if (needdate) { ver.append("-"); - s = VersionTagDate; + s = vespalib::VersionTagDate; char *e = strchr(s, '-'); if (e == NULL) { ver.append(s); diff --git a/slobrok/src/vespa/slobrok/server/rpcmirror.cpp b/slobrok/src/vespa/slobrok/server/rpcmirror.cpp new file mode 100644 index 00000000000..12cae8ad500 --- /dev/null +++ b/slobrok/src/vespa/slobrok/server/rpcmirror.cpp @@ -0,0 +1,216 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "rpcmirror.h" +#include + +LOG_SETUP(".rpcmirror"); + +namespace slobrok { + +MirrorFetch::MirrorFetch(FRT_Supervisor *orb, + FRT_RPCRequest *req, + VisibleMap &map, + vespalib::GenCnt gen) + : FNET_Task(orb->GetScheduler()), + _req(req), + _map(map), + _gen(gen) +{ +} + + +MirrorFetch::~MirrorFetch() +{ + LOG_ABORT("Should never be called!"); +} + + +void +MirrorFetch::completeReq() +{ + vespalib::GenCnt newgen = _map.genCnt(); + if (newgen == _gen) { // no change + _req->GetReturn()->AddStringArray(0); + _req->GetReturn()->AddStringArray(0); + } else { + std::vector rpcsrvlist = _map.allVisible(); + + FRT_Values &dst = *_req->GetReturn(); + size_t sz = rpcsrvlist.size(); + FRT_StringValue *names = dst.AddStringArray(sz); + FRT_StringValue *specs = dst.AddStringArray(sz); + for (uint32_t i = 0; i < rpcsrvlist.size(); ++i) { + dst.SetString(&names[i], rpcsrvlist[i]->getName()); + dst.SetString(&specs[i], rpcsrvlist[i]->getSpec()); + } + if (sz > 0) { + LOG(debug, "mirrorFetch %p -> %u, last [%s,%s]", + this, + (unsigned int)sz, + dst[0]._string_array._pt[sz-1]._str, + dst[1]._string_array._pt[sz-1]._str); + } else { + LOG(debug, "mirrorFetch %p -> 0 size", this); + } + } + _req->GetReturn()->AddInt32(newgen.getAsInt()); + LOG(debug, "mirrorFetch %p done (gen %d -> gen %d)", + this, _gen.getAsInt(), newgen.getAsInt()); + _req->Return(); +} + + +void +MirrorFetch::PerformTask() +{ + // cancel update notification + _map.removeUpdateListener(this); + completeReq(); +} + + +void +MirrorFetch::updated(VisibleMap &map) +{ + LOG_ASSERT(&map == &_map); + (void) ↦ + // unschedule timeout task + Unschedule(); + completeReq(); +} + + +void +MirrorFetch::aborted(VisibleMap &map) +{ + LOG_ASSERT(&map == &_map); + (void) ↦ + // unschedule timeout task + Unschedule(); + _req->SetError(FRTE_RPC_METHOD_FAILED, "slobrok shutting down"); + _req->Return(); +} + + +void +MirrorFetch::invoke(uint32_t msTimeout) +{ + _req->Detach(); + LOG(debug, "MirrorFetch %p invoked from %s (gen %d, timeout %d ms)", + this, _req->GetConnection()->GetSpec(), _gen.getAsInt(), msTimeout); + if (_map.genCnt() != _gen || msTimeout == 0) { + completeReq(); + } else { + _map.addUpdateListener(this); // register as update listener + if (msTimeout > 10000) + msTimeout = 10000; + Schedule((double) msTimeout / 1000.0); + } +} + +IncrementalFetch::IncrementalFetch(FRT_Supervisor *orb, + FRT_RPCRequest *req, + VisibleMap &map, + vespalib::GenCnt gen) + : FNET_Task(orb->GetScheduler()), + _req(req), + _map(map), + _gen(gen) +{ +} + + +IncrementalFetch::~IncrementalFetch() +{ + LOG_ABORT("Should never be called!"); +} + + +void +IncrementalFetch::completeReq() +{ + vespalib::GenCnt newgen = _map.genCnt(); + VisibleMap::MapDiff diff; + FRT_Values &dst = *_req->GetReturn(); + + if (newgen == _gen) { // no change + dst.AddInt32(_gen.getAsInt()); + } else if (_map.hasHistory(_gen)) { + diff = _map.history(_gen); + dst.AddInt32(_gen.getAsInt()); + } else { + dst.AddInt32(0); + diff.updated = _map.allVisible(); + } + + size_t sz = diff.removed.size(); + FRT_StringValue *rem = dst.AddStringArray(sz); + for (uint32_t i = 0; i < sz; ++i) { + dst.SetString(&rem[i], diff.removed[i].c_str()); + } + + sz = diff.updated.size(); + FRT_StringValue *names = dst.AddStringArray(sz); + FRT_StringValue *specs = dst.AddStringArray(sz); + for (uint32_t i = 0; i < sz; ++i) { + dst.SetString(&names[i], diff.updated[i]->getName()); + dst.SetString(&specs[i], diff.updated[i]->getSpec()); + } + + dst.AddInt32(newgen.getAsInt()); + LOG(debug, "mirrorFetch %p done (gen %d -> gen %d)", + this, _gen.getAsInt(), newgen.getAsInt()); + _req->Return(); +} + + +void +IncrementalFetch::PerformTask() +{ + // cancel update notification + _map.removeUpdateListener(this); + completeReq(); +} + + +void +IncrementalFetch::updated(VisibleMap &map) +{ + LOG_ASSERT(&map == &_map); + (void) ↦ + // unschedule timeout task + Unschedule(); + completeReq(); +} + + +void +IncrementalFetch::aborted(VisibleMap &map) +{ + LOG_ASSERT(&map == &_map); + (void) ↦ + // unschedule timeout task + Unschedule(); + _req->SetError(FRTE_RPC_METHOD_FAILED, "slobrok shutting down"); + _req->Return(); +} + + +void +IncrementalFetch::invoke(uint32_t msTimeout) +{ + _req->Detach(); + LOG(debug, "IncrementalFetch %p invoked from %s (gen %d, timeout %d ms)", + this, _req->GetConnection()->GetSpec(), _gen.getAsInt(), msTimeout); + if (_map.genCnt() != _gen || msTimeout == 0) { + completeReq(); + } else { + _map.addUpdateListener(this); // register as update listener + if (msTimeout > 10000) + msTimeout = 10000; + Schedule((double) msTimeout / 1000.0); + } +} + +} // namespace slobrok + diff --git a/slobrok/src/vespa/slobrok/server/rpcmirror.h b/slobrok/src/vespa/slobrok/server/rpcmirror.h index 889b00c6ba1..1bb31720db5 100644 --- a/slobrok/src/vespa/slobrok/server/rpcmirror.h +++ b/slobrok/src/vespa/slobrok/server/rpcmirror.h @@ -1,273 +1,53 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -namespace slobrok { +#include "visible_map.h" -namespace { +namespace slobrok { class MirrorFetch : public FNET_Task, public VisibleMap::IUpdateListener { private: - MirrorFetch(const MirrorFetch &); - MirrorFetch& operator=(const MirrorFetch &); - FRT_RPCRequest *_req; VisibleMap &_map; vespalib::GenCnt _gen; public: - MirrorFetch(FRT_Supervisor *orb, - FRT_RPCRequest *req, - VisibleMap &map, - vespalib::GenCnt gen); - virtual ~MirrorFetch(); + MirrorFetch(const MirrorFetch &) = delete; + MirrorFetch& operator=(const MirrorFetch &) = delete; + + MirrorFetch(FRT_Supervisor *orb, FRT_RPCRequest *req, VisibleMap &map, vespalib::GenCnt gen); + ~MirrorFetch(); void completeReq(); - virtual void PerformTask(); - virtual void updated(VisibleMap &map); - virtual void aborted(VisibleMap &map); + void PerformTask() override; + void updated(VisibleMap &map) override; + void aborted(VisibleMap &map) override; void invoke(uint32_t msTimeout); }; - -MirrorFetch::MirrorFetch(FRT_Supervisor *orb, - FRT_RPCRequest *req, - VisibleMap &map, - vespalib::GenCnt gen) - : FNET_Task(orb->GetScheduler()), - _req(req), - _map(map), - _gen(gen) -{ -} - - -MirrorFetch::~MirrorFetch() -{ - LOG_ABORT("Should never be called!"); -} - - -void -MirrorFetch::completeReq() -{ - vespalib::GenCnt newgen = _map.genCnt(); - if (newgen == _gen) { // no change - _req->GetReturn()->AddStringArray(0); - _req->GetReturn()->AddStringArray(0); - } else { - std::vector rpcsrvlist = _map.allVisible(); - - FRT_Values &dst = *_req->GetReturn(); - size_t sz = rpcsrvlist.size(); - FRT_StringValue *names = dst.AddStringArray(sz); - FRT_StringValue *specs = dst.AddStringArray(sz); - for (uint32_t i = 0; i < rpcsrvlist.size(); ++i) { - dst.SetString(&names[i], rpcsrvlist[i]->getName()); - dst.SetString(&specs[i], rpcsrvlist[i]->getSpec()); - } - if (sz > 0) { - LOG(debug, "mirrorFetch %p -> %u, last [%s,%s]", - this, - (unsigned int)sz, - dst[0]._string_array._pt[sz-1]._str, - dst[1]._string_array._pt[sz-1]._str); - } else { - LOG(debug, "mirrorFetch %p -> 0 size", this); - } - } - _req->GetReturn()->AddInt32(newgen.getAsInt()); - LOG(debug, "mirrorFetch %p done (gen %d -> gen %d)", - this, _gen.getAsInt(), newgen.getAsInt()); - _req->Return(); -} - - -void -MirrorFetch::PerformTask() -{ - // cancel update notification - _map.removeUpdateListener(this); - completeReq(); -} - - -void -MirrorFetch::updated(VisibleMap &map) -{ - LOG_ASSERT(&map == &_map); - (void) ↦ - // unschedule timeout task - Unschedule(); - completeReq(); -} - - -void -MirrorFetch::aborted(VisibleMap &map) -{ - LOG_ASSERT(&map == &_map); - (void) ↦ - // unschedule timeout task - Unschedule(); - _req->SetError(FRTE_RPC_METHOD_FAILED, "slobrok shutting down"); - _req->Return(); -} - - -void -MirrorFetch::invoke(uint32_t msTimeout) -{ - _req->Detach(); - LOG(debug, "MirrorFetch %p invoked from %s (gen %d, timeout %d ms)", - this, _req->GetConnection()->GetSpec(), _gen.getAsInt(), msTimeout); - if (_map.genCnt() != _gen || msTimeout == 0) { - completeReq(); - } else { - _map.addUpdateListener(this); // register as update listener - if (msTimeout > 10000) - msTimeout = 10000; - Schedule((double) msTimeout / 1000.0); - } -} - - - class IncrementalFetch : public FNET_Task, public VisibleMap::IUpdateListener { private: - IncrementalFetch(const IncrementalFetch &); - IncrementalFetch& operator=(const IncrementalFetch &); - FRT_RPCRequest *_req; VisibleMap &_map; vespalib::GenCnt _gen; public: - IncrementalFetch(FRT_Supervisor *orb, - FRT_RPCRequest *req, - VisibleMap &map, - vespalib::GenCnt gen); - virtual ~IncrementalFetch(); + IncrementalFetch(const IncrementalFetch &) = delete; + IncrementalFetch& operator=(const IncrementalFetch &) = delete; + + IncrementalFetch(FRT_Supervisor *orb, FRT_RPCRequest *req, VisibleMap &map, vespalib::GenCnt gen); + ~IncrementalFetch(); void completeReq(); - virtual void PerformTask(); - virtual void updated(VisibleMap &map); - virtual void aborted(VisibleMap &map); + void PerformTask() override; + void updated(VisibleMap &map) override; + void aborted(VisibleMap &map) override; void invoke(uint32_t msTimeout); }; - -IncrementalFetch::IncrementalFetch(FRT_Supervisor *orb, - FRT_RPCRequest *req, - VisibleMap &map, - vespalib::GenCnt gen) - : FNET_Task(orb->GetScheduler()), - _req(req), - _map(map), - _gen(gen) -{ -} - - -IncrementalFetch::~IncrementalFetch() -{ - LOG_ABORT("Should never be called!"); -} - - -void -IncrementalFetch::completeReq() -{ - vespalib::GenCnt newgen = _map.genCnt(); - VisibleMap::MapDiff diff; - FRT_Values &dst = *_req->GetReturn(); - - if (newgen == _gen) { // no change - dst.AddInt32(_gen.getAsInt()); - } else if (_map.hasHistory(_gen)) { - diff = _map.history(_gen); - dst.AddInt32(_gen.getAsInt()); - } else { - dst.AddInt32(0); - diff.updated = _map.allVisible(); - } - - size_t sz = diff.removed.size(); - FRT_StringValue *rem = dst.AddStringArray(sz); - for (uint32_t i = 0; i < sz; ++i) { - dst.SetString(&rem[i], diff.removed[i].c_str()); - } - - sz = diff.updated.size(); - FRT_StringValue *names = dst.AddStringArray(sz); - FRT_StringValue *specs = dst.AddStringArray(sz); - for (uint32_t i = 0; i < sz; ++i) { - dst.SetString(&names[i], diff.updated[i]->getName()); - dst.SetString(&specs[i], diff.updated[i]->getSpec()); - } - - dst.AddInt32(newgen.getAsInt()); - LOG(debug, "mirrorFetch %p done (gen %d -> gen %d)", - this, _gen.getAsInt(), newgen.getAsInt()); - _req->Return(); -} - - -void -IncrementalFetch::PerformTask() -{ - // cancel update notification - _map.removeUpdateListener(this); - completeReq(); -} - - -void -IncrementalFetch::updated(VisibleMap &map) -{ - LOG_ASSERT(&map == &_map); - (void) ↦ - // unschedule timeout task - Unschedule(); - completeReq(); -} - - -void -IncrementalFetch::aborted(VisibleMap &map) -{ - LOG_ASSERT(&map == &_map); - (void) ↦ - // unschedule timeout task - Unschedule(); - _req->SetError(FRTE_RPC_METHOD_FAILED, "slobrok shutting down"); - _req->Return(); -} - - -void -IncrementalFetch::invoke(uint32_t msTimeout) -{ - _req->Detach(); - LOG(debug, "IncrementalFetch %p invoked from %s (gen %d, timeout %d ms)", - this, _req->GetConnection()->GetSpec(), _gen.getAsInt(), msTimeout); - if (_map.genCnt() != _gen || msTimeout == 0) { - completeReq(); - } else { - _map.addUpdateListener(this); // register as update listener - if (msTimeout > 10000) - msTimeout = 10000; - Schedule((double) msTimeout / 1000.0); - } -} - - -} // namespace - -//----------------------------------------------------------------------------- - } // namespace slobrok diff --git a/slobrok/src/vespa/slobrok/server/visible_map.h b/slobrok/src/vespa/slobrok/server/visible_map.h index 04a61ea1b4d..d67cb9ace70 100644 --- a/slobrok/src/vespa/slobrok/server/visible_map.h +++ b/slobrok/src/vespa/slobrok/server/visible_map.h @@ -8,11 +8,10 @@ #include #include "history.h" +#include "named_service.h" namespace slobrok { -class NamedService; - /** * @class VisibleMap * @brief API to the collection of NamedService diff --git a/slobrok/src/vespa/slobrok/server/vtag.cpp b/slobrok/src/vespa/slobrok/server/vtag.cpp deleted file mode 100644 index 380d653bd28..00000000000 --- a/slobrok/src/vespa/slobrok/server/vtag.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include "vtag.h" - -#ifndef V_TAG -#define V_TAG "NOTAG" -#define V_TAG_DATE "NOTAG" -#define V_TAG_SYSTEM "NOTAG" -#define V_TAG_SYSTEM_REV "NOTAG" -#define V_TAG_BUILDER "NOTAG" -#endif - -namespace slobrok { - -char VersionTag[] = V_TAG; -char VersionTagDate[] = V_TAG_DATE; -char VersionTagSystem[] = V_TAG_SYSTEM; -char VersionTagSystemRev[] = V_TAG_SYSTEM_REV; -char VersionTagBuilder[] = V_TAG_BUILDER; - -} // namespace slobrok diff --git a/slobrok/src/vespa/slobrok/server/vtag.h b/slobrok/src/vespa/slobrok/server/vtag.h deleted file mode 100644 index 6e9227a5951..00000000000 --- a/slobrok/src/vespa/slobrok/server/vtag.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -namespace slobrok { - -extern char VersionTag[]; -extern char VersionTagType[]; -extern char VersionTagValue[]; -extern char VersionTagDate[]; -extern char VersionTagSystem[]; -extern char VersionTagSystemRev[]; -extern char VersionTagBuilder[]; - -} // namespace slobrok - diff --git a/storage/src/vespa/storage/common/CMakeLists.txt b/storage/src/vespa/storage/common/CMakeLists.txt index e699f055d02..3b9eb376eb7 100644 --- a/storage/src/vespa/storage/common/CMakeLists.txt +++ b/storage/src/vespa/storage/common/CMakeLists.txt @@ -4,7 +4,6 @@ vespa_add_library(storage_common OBJECT statusmetricconsumer.cpp storagelink.cpp storagelinkqueued.cpp - vtag.cpp bucketoperationlogger.cpp messagebucketid.cpp messagesender.cpp diff --git a/storage/src/vespa/storage/common/hostreporter/versionreporter.cpp b/storage/src/vespa/storage/common/hostreporter/versionreporter.cpp index 110df2c2b12..670f4ef6369 100644 --- a/storage/src/vespa/storage/common/hostreporter/versionreporter.cpp +++ b/storage/src/vespa/storage/common/hostreporter/versionreporter.cpp @@ -1,8 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include "versionreporter.h" -#include -#include +#include namespace storage { @@ -12,7 +11,7 @@ using End = vespalib::JsonStream::End; } void VersionReporter::report(vespalib::JsonStream& jsonreport) { jsonreport << "vtag" << Object() - << "version" << Vtag::currentVersion.toString() + << "version" << vespalib::Vtag::currentVersion.toString() << End(); } diff --git a/storage/src/vespa/storage/common/vtag.cpp b/storage/src/vespa/storage/common/vtag.cpp deleted file mode 100644 index cf352006904..00000000000 --- a/storage/src/vespa/storage/common/vtag.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -#include -#include -#include - -#ifndef V_TAG -#define V_TAG "NOTAG" -#define V_TAG_DATE "NOTAG" -#define V_TAG_SYSTEM "NOTAG" -#define V_TAG_SYSTEM_REV "NOTAG" -#define V_TAG_BUILDER "NOTAG" -#define V_TAG_VERSION "0" -#define V_TAG_ARCH "NOTAG" -#endif - -namespace storage { - -char VersionTag[] = V_TAG; -char VersionTagDate[] = V_TAG_DATE; -char VersionTagSystem[] = V_TAG_SYSTEM; -char VersionTagSystemRev[] = V_TAG_SYSTEM_REV; -char VersionTagBuilder[] = V_TAG_BUILDER; -char VersionTagPkg[] = V_TAG_PKG; -char VersionTagComponent[] = V_TAG_COMPONENT; -char VersionTagArch[] = V_TAG_ARCH; - -vespalib::Version Vtag::currentVersion(VersionTagComponent); - -void -Vtag::printVersionNice() -{ - char *s = VersionTag; - bool needdate = true; - if (strncmp(VersionTag, "V_", 2) == 0) { - s += 2; - do { - while (strchr("0123456789", *s) != NULL) { - printf("%c", *s++); - } - if (strncmp(s, "_RELEASE", 8) == 0) { - needdate = false; - break; - } - if (strncmp(s, "_RC", 3) == 0) { - char *e = strchr(s, '-'); - if (e == NULL) { - printf("%s", s); - } else { - printf("%.*s", (int)(e-s), s); - } - needdate = false; - break; - } - if (*s == '_' && strchr("0123456789", *++s)) { - printf("."); - } else { - break; - } - } while (*s && *s != '-'); - } else { - char *e = strchr(s, '-'); - if (e == NULL) { - printf("%s", s); - } else { - printf("%.*s", (int)(e-s), s); - } - } - if (needdate) { - s = VersionTagDate; - char *e = strchr(s, '-'); - if (e == NULL) { - printf("-%s", s); - } else { - printf("-%.*s", (int)(e-s), s); - } - } -} - -} // namespace storage diff --git a/storage/src/vespa/storage/common/vtag.h b/storage/src/vespa/storage/common/vtag.h deleted file mode 100644 index 26236f13a41..00000000000 --- a/storage/src/vespa/storage/common/vtag.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -namespace vespalib { - class Version; -} - -namespace storage { - -extern char VersionTag[]; -extern char VersionTagDate[]; -extern char VersionTagSystem[]; -extern char VersionTagSystemRev[]; -extern char VersionTagBuilder[]; - -class Vtag { -public: - static vespalib::Version currentVersion; - static void printVersionNice(); -}; - -} // namespace messagebus - diff --git a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp index ddfb0bd8a95..9445b35e222 100644 --- a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp +++ b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -293,7 +292,7 @@ StatusWebServer::handlePage(const framework::HttpUrlPath& urlpath, } else { IndexPageReporter indexRep; indexRep << "

Binary version of Vespa: " - << Vtag::currentVersion.toString() + << vespalib::Vtag::currentVersion.toString() << "

\n"; { std::vector reporters( diff --git a/vespalib/src/vespa/vespalib/component/CMakeLists.txt b/vespalib/src/vespa/vespalib/component/CMakeLists.txt index 36dba10f7d3..3b1b4c2cb41 100644 --- a/vespalib/src/vespa/vespalib/component/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/component/CMakeLists.txt @@ -3,5 +3,6 @@ vespa_add_library(vespalib_vespalib_component OBJECT SOURCES version.cpp versionspecification.cpp + vtag.cpp DEPENDS ) diff --git a/vespalib/src/vespa/vespalib/component/vtag.cpp b/vespalib/src/vespa/vespalib/component/vtag.cpp new file mode 100644 index 00000000000..c6619c29f1c --- /dev/null +++ b/vespalib/src/vespa/vespalib/component/vtag.cpp @@ -0,0 +1,80 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include +#include "vtag.h" + +#ifndef V_TAG +#define V_TAG "NOTAG" +#define V_TAG_TYPE "NOTAG" +#define V_TAG_VALUE "NOTAG" +#define V_TAG_DATE "NOTAG" +#define V_TAG_SYSTEM "NOTAG" +#define V_TAG_SYSTEM_REV "NOTAG" +#define V_TAG_BUILDER "NOTAG" +#define V_TAG_VERSION "0" +#define V_TAG_ARCH "NOTAG" +#endif + +namespace vespalib { + +char VersionTag[] = V_TAG; +char VersionTagDate[] = V_TAG_DATE; +char VersionTagSystem[] = V_TAG_SYSTEM; +char VersionTagSystemRev[] = V_TAG_SYSTEM_REV; +char VersionTagBuilder[] = V_TAG_BUILDER; +char VersionTagPkg[] = V_TAG_PKG; +char VersionTagComponent[] = V_TAG_COMPONENT; +char VersionTagArch[] = V_TAG_ARCH; + +Version Vtag::currentVersion(VersionTagComponent); + +void +Vtag::printVersionNice() +{ + char *s = VersionTag; + bool needdate = true; + if (strncmp(VersionTag, "V_", 2) == 0) { + s += 2; + do { + while (strchr("0123456789", *s) != NULL) { + printf("%c", *s++); + } + if (strncmp(s, "_RELEASE", 8) == 0) { + needdate = false; + break; + } + if (strncmp(s, "_RC", 3) == 0) { + char *e = strchr(s, '-'); + if (e == NULL) { + printf("%s", s); + } else { + printf("%.*s", (int)(e-s), s); + } + needdate = false; + break; + } + if (*s == '_' && strchr("0123456789", *++s)) { + printf("."); + } else { + break; + } + } while (*s && *s != '-'); + } else { + char *e = strchr(s, '-'); + if (e == NULL) { + printf("%s", s); + } else { + printf("%.*s", (int)(e-s), s); + } + } + if (needdate) { + s = VersionTagDate; + char *e = strchr(s, '-'); + if (e == NULL) { + printf("-%s", s); + } else { + printf("-%.*s", (int)(e-s), s); + } + } +} + +} diff --git a/vespalib/src/vespa/vespalib/component/vtag.h b/vespalib/src/vespa/vespalib/component/vtag.h new file mode 100644 index 00000000000..ed2b21413a3 --- /dev/null +++ b/vespalib/src/vespa/vespalib/component/vtag.h @@ -0,0 +1,22 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include "version.h" + +namespace vespalib { + +extern char VersionTag[]; +extern char VersionTagType[]; +extern char VersionTagValue[]; +extern char VersionTagDate[]; +extern char VersionTagSystem[]; +extern char VersionTagSystemRev[]; +extern char VersionTagBuilder[]; + +class Vtag { +public: + static Version currentVersion; + static void printVersionNice(); +}; + +} -- cgit v1.2.3