1
0

DatanodeContainerProtocol.proto 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. enum Type {
  68. CreateContainer = 1;
  69. ReadContainer = 2;
  70. UpdateContainer = 3;
  71. DeleteContainer = 4;
  72. ListContainer = 5;
  73. PutKey = 6;
  74. GetKey = 7;
  75. DeleteKey = 8;
  76. ListKey = 9;
  77. ReadChunk = 10;
  78. DeleteChunk = 11;
  79. WriteChunk = 12;
  80. ListChunk = 13;
  81. CompactChunk = 14;
  82. /** Combines Key and Chunk Operation into Single RPC. */
  83. PutSmallFile = 15;
  84. GetSmallFile = 16;
  85. }
  86. enum Result {
  87. SUCCESS = 1;
  88. UNSUPPORTED_REQUEST = 2;
  89. MALFORMED_REQUEST = 3;
  90. CONTAINER_INTERNAL_ERROR = 4;
  91. }
  92. message ContainerCommandRequestProto {
  93. required Type cmdType = 1; // Type of the command
  94. // A string that identifies this command, we generate Trace ID in Ozone
  95. // frontend and this allows us to trace that command all over ozone.
  96. optional string traceID = 2;
  97. // One of the following command is available when the corresponding
  98. // cmdType is set. At the protocol level we allow only
  99. // one command in each packet.
  100. // TODO : Upgrade to Protobuf 2.6 or later.
  101. optional CreateContainerRequestProto createContainer = 3;
  102. optional ReadContainerRequestProto readContainer = 4;
  103. optional UpdateContainerRequestProto updateContainer = 5;
  104. optional DeleteContainerRequestProto deleteContainer = 6;
  105. optional ListContainerRequestProto listContainer = 7;
  106. optional PutKeyRequestProto putKey = 8;
  107. optional GetKeyRequestProto getKey = 9;
  108. optional DeleteKeyRequestProto deleteKey = 10;
  109. optional ListKeyRequestProto listKey = 11;
  110. optional ReadChunkRequestProto readChunk = 12;
  111. optional WriteChunkRequestProto writeChunk = 13;
  112. optional DeleteChunkRequestProto deleteChunk = 14;
  113. optional ListChunkRequestProto listChunk = 15;
  114. optional PutSmallFileRequestProto putSmallFile = 16;
  115. optional GetSmallFileRequestProto getSmallFile = 17;
  116. }
  117. message ContainerCommandResponseProto {
  118. required Type cmdType = 1;
  119. optional string traceID = 2;
  120. optional CreateContainerResponseProto createContainer = 3;
  121. optional ReadContainerResponseProto readContainer = 4;
  122. optional UpdateContainerResponseProto updateContainer = 5;
  123. optional DeleteContainerResponseProto deleteContainer = 6;
  124. optional ListContainerResponseProto listContainer = 7;
  125. optional PutKeyResponseProto putKey = 8;
  126. optional GetKeyResponseProto getKey = 9;
  127. optional DeleteKeyResponseProto deleteKey = 10;
  128. optional ListKeyResponseProto listKey = 11;
  129. optional WriteChunkResponseProto writeChunk = 12;
  130. optional ReadChunkResponseProto readChunk = 13;
  131. optional DeleteChunkResponseProto deleteChunk = 14;
  132. optional ListChunkResponseProto listChunk = 15;
  133. required Result result = 17;
  134. optional string message = 18;
  135. optional PutSmallFileResponseProto putSmallFile = 19;
  136. optional GetSmallFileResponseProto getSmallFile = 20;
  137. }
  138. // A pipeline is composed of one or more datanodes that back a container.
  139. message Pipeline {
  140. required string leaderID = 1;
  141. repeated DatanodeIDProto members = 2;
  142. required string containerName = 3;
  143. }
  144. message KeyValue {
  145. required string key = 1;
  146. optional string value = 2;
  147. }
  148. message ContainerData {
  149. required string name = 1;
  150. repeated KeyValue metadata = 2;
  151. optional string dbPath = 3;
  152. optional string containerPath = 4;
  153. }
  154. message ContainerMeta {
  155. required string fileName = 1;
  156. required string hash = 2;
  157. }
  158. // Container Messages.
  159. message CreateContainerRequestProto {
  160. required Pipeline pipeline = 1;
  161. required ContainerData containerData = 2;
  162. }
  163. message CreateContainerResponseProto {
  164. }
  165. message ReadContainerRequestProto {
  166. required Pipeline pipeline = 1;
  167. required string name = 2;
  168. }
  169. message ReadContainerResponseProto {
  170. optional ContainerData containerData = 2;
  171. }
  172. message UpdateContainerRequestProto {
  173. required Pipeline pipeline = 1;
  174. required ContainerData containerData = 2;
  175. }
  176. message UpdateContainerResponseProto {
  177. }
  178. message DeleteContainerRequestProto {
  179. required Pipeline pipeline = 1;
  180. required string name = 2;
  181. }
  182. message DeleteContainerResponseProto {
  183. }
  184. message ListContainerRequestProto {
  185. required Pipeline pipeline = 1;
  186. optional string prefix = 2;
  187. required uint32 count = 3; // Max Results to return
  188. optional string prevKey = 4; // if this is not set query from start.
  189. }
  190. message ListContainerResponseProto {
  191. repeated ContainerData containerData = 1;
  192. }
  193. message KeyData {
  194. required string containerName = 1;
  195. required string name = 2;
  196. optional int64 flags = 3; // for future use.
  197. repeated KeyValue metadata = 4;
  198. repeated ChunkInfo chunks = 5;
  199. }
  200. // Key Messages.
  201. message PutKeyRequestProto {
  202. required Pipeline pipeline = 1;
  203. required KeyData keyData = 2;
  204. }
  205. message PutKeyResponseProto {
  206. }
  207. message GetKeyRequestProto {
  208. required Pipeline pipeline = 1;
  209. required KeyData keyData = 2;
  210. }
  211. message GetKeyResponseProto {
  212. required KeyData keyData = 1;
  213. }
  214. message DeleteKeyRequestProto {
  215. required Pipeline pipeline = 1;
  216. required string name = 2;
  217. }
  218. message DeleteKeyResponseProto {
  219. }
  220. message ListKeyRequestProto {
  221. required Pipeline pipeline = 1;
  222. optional string prefix = 2; // if specified returns keys that match prefix.
  223. required string prevKey = 3;
  224. required uint32 count = 4;
  225. }
  226. message ListKeyResponseProto {
  227. repeated KeyData keyData = 1;
  228. }
  229. // Chunk Operations
  230. message ChunkInfo {
  231. required string chunkName = 1;
  232. required uint64 offset = 2;
  233. required uint64 len = 3;
  234. optional string checksum = 4;
  235. repeated KeyValue metadata = 5;
  236. }
  237. message WriteChunkRequestProto {
  238. required Pipeline pipeline = 1;
  239. required string keyName = 2;
  240. required ChunkInfo chunkData = 3;
  241. required bytes data = 4;
  242. }
  243. message WriteChunkResponseProto {
  244. }
  245. message ReadChunkRequestProto {
  246. required Pipeline pipeline = 1;
  247. required string keyName = 2;
  248. required ChunkInfo chunkData = 3;
  249. }
  250. message ReadChunkResponseProto {
  251. required Pipeline pipeline = 1;
  252. required ChunkInfo chunkData = 2;
  253. required bytes data = 3;
  254. }
  255. message DeleteChunkRequestProto {
  256. required Pipeline pipeline = 1;
  257. required string keyName = 2;
  258. required ChunkInfo chunkData = 3;
  259. }
  260. message DeleteChunkResponseProto {
  261. }
  262. message ListChunkRequestProto {
  263. required Pipeline pipeline = 1;
  264. required string keyName = 2;
  265. required string prevChunkName = 3;
  266. required uint32 count = 4;
  267. }
  268. message ListChunkResponseProto {
  269. repeated ChunkInfo chunkData = 1;
  270. }
  271. /** For small file access combines write chunk and putKey into a single
  272. RPC */
  273. message PutSmallFileRequestProto {
  274. required PutKeyRequestProto key = 1;
  275. required ChunkInfo chunkInfo = 2;
  276. required bytes data = 3;
  277. }
  278. message PutSmallFileResponseProto {
  279. }
  280. message GetSmallFileRequestProto {
  281. required GetKeyRequestProto key = 1;
  282. }
  283. message GetSmallFileResponseProto {
  284. required ReadChunkResponseProto data = 1;
  285. }