-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_hdfs
90 lines (81 loc) · 3.3 KB
/
_hdfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#compdef hdfs
_hdfs()
{
typeset -A opt_args
local cur cword prev
cur=${words[CURRENT]}
prev=${words[CURRENT-1]}
_arguments -C \
'1:cmd:->cmds' \
'2:switches:->switches_lists' \
'*:arguments:->args' \
&& ret=0
case "$state" in
(cmds)
local commands; commands=(
'dfs:run a filesystem command on the file systems supported in Hadoop.'
'classpath:prints the classpath'
'namenode -format:format the DFS filesystem'
'secondarynamenode:run the DFS secondary namenode'
'namenode:run the DFS namenode'
'journalnode:run the DFS journalnode'
'zkfc:run the ZK Failover Controller daemon'
'datanode:run a DFS datanode'
'dfsadmin:run a DFS admin client'
'haadmin:run a DFS HA admin client'
'fsck:run a DFS filesystem checking utility'
'balancer:run a cluster balancing utility'
'jmxget:get JMX exported values from NameNode or DataNode.'
'mover:run a utility to move block replicas across storage types'
'oiv:apply the offline fsimage viewer to an fsimage'
'oiv_legacy:apply the offline fsimage viewer to an legacy fsimage'
'oev:apply the offline edits viewer to an edits file'
'fetchdt:fetch a delegation token from the NameNode'
'getconf:get config values from configuration'
'groups:get the groups which users belong to'
'snapshotDiff:diff two snapshots of a directory or diff the current directory contents with a snapshot'
'lsSnapshottableDir:list all snapshottable dirs owned by the current user'
'portmap:run a portmap service'
'nfs3:run an NFS version 3 gateway'
'cacheadmin:configure the HDFS cache'
'crypto:configure HDFS encryption zones'
'storagepolicies:list/get/set block storage policies'
'version:print the version'
)
_describe -t commands 'command' commands && ret=0
;;
(switches_lists)
case $line[1] in
dfs)
local switches; switches=(
'-ls:List Files'
'-rmdir:Remove Directory'
'-rm:Remove File'
'-put:Put a file on HDFS'
'-get:Get a file frem HDFS'
)
_describe -t switches 'switch' switches && ret=0
;;
namenode)
local switches; switches=(
'-format:format the DFS filesystem'
)
_describe -t switches 'switch' switches && ret=0
;;
esac
;;
(args)
case $line[2] in
(-ls)
echo "$words"
# runable="$words | sed -e 's/$/-ls \//'"
# local folders; folders=(`hdfs dfs -ls ${args:-/} | tr "/" " " | awk '{print $NF}' | tail -n +2`;)
local folders; folders=(`eval $words | tr "/" " " | awk '{print $NF}' | tail -n +2 | sed -e 's/^/\//'` )
_describe -t folders 'folder' folders && ret=0
;;
esac
;;
esac
return 1
}
_hdfs