diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-09-13 15:15:58 +0200 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2019-01-21 15:09:21 +0100 |
commit | fd92032229f603b349ee54cf71ccbaeb5b792a90 (patch) | |
tree | 2aaea0c8c6812fde5ac4138f081715f09d040156 /vespaclient | |
parent | f1791b7a17aa7d4cf6989fad48ebb3fc4e4ef93c (diff) |
Remove spooler from config-model
Diffstat (limited to 'vespaclient')
6 files changed, 0 insertions, 256 deletions
diff --git a/vespaclient/CMakeLists.txt b/vespaclient/CMakeLists.txt index ed61d730629..8be8751f2c9 100644 --- a/vespaclient/CMakeLists.txt +++ b/vespaclient/CMakeLists.txt @@ -15,7 +15,6 @@ vespa_define_module( src/vespa/vespaclient/clusterlist APPS - src/vespa/vespaclient/spoolmaster src/vespa/vespaclient/vdsstates src/vespa/vespaclient/vesparoute ) diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/.gitignore b/vespaclient/src/vespa/vespaclient/spoolmaster/.gitignore deleted file mode 100644 index 81b1279cdb1..00000000000 --- a/vespaclient/src/vespa/vespaclient/spoolmaster/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.depend -Makefile -vespa-spoolmaster diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/CMakeLists.txt b/vespaclient/src/vespa/vespaclient/spoolmaster/CMakeLists.txt deleted file mode 100644 index 5e5d8b17ff3..00000000000 --- a/vespaclient/src/vespa/vespaclient/spoolmaster/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_executable(vespaclient_spoolmaster_app - SOURCES - main.cpp - application.cpp - OUTPUT_NAME vespa-spoolmaster - INSTALL bin - DEPENDS -) diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp b/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp deleted file mode 100644 index 7406e17430d..00000000000 --- a/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/defaults.h> -#include <thread> -#include <iostream> -#include <algorithm> -#include <dirent.h> -#include <unistd.h> -#include <cstring> -#include <sys/stat.h> - -#include "application.h" - -namespace { - -std::string masterInbox() { - return vespa::Defaults::underVespaHome("var/spool/master/inbox"); -} - -std::string outboxParent() { - return vespa::Defaults::underVespaHome("var/spool/vespa"); -} - -} - -namespace spoolmaster { - -Application::Application() - : _masterInbox(masterInbox()), - _inboxFiles(), - _outboxParentDir(outboxParent()), - _outboxes() -{ - // empty -} - -Application::~Application() -{ - // empty -} - -bool -Application::scanInbox() -{ - std::vector<std::string> rv; - DIR *d = opendir(_masterInbox.c_str()); - if (d == NULL) { - perror(_masterInbox.c_str()); - mkdir(_masterInbox.c_str(), 0775); - return false; - } - - struct dirent *entry; - while ((entry = readdir(d)) != NULL) { - if (strcmp(entry->d_name, ".") == 0) continue; - if (strcmp(entry->d_name, "..") == 0) continue; - - std::string fn = _masterInbox; - fn.append("/"); - fn.append(entry->d_name); - - struct stat sb; - if (stat(fn.c_str(), &sb) == 0) { - if (S_ISREG(sb.st_mode)) { - rv.push_back(fn); - } - } else { - perror(fn.c_str()); - } - } - closedir(d); - - if (access(_masterInbox.c_str(), W_OK) < 0) { - perror(_masterInbox.c_str()); - return false; - } - - _inboxFiles = rv; - return (rv.size() > 0); -} - -bool -Application::findOutboxes() -{ - std::vector<std::string> rv; - DIR *d = opendir(_outboxParentDir.c_str()); - if (d == NULL) { - perror(_outboxParentDir.c_str()); - return false; - } - struct dirent *entry; - while ((entry = readdir(d)) != NULL) { - if (strcmp(entry->d_name, ".") == 0) continue; - if (strcmp(entry->d_name, "..") == 0) continue; - - /* XXX: should check if d_name starts with "colo." ? */ - - std::string fn = _outboxParentDir; - fn.append("/"); - fn.append(entry->d_name); - fn.append("/inbox"); - - if (fn == _masterInbox) continue; - - struct stat sb; - if (stat(fn.c_str(), &sb) == 0) { - if (S_ISDIR(sb.st_mode)) { - if (access(fn.c_str(), W_OK) < 0) { - std::cerr << "Cannot write to directory "; - perror(fn.c_str()); - continue; - } - rv.push_back(fn); - } - } else { - perror(fn.c_str()); - } - } - closedir(d); - if (rv.size() > 0) { - std::sort(rv.begin(), rv.end()); - sviter_t ni = rv.begin(); - sviter_t oi = _outboxes.begin(); - - while (ni != rv.end()) { - const std::string &newval = *ni; - if (oi == _outboxes.end()) { - std::cerr << "Found new slave inbox: " << newval << std::endl; - ++ni; - continue; - } - const std::string &oldval = *oi; - if (newval == oldval) { - ++ni; - ++oi; - } else if (newval < oldval) { - std::cerr << "Found new slave inbox: " << newval << std::endl; - ++ni; - } else /* oldval < newval */ { - std::cerr << "Slave inbox removed: " << oldval << std::endl; - ++oi; - } - } - _outboxes = rv; - return true; - } - std::cerr << "Did not find any slave inboxes in: " << _outboxParentDir << std::endl; - return false; -} - -void -Application::moveLinks() -{ - for (sviter_t fni = _inboxFiles.begin(); fni != _inboxFiles.end(); ++fni) { - const std::string& filename = *fni; - size_t ldp = filename.rfind("/"); - std::string basename = filename.substr(ldp+1); - for (sviter_t obi = _outboxes.begin(); obi != _outboxes.end(); ++obi) { - std::string newFn = *obi; - newFn.append("/"); - newFn.append(basename); - - std::cout << "linking " << filename << " -> " << newFn << std::endl; - if (link(filename.c_str(), newFn.c_str()) < 0) { - std::cerr << "linking " << filename << " -> " << newFn; - perror("failed"); - return; - } - } - if (unlink(filename.c_str()) < 0) { - std::cerr << "cannot remove " << filename; - perror(", error"); - } - } -} - - -int -Application::Main() -{ - bool aborted = false; - findOutboxes(); - - try { - while (!aborted) { - if (scanInbox() && findOutboxes()) { - moveLinks(); - } else { - std::this_thread::sleep_for(std::chrono::milliseconds(200)); - } - } - } - catch(std::exception &e) { - fprintf(stderr, "ERROR: %s\n", e.what()); - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} - -} // namespace spoolmaster diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/application.h b/vespaclient/src/vespa/vespaclient/spoolmaster/application.h deleted file mode 100644 index 0cd8e1a917a..00000000000 --- a/vespaclient/src/vespa/vespaclient/spoolmaster/application.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. -#pragma once - -#include <vespa/fastos/app.h> -#include <string> -#include <vector> - -namespace spoolmaster { -/** - * main spoolmaster application class - */ -class Application : public FastOS_Application { -private: - std::string _masterInbox; - std::vector<std::string> _inboxFiles; - - std::string _outboxParentDir; - std::vector<std::string> _outboxes; - - typedef std::vector<std::string>::iterator sviter_t; - - bool scanInbox(); - bool findOutboxes(); - void moveLinks(); -public: - Application(); - ~Application(); - int Main() override; -}; - -} diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/main.cpp b/vespaclient/src/vespa/vespaclient/spoolmaster/main.cpp deleted file mode 100644 index 40a262734bf..00000000000 --- a/vespaclient/src/vespa/vespaclient/spoolmaster/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "application.h" - -int -main(int argc, char** argv) -{ - spoolmaster::Application *app = new spoolmaster::Application(); - int retVal = app->Entry(argc, argv); - delete app; - return retVal; -} - |