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_DATANODE_H_
29#define _HDFS_LIBHDFS3_SERVER_DATANODE_H_
30
31#include "BlockLocalPathInfo.h"
32#include "client/Token.h"
33#include "ExtendedBlock.h"
34#include "rpc/RpcAuth.h"
35#include "rpc/RpcCall.h"
36#include "rpc/RpcClient.h"
37#include "rpc/RpcConfig.h"
38#include "rpc/RpcProtocolInfo.h"
39#include "rpc/RpcServerInfo.h"
40#include "SessionConfig.h"
41
42namespace Hdfs {
43namespace Internal {
44
45class Datanode {
46public:
47 virtual ~Datanode() {
48 }
49
50 /**
51 * Return the visible length of a replica.
52 * @param b The block which visible length is to be returned.
53 * @return the visible length of the block.
54 * @throw ReplicaNotFoundException
55 * @throw HdfsIOException
56 */
57 //Idempotent
58 virtual int64_t getReplicaVisibleLength(const ExtendedBlock & b)
59 /*throw (ReplicaNotFoundException, HdfsIOException)*/ = 0;
60
61 /**
62 * Retrieves the path names of the block file and metadata file stored on the
63 * local file system.
64 *
65 * In order for this method to work, one of the following should be satisfied:
66 * <ul>
67 * <li>
68 * The client user must be configured at the datanode to be able to use this
69 * method.</li>
70 * <li>
71 * When security is enabled, kerberos authentication must be used to connect
72 * to the datanode.</li>
73 * </ul>
74 *
75 * @param block The specified block on the local datanode
76 * @param token The block access token.
77 * @param info Output the BlockLocalPathInfo of block.
78 * @throw HdfsIOException
79 */
80 //Idempotent
81 virtual void getBlockLocalPathInfo(const ExtendedBlock & block,
82 const Token & token, BlockLocalPathInfo & info)
83 /*throw (HdfsIOException)*/ = 0;
84};
85
86class DatanodeImpl: public Datanode {
87public:
88 DatanodeImpl(const std::string & host, uint32_t port, const SessionConfig & c,
89 const RpcAuth & a);
90
91 virtual int64_t getReplicaVisibleLength(const ExtendedBlock & b);
92
93 virtual void getBlockLocalPathInfo(const ExtendedBlock & block,
94 const Token & token, BlockLocalPathInfo & info);
95
96private:
97 void invoke(const RpcCall & call, bool reuse);
98
99private:
100 RpcAuth auth;
101 RpcClient & client;
102 RpcConfig conf;
103 RpcProtocolInfo protocol;
104 RpcServerInfo server;
105};
106
107}
108}
109
110#endif /* _HDFS_LIBHDFS3_SERVER_DATANODE_H_ */
111