aboutsummaryrefslogtreecommitdiffstats
path: root/logd/src
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-03-20 14:09:55 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-03-20 14:09:55 +0000
commite569d802cd526c83dd01e09ae3d13976d3b6a26f (patch)
treee708bb54b1331805b50db23eeadee3b55365b072 /logd/src
parent62f1e77c11a41154876e60e698b3834830d384c5 (diff)
Rename ConfSub -> ConfigSubscriber.
Diffstat (limited to 'logd/src')
-rw-r--r--logd/src/apps/logd/main.cpp10
-rw-r--r--logd/src/logd/CMakeLists.txt2
-rw-r--r--logd/src/logd/config_subscriber.cpp (renamed from logd/src/logd/conf.cpp)24
-rw-r--r--logd/src/logd/config_subscriber.h (renamed from logd/src/logd/conf.h)15
-rw-r--r--logd/src/logd/watch.cpp12
-rw-r--r--logd/src/logd/watch.h6
6 files changed, 36 insertions, 33 deletions
diff --git a/logd/src/apps/logd/main.cpp b/logd/src/apps/logd/main.cpp
index 78e23d7464f..1967c0d7fc7 100644
--- a/logd/src/apps/logd/main.cpp
+++ b/logd/src/apps/logd/main.cpp
@@ -1,15 +1,15 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <logd/config_subscriber.h>
#include <logd/errhandle.h>
#include <logd/forward.h>
-#include <logd/conf.h>
-#include <logd/watch.h>
-#include <logd/state.h>
#include <logd/metrics.h>
+#include <logd/state.h>
+#include <logd/watch.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/vespalib/util/sig_catch.h>
#include <csignal>
#include <unistd.h>
-#include <vespa/vespalib/util/sig_catch.h>
#include <vespa/log/log.h>
LOG_SETUP("logdemon");
@@ -30,7 +30,7 @@ int main(int, char**)
const char *cfid = getenv("VESPA_CONFIG_ID");
try {
- ConfSub subscriber(fwd, config::ConfigUri(cfid));
+ ConfigSubscriber subscriber(fwd, config::ConfigUri(cfid));
int sleepcount = 0;
while (true) {
diff --git a/logd/src/logd/CMakeLists.txt b/logd/src/logd/CMakeLists.txt
index dc3a25799eb..06f0e112d67 100644
--- a/logd/src/logd/CMakeLists.txt
+++ b/logd/src/logd/CMakeLists.txt
@@ -1,7 +1,7 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(logd STATIC
SOURCES
- conf.cpp
+ config_subscriber.cpp
conn.cpp
forward.cpp
metrics.cpp
diff --git a/logd/src/logd/conf.cpp b/logd/src/logd/config_subscriber.cpp
index f01ee8141fc..18eb1b1130f 100644
--- a/logd/src/logd/conf.cpp
+++ b/logd/src/logd/config_subscriber.cpp
@@ -1,8 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "conf.h"
-#include "forward.h"
+#include "config_subscriber.h"
#include "conn.h"
+#include "forward.h"
#include <fcntl.h>
#include <unistd.h>
@@ -15,7 +15,7 @@ using ns_log::Logger;
namespace logdemon {
void
-ConfSub::configure(std::unique_ptr<LogdConfig> cfg)
+ConfigSubscriber::configure(std::unique_ptr<LogdConfig> cfg)
{
const LogdConfig &newconf(*cfg);
if (newconf.logserver.host != _logServer) {
@@ -66,7 +66,7 @@ ConfSub::configure(std::unique_ptr<LogdConfig> cfg)
}
bool
-ConfSub::checkAvailable()
+ConfigSubscriber::checkAvailable()
{
if (_subscriber.nextGeneration(0)) {
_hasAvailable = true;
@@ -75,7 +75,7 @@ ConfSub::checkAvailable()
}
void
-ConfSub::latch()
+ConfigSubscriber::latch()
{
if (checkAvailable()) {
configure(_handle->getConfig());
@@ -91,7 +91,7 @@ ConfSub::latch()
}
void
-ConfSub::connectToLogserver()
+ConfigSubscriber::connectToLogserver()
{
int newfd = makeconn(_logServer.c_str(), _logPort);
if (newfd >= 0) {
@@ -103,7 +103,7 @@ ConfSub::connectToLogserver()
}
void
-ConfSub::connectToDevNull()
+ConfigSubscriber::connectToDevNull()
{
int newfd = open("/dev/null", O_RDWR);
if (newfd >= 0) {
@@ -115,7 +115,7 @@ ConfSub::connectToDevNull()
}
void
-ConfSub::resetFileDescriptor(int newfd)
+ConfigSubscriber::resetFileDescriptor(int newfd)
{
if (_logserverfd >= 0) {
close(_logserverfd);
@@ -126,14 +126,14 @@ ConfSub::resetFileDescriptor(int newfd)
}
void
-ConfSub::closeConn()
+ConfigSubscriber::closeConn()
{
close(_logserverfd);
_logserverfd = -1;
_needToConnect = true;
}
-ConfSub::ConfSub(Forwarder &fw, const config::ConfigUri & configUri)
+ConfigSubscriber::ConfigSubscriber(Forwarder &fw, const config::ConfigUri & configUri)
: _logServer(),
_logPort(0),
_logserverfd(-1),
@@ -157,10 +157,10 @@ ConfSub::ConfSub(Forwarder &fw, const config::ConfigUri & configUri)
LOG(debug, "got handle %p", _handle.get());
}
-ConfSub::~ConfSub()
+ConfigSubscriber::~ConfigSubscriber()
{
LOG(debug, "forget logServer %s", _logServer.c_str());
LOG(debug, "done ~ConfSub()");
}
-} // namespace
+}
diff --git a/logd/src/logd/conf.h b/logd/src/logd/config_subscriber.h
index 894070fff43..bedf10bd111 100644
--- a/logd/src/logd/conf.h
+++ b/logd/src/logd/config_subscriber.h
@@ -8,7 +8,10 @@ namespace logdemon {
class Forwarder;
-class ConfSub {
+/**
+ * Class used to subscribe for logd config.
+ */
+class ConfigSubscriber {
private:
std::string _logServer;
int _logPort;
@@ -32,10 +35,10 @@ public:
bool checkAvailable();
void latch();
void closeConn();
- ConfSub(const ConfSub& other) = delete;
- ConfSub& operator=(const ConfSub& other) = delete;
- ConfSub(Forwarder &fw, const config::ConfigUri & configUri);
- ~ConfSub();
+ ConfigSubscriber(const ConfigSubscriber& other) = delete;
+ ConfigSubscriber& operator=(const ConfigSubscriber& other) = delete;
+ ConfigSubscriber(Forwarder &fw, const config::ConfigUri & configUri);
+ ~ConfigSubscriber();
int getStatePort() const { return _statePort; }
int getservfd() const { return _logserverfd; }
@@ -49,5 +52,5 @@ public:
size_t generation() const { return _subscriber.getGeneration(); }
};
-} // namespace
+}
diff --git a/logd/src/logd/watch.cpp b/logd/src/logd/watch.cpp
index b95b58a4564..6c335b2349c 100644
--- a/logd/src/logd/watch.cpp
+++ b/logd/src/logd/watch.cpp
@@ -1,15 +1,15 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "watch.h"
+#include "config_subscriber.h"
#include "errhandle.h"
#include "forward.h"
-#include "conf.h"
-#include <glob.h>
-#include <unistd.h>
+#include "watch.h"
+#include <vespa/vespalib/util/sig_catch.h>
#include <fcntl.h>
+#include <glob.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include <vespa/vespalib/util/sig_catch.h>
+#include <unistd.h>
LOG_SETUP("");
@@ -59,7 +59,7 @@ constexpr size_t G_BUFSIZE = 1024*1024;
} // namespace logdemon::<unnamed>
-Watcher::Watcher(ConfSub &cfs, Forwarder &fw)
+Watcher::Watcher(ConfigSubscriber &cfs, Forwarder &fw)
: _buffer(G_BUFSIZE),
_confsubscriber(cfs),
_forwarder(fw),
diff --git a/logd/src/logd/watch.h b/logd/src/logd/watch.h
index bcac6046b6f..fec327ab61b 100644
--- a/logd/src/logd/watch.h
+++ b/logd/src/logd/watch.h
@@ -6,13 +6,13 @@
namespace logdemon {
class Forwarder;
-class ConfSub;
+class ConfigSubscriber;
class Watcher
{
private:
std::vector<char> _buffer;
- ConfSub & _confsubscriber;
+ ConfigSubscriber & _confsubscriber;
Forwarder & _forwarder;
int _wfd;
char * getBuf() { return &_buffer[0]; }
@@ -20,7 +20,7 @@ private:
public:
Watcher(const Watcher& other) = delete;
Watcher& operator=(const Watcher& other) = delete;
- Watcher(ConfSub &cfs, Forwarder &fw);
+ Watcher(ConfigSubscriber &cfs, Forwarder &fw);
~Watcher();
void watchfile();