-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathtypes.go
148 lines (135 loc) · 3.87 KB
/
types.go
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package gowfs
import "fmt"
import "net/url"
// Root level struct for data JSON data from WebHDFS.
type HdfsJsonData struct {
Boolean bool
FileStatus FileStatus
FileStatuses FileStatuses
FileChecksum FileChecksum
ContentSummary ContentSummary
Token Token
Tokens Tokens
Long int64
RemoteException RemoteException
}
// Represents a remote webHDFS path
type Path struct {
Name string // Relative path representation (/root/leaf)
RefererUrl url.URL // URL related to path (http://server:port/root/leaf)
}
// Represents HDFS FileStatus (FileSystem.getStatus())
// See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#FileStatus_JSON_Schema
//
// Example:
// {
// "FileStatus":
// {
// "accessTime" : 0, // integer
// "blockSize" : 0, // integer
// "group" : "grp", // string
// "length" : 0, // integer - zero for directories
// "modificationTime": 1320173277227, // integer
// "owner" : "webuser", // string
// "pathSuffix" : "", // string
// "permission" : "777", // string
// "replication" : 0, // integer
// "type" : "DIRECTORY" // string - enum {FILE, DIRECTORY, SYMLINK}
// }
// }
type FileStatus struct {
AccesTime int64
BlockSize int64
Group string
Length int64
ModificationTime int64
Owner string
PathSuffix string
Permission string
Replication int64
Type string
}
// Container type for multiple FileStatus for directory, etc
// (see HDFS FileSystem.listStatus())
// NOTE: the confusing naming and Plurality is to match WebHDFS schema.
type FileStatuses struct {
FileStatus []FileStatus
}
// Type for HDFS FileSystem content summary (FileSystem.getContentSummary())
// See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#ContentSummary_JSON_Schema
//
// Example:
// {
// "ContentSummary":
// {
// "directoryCount": 2,
// "fileCount" : 1,
// "length" : 24930,
// "quota" : -1,
// "spaceConsumed" : 24930,
// "spaceQuota" : -1
// }
// }
type ContentSummary struct {
DirectoryCount int64
FileCount int64
Length int64
Quota int64
SpaceConsumed int64
SpaceQuota int64
}
// Type for HDFS FileSystem.getFileChecksum()
// See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#FileChecksum_JSON_Schema
//
// Example:
// {
// "FileChecksum":
// {
// "algorithm": "MD5-of-1MD5-of-512CRC32",
// "bytes" : "eadb10de24aa315748930df6e185c0d ...",
// "length" : 28
// }
// }
type FileChecksum struct {
Algorithm string
Bytes string
Length int64
}
// Type for HDFS FileSystem delegation token (FileSystem.getDelegationToken())
// See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Token_JSON_Schema
// Example:
// {
// "Token":
// {
// "urlString": "JQAIaG9y..."
// }
// }
type Token struct {
UrlString string
}
/*
Container type for Token
*/
type Tokens struct {
Token []Token
}
// Type for returning WebHDFS error/exceptions.
// See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#RemoteException_JSON_schema
// Example:
// {
// "RemoteException":
// {
// "exception" : "FileNotFoundException",
// "javaClassName": "java.io.FileNotFoundException",
// "message" : "File does not exist: /foo/a.patch"
// }
// }
type RemoteException struct {
Exception string
JavaClassName string
Message string
}
// Implementation of error type. Returns string representation of RemoteException.
func (re RemoteException) Error() string {
return fmt.Sprintf("RemoteException: %v [%v]\n[%v]\n", re.Exception, re.JavaClassName, re.Message)
}