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_RPC_RPCSERVERINFO_H_
29#define _HDFS_LIBHDFS3_RPC_RPCSERVERINFO_H_
30
31#include "Hash.h"
32
33#include <string>
34#include <sstream>
35
36namespace Hdfs {
37namespace Internal {
38
39class RpcServerInfo {
40public:
41
42 RpcServerInfo(const std::string & tokenService, const std::string & h, const std::string & p) :
43 host(h), port(p), tokenService(tokenService) {
44 }
45
46 RpcServerInfo(const std::string & h, uint32_t p) :
47 host(h) {
48 std::stringstream ss;
49 ss.imbue(std::locale::classic());
50 ss << p;
51 port = ss.str();
52 }
53
54 size_t hash_value() const;
55
56 bool operator ==(const RpcServerInfo & other) const {
57 return this->host == other.host && this->port == other.port && tokenService == other.tokenService;
58 }
59
60 const std::string & getTokenService() const {
61 return tokenService;
62 }
63
64 const std::string & getHost() const {
65 return host;
66 }
67
68 const std::string & getPort() const {
69 return port;
70 }
71
72 void setTokenService(const std::string & tokenService) {
73 this->tokenService = tokenService;
74 }
75
76private:
77 std::string host;
78 std::string port;
79 std::string tokenService;
80
81};
82
83}
84}
85
86HDFS_HASH_DEFINE(::Hdfs::Internal::RpcServerInfo);
87
88#endif /* _HDFS_LIBHDFS3_RPC_RPCSERVERINFO_H_ */
89