DatanodeContainerProtocol.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. ERROR_IN_COMPACT_DB = 24;
  118. }
  119. message ContainerCommandRequestProto {
  120. required Type cmdType = 1; // Type of the command
  121. // A string that identifies this command, we generate Trace ID in Ozone
  122. // frontend and this allows us to trace that command all over ozone.
  123. optional string traceID = 2;
  124. // One of the following command is available when the corresponding
  125. // cmdType is set. At the protocol level we allow only
  126. // one command in each packet.
  127. // TODO : Upgrade to Protobuf 2.6 or later.
  128. optional CreateContainerRequestProto createContainer = 3;
  129. optional ReadContainerRequestProto readContainer = 4;
  130. optional UpdateContainerRequestProto updateContainer = 5;
  131. optional DeleteContainerRequestProto deleteContainer = 6;
  132. optional ListContainerRequestProto listContainer = 7;
  133. optional PutKeyRequestProto putKey = 8;
  134. optional GetKeyRequestProto getKey = 9;
  135. optional DeleteKeyRequestProto deleteKey = 10;
  136. optional ListKeyRequestProto listKey = 11;
  137. optional ReadChunkRequestProto readChunk = 12;
  138. optional WriteChunkRequestProto writeChunk = 13;
  139. optional DeleteChunkRequestProto deleteChunk = 14;
  140. optional ListChunkRequestProto listChunk = 15;
  141. optional PutSmallFileRequestProto putSmallFile = 16;
  142. optional GetSmallFileRequestProto getSmallFile = 17;
  143. optional CloseContainerRequestProto closeContainer = 18;
  144. }
  145. message ContainerCommandResponseProto {
  146. required Type cmdType = 1;
  147. optional string traceID = 2;
  148. optional CreateContainerResponseProto createContainer = 3;
  149. optional ReadContainerResponseProto readContainer = 4;
  150. optional UpdateContainerResponseProto updateContainer = 5;
  151. optional DeleteContainerResponseProto deleteContainer = 6;
  152. optional ListContainerResponseProto listContainer = 7;
  153. optional PutKeyResponseProto putKey = 8;
  154. optional GetKeyResponseProto getKey = 9;
  155. optional DeleteKeyResponseProto deleteKey = 10;
  156. optional ListKeyResponseProto listKey = 11;
  157. optional WriteChunkResponseProto writeChunk = 12;
  158. optional ReadChunkResponseProto readChunk = 13;
  159. optional DeleteChunkResponseProto deleteChunk = 14;
  160. optional ListChunkResponseProto listChunk = 15;
  161. required Result result = 17;
  162. optional string message = 18;
  163. optional PutSmallFileResponseProto putSmallFile = 19;
  164. optional GetSmallFileResponseProto getSmallFile = 20;
  165. optional CloseContainerResponseProto closeContainer = 21;
  166. }
  167. // A pipeline is composed of one or more datanodes that back a container.
  168. message Pipeline {
  169. required string leaderID = 1;
  170. repeated DatanodeIDProto members = 2;
  171. required string containerName = 3;
  172. }
  173. message KeyValue {
  174. required string key = 1;
  175. optional string value = 2;
  176. }
  177. message ContainerData {
  178. required string name = 1;
  179. repeated KeyValue metadata = 2;
  180. optional string dbPath = 3;
  181. optional string containerPath = 4;
  182. optional bool open = 5 [default = true];
  183. optional string hash = 6;
  184. }
  185. message ContainerMeta {
  186. required string fileName = 1;
  187. required string hash = 2;
  188. }
  189. // Container Messages.
  190. message CreateContainerRequestProto {
  191. required Pipeline pipeline = 1;
  192. required ContainerData containerData = 2;
  193. }
  194. message CreateContainerResponseProto {
  195. }
  196. message ReadContainerRequestProto {
  197. required Pipeline pipeline = 1;
  198. required string name = 2;
  199. }
  200. message ReadContainerResponseProto {
  201. optional ContainerData containerData = 2;
  202. }
  203. message UpdateContainerRequestProto {
  204. required Pipeline pipeline = 1;
  205. required ContainerData containerData = 2;
  206. }
  207. message UpdateContainerResponseProto {
  208. }
  209. message DeleteContainerRequestProto {
  210. required Pipeline pipeline = 1;
  211. required string name = 2;
  212. }
  213. message DeleteContainerResponseProto {
  214. }
  215. message ListContainerRequestProto {
  216. required Pipeline pipeline = 1;
  217. optional string prefix = 2;
  218. required uint32 count = 3; // Max Results to return
  219. optional string prevKey = 4; // if this is not set query from start.
  220. }
  221. message ListContainerResponseProto {
  222. repeated ContainerData containerData = 1;
  223. }
  224. message CloseContainerRequestProto {
  225. required Pipeline pipeline = 1;
  226. }
  227. message CloseContainerResponseProto {
  228. optional Pipeline pipeline = 1;
  229. optional string hash = 2;
  230. }
  231. message KeyData {
  232. required string containerName = 1;
  233. required string name = 2;
  234. optional int64 flags = 3; // for future use.
  235. repeated KeyValue metadata = 4;
  236. repeated ChunkInfo chunks = 5;
  237. }
  238. // Key Messages.
  239. message PutKeyRequestProto {
  240. required Pipeline pipeline = 1;
  241. required KeyData keyData = 2;
  242. }
  243. message PutKeyResponseProto {
  244. }
  245. message GetKeyRequestProto {
  246. required Pipeline pipeline = 1;
  247. required KeyData keyData = 2;
  248. }
  249. message GetKeyResponseProto {
  250. required KeyData keyData = 1;
  251. }
  252. message DeleteKeyRequestProto {
  253. required Pipeline pipeline = 1;
  254. required string name = 2;
  255. }
  256. message DeleteKeyResponseProto {
  257. }
  258. message ListKeyRequestProto {
  259. required Pipeline pipeline = 1;
  260. optional string prefix = 2; // if specified returns keys that match prefix.
  261. required string prevKey = 3;
  262. required uint32 count = 4;
  263. }
  264. message ListKeyResponseProto {
  265. repeated KeyData keyData = 1;
  266. }
  267. // Chunk Operations
  268. message ChunkInfo {
  269. required string chunkName = 1;
  270. required uint64 offset = 2;
  271. required uint64 len = 3;
  272. optional string checksum = 4;
  273. repeated KeyValue metadata = 5;
  274. }
  275. message WriteChunkRequestProto {
  276. required Pipeline pipeline = 1;
  277. required string keyName = 2;
  278. required ChunkInfo chunkData = 3;
  279. required bytes data = 4;
  280. }
  281. message WriteChunkResponseProto {
  282. }
  283. message ReadChunkRequestProto {
  284. required Pipeline pipeline = 1;
  285. required string keyName = 2;
  286. required ChunkInfo chunkData = 3;
  287. }
  288. message ReadChunkResponseProto {
  289. required Pipeline pipeline = 1;
  290. required ChunkInfo chunkData = 2;
  291. required bytes data = 3;
  292. }
  293. message DeleteChunkRequestProto {
  294. required Pipeline pipeline = 1;
  295. required string keyName = 2;
  296. required ChunkInfo chunkData = 3;
  297. }
  298. message DeleteChunkResponseProto {
  299. }
  300. message ListChunkRequestProto {
  301. required Pipeline pipeline = 1;
  302. required string keyName = 2;
  303. required string prevChunkName = 3;
  304. required uint32 count = 4;
  305. }
  306. message ListChunkResponseProto {
  307. repeated ChunkInfo chunkData = 1;
  308. }
  309. /** For small file access combines write chunk and putKey into a single
  310. RPC */
  311. message PutSmallFileRequestProto {
  312. required PutKeyRequestProto key = 1;
  313. required ChunkInfo chunkInfo = 2;
  314. required bytes data = 3;
  315. }
  316. message PutSmallFileResponseProto {
  317. }
  318. message GetSmallFileRequestProto {
  319. required GetKeyRequestProto key = 1;
  320. }
  321. message GetSmallFileResponseProto {
  322. required ReadChunkResponseProto data = 1;
  323. }