1 | |
---|
2 | #!/usr/local/bin/thrift -java |
---|
3 | # |
---|
4 | # Thrift Service exported by Hadoop File System |
---|
5 | # Dhruba Borthakur (dhruba@gmail.com) |
---|
6 | # |
---|
7 | |
---|
8 | /** |
---|
9 | * The available types in Thrift: |
---|
10 | * |
---|
11 | * bool Boolean, one byte |
---|
12 | * byte Signed byte |
---|
13 | * i16 Signed 16-bit integer |
---|
14 | * i32 Signed 32-bit integer |
---|
15 | * i64 Signed 64-bit integer |
---|
16 | * double 64-bit floating point value |
---|
17 | * string String |
---|
18 | * map<t1,t2> Map from one type to another |
---|
19 | * list<t1> Ordered list of one type |
---|
20 | * set<t1> Set of unique elements of one type |
---|
21 | * |
---|
22 | */ |
---|
23 | |
---|
24 | namespace java org.apache.hadoop.thriftfs.api |
---|
25 | namespace php hadoopfs |
---|
26 | |
---|
27 | struct ThriftHandle { |
---|
28 | i64 id |
---|
29 | } |
---|
30 | |
---|
31 | struct Pathname { |
---|
32 | string pathname |
---|
33 | } |
---|
34 | |
---|
35 | struct FileStatus { |
---|
36 | 1: string path, |
---|
37 | 2: i64 length, |
---|
38 | 3: bool isdir, |
---|
39 | 4: i16 block_replication, |
---|
40 | 5: i64 blocksize, |
---|
41 | 6: i64 modification_time, |
---|
42 | 7: string permission, |
---|
43 | 8: string owner, |
---|
44 | 9: string group |
---|
45 | } |
---|
46 | |
---|
47 | struct BlockLocation { |
---|
48 | 1: list<string> hosts, /* hostnames of datanodes */ |
---|
49 | 2: list<string> names, /* hostname:portNumber of datanodes */ |
---|
50 | 3: i64 offset, /* offset of the block in the file */ |
---|
51 | 4: i64 length /* length of data */ |
---|
52 | } |
---|
53 | |
---|
54 | exception MalformedInputException { |
---|
55 | string message |
---|
56 | } |
---|
57 | |
---|
58 | exception ThriftIOException { |
---|
59 | string message |
---|
60 | } |
---|
61 | |
---|
62 | service ThriftHadoopFileSystem |
---|
63 | { |
---|
64 | |
---|
65 | // set inactivity timeout period. The period is specified in seconds. |
---|
66 | // if there are no RPC calls to the HadoopThrift server for this much |
---|
67 | // time, then the server kills itself. |
---|
68 | void setInactivityTimeoutPeriod(1:i64 periodInSeconds), |
---|
69 | |
---|
70 | // close session |
---|
71 | void shutdown(1:i32 status), |
---|
72 | |
---|
73 | // create a file and open it for writing |
---|
74 | ThriftHandle create(1:Pathname path) throws (1:ThriftIOException ouch), |
---|
75 | |
---|
76 | // create a file and open it for writing |
---|
77 | ThriftHandle createFile(1:Pathname path, 2:i16 mode, |
---|
78 | 3:bool overwrite, 4:i32 bufferSize, |
---|
79 | 5:i16 block_replication, 6:i64 blocksize) |
---|
80 | throws (1:ThriftIOException ouch), |
---|
81 | |
---|
82 | // returns a handle to an existing file for reading |
---|
83 | ThriftHandle open(1:Pathname path) throws (1:ThriftIOException ouch), |
---|
84 | |
---|
85 | // returns a handle to an existing file for appending to it. |
---|
86 | ThriftHandle append(1:Pathname path) throws (1:ThriftIOException ouch), |
---|
87 | |
---|
88 | // write a string to the open handle for the file |
---|
89 | bool write(1:ThriftHandle handle, string data) throws (1:ThriftIOException ouch), |
---|
90 | |
---|
91 | // read some bytes from the open handle for the file |
---|
92 | string read(1:ThriftHandle handle, i64 offset, i32 size) throws (1:ThriftIOException ouch), |
---|
93 | |
---|
94 | // close file |
---|
95 | bool close(1:ThriftHandle out) throws (1:ThriftIOException ouch), |
---|
96 | |
---|
97 | // delete file(s) or directory(s) |
---|
98 | bool rm(1:Pathname path, 2:bool recursive) throws (1:ThriftIOException ouch), |
---|
99 | |
---|
100 | // rename file(s) or directory(s) |
---|
101 | bool rename(1:Pathname path, 2:Pathname dest) throws (1:ThriftIOException ouch), |
---|
102 | |
---|
103 | // create directory |
---|
104 | bool mkdirs(1:Pathname path) throws (1:ThriftIOException ouch), |
---|
105 | |
---|
106 | // Does this pathname exist? |
---|
107 | bool exists(1:Pathname path) throws (1:ThriftIOException ouch), |
---|
108 | |
---|
109 | // Returns status about the path |
---|
110 | FileStatus stat(1:Pathname path) throws (1:ThriftIOException ouch), |
---|
111 | |
---|
112 | // If the path is a directory, then returns the list of pathnames in that directory |
---|
113 | list<FileStatus> listStatus(1:Pathname path) throws (1:ThriftIOException ouch), |
---|
114 | |
---|
115 | // Set permission for this file |
---|
116 | void chmod(1:Pathname path, 2:i16 mode) throws (1:ThriftIOException ouch), |
---|
117 | |
---|
118 | // set the owner and group of the file. |
---|
119 | void chown(1:Pathname path, 2:string owner, 3:string group) throws (1:ThriftIOException ouch), |
---|
120 | |
---|
121 | // set the replication factor for all blocks of the specified file |
---|
122 | void setReplication(1:Pathname path, 2:i16 replication) throws (1:ThriftIOException ouch), |
---|
123 | |
---|
124 | // get the locations of the blocks of this file |
---|
125 | list<BlockLocation> getFileBlockLocations(1:Pathname path, 2:i64 start, 3:i64 length) throws (1:ThriftIOException ouch), |
---|
126 | } |
---|