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_NAMENODE_H_
29#define _HDFS_LIBHDFS3_SERVER_NAMENODE_H_
30
31#include "client/FileStatus.h"
32#include "client/Permission.h"
33#include "DatanodeInfo.h"
34#include "Exception.h"
35#include "ExtendedBlock.h"
36#include "LocatedBlock.h"
37#include "LocatedBlocks.h"
38#include "rpc/RpcAuth.h"
39#include "rpc/RpcCall.h"
40#include "rpc/RpcClient.h"
41#include "rpc/RpcConfig.h"
42#include "rpc/RpcProtocolInfo.h"
43#include "rpc/RpcServerInfo.h"
44#include "SessionConfig.h"
45
46#include <vector>
47
48namespace Hdfs {
49namespace Internal {
50
51class Namenode {
52public:
53 /**
54 * Destroy the namenode.
55 */
56 virtual ~Namenode() {
57 }
58
59 /**
60 * Get locations of the blocks of the specified file within the specified range.
61 * DataNode locations for each block are sorted by
62 * the proximity to the client.
63 * <p>
64 * Return {//link LocatedBlocks} which contains
65 * file length, blocks and their locations.
66 * DataNode locations for each block are sorted by
67 * the distance to the client's address.
68 * <p>
69 * The client will then have to contact
70 * one of the indicated DataNodes to obtain the actual data.
71 *
72 * @param src file name
73 * @param offset range start offset
74 * @param length range length
75 * @param file length and array of blocks with their locations
76 * @param lbs output the returned blocks
77 *
78 * @throw AccessControlException If access is denied
79 * @throw FileNotFoundException If file <code>src</code> does not exist
80 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
81 * @throw HdfsIOException If an I/O error occurred
82 */
83 //Idempotent
84 virtual void getBlockLocations(const std::string & src, int64_t offset,
85 int64_t length, LocatedBlocks & lbs) /* throw (AccessControlException,
86 FileNotFoundException, UnresolvedLinkException,
87 HdfsIOException) */ = 0;
88
89 /**
90 * Create a new file entry in the namespace.
91 * <p>
92 * This will create an empty file specified by the source path.
93 * The path should reflect a full path originated at the root.
94 * The name-node does not have a notion of "current" directory for a client.
95 * <p>
96 * Once created, the file is visible and available for read to other clients.
97 * Although, other clients cannot {//link #delete(const std::string &, bool)}, re-create or
98 * {//link #rename(const std::string &, const std::string &)} it until the file is completed
99 * or explicitly as a result of lease expiration.
100 * <p>
101 * Blocks have a maximum size. Clients that intend to create
102 * multi-block files must also use
103 * {//link #addBlock(const std::string &, const std::string &, ExtendedBlock, DatanodeInfo[])}
104 *
105 * @param src path of the file being created.
106 * @param masked masked permission.
107 * @param clientName name of the current client.
108 * @param flag indicates whether the file should be
109 * overwritten if it already exists or create if it does not exist or append.
110 * @param createParent create missing parent directory if true
111 * @param replication block replication factor.
112 * @param blockSize maximum block size.
113 *
114 * @throw AccessControlException If access is denied
115 * @throw AlreadyBeingCreatedException if the path does not exist.
116 * @throw DSQuotaExceededException If file creation violates disk space
117 * quota restriction
118 * @throw FileAlreadyExistsException If file <code>src</code> already exists
119 * @throw FileNotFoundException If parent of <code>src</code> does not exist
120 * and <code>createParent</code> is false
121 * @throw ParentNotDirectoryException If parent of <code>src</code> is not a
122 * directory.
123 * @throw NSQuotaExceededException If file creation violates name space
124 * quota restriction
125 * @throw SafeModeException create not allowed in safemode
126 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
127 * @throw HdfsIOException If an I/O error occurred
128 *
129 * RuntimeExceptions:
130 * @throw InvalidPathException Path <code>src</code> is invalid
131 */
132 virtual void create(const std::string & src, const Permission & masked,
133 const std::string & clientName, int flag, bool createParent,
134 short replication, int64_t blockSize) /* throw (AccessControlException,
135 AlreadyBeingCreatedException, DSQuotaExceededException,
136 FileAlreadyExistsException, FileNotFoundException,
137 NSQuotaExceededException, ParentNotDirectoryException,
138 SafeModeException, UnresolvedLinkException, HdfsIOException) */ = 0;
139
140 /**
141 * Append to the end of the file.
142 * @param src path of the file being created.
143 * @param clientName name of the current client.
144 * @param information about the last partial block if any.
145 * @param lb output the returned block.s
146 *
147 * @throw AccessControlException if permission to append file is
148 * denied by the system. As usually on the client side the exception will
149 * be wrapped into {//link org.apache.hadoop.ipc.RemoteException}.
150 * Allows appending to an existing file if the server is
151 * configured with the parameter dfs.support.append set to true, otherwise
152 * throw an HdfsIOException.
153 *
154 * @throw AccessControlException If permission to append to file is denied
155 * @throw FileNotFoundException If file <code>src</code> is not found
156 * @throw DSQuotaExceededException If append violates disk space quota
157 * restriction
158 * @throw SafeModeException append not allowed in safemode
159 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
160 * @throw HdfsIOException If an I/O error occurred.
161 *
162 * RuntimeExceptions:
163 * @throw UnsupportedOperationException if append is not supported
164 */
165 virtual std::pair<shared_ptr<LocatedBlock>, shared_ptr<FileStatus>> append(
166 const std::string& src, const std::string& clientName)
167 /* throw (AccessControlException,
168 DSQuotaExceededException, FileNotFoundException,
169 SafeModeException, UnresolvedLinkException, HdfsIOException) */ = 0;
170
171 /**
172 * Set replication for an existing file.
173 * <p>
174 * The NameNode sets replication to the new value and returns.
175 * The actual block replication is not expected to be performed during
176 * this method call. The blocks will be populated or removed in the
177 * background as the result of the routine block maintenance procedures.
178 *
179 * @param src file name
180 * @param replication new replication
181 *
182 * @param true if successful) = 0;
183 * false if file does not exist or is a directory
184 *
185 * @throw AccessControlException If access is denied
186 * @throw DSQuotaExceededException If replication violates disk space
187 * quota restriction
188 * @throw FileNotFoundException If file <code>src</code> is not found
189 * @throw SafeModeException not allowed in safemode
190 * @throw UnresolvedLinkException if <code>src</code> contains a symlink
191 * @throw HdfsIOException If an I/O error occurred
192 */
193 //Idempotent
194 virtual bool setReplication(const std::string & src, short replication)
195 /* throw (AccessControlException, DSQuotaExceededException,
196 FileNotFoundException, SafeModeException, UnresolvedLinkException,
197 HdfsIOException) */ = 0;
198
199 /**
200 * Set permissions for an existing file/directory.
201 *
202 * @throw AccessControlException If access is denied
203 * @throw FileNotFoundException If file <code>src</code> is not found
204 * @throw SafeModeException not allowed in safemode
205 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
206 * @throw HdfsIOException If an I/O error occurred
207 */
208 //Idempotent
209 virtual void setPermission(const std::string & src,
210 const Permission & permission) /* throw (AccessControlException,
211 FileNotFoundException, SafeModeException,
212 UnresolvedLinkException, HdfsIOException) */ = 0;
213
214 /**
215 * Set Owner of a path (i.e. a file or a directory).
216 * The parameters username and groupname cannot both be null.
217 * @param src
218 * @param username If it is null, the original username remains unchanged.
219 * @param groupname If it is null, the original groupname remains unchanged.
220 *
221 * @throw AccessControlException If access is denied
222 * @throw FileNotFoundException If file <code>src</code> is not found
223 * @throw SafeModeException not allowed in safemode
224 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
225 * @throw HdfsIOException If an I/O error occurred
226 */
227 //Idempotent
228 virtual void setOwner(const std::string & src, const std::string & username,
229 const std::string & groupname) /* throw (AccessControlException,
230 FileNotFoundException, SafeModeException,
231 UnresolvedLinkException, HdfsIOException) */ = 0;
232
233 /**
234 * The client can give up on a block by calling abandonBlock().
235 * The client can then
236 * either obtain a new block, or complete or abandon the file.
237 * Any partial writes to the block will be discarded.
238 *
239 * @throw AccessControlException If access is denied
240 * @throw FileNotFoundException file <code>src</code> is not found
241 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
242 * @throw HdfsIOException If an I/O error occurred
243 */
244 virtual void abandonBlock(const ExtendedBlock & b, const std::string & src,
245 const std::string & holder) /* throw (AccessControlException,
246 FileNotFoundException, UnresolvedLinkException,
247 HdfsIOException) */ = 0;
248
249 /**
250 * A client that wants to write an additional block to the
251 * indicated filename (which must currently be open for writing)
252 * should call addBlock().
253 *
254 * addBlock() allocates a new block and datanodes the block data
255 * should be replicated to.
256 *
257 * addBlock() also commits the previous block by reporting
258 * to the name-node the actual generation stamp and the length
259 * of the block that the client has transmitted to data-nodes.
260 *
261 * @param src the file being created
262 * @param clientName the name of the client that adds the block
263 * @param previous previous block
264 * @param excludeNodes a list of nodes that should not be
265 * allocated for the current block
266 *
267 * @param LocatedBlock allocated block information.
268 * @param lb output the returned block.
269 *
270 * @throw AccessControlException If access is denied
271 * @throw FileNotFoundException If file <code>src</code> is not found
272 * @throw NotReplicatedYetException previous blocks of the file are not
273 * replicated yet. Blocks cannot be added until replication
274 * completes.
275 * @throw SafeModeException create not allowed in safemode
276 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
277 * @throw HdfsIOException If an I/O error occurred
278 */
279 virtual shared_ptr<LocatedBlock> addBlock(const std::string & src,
280 const std::string & clientName, const ExtendedBlock * previous,
281 const std::vector<DatanodeInfo> & excludeNodes)
282 /* throw (AccessControlException, FileNotFoundException,
283 NotReplicatedYetException, SafeModeException,
284 UnresolvedLinkException, HdfsIOException) */ = 0;
285
286 /**
287 * Get a datanode for an existing pipeline.
288 *
289 * @param src the file being written
290 * @param blk the block being written
291 * @param existings the existing nodes in the pipeline
292 * @param excludes the excluded nodes
293 * @param numAdditionalNodes number of additional datanodes
294 * @param clientName the name of the client
295 *
296 * @param the located block.
297 * @param output the returned block.
298 *
299 * @throw AccessControlException If access is denied
300 * @throw FileNotFoundException If file <code>src</code> is not found
301 * @throw SafeModeException create not allowed in safemode
302 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
303 * @throw HdfsIOException If an I/O error occurred
304 */
305 //Idempotent
306 virtual shared_ptr<LocatedBlock> getAdditionalDatanode(const std::string & src,
307 const ExtendedBlock & blk,
308 const std::vector<DatanodeInfo> & existings,
309 const std::vector<std::string> & storageIDs,
310 const std::vector<DatanodeInfo> & excludes, int numAdditionalNodes,
311 const std::string & clientName)
312 /* throw (AccessControlException, FileNotFoundException,
313 SafeModeException, UnresolvedLinkException, HdfsIOException) */ = 0;
314
315 /**
316 * The client is done writing data to the given filename, and would
317 * like to complete it.
318 *
319 * The function returns whether the file has been closed successfully.
320 * If the function returns false, the caller should try again.
321 *
322 * close() also commits the last block of file by reporting
323 * to the name-node the actual generation stamp and the length
324 * of the block that the client has transmitted to data-nodes.
325 *
326 * A call to complete() will not return true until all the file's
327 * blocks have been replicated the minimum number of times. Thus,
328 * DataNode failures may cause a client to call complete() several
329 * times before succeeding.
330 *
331 * @throw AccessControlException If access is denied
332 * @throw FileNotFoundException If file <code>src</code> is not found
333 * @throw SafeModeException create not allowed in safemode
334 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
335 * @throw HdfsIOException If an I/O error occurred
336 */
337 virtual bool complete(const std::string & src,
338 const std::string & clientName, const ExtendedBlock * last)
339 /* throw (AccessControlException, FileNotFoundException,
340 SafeModeException, UnresolvedLinkException, HdfsIOException) */ = 0;
341
342 /**
343 * The client wants to report corrupted blocks (blocks with specified
344 * locations on datanodes).
345 * @param blocks Array of located blocks to report
346 */
347 //Idempotent
348 /* virtual void reportBadBlocks(const std::vector<LocatedBlock> & blocks)
349 throw (HdfsIOException) = 0;*/
350
351 /**
352 * Rename an item in the file system namespace.
353 * @param src existing file or directory name.
354 * @param dst new name.
355 * @param true if successful, or false if the old name does not exist
356 * or if the new name already belongs to the namespace.
357 *
358 * @throw HdfsIOException an I/O error occurred
359 */
360 virtual bool rename(const std::string & src, const std::string & dst)
361 /* throw (UnresolvedLinkException, HdfsIOException) */ = 0;
362
363 /**
364 * Moves blocks from srcs to trg and delete srcs
365 *
366 * @param trg existing file
367 * @param srcs - list of existing files (same block size, same replication)
368 * @throw HdfsIOException if some arguments are invalid
369 * @throw UnresolvedLinkException if <code>trg</code> or <code>srcs</code>
370 * contains a symlink
371 */
372 /* virtual void concat(const std::string & trg,
373 const std::vector<std::string> & srcs) throw (HdfsIOException,
374 UnresolvedLinkException) = 0;*/
375
376 /**
377 * Truncate a file to the indicated length
378 *
379 * @param src existing file
380 * @param size the target size
381 * @param clientName name of the current client.
382 *
383 * @return true if and client does not need to wait for block recovery,
384 * false if client needs to wait for block recovery.
385 *
386 * @throws HdfsIOException if some arguments are invalid
387 * @throws UnresolvedLinkException if <code>f</code>
388 * contains a symlink
389 */
390 virtual bool truncate(const std::string & src, int64_t size,
391 const std::string & clientName)
392 /* throw (HdfsIOException, UnresolvedLinkException) */ = 0;
393
394 /**
395 * Get the lease of the indicated file.
396 *
397 * @param src existing file
398 * @param clientName name of the current client.
399 * @throws HdfsIOException if some arguments are invalid
400 * @throws UnresolvedLinkException if <code>f</code>
401 * contains a symlink
402 */
403 virtual void getLease(const std::string & src,
404 const std::string & clientName) /* throw (HdfsIOException,
405 UnresolvedLinkException) */ = 0;
406
407 /**
408 * Release the lease of the indicated file.
409 *
410 * @param src existing file
411 * @param clientName name of the current client.
412 * @throws HdfsIOException if some arguments are invalid
413 * @throws UnresolvedLinkException if <code>f</code>
414 * contains a symlink
415 */
416 virtual void releaseLease(const std::string & src,
417 const std::string & clientName) /* throw (HdfsIOException,
418 UnresolvedLinkException) */ = 0;
419
420 /**
421 * Rename src to dst.
422 * <ul>
423 * <li>Fails if src is a file and dst is a directory.
424 * <li>Fails if src is a directory and dst is a file.
425 * <li>Fails if the parent of dst does not exist or is a file.
426 * </ul>
427 * <p>
428 * Without OVERWRITE option, rename fails if the dst already exists.
429 * With OVERWRITE option, rename overwrites the dst, if it is a file
430 * or an empty directory. Rename fails if dst is a non-empty directory.
431 * <p>
432 * This implementation of rename is atomic.
433 * <p>
434 * @param src existing file or directory name.
435 * @param dst new name.
436 * @param options Rename options
437 *
438 * @throw AccessControlException If access is denied
439 * @throw DSQuotaExceededException If rename violates disk space
440 * quota restriction
441 * @throw FileAlreadyExistsException If <code>dst</code> already exists and
442 * <code>options</options> has {//link Rename#OVERWRITE} option
443 * false.
444 * @throw FileNotFoundException If <code>src</code> does not exist
445 * @throw NSQuotaExceededException If rename violates namespace
446 * quota restriction
447 * @throw ParentNotDirectoryException If parent of <code>dst</code>
448 * is not a directory
449 * @throw SafeModeException rename not allowed in safemode
450 * @throw UnresolvedLinkException If <code>src</code> or
451 * <code>dst</code> contains a symlink
452 * @throw HdfsIOException If an I/O error occurred
453 */
454 /*virtual void rename2(const std::string & src, const std::string & dst)
455 throw (AccessControlException, DSQuotaExceededException,
456 FileAlreadyExistsException, FileNotFoundException,
457 NSQuotaExceededException, ParentNotDirectoryException,
458 SafeModeException, UnresolvedLinkException, HdfsIOException) = 0;*/
459
460 /**
461 * Delete the given file or directory from the file system.
462 * <p>
463 * same as delete but provides a way to avoid accidentally
464 * deleting non empty directories programmatically.
465 * @param src existing name
466 * @param recursive if true deletes a non empty directory recursively,
467 * else throw( an exception.
468 * @param true only if the existing file or directory was actually removed
469 * from the file system.
470 *
471 * @throw AccessControlException If access is denied
472 * @throw FileNotFoundException If file <code>src</code> is not found
473 * @throw SafeModeException create not allowed in safemode
474 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
475 * @throw HdfsIOException If an I/O error occurred
476 */
477 virtual bool deleteFile(const std::string & src, bool recursive)
478 /* throw (AccessControlException, FileNotFoundException,
479 SafeModeException, UnresolvedLinkException, HdfsIOException) */ = 0;
480
481 /**
482 * Create a directory (or hierarchy of directories) with the given
483 * name and permission.
484 *
485 * @param src The path of the directory being created
486 * @param masked The masked permission of the directory being created
487 * @param createParent create missing parent directory if true
488 *
489 * @param True if the operation success.
490 *
491 * @throw AccessControlException If access is denied
492 * @throw FileAlreadyExistsException If <code>src</code> already exists
493 * @throw FileNotFoundException If parent of <code>src</code> does not exist
494 * and <code>createParent</code> is false
495 * @throw NSQuotaExceededException If file creation violates quota restriction
496 * @throw ParentNotDirectoryException If parent of <code>src</code>
497 * is not a directory
498 * @throw SafeModeException create not allowed in safemode
499 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
500 * @throw HdfsIOException If an I/O error occurred.
501 *
502 * RunTimeExceptions:
503 * @throw InvalidPathException If <code>src</code> is invalid
504 */
505 //Idempotent
506 virtual bool mkdirs(const std::string & src, const Permission & masked,
507 bool createParent) /* throw (AccessControlException,
508 FileAlreadyExistsException, FileNotFoundException,
509 NSQuotaExceededException, ParentNotDirectoryException,
510 SafeModeException, UnresolvedLinkException, HdfsIOException) */ = 0;
511
512 /**
513 * Get a partial listing of the indicated directory
514 *
515 * @param src the directory name
516 * @param startAfter the name to start listing after encoded in java UTF8
517 * @param needLocation if the FileStatus should contain block locations
518 *
519 * @param a partial listing starting after startAfter
520 * @param dl append the returned directories.
521 *
522 * @throw AccessControlException permission denied
523 * @throw FileNotFoundException file <code>src</code> is not found
524 * @throw UnresolvedLinkException If <code>src</code> contains a symlink
525 * @throw HdfsIOException If an I/O error occurred
526 */
527 //Idempotent
528 virtual bool getListing(const std::string & src,
529 const std::string & startAfter, bool needLocation,
530 std::vector<FileStatus> & dl) /* throw (AccessControlException,
531 FileNotFoundException, UnresolvedLinkException,
532 HdfsIOException) */ = 0;
533
534 /**
535 * Client programs can cause stateful changes in the NameNode
536 * that affect other clients. A client may obtain a file and
537 * neither abandon nor complete it. A client might hold a series
538 * of locks that prevent other clients from proceeding.
539 * Clearly, it would be bad if a client held a bunch of locks
540 * that it never gave up. This can happen easily if the client
541 * dies unexpectedly.
542 * <p>
543 * So, the NameNode will revoke the locks and live file-creates
544 * for clients that it thinks have died. A client tells the
545 * NameNode that it is still alive by periodically calling
546 * renewLease(). If a certain amount of time passes since
547 * the last call to renewLease(), the NameNode assumes the
548 * client has died.
549 *
550 * @throw AccessControlException permission denied
551 * @throw HdfsIOException If an I/O error occurred
552 */
553 //Idempotent
554 virtual void renewLease(const std::string & clientName)
555 /* throw (AccessControlException, HdfsIOException) */ = 0;
556
557 /**
558 * Start lease recovery.
559 * Lightweight NameNode operation to trigger lease recovery
560 *
561 * @param src path of the file to start lease recovery
562 * @param clientName name of the current client
563 * @param true if the file is already closed
564 * @throw HdfsIOException
565 */
566 //Idempotent
567 /*
568 virtual bool recoverLease(const std::string & src,
569 const std::string & clientName) throw (HdfsIOException) = 0;
570 */
571
572 /**
573 * Get a set of statistics about the filesystem.
574 * Right now, only seven values are returned.
575 * <ul>
576 * <li> [0] contains the total storage capacity of the system, in bytes.</li>
577 * <li> [1] contains the total used space of the system, in bytes.</li>
578 * <li> [2] contains the available storage of the system, in bytes.</li>
579 * <li> [3] contains number of under replicated blocks in the system.</li>
580 * <li> [4] contains number of blocks with a corrupt replica. </li>
581 * <li> [5] contains number of blocks without any good replicas left. </li>
582 * </ul>
583 * Use constants like {//link #GET_STATS_CAPACITY_IDX} in place of
584 * actual numbers to index into the array.
585 */
586 //Idempotent
587 virtual std::vector<int64_t> getFsStats() /* throw (HdfsIOException) */ = 0;
588
589 /**
590 * Dumps namenode data structures into specified file. If the file
591 * already exists, then append.
592 *
593 * @throw HdfsIOException
594 */
595 /* virtual void metaSave(
596 const std::string & filename) throw (HdfsIOException) = 0;*/
597
598 /**
599 * Get the file info for a specific file or directory.
600 * @param src The const std::string & representation of the path to the file
601 *
602 * @param object containing information regarding the file
603 * or null if file not found
604 * @throw AccessControlException permission denied
605 * @throw FileNotFoundException file <code>src</code> is not found
606 * @throw UnresolvedLinkException if the path contains a symlink.
607 * @throw HdfsIOException If an I/O error occurred
608 */
609 //Idempotent
610 virtual FileStatus getFileInfo(const std::string & src)
611 /* throw (AccessControlException, FileNotFoundException,
612 UnresolvedLinkException, HdfsIOException) */ = 0;
613
614 /**
615 * Get the file info for a specific file or directory. If the path
616 * refers to a symlink then the FileStatus of the symlink is returned.
617 * @param src The const std::string & representation of the path to the file
618 *
619 * @param object containing information regarding the file
620 * or null if file not found
621 *
622 * @throw AccessControlException permission denied
623 * @throw UnresolvedLinkException if <code>src</code> contains a symlink
624 * @throw HdfsIOException If an I/O error occurred
625 */
626 //Idempotent
627 /* virtual FileStatus getFileLinkInfo(const std::string & src)
628 throw (AccessControlException, UnresolvedLinkException,
629 HdfsIOException) = 0;*/
630
631 /**
632 * Get {//link ContentSummary} rooted at the specified directory.
633 * @param path The const std::string & representation of the path
634 *
635 * @throw AccessControlException permission denied
636 * @throw FileNotFoundException file <code>path</code> is not found
637 * @throw UnresolvedLinkException if <code>path</code> contains a symlink.
638 * @throw HdfsIOException If an I/O error occurred
639 */
640 //Idempotent
641 /* virtual ContentSummary getContentSummary(const std::string & path)
642 throw (AccessControlException, FileNotFoundException,
643 UnresolvedLinkException, HdfsIOException) = 0;*/
644
645 /**
646 * Set the quota for a directory.
647 * @param path The const std::string & representation of the path to the directory
648 * @param namespaceQuota Limit on the number of names in the tree rooted
649 * at the directory
650 * @param diskspaceQuota Limit on disk space occupied all the files under
651 * this directory.
652 * <br><br>
653 *
654 * The quota can have three types of values : (1) 0 or more will set
655 * the quota to that value, (2) {//link HdfsConstants#QUOTA_DONT_SET} implies
656 * the quota will not be changed, and (3) {//link HdfsConstants#QUOTA_RESET}
657 * implies the quota will be reset. Any other value is a runtime error.
658 *
659 * @throw AccessControlException permission denied
660 * @throw FileNotFoundException file <code>path</code> is not found
661 * @throw QuotaExceededException if the directory size
662 * is greater than the given quota
663 * @throw UnresolvedLinkException if the <code>path</code> contains a symlink.
664 * @throw HdfsIOException If an I/O error occurred
665 */
666 //Idempotent
667 /*
668 virtual void setQuota(const std::string & path, int64_t namespaceQuota,
669 int64_t diskspaceQuota) throw (AccessControlException,
670 FileNotFoundException, UnresolvedLinkException,
671 HdfsIOException) = 0;
672 */
673
674 /**
675 * Write all metadata for this file into persistent storage.
676 * The file must be currently open for writing.
677 * @param src The const std::string & representation of the path
678 * @param client The const std::string & representation of the client
679 *
680 * @throw AccessControlException permission denied
681 * @throw FileNotFoundException file <code>src</code> is not found
682 * @throw UnresolvedLinkException if <code>src</code> contains a symlink.
683 * @throw HdfsIOException If an I/O error occurred
684 */
685 //Idempotent
686 virtual void fsync(const std::string & src, const std::string & client)
687 /* throw (AccessControlException, FileNotFoundException,
688 UnresolvedLinkException, HdfsIOException) */ = 0;
689
690 /**
691 * Sets the modification and access time of the file to the specified time.
692 * @param src The const std::string & representation of the path
693 * @param mtime The number of milliseconds since Jan 1, 1970.
694 * Setting mtime to -1 means that modification time should not be set
695 * by this call.
696 * @param atime The number of milliseconds since Jan 1, 1970.
697 * Setting atime to -1 means that access time should not be set
698 * by this call.
699 *
700 * @throw AccessControlException permission denied
701 * @throw FileNotFoundException file <code>src</code> is not found
702 * @throw UnresolvedLinkException if <code>src</code> contains a symlink.
703 * @throw HdfsIOException If an I/O error occurred
704 */
705 //Idempotent
706 virtual void setTimes(const std::string & src, int64_t mtime, int64_t atime)
707 /* throw (AccessControlException, FileNotFoundException,
708 UnresolvedLinkException, HdfsIOException) */ = 0;
709
710 /**
711 * Create symlink to a file or directory.
712 * @param target The path of the destination that the
713 * link points to.
714 * @param link The path of the link being created.
715 * @param dirPerm permissions to use when creating parent directories
716 * @param createParent - if true then missing parent dirs are created
717 * if false then parent must exist
718 *
719 * @throw AccessControlException permission denied
720 * @throw FileAlreadyExistsException If file <code>link</code> already exists
721 * @throw FileNotFoundException If parent of <code>link</code> does not exist
722 * and <code>createParent</code> is false
723 * @throw ParentNotDirectoryException If parent of <code>link</code> is not a
724 * directory.
725 * @throw UnresolvedLinkException if <code>link</target> contains a symlink.
726 * @throw HdfsIOException If an I/O error occurred
727 */
728 /* virtual void createSymlink(const std::string & target,
729 const std::string & link, const Permission & dirPerm,
730 bool createParent) throw (AccessControlException,
731 FileAlreadyExistsException, FileNotFoundException,
732 ParentNotDirectoryException, SafeModeException,
733 UnresolvedLinkException, HdfsIOException) = 0;*/
734
735 /**
736 * Return the target of the given symlink. If there is an intermediate
737 * symlink in the path (ie a symlink leading up to the final path component)
738 * then the given path is returned with this symlink resolved.
739 *
740 * @param path The path with a link that needs resolution.
741 * @param The path after resolving the first symbolic link in the path.
742 * @throw AccessControlException permission denied
743 * @throw FileNotFoundException If <code>path</code> does not exist
744 * @throw HdfsIOException If the given path does not refer to a symlink
745 * or an I/O error occurred
746 */
747 //Idempotent
748 /* virtual std::string getLinkTarget(const std::string & path)
749 throw (AccessControlException, FileNotFoundException,
750 HdfsIOException) = 0;*/
751
752 /**
753 * Get a new generation stamp together with an access token for
754 * a block under construction
755 *
756 * This method is called only when a client needs to recover a failed
757 * pipeline or set up a pipeline for appending to a block.
758 *
759 * @param block a block
760 * @param clientName the name of the client
761 * @param a located block with a new generation stamp and an access token
762 * @param lb output the returned block.
763 * @throw HdfsIOException if any error occurs
764 */
765 //Idempotent
766 virtual shared_ptr<LocatedBlock> updateBlockForPipeline(const ExtendedBlock & block,
767 const std::string & clientName)
768 /* throw (HdfsIOException) */ = 0;
769
770 /**
771 * Update a pipeline for a block under construction
772 *
773 * @param clientName the name of the client
774 * @param oldBlock the old block
775 * @param newBlock the new block containing new generation stamp and length
776 * @param newNodes datanodes in the pipeline
777 * @throw HdfsIOException if any error occurs
778 */
779 virtual void updatePipeline(const std::string & clientName,
780 const ExtendedBlock & oldBlock, const ExtendedBlock & newBlock,
781 const std::vector<DatanodeInfo> & newNodes,
782 const std::vector<std::string> & storageIDs) /* throw (HdfsIOException) */ = 0;
783
784 /**
785 * Get a valid Delegation Token.
786 *
787 * @param renewer the designated renewer for the token
788 * @return Token<DelegationTokenIdentifier>
789 * @throws IOException
790 */
791 virtual Token getDelegationToken(const std::string & renewer)
792 /* throws IOException*/ = 0;
793
794 /**
795 * Renew an existing delegation token.
796 *
797 * @param token delegation token obtained earlier
798 * @return the new expiration time
799 * @throws IOException
800 */
801 virtual int64_t renewDelegationToken(const Token & token)
802 /*throws IOException*/ = 0;
803
804 /**
805 * Cancel an existing delegation token.
806 *
807 * @param token delegation token
808 * @throws IOException
809 */
810 virtual void cancelDelegationToken(const Token & token)
811 /*throws IOException*/ = 0;
812
813 /**
814 * close the namenode connection.
815 */
816 virtual void close() {};
817};
818
819}
820}
821
822#endif /* _HDFS_LIBHDFS3_SERVER_NAMENODE_H_ */
823