StorageContainerDatanodeProtocol.proto 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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://wiki.apache.org/hadoop/Compatibility
  21. * for what changes are allowed for a *unstable* .proto interface.
  22. */
  23. option java_package = "org.apache.hadoop.ozone.protocol.proto";
  24. option java_outer_classname = "StorageContainerDatanodeProtocolProtos";
  25. option java_generic_services = true;
  26. option java_generate_equals_and_hash = true;
  27. package hadoop.hdfs;
  28. import "hdfs.proto";
  29. import "HdfsServer.proto";
  30. import "DatanodeProtocol.proto";
  31. import "Ozone.proto";
  32. /**
  33. * This message is send by data node to indicate that it is alive or it is
  34. * registering with the node manager.
  35. */
  36. message SCMHeartbeatRequestProto {
  37. required DatanodeIDProto datanodeID = 1;
  38. optional SCMNodeReport nodeReport = 2;
  39. optional ReportState containerReportState = 3;
  40. }
  41. enum ContainerState {
  42. closed = 0;
  43. open = 1;
  44. }
  45. /**
  46. NodeState contains messages from datanode to SCM saying that it has
  47. some information that SCM might be interested in.*/
  48. message ReportState {
  49. enum states {
  50. noContainerReports = 0;
  51. completeContinerReport = 1;
  52. deltaContainerReport = 2;
  53. }
  54. required states state = 1;
  55. required int64 count = 2 [default = 0];
  56. }
  57. /**
  58. This message is used to persist the information about a container in the
  59. SCM database, This information allows SCM to startup faster and avoid having
  60. all container info in memory all the time.
  61. */
  62. message ContainerPersistanceProto {
  63. required ContainerState state = 1;
  64. required hadoop.hdfs.ozone.Pipeline pipeline = 2;
  65. required ContainerInfo info = 3;
  66. }
  67. /**
  68. This message is used to do a quick look up of which containers are effected
  69. if a node goes down
  70. */
  71. message NodeContianerMapping {
  72. repeated string contianerName = 1;
  73. }
  74. /**
  75. A container report contains the following information.
  76. */
  77. message ContainerInfo {
  78. required string containerName = 1;
  79. required string finalhash = 2;
  80. optional int64 size = 3;
  81. optional int64 keycount = 4;
  82. }
  83. /**
  84. A set of container reports, max count is generally set to
  85. 8192 since that keeps the size of the reports under 1 MB.
  86. */
  87. message ContainerReportsProto {
  88. enum reportType {
  89. fullReport = 0;
  90. deltaReport = 1;
  91. }
  92. repeated ContainerInfo reports = 1;
  93. required reportType type = 2;
  94. }
  95. /**
  96. * This message is send along with the heart beat to report datanode
  97. * storage utilization by SCM.
  98. */
  99. message SCMNodeReport {
  100. repeated SCMStorageReport storageReport = 1;
  101. }
  102. message SCMStorageReport {
  103. required string storageUuid = 1;
  104. optional uint64 capacity = 2 [default = 0];
  105. optional uint64 scmUsed = 3 [default = 0];
  106. optional uint64 remaining = 4 [default = 0];
  107. optional StorageTypeProto storageType = 5 [default = DISK];
  108. }
  109. message SCMRegisterRequestProto {
  110. required DatanodeIDProto datanodeID = 1;
  111. optional SCMNodeAddressList addressList = 2;
  112. }
  113. /**
  114. * Request for version info of the software stack on the server.
  115. */
  116. message SCMVersionRequestProto {
  117. }
  118. /**
  119. * Generic response that is send to a version request. This allows keys to be
  120. * added on the fly and protocol to remain stable.
  121. */
  122. message SCMVersionResponseProto {
  123. required uint32 softwareVersion = 1;
  124. repeated hadoop.hdfs.ozone.KeyValue keys = 2;
  125. }
  126. message SCMNodeAddressList {
  127. repeated string addressList = 1;
  128. }
  129. /**
  130. * Datanode ID returned by the SCM. This is similar to name node
  131. * registeration of a datanode.
  132. */
  133. message SCMRegisteredCmdResponseProto {
  134. enum ErrorCode {
  135. success = 1;
  136. errorNodeNotPermitted = 2;
  137. }
  138. required ErrorCode errorCode = 2;
  139. optional string datanodeUUID = 3;
  140. optional string clusterID = 4;
  141. optional SCMNodeAddressList addressList = 5;
  142. }
  143. /**
  144. * Container ID maintains the container's Identity along with cluster ID
  145. * after the registration is done.
  146. */
  147. message ContainerNodeIDProto {
  148. required DatanodeIDProto datanodeID = 1;
  149. optional string clusterID = 2;
  150. }
  151. /**
  152. This command tells the data node to send in the container report when possible
  153. */
  154. message SendContainerReportProto {
  155. }
  156. /**
  157. Type of commands supported by SCM to datanode protocol.
  158. */
  159. enum Type {
  160. versionCommand = 2;
  161. registeredCommand = 3;
  162. sendContainerReport = 4;
  163. }
  164. /*
  165. * These are commands returned by SCM for to the datanode to execute.
  166. */
  167. message SCMCommandResponseProto {
  168. required Type cmdType = 2; // Type of the command
  169. optional SCMRegisteredCmdResponseProto registeredProto = 3;
  170. optional SCMVersionResponseProto versionProto = 4;
  171. optional SendContainerReportProto sendReport = 5;
  172. }
  173. /*
  174. * A group of commands for the datanode to execute
  175. */
  176. message SCMHeartbeatResponseProto {
  177. repeated SCMCommandResponseProto commands = 1;
  178. }
  179. /**
  180. * Protocol used from a datanode to StorageContainerManager.
  181. *
  182. * Please see the request and response messages for details of the RPC calls.
  183. *
  184. * Here is a simple state diagram that shows how a datanode would boot up and
  185. * communicate with SCM.
  186. *
  187. * -----------------------
  188. * | Start |
  189. * ---------- ------------
  190. * |
  191. * |
  192. * |
  193. * |
  194. * |
  195. * |
  196. * |
  197. * ----------v-------------
  198. * | Searching for SCM ------------
  199. * ---------- ------------- |
  200. * | |
  201. * | |
  202. * | ----------v-------------
  203. * | | Register if needed |
  204. * | ----------- ------------
  205. * | |
  206. * v |
  207. * ----------- ---------------- |
  208. * --------- Heartbeat state <--------
  209. * | --------^-------------------
  210. * | |
  211. * | |
  212. * | |
  213. * | |
  214. * | |
  215. * | |
  216. * | |
  217. * ------------------
  218. *
  219. *
  220. *
  221. * Here is how this protocol is used by the datanode. When a datanode boots up
  222. * it moves into a stated called SEARCHING_SCM. In this state datanode is
  223. * trying to establish communication with the SCM. The address of the SCMs are
  224. * retrieved from the configuration information.
  225. *
  226. * In the SEARCHING_SCM state, only rpc call made by datanode is a getVersion
  227. * call to SCM. Once any of the SCMs reply, datanode checks if it has a local
  228. * persisted datanode ID. If it has this means that this datanode is already
  229. * registered with some SCM. If this file is not found, datanode assumes that
  230. * it needs to do a registration.
  231. *
  232. * If registration is need datanode moves into REGISTER state. It will
  233. * send a register call with datanodeID data structure and presist that info.
  234. *
  235. * The response to the command contains clusterID. This information is
  236. * also persisted by the datanode and moves into heartbeat state.
  237. *
  238. * Once in the heartbeat state, datanode sends heartbeats and container reports
  239. * to SCM and process commands issued by SCM until it is shutdown.
  240. *
  241. */
  242. service StorageContainerDatanodeProtocolService {
  243. /**
  244. * Gets the version information from the SCM.
  245. */
  246. rpc getVersion (SCMVersionRequestProto) returns (SCMVersionResponseProto);
  247. /**
  248. * Registers a data node with SCM.
  249. */
  250. rpc register (SCMRegisterRequestProto) returns (SCMRegisteredCmdResponseProto);
  251. /**
  252. * Send heartbeat from datanode to SCM. HB's under SCM looks more
  253. * like life line protocol than HB's under HDFS. In other words, it is
  254. * extremely light weight and contains no data payload.
  255. */
  256. rpc sendHeartbeat (SCMHeartbeatRequestProto) returns (SCMHeartbeatResponseProto);
  257. /**
  258. send container reports sends the container report to SCM. This will
  259. return a null command as response.
  260. */
  261. rpc sendContainerReport(ContainerReportsProto) returns (SCMHeartbeatResponseProto);
  262. }