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_CLIENT_FILESYSTEMKEY_H_
29#define _HDFS_LIBHDFS3_CLIENT_FILESYSTEMKEY_H_
30
31#include "Hash.h"
32#include "UserInfo.h"
33
34#include <string>
35
36namespace Hdfs {
37namespace Internal {
38
39class FileSystemKey {
40public:
41 FileSystemKey(const std::string & uri, const char * user);
42
43 FileSystemKey(const std::string & auth, const std::string & host,
44 const std::string & port, const std::string & scheme,
45 const std::string & user, size_t u) :
46 authority(auth), host(host), port(port), scheme(scheme), user(user) {
47 }
48
49 bool operator ==(const FileSystemKey & other) const {
50 return scheme == other.scheme && authority == other.authority;
51 }
52
53 size_t hash_value() const {
54 size_t values[] = { StringHasher(scheme), StringHasher(authority)};
55 return CombineHasher(values, sizeof(values) / sizeof(values[0]));
56 }
57
58 const std::string & getHost() const {
59 return host;
60 }
61
62 void setHost(const std::string & host) {
63 this->host = host;
64 }
65
66 const std::string & getPort() const {
67 return port;
68 }
69
70 void setPort(const std::string & port) {
71 this->port = port;
72 }
73
74 const std::string & getScheme() const {
75 return scheme;
76 }
77
78 void setScheme(const std::string & scheme) {
79 this->scheme = scheme;
80 }
81
82 const UserInfo & getUser() const {
83 return user;
84 }
85
86 void setUser(const UserInfo & user) {
87 this->user = user;
88 }
89
90 void addToken(const Token & token) {
91 user.addToken(token);
92 }
93
94private:
95 std::string authority;
96 std::string host;
97 std::string port;
98 std::string scheme;
99 UserInfo user;
100};
101
102}
103}
104
105HDFS_HASH_DEFINE(Hdfs::Internal::FileSystemKey);
106
107#endif /* _HDFS_LIBHDFS3_CLIENT_FILESYSTEMKEY_H_ */
108