Skip to content

Commit e7312b1

Browse files
committed
HDFS-3610. fuse_dfs: Provide a way to use the default (configured) NN URI. Contributed by Colin Patrick McCabe
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1361565 13f79535-47bb-0310-9956-ffa450edef68
1 parent 4ced78a commit e7312b1

20 files changed

+54
-35
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ Branch-2 ( Unreleased changes )
324324

325325
HDFS-3539. libhdfs code cleanups. (Colin Patrick McCabe via eli)
326326

327+
HDFS-3610. fuse_dfs: Provide a way to use the default (configured) NN URI.
328+
(Colin Patrick McCabe via eli)
329+
327330
OPTIMIZATIONS
328331

329332
HDFS-2982. Startup performance suffers when there are many edit log

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_connect.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static void findKerbTicketCachePath(char *path, size_t pathLen)
172172
* Connect to the NN as the current user/group.
173173
* Returns a fs handle on success, or NULL on failure.
174174
*/
175-
hdfsFS doConnectAsUser(const char *hostname, int port) {
175+
hdfsFS doConnectAsUser(const char *nn_uri, int nn_port) {
176176
struct hdfsBuilder *bld;
177177
uid_t uid = fuse_get_context()->uid;
178178
char *user = getUsername(uid);
@@ -202,8 +202,10 @@ hdfsFS doConnectAsUser(const char *hostname, int port) {
202202
goto done;
203203
}
204204
hdfsBuilderSetForceNewInstance(bld);
205-
hdfsBuilderSetNameNode(bld, hostname);
206-
hdfsBuilderSetNameNodePort(bld, port);
205+
hdfsBuilderSetNameNode(bld, nn_uri);
206+
if (nn_port) {
207+
hdfsBuilderSetNameNodePort(bld, nn_port);
208+
}
207209
hdfsBuilderSetUserName(bld, user);
208210
if (hdfsAuthConf == AUTH_CONF_KERBEROS) {
209211
findKerbTicketCachePath(kpath, sizeof(kpath));

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_connect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "fuse_dfs.h"
2323

24-
hdfsFS doConnectAsUser(const char *hostname, int port);
24+
hdfsFS doConnectAsUser(const char *nn_uri, int nn_port);
2525
int doDisconnect(hdfsFS fs);
2626
int allocFsTable(void);
2727

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_context_handle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//
3232
typedef struct dfs_context_struct {
3333
int debug;
34-
char *nn_hostname;
34+
char *nn_uri;
3535
int nn_port;
3636
int read_only;
3737
int usetrash;

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_dfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ int main(int argc, char *argv[])
101101
fuse_opt_add_arg(&args, buf);
102102
}
103103

104-
if (options.server == NULL || options.port == 0) {
104+
if (options.nn_uri == NULL) {
105105
print_usage(argv[0]);
106106
exit(0);
107107
}
108108

109109
// Check connection as root
110110
if (options.initchecks == 1) {
111-
hdfsFS tempFS = hdfsConnectAsUser(options.server, options.port, "root");
111+
hdfsFS tempFS = hdfsConnectAsUser(options.nn_uri, options.nn_port, "root");
112112
if (NULL == tempFS) {
113113
const char *cp = getenv("CLASSPATH");
114114
const char *ld = getenv("LD_LIBRARY_PATH");

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_impls_chmod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int dfs_chmod(const char *path, mode_t mode)
3131
assert(dfs);
3232
assert('/' == *path);
3333

34-
hdfsFS userFS = doConnectAsUser(dfs->nn_hostname, dfs->nn_port);
34+
hdfsFS userFS = doConnectAsUser(dfs->nn_uri, dfs->nn_port);
3535
if (userFS == NULL) {
3636
ERROR("Could not connect to HDFS");
3737
ret = -EIO;

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_impls_chown.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int dfs_chown(const char *path, uid_t uid, gid_t gid)
5454
goto cleanup;
5555
}
5656

57-
userFS = doConnectAsUser(dfs->nn_hostname, dfs->nn_port);
57+
userFS = doConnectAsUser(dfs->nn_uri, dfs->nn_port);
5858
if (userFS == NULL) {
5959
ERROR("Could not connect to HDFS");
6060
ret = -EIO;

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_impls_getattr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ int dfs_getattr(const char *path, struct stat *st)
3131
assert(path);
3232
assert(st);
3333

34-
hdfsFS fs = doConnectAsUser(dfs->nn_hostname,dfs->nn_port);
34+
hdfsFS fs = doConnectAsUser(dfs->nn_uri, dfs->nn_port);
3535
if (NULL == fs) {
36-
ERROR("Could not connect to %s:%d", dfs->nn_hostname, dfs->nn_port);
36+
ERROR("Could not connect to %s:%d", dfs->nn_uri, dfs->nn_port);
3737
return -EIO;
3838
}
3939

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_impls_mkdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int dfs_mkdir(const char *path, mode_t mode)
4141
return -EACCES;
4242
}
4343

44-
hdfsFS userFS = doConnectAsUser(dfs->nn_hostname, dfs->nn_port);
44+
hdfsFS userFS = doConnectAsUser(dfs->nn_uri, dfs->nn_port);
4545
if (userFS == NULL) {
4646
ERROR("Could not connect");
4747
return -EIO;

hadoop-hdfs-project/hadoop-hdfs/src/contrib/fuse-dfs/src/fuse_impls_open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int dfs_open(const char *path, struct fuse_file_info *fi)
4545
return -EIO;
4646
}
4747

48-
fh->fs = doConnectAsUser(dfs->nn_hostname, dfs->nn_port);
48+
fh->fs = doConnectAsUser(dfs->nn_uri, dfs->nn_port);
4949
if (fh->fs == NULL) {
5050
ERROR("Could not connect to dfs");
5151
return -EIO;

0 commit comments

Comments
 (0)