summaryrefslogtreecommitdiffstats
path: root/slobrok
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-04-05 19:34:49 +0200
committerGitHub <noreply@github.com>2018-04-05 19:34:49 +0200
commit1a217ade5f61adb837e9f0a257b92a63ba47a2ae (patch)
tree66d47aa6276fce9d77ec30fff9168c85015503b3 /slobrok
parentc89efc910e1685fff335a08f3a45264638806771 (diff)
Revert "Balder/quick restart of slobrok"
Diffstat (limited to 'slobrok')
-rw-r--r--slobrok/src/apps/slobrok/slobrok.cpp11
-rw-r--r--slobrok/src/vespa/slobrok/cfg.cpp3
-rw-r--r--slobrok/src/vespa/slobrok/server/CMakeLists.txt1
-rw-r--r--slobrok/src/vespa/slobrok/server/configshim.cpp12
-rw-r--r--slobrok/src/vespa/slobrok/server/configshim.h11
-rw-r--r--slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp61
-rw-r--r--slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.h31
-rw-r--r--slobrok/src/vespa/slobrok/server/sbenv.cpp42
-rw-r--r--slobrok/src/vespa/slobrok/server/sbenv.h6
9 files changed, 42 insertions, 136 deletions
diff --git a/slobrok/src/apps/slobrok/slobrok.cpp b/slobrok/src/apps/slobrok/slobrok.cpp
index e69f2df53f0..277cc2f3a87 100644
--- a/slobrok/src/apps/slobrok/slobrok.cpp
+++ b/slobrok/src/apps/slobrok/slobrok.cpp
@@ -50,6 +50,7 @@ int
App::Main()
{
uint32_t portnum = 2773;
+ uint32_t statePort = 0;
vespalib::string cfgId;
int argi = 1;
@@ -60,6 +61,9 @@ App::Main()
case 'c':
cfgId = std::string(optArg);
break;
+ case 's':
+ statePort = atoi(optArg);
+ break;
case 'p':
portnum = atoi(optArg);
break;
@@ -73,11 +77,10 @@ App::Main()
if (cfgId.empty()) {
LOG(debug, "no config id specified");
ConfigShim shim(portnum);
- mainobj = std::make_unique<SBEnv>(shim);
+ mainobj.reset(new SBEnv(shim));
} else {
- ConfigShim shim(portnum, cfgId);
- shim.enableStateServer(true);
- mainobj = std::make_unique<SBEnv>(shim);
+ ConfigShim shim(portnum, statePort, cfgId);
+ mainobj.reset(new SBEnv(shim));
}
hook_sigterm();
res = mainobj->MainLoop();
diff --git a/slobrok/src/vespa/slobrok/cfg.cpp b/slobrok/src/vespa/slobrok/cfg.cpp
index a1f165fa7ea..720fb5df962 100644
--- a/slobrok/src/vespa/slobrok/cfg.cpp
+++ b/slobrok/src/vespa/slobrok/cfg.cpp
@@ -1,6 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "cfg.h"
+#include <vespa/log/log.h>
+LOG_SETUP(".slobrok.configurator");
+
namespace slobrok {
namespace {
diff --git a/slobrok/src/vespa/slobrok/server/CMakeLists.txt b/slobrok/src/vespa/slobrok/server/CMakeLists.txt
index a6772404ead..5ca41967524 100644
--- a/slobrok/src/vespa/slobrok/server/CMakeLists.txt
+++ b/slobrok/src/vespa/slobrok/server/CMakeLists.txt
@@ -22,7 +22,6 @@ vespa_add_library(slobrok_slobrokserver
slobrokserver.cpp
visible_map.cpp
metrics_producer.cpp
- reconfigurable_stateserver.cpp
INSTALL lib64
DEPENDS
slobrok
diff --git a/slobrok/src/vespa/slobrok/server/configshim.cpp b/slobrok/src/vespa/slobrok/server/configshim.cpp
index 15c39516ded..83f91a29b30 100644
--- a/slobrok/src/vespa/slobrok/server/configshim.cpp
+++ b/slobrok/src/vespa/slobrok/server/configshim.cpp
@@ -5,26 +5,24 @@
namespace slobrok {
ConfigShim::ConfigShim(uint32_t port)
- : _port(port),
- _enableStateServer(false),
- _configId(""),
+ : _port(port), _statePort(0), _configId(""),
_factory(config::ConfigUri::createEmpty())
{}
-ConfigShim::ConfigShim(uint32_t port, const std::string& cfgId)
+ConfigShim::ConfigShim(uint32_t port, uint32_t statePort_in, const std::string& cfgId)
: _port(port),
- _enableStateServer(false),
+ _statePort(statePort_in),
_configId(cfgId),
_factory(config::ConfigUri(_configId))
{}
ConfigShim::ConfigShim(uint32_t port, const std::string& cfgId, config::IConfigContext::SP cfgCtx)
: _port(port),
- _enableStateServer(false),
+ _statePort(0),
_configId(cfgId),
_factory(config::ConfigUri(cfgId, cfgCtx))
{}
-ConfigShim::~ConfigShim() = default;
+ConfigShim::~ConfigShim() {}
}
diff --git a/slobrok/src/vespa/slobrok/server/configshim.h b/slobrok/src/vespa/slobrok/server/configshim.h
index 750f6a4c139..ed3c04b6233 100644
--- a/slobrok/src/vespa/slobrok/server/configshim.h
+++ b/slobrok/src/vespa/slobrok/server/configshim.h
@@ -9,20 +9,19 @@ namespace slobrok {
class ConfigShim
{
private:
- uint32_t _port;
- bool _enableStateServer;
- std::string _configId;
+ uint32_t _port;
+ uint32_t _statePort;
+ std::string _configId;
ConfiguratorFactory _factory;
public:
ConfigShim(uint32_t port);
- ConfigShim(uint32_t port, const std::string& cfgId);
+ ConfigShim(uint32_t port, uint32_t statePort_in, const std::string& cfgId);
ConfigShim(uint32_t port, const std::string& cfgId, config::IConfigContext::SP cfgCtx);
~ConfigShim();
- ConfigShim & enableStateServer(bool v) { _enableStateServer = v; return *this; }
- bool enableStateServer() const { return _enableStateServer; }
uint32_t portNumber() const { return _port; }
+ uint32_t statePort() const { return _statePort; }
std::string configId() const { return _configId; }
const char *id() const { return _configId.c_str(); }
const ConfiguratorFactory & factory() const { return _factory; }
diff --git a/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp b/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp
deleted file mode 100644
index ca6dcad1932..00000000000
--- a/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "reconfigurable_stateserver.h"
-#include <vespa/vespalib/util/exceptions.h>
-#include <vespa/vespalib/net/state_server.h>
-#include <thread>
-
-#include <vespa/log/log.h>
-#include <vespa/config/common/exceptions.h>
-
-LOG_SETUP(".reconfigurable_stateserver");
-
-using namespace std::chrono_literals;
-
-namespace slobrok {
-
-ReconfigurableStateServer::ReconfigurableStateServer(const config::ConfigUri & configUri,
- vespalib::HealthProducer & health,
- vespalib::MetricsProducer & metrics,
- vespalib::ComponentConfigProducer & components)
- : _health(health),
- _metrics(metrics),
- _components(components),
- _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
- _server()
-{
- _configFetcher->subscribe<vespa::config::StateserverConfig>(configUri.getConfigId(), this);
- _configFetcher->start();
-}
-
-ReconfigurableStateServer::~ReconfigurableStateServer()
-{
- _configFetcher->close();
-}
-
-void
-ReconfigurableStateServer::configure(std::unique_ptr<vespa::config::StateserverConfig> config)
-{
- _server.reset();
- for (size_t retryTime(1); !_server && (retryTime < 10); retryTime++) {
- try {
- _server = std::make_unique<vespalib::StateServer>(config->httpport, _health, _metrics, _components);
- } catch (vespalib::PortListenException & e) {
- LOG(warning, "Failed listening to network port(%d) with protocol(%s): '%s', will retry for 60s",
- e.get_port(), e.get_protocol().c_str(), e.what());
- std::this_thread::sleep_for(retryTime * 1s);
- }
- }
- if (!_server) {
- try {
- _server = std::make_unique<vespalib::StateServer>(config->httpport, _health, _metrics, _components);
- } catch (vespalib::PortListenException & e) {
- LOG(error, "Failed listening to network port(%d) with protocol(%s): '%s', giving up and restarting.",
- e.get_port(), e.get_protocol().c_str(), e.what());
- std::quick_exit(17);
- }
- }
-
-}
-
-}
diff --git a/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.h b/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.h
deleted file mode 100644
index a8747d09bfd..00000000000
--- a/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.h
+++ /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 <vespa/config/helper/configfetcher.h>
-#include <vespa/config/subscription/configuri.h>
-#include <vespa/config-stateserver.h>
-
-namespace vespalib {
- class HealthProducer;
- class MetricsProducer;
- class ComponentConfigProducer;
- class StateServer;
-}
-namespace slobrok {
-
-class ReconfigurableStateServer : private config::IFetcherCallback<vespa::config::StateserverConfig> {
-public:
- ReconfigurableStateServer(const config::ConfigUri & configUri,
- vespalib::HealthProducer & healt,
- vespalib::MetricsProducer & metrics,
- vespalib::ComponentConfigProducer & component);
- ~ReconfigurableStateServer();
-private:
- void configure(std::unique_ptr<vespa::config::StateserverConfig> config) override;
- vespalib::HealthProducer & _health;
- vespalib::MetricsProducer & _metrics;
- vespalib::ComponentConfigProducer & _components;
- std::unique_ptr<config::ConfigFetcher> _configFetcher;
- std::unique_ptr<vespalib::StateServer> _server;
-};
-
-}
diff --git a/slobrok/src/vespa/slobrok/server/sbenv.cpp b/slobrok/src/vespa/slobrok/server/sbenv.cpp
index 35af0daf24a..002dd2244ca 100644
--- a/slobrok/src/vespa/slobrok/server/sbenv.cpp
+++ b/slobrok/src/vespa/slobrok/server/sbenv.cpp
@@ -1,25 +1,20 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "reconfigurable_stateserver.h"
#include "sbenv.h"
#include "selfcheck.h"
#include "remote_check.h"
+#include <sstream>
+#include <vespa/vespalib/net/state_server.h>
#include <vespa/vespalib/util/host_name.h>
-#include <vespa/vespalib/util/exceptions.h>
+#include <vespa/vespalib/util/exception.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/fnet/transport.h>
-#include <vespa/config/helper/configfetcher.h>
-#include <thread>
-#include <sstream>
#include <vespa/log/log.h>
LOG_SETUP(".sbenv");
-using namespace std::chrono_literals;
-
namespace slobrok {
-
namespace {
void
@@ -85,16 +80,17 @@ ConfigTask::PerformTask()
} // namespace slobrok::<unnamed>
SBEnv::SBEnv(const ConfigShim &shim)
- : _transport(std::make_unique<FNET_Transport>()),
- _supervisor(std::make_unique<FRT_Supervisor>(_transport.get(), nullptr)),
- _configShim(shim),
+ : _transport(new FNET_Transport()),
+ _supervisor(new FRT_Supervisor(_transport.get(), NULL)),
+ _sbPort(shim.portNumber()),
+ _statePort(shim.statePort()),
_configurator(shim.factory().create(*this)),
_shuttingDown(false),
_partnerList(),
_me(),
_rpcHooks(*this, _rpcsrvmap, _rpcsrvmanager),
- _selfchecktask(std::make_unique<SelfCheck>(getSupervisor()->GetScheduler(), _rpcsrvmap, _rpcsrvmanager)),
- _remotechecktask(std::make_unique<RemoteCheck>(getSupervisor()->GetScheduler(), _rpcsrvmap, _rpcsrvmanager, _exchanger)),
+ _selfchecktask(new SelfCheck(getSupervisor()->GetScheduler(), _rpcsrvmap, _rpcsrvmanager)),
+ _remotechecktask(new RemoteCheck(getSupervisor()->GetScheduler(), _rpcsrvmap, _rpcsrvmanager, _exchanger)),
_health(),
_metrics(_rpcHooks, *_transport),
_components(),
@@ -102,7 +98,7 @@ SBEnv::SBEnv(const ConfigShim &shim)
_exchanger(*this, _rpcsrvmap),
_rpcsrvmap()
{
- srandom(time(nullptr) ^ getpid());
+ srandom(time(NULL) ^ getpid());
_rpcHooks.initRPC(getSupervisor());
}
@@ -162,22 +158,20 @@ toString(const std::vector<std::string> & v) {
int
SBEnv::MainLoop()
{
- if (! getSupervisor()->Listen(_configShim.portNumber())) {
- LOG(error, "unable to listen to port %d", _configShim.portNumber());
+ vespalib::StateServer stateServer(_statePort, _health, _metrics, _components);
+
+ if (! getSupervisor()->Listen(_sbPort)) {
+ LOG(error, "unable to listen to port %d", _sbPort);
EV_STOPPING("slobrok", "could not listen");
return 1;
} else {
- LOG(config, "listening on port %d", _configShim.portNumber());
+ LOG(config, "listening on port %d", _sbPort);
}
- std::string myspec = createSpec(_configShim.portNumber());
-
- _me = std::make_unique<ManagedRpcServer>(myspec.c_str(), myspec.c_str(), _rpcsrvmanager);
+ std::string myspec = createSpec(_sbPort);
- std::unique_ptr<ReconfigurableStateServer> stateServer;
- if (_configShim.enableStateServer()) {
- stateServer = std::make_unique<ReconfigurableStateServer>(_configShim.configId(), _health, _metrics, _components);
- }
+ _me.reset(new ManagedRpcServer(myspec.c_str(), myspec.c_str(),
+ _rpcsrvmanager));
try {
_configurator->poll();
diff --git a/slobrok/src/vespa/slobrok/server/sbenv.h b/slobrok/src/vespa/slobrok/server/sbenv.h
index 8c897c9c999..f96b7540b3a 100644
--- a/slobrok/src/vespa/slobrok/server/sbenv.h
+++ b/slobrok/src/vespa/slobrok/server/sbenv.h
@@ -8,10 +8,10 @@
#include "exchange_manager.h"
#include "configshim.h"
#include "ok_state.h"
-#include "metrics_producer.h"
#include <vespa/config-slobroks.h>
#include <vespa/slobrok/cfg.h>
#include <vespa/vespalib/net/simple_health_producer.h>
+#include "metrics_producer.h"
#include <vespa/vespalib/net/simple_component_config_producer.h>
class FastOS_ThreadPool;
@@ -23,6 +23,7 @@ namespace slobrok {
class NamedService;
class ManagedRpcServer;
+class RemoteRpcServer;
class RPCHooks;
class SelfCheck;
class RemoteCheck;
@@ -39,7 +40,8 @@ private:
std::unique_ptr<FNET_Transport> _transport;
std::unique_ptr<FRT_Supervisor> _supervisor;
- ConfigShim _configShim;
+ uint32_t _sbPort;
+ uint32_t _statePort;
Configurator::UP _configurator;
bool _shuttingDown;