diff options
| author | Per Larsson <[email protected]> | 2021-09-17 13:11:04 +0200 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-09-17 13:11:04 +0200 |
| commit | d812fcc3eab88733cbef084eefd089d22177aae4 (patch) | |
| tree | bb64fa6c64f9707246577de148749b35d1e25987 /zen | |
| parent | Added helper function for iterating string tokens. (diff) | |
| parent | Added namespace scopes to more includes for better consistency (diff) | |
| download | archived-zen-d812fcc3eab88733cbef084eefd089d22177aae4.tar.xz archived-zen-d812fcc3eab88733cbef084eefd089d22177aae4.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zen')
| -rw-r--r-- | zen/cmds/cache.cpp | 2 | ||||
| -rw-r--r-- | zen/cmds/copy.cpp | 4 | ||||
| -rw-r--r-- | zen/cmds/copy.h | 4 | ||||
| -rw-r--r-- | zen/cmds/dedup.cpp | 4 | ||||
| -rw-r--r-- | zen/cmds/dedup.h | 4 | ||||
| -rw-r--r-- | zen/cmds/deploy.cpp | 4 | ||||
| -rw-r--r-- | zen/cmds/deploy.h | 4 | ||||
| -rw-r--r-- | zen/cmds/hash.cpp | 4 | ||||
| -rw-r--r-- | zen/cmds/hash.h | 4 | ||||
| -rw-r--r-- | zen/cmds/run.cpp | 6 | ||||
| -rw-r--r-- | zen/cmds/run.h | 5 | ||||
| -rw-r--r-- | zen/cmds/scrub.cpp | 23 | ||||
| -rw-r--r-- | zen/cmds/scrub.h | 20 | ||||
| -rw-r--r-- | zen/cmds/status.cpp | 5 | ||||
| -rw-r--r-- | zen/cmds/status.h | 4 | ||||
| -rw-r--r-- | zen/cmds/top.cpp | 26 | ||||
| -rw-r--r-- | zen/cmds/top.h | 4 | ||||
| -rw-r--r-- | zen/cmds/up.cpp | 6 | ||||
| -rw-r--r-- | zen/cmds/up.h | 4 | ||||
| -rw-r--r-- | zen/zen.cpp | 50 |
20 files changed, 145 insertions, 42 deletions
diff --git a/zen/cmds/cache.cpp b/zen/cmds/cache.cpp index 69e500293..202bf9246 100644 --- a/zen/cmds/cache.cpp +++ b/zen/cmds/cache.cpp @@ -5,7 +5,7 @@ #include <zencore/filesystem.h> #include <zencore/logging.h> #include <zenhttp/httpcommon.h> -#include <zenserverprocess.h> +#include <zenutil/zenserverprocess.h> #include <memory> diff --git a/zen/cmds/copy.cpp b/zen/cmds/copy.cpp index 4ce09c982..6b3965f99 100644 --- a/zen/cmds/copy.cpp +++ b/zen/cmds/copy.cpp @@ -7,6 +7,8 @@ #include <zencore/string.h> #include <zencore/timer.h> +namespace zen { + CopyCommand::CopyCommand() { m_Options.add_options()("h,help", "Print help"); @@ -94,3 +96,5 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} diff --git a/zen/cmds/copy.h b/zen/cmds/copy.h index 22b240d11..c2a7fd23b 100644 --- a/zen/cmds/copy.h +++ b/zen/cmds/copy.h @@ -4,6 +4,8 @@ #include "../zen.h" +namespace zen { + /** Copy files, possibly using block cloning */ class CopyCommand : public ZenCmdBase @@ -22,3 +24,5 @@ private: std::string m_CopyTarget; bool m_NoClone = false; }; + +} diff --git a/zen/cmds/dedup.cpp b/zen/cmds/dedup.cpp index 90a4fea76..f95a87518 100644 --- a/zen/cmds/dedup.cpp +++ b/zen/cmds/dedup.cpp @@ -12,6 +12,8 @@ #include <ppl.h> +namespace zen { + DedupCommand::DedupCommand() { m_Options.add_options()("h,help", "Print help"); @@ -290,3 +292,5 @@ DedupCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} diff --git a/zen/cmds/dedup.h b/zen/cmds/dedup.h index 0f0aecc8e..c955d4bbd 100644 --- a/zen/cmds/dedup.h +++ b/zen/cmds/dedup.h @@ -6,6 +6,8 @@ #include <ppl.h> +namespace zen { + /** Deduplicate files in a tree using block cloning */ class DedupCommand : public ZenCmdBase @@ -24,3 +26,5 @@ private: std::string m_DedupTarget; size_t m_SizeThreshold = 1024 * 1024; }; + +} diff --git a/zen/cmds/deploy.cpp b/zen/cmds/deploy.cpp index b8879fefb..faaf0030c 100644 --- a/zen/cmds/deploy.cpp +++ b/zen/cmds/deploy.cpp @@ -5,6 +5,8 @@ #include <zencore/logging.h> #include <zencore/string.h> +namespace zen { + DeployCommand::DeployCommand() { m_Options.add_options()("h,help", "Print help"); @@ -80,3 +82,5 @@ DeployCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} diff --git a/zen/cmds/deploy.h b/zen/cmds/deploy.h index 1109aaf17..565e11bf3 100644 --- a/zen/cmds/deploy.h +++ b/zen/cmds/deploy.h @@ -4,6 +4,8 @@ #include "../zen.h" +namespace zen { + /** Deploy files from Zen build store */ class DeployCommand : public ZenCmdBase @@ -23,3 +25,5 @@ private: bool m_NoClone = false; bool m_IsClean = false; }; + +} diff --git a/zen/cmds/hash.cpp b/zen/cmds/hash.cpp index b6276dbc1..e9484c453 100644 --- a/zen/cmds/hash.cpp +++ b/zen/cmds/hash.cpp @@ -9,6 +9,8 @@ #include <ppl.h> +namespace zen { + HashCommand::HashCommand() { m_Options.add_options()("d,dir", "Directory to scan", cxxopts::value<std::string>(m_ScanDirectory))( @@ -123,3 +125,5 @@ HashCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) // TODO: implement snapshot enumeration and display return 0; } + +} diff --git a/zen/cmds/hash.h b/zen/cmds/hash.h index b994b497d..8ed8e9fa3 100644 --- a/zen/cmds/hash.h +++ b/zen/cmds/hash.h @@ -7,6 +7,8 @@ #include <ppl.h> +namespace zen { + /** Generate hash list file */ class HashCommand : public ZenCmdBase @@ -23,3 +25,5 @@ private: std::string m_ScanDirectory; std::string m_OutputFile; }; + +} diff --git a/zen/cmds/run.cpp b/zen/cmds/run.cpp index e5210f695..711a3a341 100644 --- a/zen/cmds/run.cpp +++ b/zen/cmds/run.cpp @@ -12,7 +12,7 @@ #include <zencore/logging.h> #include <zencore/string.h> #include <zencore/timer.h> -#include <zenserverprocess.h> +#include <zenutil/zenserverprocess.h> #include <filesystem> @@ -35,6 +35,8 @@ ////////////////////////////////////////////////////////////////////////// +namespace zen { + using namespace std::literals; RunCommand::RunCommand() @@ -181,3 +183,5 @@ RunCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} diff --git a/zen/cmds/run.h b/zen/cmds/run.h index 8fa1f6ae9..f4eb4ef76 100644 --- a/zen/cmds/run.h +++ b/zen/cmds/run.h @@ -2,10 +2,9 @@ #pragma once -#include "../internalfile.h" #include "../zen.h" -#include <ppl.h> +namespace zen { /** Execute a command (using Zen) */ @@ -23,3 +22,5 @@ private: std::string m_TargetHost; std::string m_ExeTree; }; + +} diff --git a/zen/cmds/scrub.cpp b/zen/cmds/scrub.cpp index a9b8505ec..73d2b45ee 100644 --- a/zen/cmds/scrub.cpp +++ b/zen/cmds/scrub.cpp @@ -1,9 +1,12 @@ // Copyright Epic Games, Inc. All Rights Reserved. #include "scrub.h" +#include <zenutil/zenserverprocess.h> using namespace std::literals; +namespace zen { + ScrubCommand::ScrubCommand() { } @@ -17,3 +20,23 @@ ScrubCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +////////////////////////////////////////////////////////////////////////// + +GcCommand::GcCommand() +{ +} + +GcCommand::~GcCommand() +{ +} + +int +GcCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) +{ + ZEN_UNUSED(GlobalOptions, argc, argv); + + return 0; +} + +} diff --git a/zen/cmds/scrub.h b/zen/cmds/scrub.h index 1bfb4ad6c..a3f25c259 100644 --- a/zen/cmds/scrub.h +++ b/zen/cmds/scrub.h @@ -2,10 +2,9 @@ #pragma once -#include "../internalfile.h" #include "../zen.h" -#include <ppl.h> +namespace zen { /** Scrub storage */ @@ -21,3 +20,20 @@ public: private: cxxopts::Options m_Options{"scrub", "Scrub zen storage"}; }; + +/** Garbage collect storage + */ +class GcCommand : public ZenCmdBase +{ +public: + GcCommand(); + ~GcCommand(); + + virtual int Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override; + virtual cxxopts::Options* Options() override { return &m_Options; } + +private: + cxxopts::Options m_Options{"gc", "Garbage collect zen storage"}; +}; + +} diff --git a/zen/cmds/status.cpp b/zen/cmds/status.cpp index 6741ab9e9..1050b5b96 100644 --- a/zen/cmds/status.cpp +++ b/zen/cmds/status.cpp @@ -3,7 +3,8 @@ #include "status.h" #include <zencore/logging.h> -#include <memory> + +namespace zen { StatusCommand::StatusCommand() { @@ -18,3 +19,5 @@ StatusCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} diff --git a/zen/cmds/status.h b/zen/cmds/status.h index bb439f340..f2c68b96a 100644 --- a/zen/cmds/status.h +++ b/zen/cmds/status.h @@ -4,6 +4,8 @@ #include "../zen.h" +namespace zen { + class StatusCommand : public ZenCmdBase { public: @@ -16,3 +18,5 @@ public: private: cxxopts::Options m_Options{"status", "Show zen status"}; }; + +} diff --git a/zen/cmds/top.cpp b/zen/cmds/top.cpp index b0d684705..3ff7edcda 100644 --- a/zen/cmds/top.cpp +++ b/zen/cmds/top.cpp @@ -3,12 +3,16 @@ #include "top.h" #include <zencore/logging.h> -#include <zenserverprocess.h> +#include <zencore/uid.h> +#include <zencore/fmtutils.h> +#include <zenutil/zenserverprocess.h> #include <memory> ////////////////////////////////////////////////////////////////////////// +namespace zen { + TopCommand::TopCommand() { } @@ -28,7 +32,23 @@ TopCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } - State.Snapshot([&](const ZenServerState::ZenServerEntry& Entry) { ZEN_INFO("Port {} : pid {}", Entry.ListenPort, Entry.Pid); }); + int n = 0; + const int HeaderPeriod = 20; + + for (;;) + { + if ((n++ % HeaderPeriod) == 0) + { + ZEN_CONSOLE("{:>5} {:>6} {:>24}", "port", "pid", "session"); + } + + State.Snapshot([&](const ZenServerState::ZenServerEntry& Entry) { ZEN_CONSOLE("{:5} {:6} {:24}", Entry.ListenPort, Entry.Pid, Entry.GetSessionId()); }); + + zen::Sleep(1000); + + State.Sweep(); + } + return 0; } @@ -58,3 +78,5 @@ PsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} diff --git a/zen/cmds/top.h b/zen/cmds/top.h index 32ba6c57b..a842089ff 100644 --- a/zen/cmds/top.h +++ b/zen/cmds/top.h @@ -4,6 +4,8 @@ #include "../zen.h" +namespace zen { + class TopCommand : public ZenCmdBase { public: @@ -29,3 +31,5 @@ public: private: cxxopts::Options m_Options{"ps", "Enumerate running Zen server instances"}; }; + +} diff --git a/zen/cmds/up.cpp b/zen/cmds/up.cpp index a1047fd57..048133fc9 100644 --- a/zen/cmds/up.cpp +++ b/zen/cmds/up.cpp @@ -4,10 +4,12 @@ #include <zencore/filesystem.h> #include <zencore/logging.h> -#include <zenserverprocess.h> +#include <zenutil/zenserverprocess.h> #include <memory> +namespace zen { + UpCommand::UpCommand() { } @@ -98,3 +100,5 @@ DownCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} diff --git a/zen/cmds/up.h b/zen/cmds/up.h index a3c6eaa06..fda62693a 100644 --- a/zen/cmds/up.h +++ b/zen/cmds/up.h @@ -4,6 +4,8 @@ #include "../zen.h" +namespace zen { + class UpCommand : public ZenCmdBase { public: @@ -29,3 +31,5 @@ public: private: cxxopts::Options m_Options{"down", "Bring down zen service"}; }; + +} diff --git a/zen/zen.cpp b/zen/zen.cpp index d8bfa13e5..6390c832f 100644 --- a/zen/zen.cpp +++ b/zen/zen.cpp @@ -42,6 +42,7 @@ ////////////////////////////////////////////////////////////////////////// + class TemplateCommand : public ZenCmdBase { public: @@ -94,29 +95,12 @@ private: int main(int argc, char** argv) { + using namespace zen; + mi_version(); zen::logging::InitializeLogging(); -#if TEST_UWS - /* Overly simple hello world app, using multiple threads */ - std::vector<std::thread*> threads(4); - - std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread* /*t*/) { - return new std::thread([]() { - uWS::App() - .get("/*", - [&](uWS::HttpResponse<false>* res, uWS::HttpRequest*) { - zen::Sleep(1); - res->end("hello, world!"); - }) - .listen(1337, [&](auto* listen_socket) { ZEN_UNUSED(listen_socket); }) - .run(); - }); - }); - - std::for_each(threads.begin(), threads.end(), [](std::thread* t) { t->join(); }); -#endif ////////////////////////////////////////////////////////////////////////// auto _ = zen::MakeGuard([] { spdlog::shutdown(); }); @@ -141,19 +125,21 @@ main(int argc, char** argv) ZenCmdBase* Cmd; const char* CmdSummary; } Commands[] = { - {"chunk", &ChunkCmd, "Perform chunking"}, - {"copy", &CopyCmd, "Copy file(s)"}, - {"deploy", &DeployCmd, "Deploy data"}, - {"dedup", &DedupCmd, "Dedup files"}, - {"drop", &DropCmd, "Drop cache bucket(s)"}, - {"hash", &HashCmd, "Compute file hashes"}, - {"runtests", &RunTestsCmd, "Run zen tests"}, - {"run", &RunCmd, "Remote execution"}, - {"status", &StatusCmd, "Show zen status"}, - {"ps", &PsCmd, "Enumerate running zen server instances"}, - {"top", &TopCmd, "Monitor zen server activity"}, - {"up", &UpCmd, "Bring zen server up"}, - {"down", &DownCmd, "Bring zen server down"}, + // clang-format off + {"chunk", &ChunkCmd, "Perform chunking"}, + {"copy", &CopyCmd, "Copy file(s)"}, + {"deploy", &DeployCmd, "Deploy data"}, + {"dedup", &DedupCmd, "Dedup files"}, + {"drop", &DropCmd, "Drop cache bucket(s)"}, + {"hash", &HashCmd, "Compute file hashes"}, + {"runtests", &RunTestsCmd, "Run zen tests"}, + {"run", &RunCmd, "Remote execution"}, + {"status", &StatusCmd, "Show zen status"}, + {"ps", &PsCmd, "Enumerate running zen server instances"}, + {"top", &TopCmd, "Monitor zen server activity"}, + {"up", &UpCmd, "Bring zen server up"}, + {"down", &DownCmd, "Bring zen server down"}, + // clang-format on }; // Build set containing available commands |