DatanodeContainerProtocol.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. /**
  19. * These .proto interfaces are private and Unstable.
  20. * Please see http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/InterfaceClassification.html
  21. * for what changes are allowed for a *Unstable* .proto interface.
  22. */
  23. // This file contains protocol buffers that are used to transfer data
  24. // to and from the datanode.
  25. option java_package = "org.apache.hadoop.hdfs.ozone.protocol.proto";
  26. option java_outer_classname = "ContainerProtos";
  27. option java_generate_equals_and_hash = true;
  28. package hadoop.hdfs.ozone;
  29. import "hdfs.proto";
  30. /**
  31. * Commands that are used to manipulate the state of containers on a datanode.
  32. *
  33. * These commands allow us to work against the datanode - from
  34. * StorageContainer Manager as well as clients.
  35. *
  36. * 1. CreateContainer - This call is usually made by Storage Container
  37. * manager, when we need to create a new container on a given datanode.
  38. *
  39. * 2. ReadContainer - Allows end user to stat a container. For example
  40. * this allows us to return the metadata of a container.
  41. *
  42. * 3. UpdateContainer - Updates a container metadata.
  43. * 4. DeleteContainer - This call is made to delete a container.
  44. *
  45. * 5. ListContainer - Returns the list of containers on this
  46. * datanode. This will be used by tests and tools.
  47. *
  48. * 6. PutKey - Given a valid container, creates a key.
  49. *
  50. * 7. GetKey - Allows user to read the metadata of a Key.
  51. *
  52. * 8. DeleteKey - Deletes a given key.
  53. *
  54. * 9. ListKey - Returns a list of keys that are present inside
  55. * a given container.
  56. *
  57. * 10. ReadChunk - Allows us to read a chunk.
  58. *
  59. * 11. DeleteChunk - Delete an unused chunk.
  60. *
  61. * 12. WriteChunk - Allows us to write a chunk
  62. *
  63. * 13. ListChunk - Given a Container/Key returns the list of Chunks.
  64. *
  65. * 14. CompactChunk - Re-writes a chunk based on Offsets.
  66. *
  67. * 15. PutSmallFile - A single RPC that combines both putKey and WriteChunk.
  68. *
  69. * 16. GetSmallFile - A single RPC that combines both getKey and ReadChunk.
  70. *
  71. * 17. CloseContainer - Closes an open container and makes it immutable.
  72. */
  73. enum Type {
  74. CreateContainer = 1;
  75. ReadContainer = 2;
  76. UpdateContainer = 3;
  77. DeleteContainer = 4;
  78. ListContainer = 5;
  79. PutKey = 6;
  80. GetKey = 7;
  81. DeleteKey = 8;
  82. ListKey = 9;
  83. ReadChunk = 10;
  84. DeleteChunk = 11;
  85. WriteChunk = 12;
  86. ListChunk = 13;
  87. CompactChunk = 14;
  88. /** Combines Key and Chunk Operation into Single RPC. */
  89. PutSmallFile = 15;
  90. GetSmallFile = 16;
  91. CloseContainer = 17;
  92. }
  93. enum Result {
  94. SUCCESS = 1;
  95. UNSUPPORTED_REQUEST = 2;
  96. MALFORMED_REQUEST = 3;
  97. CONTAINER_INTERNAL_ERROR = 4;
  98. INVALID_CONFIG = 5;
  99. INVALID_FILE_HASH_FOUND = 6;
  100. CONTAINER_EXISTS = 7;
  101. NO_SUCH_ALGORITHM = 8;
  102. CONTAINER_NOT_FOUND = 9;
  103. IO_EXCEPTION = 10;
  104. UNABLE_TO_READ_METADATA_DB = 11;
  105. NO_SUCH_KEY = 12;
  106. OVERWRITE_FLAG_REQUIRED = 13;
  107. UNABLE_TO_FIND_DATA_DIR = 14;
  108. INVALID_WRITE_SIZE = 15;
  109. CHECKSUM_MISMATCH = 16;
  110. UNABLE_TO_FIND_CHUNK = 17;
  111. PROTOC_DECODING_ERROR = 18;
  112. INVALID_ARGUMENT = 19;
  113. PUT_SMALL_FILE_ERROR = 20;
  114. GET_SMALL_FILE_ERROR = 21;
  115. CLOSED_CONTAINER_IO = 22;
  116. ERROR_CONTAINER_NOT_EMPTY = 23;
  117. }
  118. message ContainerCommandRequestProto {
  119. required Type cmdType = 1; // Type of the command
  120. // A string that identifies this command, we generate Trace ID in Ozone
  121. // frontend and this allows us to trace that command all over ozone.
  122. optional string traceID = 2;
  123. // One of the following command is available when the corresponding
  124. // cmdType is set. At the protocol level we allow only
  125. // one command in each packet.
  126. // TODO : Upgrade to Protobuf 2.6 or later.
  127. optional CreateContainerRequestProto createContainer = 3;
  128. optional ReadContainerRequestProto readContainer = 4;
  129. optional UpdateContainerRequestProto updateContainer = 5;
  130. optional DeleteContainerRequestProto deleteContainer = 6;
  131. optional ListContainerRequestProto listContainer = 7;
  132. optional PutKeyRequestProto putKey = 8;
  133. optional GetKeyRequestProto getKey = 9;
  134. optional DeleteKeyRequestProto deleteKey = 10;
  135. optional ListKeyRequestProto listKey = 11;
  136. optional ReadChunkRequestProto readChunk = 12;
  137. optional WriteChunkRequestProto writeChunk = 13;
  138. optional DeleteChunkRequestProto deleteChunk = 14;
  139. optional ListChunkRequestProto listChunk = 15;
  140. optional PutSmallFileRequestProto putSmallFile = 16;
  141. optional GetSmallFileRequestProto getSmallFile = 17;
  142. optional CloseContainerRequestProto closeContainer = 18;
  143. }
  144. message ContainerCommandResponseProto {
  145. required Type cmdType = 1;
  146. optional string traceID = 2;
  147. optional CreateContainerResponseProto createContainer = 3;
  148. optional ReadContainerResponseProto readContainer = 4;
  149. optional UpdateContainerResponseProto updateContainer = 5;
  150. optional DeleteContainerResponseProto deleteContainer = 6;
  151. optional ListContainerResponseProto listContainer = 7;
  152. optional PutKeyResponseProto putKey = 8;
  153. optional GetKeyResponseProto getKey = 9;
  154. optional DeleteKeyResponseProto deleteKey = 10;
  155. optional ListKeyResponseProto listKey = 11;
  156. optional WriteChunkResponseProto writeChunk = 12;
  157. optional ReadChunkResponseProto readChunk = 13;
  158. optional DeleteChunkResponseProto deleteChunk = 14;
  159. optional ListChunkResponseProto listChunk = 15;
  160. required Result result = 17;
  161. optional string message = 18;
  162. optional PutSmallFileResponseProto putSmallFile = 19;
  163. optional GetSmallFileResponseProto getSmallFile = 20;
  164. optional CloseContainerResponseProto closeContainer = 21;
  165. }
  166. // A pipeline is composed of one or more datanodes that back a container.
  167. message Pipeline {
  168. required string leaderID = 1;
  169. repeated DatanodeIDProto members = 2;
  170. required string containerName = 3;
  171. }
  172. message KeyValue {
  173. required string key = 1;
  174. optional string value = 2;
  175. }
  176. message ContainerData {
  177. required string name = 1;
  178. repeated KeyValue metadata = 2;
  179. optional string dbPath = 3;
  180. optional string containerPath = 4;
  181. optional bool open = 5 [default = true];
  182. optional string hash = 6;
  183. }
  184. message ContainerMeta {
  185. required string fileName = 1;
  186. required string hash = 2;
  187. }
  188. // Container Messages.
  189. message CreateContainerRequestProto {
  190. required Pipeline pipeline = 1;
  191. required ContainerData containerData = 2;
  192. }
  193. message CreateContainerResponseProto {
  194. }
  195. message ReadContainerRequestProto {
  196. required Pipeline pipeline = 1;
  197. required string name = 2;
  198. }
  199. message ReadContainerResponseProto {
  200. optional ContainerData containerData = 2;
  201. }
  202. message UpdateContainerRequestProto {
  203. required Pipeline pipeline = 1;
  204. required ContainerData containerData = 2;
  205. }
  206. message UpdateContainerResponseProto {
  207. }
  208. message DeleteContainerRequestProto {
  209. required Pipeline pipeline = 1;
  210. required string name = 2;
  211. }
  212. message DeleteContainerResponseProto {
  213. }
  214. message ListContainerRequestProto {
  215. required Pipeline pipeline = 1;
  216. optional string prefix = 2;
  217. required uint32 count = 3; // Max Results to return
  218. optional string prevKey = 4; // if this is not set query from start.
  219. }
  220. message ListContainerResponseProto {
  221. repeated ContainerData containerData = 1;
  222. }
  223. message CloseContainerRequestProto {
  224. required Pipeline pipeline = 1;
  225. }
  226. message CloseContainerResponseProto {
  227. optional Pipeline pipeline = 1;
  228. optional string hash = 2;
  229. }
  230. message KeyData {
  231. required string containerName = 1;
  232. required string name = 2;
  233. optional int64 flags = 3; // for future use.
  234. repeated KeyValue metadata = 4;
  235. repeated ChunkInfo chunks = 5;
  236. }
  237. // Key Messages.
  238. message PutKeyRequestProto {
  239. required Pipeline pipeline = 1;
  240. required KeyData keyData = 2;
  241. }
  242. message PutKeyResponseProto {
  243. }
  244. message GetKeyRequestProto {
  245. required Pipeline pipeline = 1;
  246. required KeyData keyData = 2;
  247. }
  248. message GetKeyResponseProto {
  249. required KeyData keyData = 1;
  250. }
  251. message DeleteKeyRequestProto {
  252. required Pipeline pipeline = 1;
  253. required string name = 2;
  254. }
  255. message DeleteKeyResponseProto {
  256. }
  257. message ListKeyRequestProto {
  258. required Pipeline pipeline = 1;
  259. optional string prefix = 2; // if specified returns keys that match prefix.
  260. required string prevKey = 3;
  261. required uint32 count = 4;
  262. }
  263. message ListKeyResponseProto {
  264. repeated KeyData keyData = 1;
  265. }
  266. // Chunk Operations
  267. message ChunkInfo {
  268. required string chunkName = 1;
  269. required uint64 offset = 2;
  270. required uint64 len = 3;
  271. optional string checksum = 4;
  272. repeated KeyValue metadata = 5;
  273. }
  274. message WriteChunkRequestProto {
  275. required Pipeline pipeline = 1;
  276. required string keyName = 2;
  277. required ChunkInfo chunkData = 3;
  278. required bytes data = 4;
  279. }
  280. message WriteChunkResponseProto {
  281. }
  282. message ReadChunkRequestProto {
  283. required Pipeline pipeline = 1;
  284. required string keyName = 2;
  285. required ChunkInfo chunkData = 3;
  286. }
  287. message ReadChunkResponseProto {
  288. required Pipeline pipeline = 1;
  289. required ChunkInfo chunkData = 2;
  290. required bytes data = 3;
  291. }
  292. message DeleteChunkRequestProto {
  293. required Pipeline pipeline = 1;
  294. required string keyName = 2;
  295. required ChunkInfo chunkData = 3;
  296. }
  297. message DeleteChunkResponseProto {
  298. }
  299. message ListChunkRequestProto {
  300. required Pipeline pipeline = 1;
  301. required string keyName = 2;
  302. required string prevChunkName = 3;
  303. required uint32 count = 4;
  304. }
  305. message ListChunkResponseProto {
  306. repeated ChunkInfo chunkData = 1;
  307. }
  308. /** For small file access combines write chunk and putKey into a single
  309. RPC */
  310. message PutSmallFileRequestProto {
  311. required PutKeyRequestProto key = 1;
  312. required ChunkInfo chunkInfo = 2;
  313. required bytes data = 3;
  314. }
  315. message PutSmallFileResponseProto {
  316. }
  317. message GetSmallFileRequestProto {
  318. required GetKeyRequestProto key = 1;
  319. }
  320. message GetSmallFileResponseProto {
  321. required ReadChunkResponseProto data = 1;
  322. }