Apache Mesos
fetcher.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __MESOS_URI_FETCHER_HPP__
18 #define __MESOS_URI_FETCHER_HPP__
19 
20 #include <set>
21 #include <string>
22 #include <vector>
23 
24 #include <mesos/mesos.hpp>
25 
26 #include <process/future.hpp>
27 #include <process/owned.hpp>
28 #include <process/shared.hpp>
29 
30 #include <stout/hashmap.hpp>
31 #include <stout/nothing.hpp>
32 
33 #include <mesos/uri/uri.hpp>
34 
35 namespace mesos {
36 namespace uri {
37 
38 
46 class Fetcher
47 {
48 public:
52  class Plugin
53  {
54  public:
55  virtual ~Plugin() {}
56 
60  virtual std::set<std::string> schemes() const = 0;
61 
65  virtual std::string name() const = 0;
66 
77  // TODO(gilbert): Change the parameter 'data' as a hashmap
78  // of <string, Secret::Value>, and update the comment.
80  const URI& uri,
81  const std::string& directory,
82  const Option<std::string>& data = None(),
83  const Option<std::string>& outputFileName = None()) const = 0;
84  };
85 
91  Fetcher(const std::vector<process::Owned<Plugin>>& plugins);
92 
102  // TODO(jieyu): Consider using 'Path' for 'directory' here.
104  const URI& uri,
105  const std::string& directory,
106  const Option<std::string>& data = None(),
107  const Option<std::string>& outputFileName = None()) const;
108 
120  const URI& uri,
121  const std::string& directory,
122  const std::string& name,
123  const Option<std::string>& data = None(),
124  const Option<std::string>& outputFileName = None()) const;
125 
126 private:
127  Fetcher(const Fetcher&) = delete; // Not copyable.
128  Fetcher& operator=(const Fetcher&) = delete; // Not assignable.
129 
132 };
133 
134 } // namespace uri {
135 } // namespace mesos {
136 
137 #endif // __MESOS_URI_FETCHER_HPP__
Fetcher(const std::vector< process::Owned< Plugin >> &plugins)
Create the Fetcher instance with the given plugins.
Definition: hashmap.hpp:38
Definition: agent.hpp:25
virtual ~Plugin()
Definition: fetcher.hpp:55
Definition: none.hpp:27
virtual std::set< std::string > schemes() const =0
Returns the URI schemes that this plugin handles.
Provides an abstraction for fetching URIs.
Definition: fetcher.hpp:46
Definition: uri.hpp:21
Definition: owned.hpp:36
virtual std::string name() const =0
Returns the name that this plugin registered with.
virtual process::Future< Nothing > fetch(const URI &uri, const std::string &directory, const Option< std::string > &data=None(), const Option< std::string > &outputFileName=None()) const =0
Fetches a URI to the given directory.
Represents a fetcher plugin that handles one or more URI schemes.
Definition: fetcher.hpp:52