Apache Mesos
hdfs.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 __HDFS_HPP__
18 #define __HDFS_HPP__
19 
20 #include <string>
21 
22 #include <process/future.hpp>
23 #include <process/owned.hpp>
24 
25 #include <stout/bytes.hpp>
26 #include <stout/none.hpp>
27 #include <stout/nothing.hpp>
28 #include <stout/option.hpp>
29 #include <stout/try.hpp>
30 
31 
32 // TODO(benh): We should get the hostname:port (or ip:port) of the
33 // server via:
34 //
35 // hadoop dfsadmin -report | grep Name: | awk '{ print $2 }'
36 //
37 // The advantage of doing this is then we can explicitly use the
38 // 'hdfs://hostname' prefix when we're trying to do copies to avoid
39 // silent failures when HDFS is down and the tools just copies
40 // locally.
41 //
42 // Note that if HDFS is not on port 9000 then we'll also need to do an
43 // HTTP GET on hostname:port and grab the information in the
44 // <title>...</title> (this is the best hack I can think of to get
45 // 'fs.default.name' given the tools available).
46 class HDFS
47 {
48 public:
50  const Option<std::string>& hadoop = None());
51 
52  process::Future<bool> exists(const std::string& path);
53  process::Future<Bytes> du(const std::string& path);
54  process::Future<Nothing> rm(const std::string& path);
55 
57  const std::string& from,
58  const std::string& to);
59 
61  const std::string& from,
62  const std::string& to);
63 
64 private:
65  explicit HDFS(const std::string& _hadoop)
66  : hadoop(_hadoop) {}
67 
68  const std::string hadoop;
69 };
70 
71 #endif // __HDFS_HPP__
Definition: try.hpp:34
Definition: hdfs.hpp:46
process::Future< Nothing > copyFromLocal(const std::string &from, const std::string &to)
process::Future< Nothing > copyToLocal(const std::string &from, const std::string &to)
process::Future< Nothing > rm(const std::string &path)
process::Future< Bytes > du(const std::string &path)
process::Future< bool > exists(const std::string &path)
Definition: none.hpp:27
static Try< process::Owned< HDFS > > create(const Option< std::string > &hadoop=None())