DatanodeContainerProtocol.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. import "Ozone.proto";
  31. /**
  32. * Commands that are used to manipulate the state of containers on a datanode.
  33. *
  34. * These commands allow us to work against the datanode - from
  35. * StorageContainer Manager as well as clients.
  36. *
  37. * 1. CreateContainer - This call is usually made by Storage Container
  38. * manager, when we need to create a new container on a given datanode.
  39. *
  40. * 2. ReadContainer - Allows end user to stat a container. For example
  41. * this allows us to return the metadata of a container.
  42. *
  43. * 3. UpdateContainer - Updates a container metadata.
  44. * 4. DeleteContainer - This call is made to delete a container.
  45. *
  46. * 5. ListContainer - Returns the list of containers on this
  47. * datanode. This will be used by tests and tools.
  48. *
  49. * 6. PutKey - Given a valid container, creates a key.
  50. *
  51. * 7. GetKey - Allows user to read the metadata of a Key.
  52. *
  53. * 8. DeleteKey - Deletes a given key.
  54. *
  55. * 9. ListKey - Returns a list of keys that are present inside
  56. * a given container.
  57. *
  58. * 10. ReadChunk - Allows us to read a chunk.
  59. *
  60. * 11. DeleteChunk - Delete an unused chunk.
  61. *
  62. * 12. WriteChunk - Allows us to write a chunk
  63. *
  64. * 13. ListChunk - Given a Container/Key returns the list of Chunks.
  65. *
  66. * 14. CompactChunk - Re-writes a chunk based on Offsets.
  67. *
  68. * 15. PutSmallFile - A single RPC that combines both putKey and WriteChunk.
  69. *
  70. * 16. GetSmallFile - A single RPC that combines both getKey and ReadChunk.
  71. *
  72. * 17. CloseContainer - Closes an open container and makes it immutable.
  73. *
  74. * 18. CopyContainer - Copies a container from a remote machine.
  75. */
  76. enum Type {
  77. CreateContainer = 1;
  78. ReadContainer = 2;
  79. UpdateContainer = 3;
  80. DeleteContainer = 4;
  81. ListContainer = 5;
  82. PutKey = 6;
  83. GetKey = 7;
  84. DeleteKey = 8;
  85. ListKey = 9;
  86. ReadChunk = 10;
  87. DeleteChunk = 11;
  88. WriteChunk = 12;
  89. ListChunk = 13;
  90. CompactChunk = 14;
  91. /** Combines Key and Chunk Operation into Single RPC. */
  92. PutSmallFile = 15;
  93. GetSmallFile = 16;
  94. CloseContainer = 17;
  95. }
  96. enum Result {
  97. SUCCESS = 1;
  98. UNSUPPORTED_REQUEST = 2;
  99. MALFORMED_REQUEST = 3;
  100. CONTAINER_INTERNAL_ERROR = 4;
  101. INVALID_CONFIG = 5;
  102. INVALID_FILE_HASH_FOUND = 6;
  103. CONTAINER_EXISTS = 7;
  104. NO_SUCH_ALGORITHM = 8;
  105. CONTAINER_NOT_FOUND = 9;
  106. IO_EXCEPTION = 10;
  107. UNABLE_TO_READ_METADATA_DB = 11;
  108. NO_SUCH_KEY = 12;
  109. OVERWRITE_FLAG_REQUIRED = 13;
  110. UNABLE_TO_FIND_DATA_DIR = 14;
  111. INVALID_WRITE_SIZE = 15;
  112. CHECKSUM_MISMATCH = 16;
  113. UNABLE_TO_FIND_CHUNK = 17;
  114. PROTOC_DECODING_ERROR = 18;
  115. INVALID_ARGUMENT = 19;
  116. PUT_SMALL_FILE_ERROR = 20;
  117. GET_SMALL_FILE_ERROR = 21;
  118. CLOSED_CONTAINER_IO = 22;
  119. ERROR_CONTAINER_NOT_EMPTY = 23;
  120. ERROR_IN_COMPACT_DB = 24;
  121. UNCLOSED_CONTAINER_IO = 25;
  122. DELETE_ON_OPEN_CONTAINER = 26;
  123. CLOSED_CONTAINER_RETRY = 27;
  124. }
  125. message ContainerCommandRequestProto {
  126. required Type cmdType = 1; // Type of the command
  127. // A string that identifies this command, we generate Trace ID in Ozone
  128. // frontend and this allows us to trace that command all over ozone.
  129. optional string traceID = 2;
  130. // One of the following command is available when the corresponding
  131. // cmdType is set. At the protocol level we allow only
  132. // one command in each packet.
  133. // TODO : Upgrade to Protobuf 2.6 or later.
  134. optional CreateContainerRequestProto createContainer = 3;
  135. optional ReadContainerRequestProto readContainer = 4;
  136. optional UpdateContainerRequestProto updateContainer = 5;
  137. optional DeleteContainerRequestProto deleteContainer = 6;
  138. optional ListContainerRequestProto listContainer = 7;
  139. optional PutKeyRequestProto putKey = 8;
  140. optional GetKeyRequestProto getKey = 9;
  141. optional DeleteKeyRequestProto deleteKey = 10;
  142. optional ListKeyRequestProto listKey = 11;
  143. optional ReadChunkRequestProto readChunk = 12;
  144. optional WriteChunkRequestProto writeChunk = 13;
  145. optional DeleteChunkRequestProto deleteChunk = 14;
  146. optional ListChunkRequestProto listChunk = 15;
  147. optional PutSmallFileRequestProto putSmallFile = 16;
  148. optional GetSmallFileRequestProto getSmallFile = 17;
  149. optional CloseContainerRequestProto closeContainer = 18;
  150. required string datanodeID = 19;
  151. }
  152. message ContainerCommandResponseProto {
  153. required Type cmdType = 1;
  154. optional string traceID = 2;
  155. optional CreateContainerResponseProto createContainer = 3;
  156. optional ReadContainerResponseProto readContainer = 4;
  157. optional UpdateContainerResponseProto updateContainer = 5;
  158. optional DeleteContainerResponseProto deleteContainer = 6;
  159. optional ListContainerResponseProto listContainer = 7;
  160. optional PutKeyResponseProto putKey = 8;
  161. optional GetKeyResponseProto getKey = 9;
  162. optional DeleteKeyResponseProto deleteKey = 10;
  163. optional ListKeyResponseProto listKey = 11;
  164. optional WriteChunkResponseProto writeChunk = 12;
  165. optional ReadChunkResponseProto readChunk = 13;
  166. optional DeleteChunkResponseProto deleteChunk = 14;
  167. optional ListChunkResponseProto listChunk = 15;
  168. required Result result = 17;
  169. optional string message = 18;
  170. optional PutSmallFileResponseProto putSmallFile = 19;
  171. optional GetSmallFileResponseProto getSmallFile = 20;
  172. optional CloseContainerResponseProto closeContainer = 21;
  173. }
  174. message ContainerData {
  175. required string name = 1;
  176. repeated KeyValue metadata = 2;
  177. optional string dbPath = 3;
  178. optional string containerPath = 4;
  179. optional bool open = 5 [default = true];
  180. optional string hash = 6;
  181. optional int64 bytesUsed = 7;
  182. optional int64 size = 8;
  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. optional bool forceUpdate = 3 [default = false];
  206. }
  207. message UpdateContainerResponseProto {
  208. }
  209. message DeleteContainerRequestProto {
  210. required Pipeline pipeline = 1;
  211. required string name = 2;
  212. optional bool forceDelete = 3 [default = false];
  213. }
  214. message DeleteContainerResponseProto {
  215. }
  216. message ListContainerRequestProto {
  217. required Pipeline pipeline = 1;
  218. optional string prefix = 2;
  219. required uint32 count = 3; // Max Results to return
  220. optional string prevKey = 4; // if this is not set query from start.
  221. }
  222. message ListContainerResponseProto {
  223. repeated ContainerData containerData = 1;
  224. }
  225. message CloseContainerRequestProto {
  226. required Pipeline pipeline = 1;
  227. }
  228. message CloseContainerResponseProto {
  229. optional Pipeline pipeline = 1;
  230. optional string hash = 2;
  231. }
  232. message KeyData {
  233. required string containerName = 1;
  234. required string name = 2;
  235. optional int64 flags = 3; // for future use.
  236. repeated KeyValue metadata = 4;
  237. repeated ChunkInfo chunks = 5;
  238. }
  239. // Key Messages.
  240. message PutKeyRequestProto {
  241. required Pipeline pipeline = 1;
  242. required KeyData keyData = 2;
  243. }
  244. message PutKeyResponseProto {
  245. }
  246. message GetKeyRequestProto {
  247. required Pipeline pipeline = 1;
  248. required KeyData keyData = 2;
  249. }
  250. message GetKeyResponseProto {
  251. required KeyData keyData = 1;
  252. }
  253. message DeleteKeyRequestProto {
  254. required Pipeline pipeline = 1;
  255. required string name = 2;
  256. }
  257. message DeleteKeyResponseProto {
  258. }
  259. message ListKeyRequestProto {
  260. required Pipeline pipeline = 1;
  261. optional string prefix = 2; // if specified returns keys that match prefix.
  262. required string prevKey = 3;
  263. required uint32 count = 4;
  264. }
  265. message ListKeyResponseProto {
  266. repeated KeyData keyData = 1;
  267. }
  268. // Chunk Operations
  269. message ChunkInfo {
  270. required string chunkName = 1;
  271. required uint64 offset = 2;
  272. required uint64 len = 3;
  273. optional string checksum = 4;
  274. repeated KeyValue metadata = 5;
  275. }
  276. message WriteChunkRequestProto {
  277. required Pipeline pipeline = 1;
  278. required string keyName = 2;
  279. required ChunkInfo chunkData = 3;
  280. required bytes data = 4;
  281. }
  282. message WriteChunkResponseProto {
  283. }
  284. message ReadChunkRequestProto {
  285. required Pipeline pipeline = 1;
  286. required string keyName = 2;
  287. required ChunkInfo chunkData = 3;
  288. }
  289. message ReadChunkResponseProto {
  290. required Pipeline pipeline = 1;
  291. required ChunkInfo chunkData = 2;
  292. required bytes data = 3;
  293. }
  294. message DeleteChunkRequestProto {
  295. required Pipeline pipeline = 1;
  296. required string keyName = 2;
  297. required ChunkInfo chunkData = 3;
  298. }
  299. message DeleteChunkResponseProto {
  300. }
  301. message ListChunkRequestProto {
  302. required Pipeline pipeline = 1;
  303. required string keyName = 2;
  304. required string prevChunkName = 3;
  305. required uint32 count = 4;
  306. }
  307. message ListChunkResponseProto {
  308. repeated ChunkInfo chunkData = 1;
  309. }
  310. /** For small file access combines write chunk and putKey into a single
  311. RPC */
  312. message PutSmallFileRequestProto {
  313. required PutKeyRequestProto key = 1;
  314. required ChunkInfo chunkInfo = 2;
  315. required bytes data = 3;
  316. }
  317. message PutSmallFileResponseProto {
  318. }
  319. message GetSmallFileRequestProto {
  320. required GetKeyRequestProto key = 1;
  321. }
  322. message GetSmallFileResponseProto {
  323. required ReadChunkResponseProto data = 1;
  324. }
  325. message CopyContainerRequestProto {
  326. required string containerName = 1;
  327. required uint64 readOffset = 2;
  328. optional uint64 len = 3;
  329. }
  330. message CopyContainerResponseProto {
  331. required string archiveName = 1;
  332. required uint64 readOffset = 2;
  333. required uint64 len = 3;
  334. required bool eof = 4;
  335. repeated bytes data = 5;
  336. optional int64 checksum = 6;
  337. }