Renamed resource provider `AgentRegistrar` to `GenericRegistrar`. This registrar and its matching process can work on generic storage and it is currently used to work on an agent's persist store.
Its name should not be tied to the agent, so we rename the registrar in this patch. Review: https://reviews.apache.org/r/66526/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e286bbf2 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e286bbf2 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e286bbf2 Branch: refs/heads/master Commit: e286bbf258fa6d5434f8c504a03abc862dd87f62 Parents: 3f0cd11 Author: Benjamin Bannier <[email protected]> Authored: Tue May 1 13:09:05 2018 -0700 Committer: Chun-Hung Hsiao <[email protected]> Committed: Tue May 1 13:09:05 2018 -0700 ---------------------------------------------------------------------- src/resource_provider/registrar.cpp | 35 +++++++++++----------- src/resource_provider/registrar.hpp | 10 +++---- src/tests/resource_provider_manager_tests.cpp | 4 +-- 3 files changed, 25 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/e286bbf2/src/resource_provider/registrar.cpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/registrar.cpp b/src/resource_provider/registrar.cpp index dbb55dd..53b403e 100644 --- a/src/resource_provider/registrar.cpp +++ b/src/resource_provider/registrar.cpp @@ -88,7 +88,7 @@ bool Registrar::Operation::set() Try<Owned<Registrar>> Registrar::create(Owned<Storage> storage) { - return new AgentRegistrar(std::move(storage)); + return new GenericRegistrar(std::move(storage)); } @@ -145,10 +145,10 @@ Try<bool> RemoveResourceProvider::perform(Registry* registry) } -class AgentRegistrarProcess : public Process<AgentRegistrarProcess> +class GenericRegistrarProcess : public Process<GenericRegistrarProcess> { public: - AgentRegistrarProcess(Owned<Storage> storage); + GenericRegistrarProcess(Owned<Storage> storage); Future<Nothing> recover(); @@ -182,13 +182,13 @@ private: }; -AgentRegistrarProcess::AgentRegistrarProcess(Owned<Storage> _storage) - : ProcessBase(process::ID::generate("resource-provider-agent-registrar")), +GenericRegistrarProcess::GenericRegistrarProcess(Owned<Storage> _storage) + : ProcessBase(process::ID::generate("resource-provider-generic-registrar")), storage(std::move(_storage)), state(storage.get()) {} -Future<Nothing> AgentRegistrarProcess::recover() +Future<Nothing> GenericRegistrarProcess::recover() { constexpr char NAME[] = "RESOURCE_PROVIDER_REGISTRAR"; @@ -206,7 +206,8 @@ Future<Nothing> AgentRegistrarProcess::recover() } -Future<bool> AgentRegistrarProcess::apply(Owned<Registrar::Operation> operation) +Future<bool> GenericRegistrarProcess::apply( + Owned<Registrar::Operation> operation) { if (recovered.isNone()) { return Failure("Attempted to apply the operation before recovering"); @@ -216,7 +217,7 @@ Future<bool> AgentRegistrarProcess::apply(Owned<Registrar::Operation> operation) } -Future<bool> AgentRegistrarProcess::_apply( +Future<bool> GenericRegistrarProcess::_apply( Owned<Registrar::Operation> operation) { if (error.isSome()) { @@ -234,7 +235,7 @@ Future<bool> AgentRegistrarProcess::_apply( } -void AgentRegistrarProcess::update() +void GenericRegistrarProcess::update() { CHECK(!updating); CHECK_NONE(error); @@ -275,7 +276,7 @@ void AgentRegistrarProcess::update() } -void AgentRegistrarProcess::_update( +void GenericRegistrarProcess::_update( const Future<Option<Variable<Registry>>>& store, const Registry& updatedRegistry, deque<Owned<Registrar::Operation>> applied) @@ -322,31 +323,31 @@ void AgentRegistrarProcess::_update( } -AgentRegistrar::AgentRegistrar(Owned<Storage> storage) - : process(new AgentRegistrarProcess(std::move(storage))) +GenericRegistrar::GenericRegistrar(Owned<Storage> storage) + : process(new GenericRegistrarProcess(std::move(storage))) { process::spawn(process.get(), false); } -AgentRegistrar::~AgentRegistrar() +GenericRegistrar::~GenericRegistrar() { process::terminate(*process); process::wait(*process); } -Future<Nothing> AgentRegistrar::recover() +Future<Nothing> GenericRegistrar::recover() { - return dispatch(process.get(), &AgentRegistrarProcess::recover); + return dispatch(process.get(), &GenericRegistrarProcess::recover); } -Future<bool> AgentRegistrar::apply(Owned<Operation> operation) +Future<bool> GenericRegistrar::apply(Owned<Operation> operation) { return dispatch( process.get(), - &AgentRegistrarProcess::apply, + &GenericRegistrarProcess::apply, std::move(operation)); } http://git-wip-us.apache.org/repos/asf/mesos/blob/e286bbf2/src/resource_provider/registrar.hpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/registrar.hpp b/src/resource_provider/registrar.hpp index 34cb166..3c10785 100644 --- a/src/resource_provider/registrar.hpp +++ b/src/resource_provider/registrar.hpp @@ -105,22 +105,22 @@ private: }; -class AgentRegistrarProcess; +class GenericRegistrarProcess; -class AgentRegistrar : public Registrar +class GenericRegistrar : public Registrar { public: - AgentRegistrar(process::Owned<state::Storage> storage); + GenericRegistrar(process::Owned<state::Storage> storage); - ~AgentRegistrar() override; + ~GenericRegistrar() override; process::Future<Nothing> recover() override; process::Future<bool> apply(process::Owned<Operation> operation) override; private: - std::unique_ptr<AgentRegistrarProcess> process; + std::unique_ptr<GenericRegistrarProcess> process; }; http://git-wip-us.apache.org/repos/asf/mesos/blob/e286bbf2/src/tests/resource_provider_manager_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/resource_provider_manager_tests.cpp b/src/tests/resource_provider_manager_tests.cpp index 72e8122..ceb7854 100644 --- a/src/tests/resource_provider_manager_tests.cpp +++ b/src/tests/resource_provider_manager_tests.cpp @@ -819,8 +819,8 @@ TEST_P(ResourceProviderManagerHttpApiTest, AgentEndpoint) class ResourceProviderRegistrarTest : public tests::MesosTest {}; -// Test that the agent resource provider registrar works as expected. -TEST_F(ResourceProviderRegistrarTest, AgentRegistrar) +// Test that the generic resource provider registrar works as expected. +TEST_F(ResourceProviderRegistrarTest, GenericRegistrar) { ResourceProviderID resourceProviderId; resourceProviderId.set_value("foo");
