diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-17 22:48:14 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-17 22:48:14 +0000 |
commit | 255cf0089aa663da16125ad9b37df93650ea200c (patch) | |
tree | eb982c8a85f46c1dba4020d5667bffb427a5d1ed /filedistribution | |
parent | 590d93aa5d11a9bab41d0b50af87b7f4154311e8 (diff) |
use a common typedef.
Diffstat (limited to 'filedistribution')
19 files changed, 37 insertions, 44 deletions
diff --git a/filedistribution/src/tests/zkfacade/test-zkfacade.cpp b/filedistribution/src/tests/zkfacade/test-zkfacade.cpp index ada601742db..8589cb95d10 100644 --- a/filedistribution/src/tests/zkfacade/test-zkfacade.cpp +++ b/filedistribution/src/tests/zkfacade/test-zkfacade.cpp @@ -36,7 +36,7 @@ struct Watcher : public ZKFacade::NodeChangedWatcher { struct Fixture { ComponentsDeleter _componentsDeleter; std::shared_ptr<ZKFacade> zk; - ZKFacade::Path testNode; + Path testNode; Fixture() { zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(createSequenceNode) { zk->setData(testNode, "", 0); - ZKFacade::Path prefix = testNode / "prefix"; + Path prefix = testNode / "prefix"; zk->createSequenceNode(prefix, "test", 4); zk->createSequenceNode(prefix, "test", 4); zk->createSequenceNode(prefix, "test", 4); @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(retainOnly) BOOST_AUTO_TEST_CASE(addEphemeralNode) { - ZKFacade::Path ephemeralNode = "/test-ephemeral-node"; + Path ephemeralNode = "/test-ephemeral-node"; zk->removeIfExists(ephemeralNode); //Checked deleter is ok here since we're not installing any watchers diff --git a/filedistribution/src/vespa/filedistribution/common/exception.h b/filedistribution/src/vespa/filedistribution/common/exception.h index d55b218c7cf..f1d1a6c7052 100644 --- a/filedistribution/src/vespa/filedistribution/common/exception.h +++ b/filedistribution/src/vespa/filedistribution/common/exception.h @@ -2,9 +2,12 @@ #pragma once #include <vespa/vespalib/util/exceptions.h> +#include <boost/filesystem/path.hpp> namespace filedistribution { +using Path = boost::filesystem::path; + VESPA_DEFINE_EXCEPTION(FileDoesNotExistException, vespalib::Exception); } diff --git a/filedistribution/src/vespa/filedistribution/common/vespa_logfwd.cpp b/filedistribution/src/vespa/filedistribution/common/vespa_logfwd.cpp index 954c8639bad..c5785f9e24e 100644 --- a/filedistribution/src/vespa/filedistribution/common/vespa_logfwd.cpp +++ b/filedistribution/src/vespa/filedistribution/common/vespa_logfwd.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <stdarg.h> -#include <boost/scoped_array.hpp> #include "logfwd.h" diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedownloader.h b/filedistribution/src/vespa/filedistribution/distributor/filedownloader.h index 4a40293ae07..c089f31976a 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedownloader.h +++ b/filedistribution/src/vespa/filedistribution/distributor/filedownloader.h @@ -40,7 +40,7 @@ class FileDownloader libtorrent::session _session; std::atomic<bool> _closed; - const boost::filesystem::path _dbPath; + const Path _dbPath; typedef std::vector<char> ResumeDataBuffer; boost::optional<ResumeDataBuffer> getResumeData(const std::string& fileReference); @@ -58,14 +58,14 @@ public: FileDownloader(const std::shared_ptr<FileDistributionTracker>& tracker, const std::string& hostName, int port, - const boost::filesystem::path& dbPath); + const Path& dbPath); ~FileDownloader(); DirectoryGuard::UP getGuard() { return std::make_unique<DirectoryGuard>(_dbPath); } void runEventLoop(); void addTorrent(const std::string& fileReference, const Buffer& buffer); bool hasTorrent(const std::string& fileReference) const; - boost::optional<boost::filesystem::path> pathToCompletedFile(const std::string& fileReference) const; + boost::optional<Path> pathToCompletedFile(const std::string& fileReference) const; void removeAllTorrentsBut(const std::set<std::string> & filesToRetain); void signalIfFinishedDownloading(const std::string& fileReference); diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.cpp b/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.cpp index ea38f518caa..5b6ad4f83ff 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.cpp +++ b/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.cpp @@ -12,6 +12,7 @@ LOG_SETUP(".filedownloadermanager"); using namespace std::literals; using filedistribution::FileDownloaderManager; +using filedistribution::Path; namespace { void logStartDownload(const std::set<std::string> & filesToDownload) { @@ -50,7 +51,7 @@ FileDownloaderManager::start() FileDistributionModel::FilesToDownloadChangedSignal::slot_type(std::ref(_startDownloads)).track_foreign(shared_from_this())); } -boost::optional< boost::filesystem::path > +boost::optional< Path > FileDownloaderManager::getPath(const std::string& fileReference) { return _fileDownloader->pathToCompletedFile(fileReference); } @@ -116,7 +117,7 @@ FileDownloaderManager::SetFinishedDownloadingStatus::SetFinishedDownloadingStatu void FileDownloaderManager::SetFinishedDownloadingStatus::operator()( - const std::string& fileReference, const boost::filesystem::path&) { + const std::string& fileReference, const Path&) { //Prevent concurrent modifications to peer node in zk. LockGuard updateFilesToDownloadGuard(_parent._updateFilesToDownloadMutex); diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.h b/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.h index 1294f7d7f77..64a2a8a744e 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.h +++ b/filedistribution/src/vespa/filedistribution/distributor/filedownloadermanager.h @@ -23,7 +23,7 @@ class FileDownloaderManager : public FileProvider, class SetFinishedDownloadingStatus { FileDownloaderManager& _parent; public: - void operator()(const std::string& fileReference, const boost::filesystem::path&); + void operator()(const std::string& fileReference, const Path&); SetFinishedDownloadingStatus(FileDownloaderManager*); }; @@ -49,7 +49,7 @@ public: ~FileDownloaderManager(); void start(); - boost::optional<boost::filesystem::path> getPath(const std::string& fileReference); + boost::optional<Path> getPath(const std::string& fileReference); void downloadFile(const std::string& fileReference); //FileProvider overrides diff --git a/filedistribution/src/vespa/filedistribution/manager/createtorrent.cpp b/filedistribution/src/vespa/filedistribution/manager/createtorrent.cpp index a8e7505cfed..52b05cd78be 100644 --- a/filedistribution/src/vespa/filedistribution/manager/createtorrent.cpp +++ b/filedistribution/src/vespa/filedistribution/manager/createtorrent.cpp @@ -61,7 +61,7 @@ fileReferenceToString(const libtorrent::sha1_hash& fileReference) { filedistribution:: CreateTorrent:: -CreateTorrent(const boost::filesystem::path& path) +CreateTorrent(const Path& path) :_path(path), _entry(createEntry(_path)) {} diff --git a/filedistribution/src/vespa/filedistribution/manager/createtorrent.h b/filedistribution/src/vespa/filedistribution/manager/createtorrent.h index ad1ad4379dd..cffeb435643 100644 --- a/filedistribution/src/vespa/filedistribution/manager/createtorrent.h +++ b/filedistribution/src/vespa/filedistribution/manager/createtorrent.h @@ -6,15 +6,16 @@ #include <libtorrent/create_torrent.hpp> #include <vespa/filedistribution/common/buffer.h> +#include <vespa/filedistribution/common/exception.h> namespace filedistribution { class CreateTorrent { - boost::filesystem::path _path; + Path _path; libtorrent::entry _entry; public: - CreateTorrent(const boost::filesystem::path& path); + CreateTorrent(const Path& path); Buffer bencode() const; const std::string fileReference() const; }; diff --git a/filedistribution/src/vespa/filedistribution/manager/filedb.h b/filedistribution/src/vespa/filedistribution/manager/filedb.h index d5031fff8f1..195f1a65ffc 100644 --- a/filedistribution/src/vespa/filedistribution/manager/filedb.h +++ b/filedistribution/src/vespa/filedistribution/manager/filedb.h @@ -8,9 +8,9 @@ namespace filedistribution { class FileDB { - boost::filesystem::path _dbPath; + Path _dbPath; public: - FileDB(boost::filesystem::path dbPath); + FileDB(Path dbPath); DirectoryGuard::UP getGuard() { return std::make_unique<DirectoryGuard>(_dbPath); } /** * @@ -19,7 +19,7 @@ public: * @param name The name the file shall have. * @return true if it was added, false if it was already present. */ - bool add(const DirectoryGuard & directoryGuard, boost::filesystem::path original, const std::string& name); + bool add(const DirectoryGuard & directoryGuard, Path original, const std::string& name); }; } //namespace filedistribution diff --git a/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.cpp b/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.cpp index 1e80ff375a4..7829744949f 100644 --- a/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.cpp +++ b/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.cpp @@ -8,9 +8,9 @@ #include <vespa/filedistribution/common/logfwd.h> using filedistribution::DeployedFilesToDownload; +using filedistribution::Path; typedef std::vector<std::string> StringVector; -typedef boost::filesystem::path Path; namespace filedistribution { @@ -27,7 +27,7 @@ readApplicationId(filedistribution::ZKFacade & zk, const Path & deployNode) } -const DeployedFilesToDownload::Path +const Path DeployedFilesToDownload::addNewDeployNode(Path parentPath, const FileReferences& files) { Path path = parentPath / "deploy_"; diff --git a/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.h b/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.h index aeed0922fc8..099eb11cbe9 100644 --- a/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.h +++ b/filedistribution/src/vespa/filedistribution/model/deployedfilestodownload.h @@ -7,12 +7,11 @@ namespace filedistribution { -const std::string readApplicationId(ZKFacade & zk, const boost::filesystem::path & deployNode); +const std::string readApplicationId(ZKFacade & zk, const Path & deployNode); class DeployedFilesToDownload { //includes the current deploy run; static const size_t numberOfDeploysToKeepFiles = 2; - typedef boost::filesystem::path Path; ZKFacade& _zk; @@ -22,7 +21,7 @@ class DeployedFilesToDownload { //Nothrow template <typename INSERT_ITERATOR> - void readDeployFile(const boost::filesystem::path& path, INSERT_ITERATOR insertionIterator); + void readDeployFile(const Path& path, INSERT_ITERATOR insertionIterator); void addAppIdToDeployNode(const Path & deployNode, const std::string & appId); std::map<std::string, std::vector<std::string> > groupChildrenByAppId(const Path & parentPath, const std::vector<std::string> & children); void deleteExpiredDeployNodes(Path parentPath, std::vector<std::string> children); diff --git a/filedistribution/src/vespa/filedistribution/model/filedbmodel.h b/filedistribution/src/vespa/filedistribution/model/filedbmodel.h index 63894a1f3e5..1f2d24f2ce0 100644 --- a/filedistribution/src/vespa/filedistribution/model/filedbmodel.h +++ b/filedistribution/src/vespa/filedistribution/model/filedbmodel.h @@ -11,7 +11,7 @@ namespace filedistribution { class DirectoryGuard { public: typedef std::unique_ptr<DirectoryGuard> UP; - DirectoryGuard(boost::filesystem::path path); + DirectoryGuard(Path path); ~DirectoryGuard(); private: int _fd; diff --git a/filedistribution/src/vespa/filedistribution/model/filedistributionmodel.h b/filedistribution/src/vespa/filedistribution/model/filedistributionmodel.h index 3b4e3784de5..32485b60159 100644 --- a/filedistribution/src/vespa/filedistribution/model/filedistributionmodel.h +++ b/filedistribution/src/vespa/filedistribution/model/filedistributionmodel.h @@ -6,7 +6,6 @@ #include <string> #include <set> -#include <boost/filesystem/path.hpp> #include <boost/signals2.hpp> #include <libtorrent/peer.hpp> diff --git a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h index 224009822e1..0c89e8b12ae 100644 --- a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h +++ b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h @@ -30,7 +30,7 @@ class FileDistributionModelImpl : public FileDistributionModel, bool /*changed*/ updateActiveFileReferences(const std::vector<vespalib::string>& fileReferences); - ZKFacade::Path getPeerEntryPath(const std::string& fileReference); + Path getPeerEntryPath(const std::string& fileReference); public: FileDistributionModelImpl(const std::string& hostName, int port, const std::shared_ptr<ZKFacade>& zk) :_hostName(hostName), diff --git a/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp b/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp index d90777455c2..f52b3a7e616 100644 --- a/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp +++ b/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp @@ -24,8 +24,7 @@ using filedistribution::Buffer; using filedistribution::ZKGenericException; using filedistribution::ZKException; using filedistribution::ZKLogging; - -typedef ZKFacade::Path Path; +using filedistribution::Path; namespace { diff --git a/filedistribution/src/vespa/filedistribution/model/zkfacade.h b/filedistribution/src/vespa/filedistribution/model/zkfacade.h index 08577483908..9197b33f64b 100644 --- a/filedistribution/src/vespa/filedistribution/model/zkfacade.h +++ b/filedistribution/src/vespa/filedistribution/model/zkfacade.h @@ -4,7 +4,6 @@ #include <string> #include <vector> #include <mutex> -#include <boost/filesystem/path.hpp> #include <boost/signals2.hpp> #include <vespa/filedistribution/common/buffer.h> @@ -70,7 +69,6 @@ public: }; typedef std::shared_ptr<NodeChangedWatcher> NodeChangedWatcherSP; - typedef boost::filesystem::path Path; ZKFacade(const ZKFacade &) = delete; ZKFacade & operator = (const ZKFacade &) = delete; diff --git a/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp b/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp index d7f0b91360f..a249aefd8e2 100644 --- a/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp +++ b/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp @@ -36,7 +36,7 @@ isEntryForHost(const std::string& host, const std::string& peerEntry) { } std::vector<std::string> -getSortedChildren(ZKFacade& zk, const ZKFileDBModel::Path& path) { +getSortedChildren(ZKFacade& zk, const Path& path) { std::vector<std::string> children = zk.getChildren(path); std::sort(children.begin(), children.end()); return children; @@ -47,9 +47,9 @@ getSortedChildren(ZKFacade& zk, const ZKFileDBModel::Path& path) { VESPA_IMPLEMENT_EXCEPTION(InvalidProgressException, vespalib::Exception); VESPA_IMPLEMENT_EXCEPTION(InvalidHostStatusException, vespalib::Exception); -const ZKFileDBModel::Path ZKFileDBModel::_root = "/vespa/filedistribution"; -const ZKFileDBModel::Path ZKFileDBModel::_fileDBPath = _root / "files"; -const ZKFileDBModel::Path ZKFileDBModel::_hostsPath = _root / "hosts"; +const Path ZKFileDBModel::_root = "/vespa/filedistribution"; +const Path ZKFileDBModel::_fileDBPath = _root / "files"; +const Path ZKFileDBModel::_hostsPath = _root / "hosts"; bool ZKFileDBModel::hasFile(const std::string& fileReference) { @@ -296,7 +296,7 @@ ZKFileDBModel::getProgress(const std::string& fileReference, FileDBModel::~FileDBModel() {} -DirectoryGuard::DirectoryGuard(boost::filesystem::path path) : +DirectoryGuard::DirectoryGuard(Path path) : _fd(-1) { _fd = open(path.c_str(), O_RDONLY); diff --git a/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.h b/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.h index fc3b088a385..7be2a383e7b 100644 --- a/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.h +++ b/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.h @@ -7,8 +7,6 @@ namespace filedistribution { class ZKFileDBModel : public FileDBModel { -public: - typedef boost::filesystem::path Path; private: const std::shared_ptr<ZKFacade> _zk; char getProgress(const Path& path); diff --git a/filedistribution/src/vespa/filedistribution/rpc/fileprovider.h b/filedistribution/src/vespa/filedistribution/rpc/fileprovider.h index 4eeeee5e359..513535db686 100644 --- a/filedistribution/src/vespa/filedistribution/rpc/fileprovider.h +++ b/filedistribution/src/vespa/filedistribution/rpc/fileprovider.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <vespa/filedistribution/common/exception.h> #include<boost/optional.hpp> -#include<boost/filesystem/path.hpp> #include<boost/signals2.hpp> namespace filedistribution { @@ -11,9 +11,7 @@ class FileProvider { public: using SP = std::shared_ptr<FileProvider>; - typedef boost::signals2::signal<void (const std::string& /* fileReference */, - const boost::filesystem::path&)> - DownloadCompletedSignal; + typedef boost::signals2::signal<void (const std::string& /* fileReference */, const Path&)> DownloadCompletedSignal; typedef DownloadCompletedSignal::slot_type DownloadCompletedHandler; enum FailedDownloadReason { @@ -21,12 +19,10 @@ public: FileReferenceRemoved }; - typedef boost::signals2::signal<void (const std::string& /* fileReference */, - FailedDownloadReason)> - DownloadFailedSignal; + typedef boost::signals2::signal<void (const std::string& /* fileReference */, FailedDownloadReason)> DownloadFailedSignal; typedef DownloadFailedSignal::slot_type DownloadFailedHandler; - virtual boost::optional<boost::filesystem::path> getPath(const std::string& fileReference) = 0; + virtual boost::optional<Path> getPath(const std::string& fileReference) = 0; virtual void downloadFile(const std::string& fileReference) = 0; virtual ~FileProvider() {} |