You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/06/30 18:41:41 UTC
[07/13] mesos git commit: Added stubs for the ResourceProviderManager.
Added stubs for the ResourceProviderManager.
ResourceProviderManager will be used to manage resource providers,
both local and external. It'll be used by the agent to manage local
resource providers and used by the master to manage external resource
providers. It'll expose an API endpoint allowing resource providers to
subscribe to the manager.
Review: https://reviews.apache.org/r/59934
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/17c563e4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/17c563e4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/17c563e4
Branch: refs/heads/master
Commit: 17c563e455b13bfd9dd371f4f4643677163559a9
Parents: 89da4d5
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Jun 8 12:09:01 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jun 30 11:07:35 2017 -0700
----------------------------------------------------------------------
src/CMakeLists.txt | 1 +
src/Makefile.am | 2 +
src/resource_provider/manager.cpp | 90 ++++++++++++++++++++++++++++++++++
src/resource_provider/manager.hpp | 56 +++++++++++++++++++++
4 files changed, 149 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/17c563e4/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d5eb488..a1cc956 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -400,6 +400,7 @@ set(POSIX_SRC
set(RESOURCE_PROVIDER_SRC
resource_provider/driver.cpp
+ resource_provider/manager.cpp
resource_provider/storage/provider.cpp
)
http://git-wip-us.apache.org/repos/asf/mesos/blob/17c563e4/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index daf51d7..d64647a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -945,6 +945,7 @@ libmesos_no_3rdparty_la_SOURCES += \
oci/spec.cpp \
posix/rlimits.cpp \
resource_provider/driver.cpp \
+ resource_provider/manager.cpp \
resource_provider/storage/provider.cpp \
sched/sched.cpp \
scheduler/scheduler.cpp \
@@ -1079,6 +1080,7 @@ libmesos_no_3rdparty_la_SOURCES += \
messages/messages.hpp \
module/manager.hpp \
posix/rlimits.hpp \
+ resource_provider/manager.hpp \
resource_provider/storage/provider.hpp \
sched/constants.hpp \
sched/flags.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/17c563e4/src/resource_provider/manager.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/manager.cpp b/src/resource_provider/manager.cpp
new file mode 100644
index 0000000..1a6b107
--- /dev/null
+++ b/src/resource_provider/manager.cpp
@@ -0,0 +1,90 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "resource_provider/manager.hpp"
+
+#include <glog/logging.h>
+
+#include <process/dispatch.hpp>
+#include <process/id.hpp>
+#include <process/process.hpp>
+
+namespace http = process::http;
+
+using process::Failure;
+using process::Future;
+using process::Owned;
+using process::Process;
+using process::ProcessBase;
+
+using process::dispatch;
+using process::spawn;
+using process::terminate;
+using process::wait;
+
+using process::http::authentication::Principal;
+
+namespace mesos {
+namespace internal {
+
+class ResourceProviderManagerProcess
+ : public Process<ResourceProviderManagerProcess>
+{
+public:
+ ResourceProviderManagerProcess()
+ : ProcessBase(process::ID::generate("resource-provider-manager")) {}
+
+ Future<http::Response> api(
+ const http::Request& request,
+ const Option<Principal>& principal);
+};
+
+
+Future<http::Response> ResourceProviderManagerProcess::api(
+ const http::Request& request,
+ const Option<Principal>& principal)
+{
+ return Failure("Unimplemented");
+}
+
+
+ResourceProviderManager::ResourceProviderManager()
+ : process(new ResourceProviderManagerProcess())
+{
+ spawn(CHECK_NOTNULL(process.get()));
+}
+
+
+ResourceProviderManager::~ResourceProviderManager()
+{
+ terminate(process.get());
+ wait(process.get());
+}
+
+
+Future<http::Response> ResourceProviderManager::api(
+ const http::Request& request,
+ const Option<Principal>& principal) const
+{
+ return dispatch(
+ process.get(),
+ &ResourceProviderManagerProcess::api,
+ request,
+ principal);
+}
+
+} // namespace internal {
+} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/17c563e4/src/resource_provider/manager.hpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/manager.hpp b/src/resource_provider/manager.hpp
new file mode 100644
index 0000000..0bba75d
--- /dev/null
+++ b/src/resource_provider/manager.hpp
@@ -0,0 +1,56 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __RESOURCE_PROVIDER_MANAGER_HPP__
+#define __RESOURCE_PROVIDER_MANAGER_HPP__
+
+#include <process/authenticator.hpp>
+#include <process/future.hpp>
+#include <process/http.hpp>
+#include <process/owned.hpp>
+
+namespace mesos {
+namespace internal {
+
+// Forward declarations.
+class ResourceProviderManagerProcess;
+
+
+class ResourceProviderManager
+{
+public:
+ ResourceProviderManager();
+ ~ResourceProviderManager();
+
+ ResourceProviderManager(
+ const ResourceProviderManager& other) = delete;
+
+ ResourceProviderManager& operator=(
+ const ResourceProviderManager& other) = delete;
+
+ // The API endpoint handler.
+ process::Future<process::http::Response> api(
+ const process::http::Request& request,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+private:
+ process::Owned<ResourceProviderManagerProcess> process;
+};
+
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __RESOURCE_PROVIDER_MANAGER_HPP__