1 | /******************************************************************** |
2 | * Copyright (c) 2013 - 2014, Pivotal Inc. |
3 | * All rights reserved. |
4 | * |
5 | * Author: Zhanwei Wang |
6 | ********************************************************************/ |
7 | /******************************************************************** |
8 | * 2014 - |
9 | * open source under Apache License Version 2.0 |
10 | ********************************************************************/ |
11 | /** |
12 | * Licensed to the Apache Software Foundation (ASF) under one |
13 | * or more contributor license agreements. See the NOTICE file |
14 | * distributed with this work for additional information |
15 | * regarding copyright ownership. The ASF licenses this file |
16 | * to you under the Apache License, Version 2.0 (the |
17 | * "License"); you may not use this file except in compliance |
18 | * with the License. You may obtain a copy of the License at |
19 | * |
20 | * http://www.apache.org/licenses/LICENSE-2.0 |
21 | * |
22 | * Unless required by applicable law or agreed to in writing, software |
23 | * distributed under the License is distributed on an "AS IS" BASIS, |
24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
25 | * See the License for the specific language governing permissions and |
26 | * limitations under the License. |
27 | */ |
28 | #ifndef _HDFS_LIBHDFS3_SERVER_NAMENODEIMPL_H_ |
29 | #define _HDFS_LIBHDFS3_SERVER_NAMENODEIMPL_H_ |
30 | |
31 | #include "Namenode.h" |
32 | |
33 | namespace Hdfs { |
34 | namespace Internal { |
35 | |
36 | class NamenodeImpl: public Namenode { |
37 | public: |
38 | NamenodeImpl(const char * host, const char * port, const std::string & tokenService, const SessionConfig & c, |
39 | const RpcAuth & a); |
40 | |
41 | ~NamenodeImpl(); |
42 | |
43 | //Idempotent |
44 | void getBlockLocations(const std::string & src, int64_t offset, |
45 | int64_t length, LocatedBlocks & lbs) /* throw (AccessControlException, |
46 | FileNotFoundException, UnresolvedLinkException, |
47 | HdfsIOException) */; |
48 | |
49 | void create(const std::string & src, const Permission & masked, |
50 | const std::string & clientName, int flag, bool createParent, |
51 | short replication, int64_t blockSize) /* throw (AccessControlException, |
52 | AlreadyBeingCreatedException, DSQuotaExceededException, |
53 | FileAlreadyExistsException, FileNotFoundException, |
54 | NSQuotaExceededException, ParentNotDirectoryException, |
55 | SafeModeException, UnresolvedLinkException, HdfsIOException) */; |
56 | |
57 | std::pair<shared_ptr<LocatedBlock>, shared_ptr<FileStatus> > append( |
58 | const std::string& src, const std::string& clientName) |
59 | /* throw (AccessControlException, |
60 | DSQuotaExceededException, FileNotFoundException, |
61 | SafeModeException, UnresolvedLinkException, HdfsIOException) */; |
62 | |
63 | //Idempotent |
64 | bool setReplication(const std::string & src, short replication) |
65 | /* throw (AccessControlException, DSQuotaExceededException, |
66 | FileNotFoundException, SafeModeException, UnresolvedLinkException, |
67 | HdfsIOException) */; |
68 | |
69 | //Idempotent |
70 | void setPermission(const std::string & src, const Permission & permission) |
71 | /* throw (AccessControlException, FileNotFoundException, |
72 | SafeModeException, UnresolvedLinkException, HdfsIOException) */; |
73 | |
74 | //Idempotent |
75 | void setOwner(const std::string & src, const std::string & username, |
76 | const std::string & groupname) /* throw (AccessControlException, |
77 | FileNotFoundException, SafeModeException, |
78 | UnresolvedLinkException, HdfsIOException) */; |
79 | |
80 | void abandonBlock(const ExtendedBlock & b, const std::string & src, |
81 | const std::string & holder) /* throw (AccessControlException, |
82 | FileNotFoundException, UnresolvedLinkException, |
83 | HdfsIOException) */; |
84 | |
85 | shared_ptr<LocatedBlock> addBlock(const std::string & src, const std::string & clientName, |
86 | const ExtendedBlock * previous, |
87 | const std::vector<DatanodeInfo> & excludeNodes) |
88 | /* throw (AccessControlException, FileNotFoundException, |
89 | NotReplicatedYetException, SafeModeException, |
90 | UnresolvedLinkException, HdfsIOException) */; |
91 | |
92 | //Idempotent |
93 | shared_ptr<LocatedBlock> getAdditionalDatanode(const std::string & src, |
94 | const ExtendedBlock & blk, |
95 | const std::vector<DatanodeInfo> & existings, |
96 | const std::vector<std::string> & storageIDs, |
97 | const std::vector<DatanodeInfo> & excludes, int numAdditionalNodes, |
98 | const std::string & clientName) |
99 | /* throw (AccessControlException, FileNotFoundException, |
100 | SafeModeException, UnresolvedLinkException, HdfsIOException) */; |
101 | |
102 | bool complete(const std::string & src, const std::string & clientName, |
103 | const ExtendedBlock * last) /* throw (AccessControlException, |
104 | FileNotFoundException, SafeModeException, |
105 | UnresolvedLinkException, HdfsIOException) */; |
106 | |
107 | //Idempotent |
108 | void reportBadBlocks(const std::vector<LocatedBlock> & blocks) |
109 | /* throw (HdfsIOException) */; |
110 | |
111 | bool rename(const std::string & src, const std::string & dst) |
112 | /* throw (UnresolvedLinkException, HdfsIOException) */; |
113 | |
114 | void concat(const std::string & trg, const std::vector<std::string> & srcs) |
115 | /* throw (HdfsIOException, UnresolvedLinkException) */; |
116 | |
117 | bool truncate(const std::string & src, int64_t size, |
118 | const std::string & clientName) |
119 | /* throw (HdfsIOException, UnresolvedLinkException) */; |
120 | |
121 | void getLease(const std::string & src, const std::string & clientName) |
122 | /* throw (HdfsIOException, UnresolvedLinkException) */; |
123 | |
124 | void releaseLease(const std::string & src, const std::string & clientName) |
125 | /* throw (HdfsIOException, UnresolvedLinkException) */; |
126 | |
127 | /*void rename2(const std::string & src, const std::string & dst) |
128 | throw (AccessControlException, DSQuotaExceededException, |
129 | FileAlreadyExistsException, FileNotFoundException, |
130 | NSQuotaExceededException, ParentNotDirectoryException, |
131 | SafeModeException, UnresolvedLinkException, HdfsIOException) ;*/ |
132 | |
133 | bool deleteFile(const std::string & src, bool recursive) |
134 | /* throw (AccessControlException, FileNotFoundException, |
135 | SafeModeException, UnresolvedLinkException, HdfsIOException) */; |
136 | |
137 | //Idempotent |
138 | bool mkdirs(const std::string & src, const Permission & masked, |
139 | bool createParent) /* throw (AccessControlException, |
140 | FileAlreadyExistsException, FileNotFoundException, |
141 | NSQuotaExceededException, ParentNotDirectoryException, |
142 | SafeModeException, UnresolvedLinkException, HdfsIOException) */; |
143 | |
144 | //Idempotent |
145 | bool getListing(const std::string & src, const std::string & startAfter, |
146 | bool needLocation, std::vector<FileStatus> & dl) |
147 | /* throw (AccessControlException, FileNotFoundException, |
148 | UnresolvedLinkException, HdfsIOException) */; |
149 | |
150 | //Idempotent |
151 | void renewLease(const std::string & clientName) |
152 | /* throw (AccessControlException, HdfsIOException) */; |
153 | |
154 | //Idempotent |
155 | bool recoverLease(const std::string & src, const std::string & clientName) |
156 | /* throw (HdfsIOException) */; |
157 | |
158 | //Idempotent |
159 | std::vector<int64_t> getFsStats() /* throw (HdfsIOException) */; |
160 | |
161 | void metaSave(const std::string & filename) /* throw (HdfsIOException) */; |
162 | |
163 | //Idempotent |
164 | FileStatus getFileInfo(const std::string & src) |
165 | /* throw (AccessControlException, FileNotFoundException, |
166 | UnresolvedLinkException, HdfsIOException) */; |
167 | |
168 | //Idempotent |
169 | FileStatus getFileLinkInfo(const std::string & src) |
170 | /* throw (AccessControlException, UnresolvedLinkException, |
171 | HdfsIOException) */; |
172 | |
173 | /* //Idempotent |
174 | ContentSummary getContentSummary(const std::string & path) |
175 | throw (AccessControlException, FileNotFoundException, |
176 | UnresolvedLinkException, HdfsIOException) ;*/ |
177 | |
178 | //Idempotent |
179 | void setQuota(const std::string & path, int64_t namespaceQuota, |
180 | int64_t diskspaceQuota) /* throw (AccessControlException, |
181 | FileNotFoundException, UnresolvedLinkException, |
182 | HdfsIOException) */; |
183 | |
184 | //Idempotent |
185 | void fsync(const std::string & src, const std::string & client) |
186 | /* throw (AccessControlException, FileNotFoundException, |
187 | UnresolvedLinkException, HdfsIOException) */; |
188 | |
189 | //Idempotent |
190 | void setTimes(const std::string & src, int64_t mtime, int64_t atime) |
191 | /* throw (AccessControlException, FileNotFoundException, |
192 | UnresolvedLinkException, HdfsIOException) */; |
193 | |
194 | void createSymlink(const std::string & target, const std::string & link, |
195 | const Permission & dirPerm, bool createParent) |
196 | /* throw (AccessControlException, FileAlreadyExistsException, |
197 | FileNotFoundException, ParentNotDirectoryException, |
198 | SafeModeException, UnresolvedLinkException, HdfsIOException) */; |
199 | |
200 | //Idempotent |
201 | std::string getLinkTarget(const std::string & path) |
202 | /* throw (AccessControlException, FileNotFoundException, |
203 | HdfsIOException) */; |
204 | |
205 | //Idempotent |
206 | shared_ptr<LocatedBlock> updateBlockForPipeline(const ExtendedBlock & block, |
207 | const std::string & clientName) |
208 | /* throw (HdfsIOException) */; |
209 | |
210 | void updatePipeline(const std::string & clientName, |
211 | const ExtendedBlock & oldBlock, const ExtendedBlock & newBlock, |
212 | const std::vector<DatanodeInfo> & newNodes, |
213 | const std::vector<std::string> & storageIDs) /* throw (HdfsIOException) */; |
214 | |
215 | //Idempotent |
216 | Token getDelegationToken(const std::string & renewer) |
217 | /* throws IOException*/; |
218 | |
219 | //Idempotent |
220 | int64_t renewDelegationToken(const Token & token) |
221 | /*throws IOException*/; |
222 | |
223 | //Idempotent |
224 | void cancelDelegationToken(const Token & token) |
225 | /*throws IOException*/; |
226 | |
227 | private: |
228 | void invoke(const RpcCall & call); |
229 | |
230 | private: |
231 | RpcAuth auth; |
232 | RpcClient & client; |
233 | RpcConfig conf; |
234 | RpcProtocolInfo protocol; |
235 | RpcServerInfo server; |
236 | |
237 | }; |
238 | |
239 | } |
240 | } |
241 | |
242 | #endif /* _HDFS_LIBHDFS3_SERVER_NAMENODEIMPL_H_ */ |
243 | |