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/**
20 * These .proto interfaces are private and stable.
21 * Please see http://wiki.apache.org/hadoop/Compatibility
22 * for what changes are allowed for a *stable* .proto interface.
23 */
24
25option java_package = "org.apache.hadoop.hdfs.qjournal.protocol";
26option java_outer_classname = "QJournalProtocolProtos";
27option java_generic_services = true;
28option java_generate_equals_and_hash = true;
29package hadoop.hdfs.qjournal;
30
31import "hdfs.proto";
32
33message JournalIdProto {
34  required string identifier = 1;
35}
36
37message RequestInfoProto {
38  required JournalIdProto journalId = 1;
39  required uint64 epoch = 2;
40  required uint64 ipcSerialNumber = 3;
41
42  // Whenever a writer makes a request, it informs
43  // the node of the latest committed txid. This may
44  // be higher than the transaction data included in the
45  // request itself, eg in the case that the node has
46  // fallen behind.
47  optional uint64 committedTxId = 4;
48}
49
50message SegmentStateProto {
51  required uint64 startTxId = 1;
52  required uint64 endTxId = 2;
53  required bool isInProgress = 3;
54}
55
56/**
57 * The storage format used on local disk for previously
58 * accepted decisions.
59 */
60message PersistedRecoveryPaxosData {
61  required SegmentStateProto segmentState = 1;
62  required uint64 acceptedInEpoch = 2;
63}
64
65/**
66 * journal()
67 */
68
69message JournalRequestProto {
70  required RequestInfoProto reqInfo = 1;
71  required uint64 firstTxnId = 2;
72  required uint32 numTxns = 3;
73  required bytes records = 4;
74  required uint64 segmentTxnId = 5;
75}
76
77message JournalResponseProto {
78}
79
80/**
81 * heartbeat()
82 */
83
84message HeartbeatRequestProto {
85  required RequestInfoProto reqInfo = 1;
86}
87
88message HeartbeatResponseProto { // void response
89}
90
91/**
92 * startLogSegment()
93 */
94message StartLogSegmentRequestProto {
95  required RequestInfoProto reqInfo = 1;
96  required uint64 txid = 2; // Transaction ID
97  optional sint32 layoutVersion = 3; // the LayoutVersion in the client
98}
99
100message StartLogSegmentResponseProto {
101}
102
103/**
104 * finalizeLogSegment()
105 */
106message FinalizeLogSegmentRequestProto {
107  required RequestInfoProto reqInfo = 1;
108  required uint64 startTxId = 2;
109  required uint64 endTxId = 3;
110}
111
112message FinalizeLogSegmentResponseProto {
113}
114
115/**
116 * purgeLogs()
117 */
118message PurgeLogsRequestProto {
119  required RequestInfoProto reqInfo = 1;
120  required uint64 minTxIdToKeep = 2;
121}
122
123message PurgeLogsResponseProto {
124}
125
126/**
127 * isFormatted()
128 */
129message IsFormattedRequestProto {
130  required JournalIdProto jid = 1;
131}
132
133message IsFormattedResponseProto {
134  required bool isFormatted = 1;
135}
136
137/**
138 * discardSegments()
139 */
140message DiscardSegmentsRequestProto {
141  required JournalIdProto jid = 1;
142  required uint64 startTxId = 2;
143}
144
145message DiscardSegmentsResponseProto {
146}
147
148/**
149 * getJournalCTime()
150 */
151message GetJournalCTimeRequestProto {
152  required JournalIdProto jid = 1;
153}
154
155message GetJournalCTimeResponseProto {
156  required int64 resultCTime = 1;
157}
158
159/**
160 * doPreUpgrade()
161 */
162message DoPreUpgradeRequestProto {
163  required JournalIdProto jid = 1;
164}
165
166message DoPreUpgradeResponseProto {
167}
168
169/**
170 * doUpgrade()
171 */
172message DoUpgradeRequestProto {
173  required JournalIdProto jid = 1;
174  required StorageInfoProto sInfo = 2;
175}
176
177message DoUpgradeResponseProto {
178}
179
180/**
181 * doFinalize()
182 */
183message DoFinalizeRequestProto {
184  required JournalIdProto jid = 1;
185}
186
187message DoFinalizeResponseProto {
188}
189
190/**
191 * canRollBack()
192 */
193message CanRollBackRequestProto {
194  required JournalIdProto jid = 1;
195  required StorageInfoProto storage = 2;
196  required StorageInfoProto prevStorage = 3;
197  required int32 targetLayoutVersion = 4;
198}
199
200message CanRollBackResponseProto {
201  required bool canRollBack = 1;
202}
203
204/**
205 * doRollback()
206 */
207message DoRollbackRequestProto {
208  required JournalIdProto jid = 1;
209}
210
211message DoRollbackResponseProto {
212}
213
214/**
215 * getJournalState()
216 */
217message GetJournalStateRequestProto {
218  required JournalIdProto jid = 1;
219}
220
221message GetJournalStateResponseProto {
222  required uint64 lastPromisedEpoch = 1;
223  // Deprecated by fromURL
224  required uint32 httpPort = 2;
225  optional string fromURL = 3;
226}
227
228/**
229 * format()
230 */
231message FormatRequestProto {
232  required JournalIdProto jid = 1;
233  required NamespaceInfoProto nsInfo = 2;
234}
235
236message FormatResponseProto {
237}
238
239/**
240 * newEpoch()
241 */
242message NewEpochRequestProto {
243  required JournalIdProto jid = 1;
244  required NamespaceInfoProto nsInfo = 2;
245  required uint64 epoch = 3;
246}
247
248message NewEpochResponseProto {
249  optional uint64 lastSegmentTxId = 1;
250}
251
252/**
253 * getEditLogManifest()
254 */
255message GetEditLogManifestRequestProto {
256  required JournalIdProto jid = 1;
257  required uint64 sinceTxId = 2;  // Transaction ID
258  // Whether or not the client will be reading from the returned streams.
259  // optional bool forReading = 3 [default = true]; <obsolete, do not reuse>
260  optional bool inProgressOk = 4 [default = false];
261}
262
263message GetEditLogManifestResponseProto {
264  required RemoteEditLogManifestProto manifest = 1;
265  // Deprecated by fromURL
266  required uint32 httpPort = 2;
267  optional string fromURL = 3;
268
269  // TODO: we should add nsinfo somewhere
270  // to verify that it matches up with our expectation
271  // required NamespaceInfoProto nsInfo = 2;
272}
273
274/**
275 * prepareRecovery()
276 */
277message PrepareRecoveryRequestProto {
278  required RequestInfoProto reqInfo = 1;
279  required uint64 segmentTxId = 2;
280}
281
282message PrepareRecoveryResponseProto {
283  optional SegmentStateProto segmentState = 1;
284  optional uint64 acceptedInEpoch = 2;
285  required uint64 lastWriterEpoch = 3;
286
287  // The highest committed txid that this logger has ever seen.
288  // This may be higher than the data it actually has, in the case
289  // that it was lagging before the old writer crashed.
290  optional uint64 lastCommittedTxId = 4;
291}
292
293/**
294 * acceptRecovery()
295 */
296message AcceptRecoveryRequestProto {
297  required RequestInfoProto reqInfo = 1;
298
299  /** Details on the segment to recover */
300  required SegmentStateProto stateToAccept = 2;
301
302  /** The URL from which the log may be copied */
303  required string fromURL = 3;
304}
305
306message AcceptRecoveryResponseProto {
307}
308
309
310/**
311 * Protocol used to journal edits to a JournalNode.
312 * See the request and response for details of rpc call.
313 */
314service QJournalProtocolService {
315  rpc isFormatted(IsFormattedRequestProto) returns (IsFormattedResponseProto);
316
317  rpc discardSegments(DiscardSegmentsRequestProto) returns (DiscardSegmentsResponseProto);
318
319  rpc getJournalCTime(GetJournalCTimeRequestProto) returns (GetJournalCTimeResponseProto);
320
321  rpc doPreUpgrade(DoPreUpgradeRequestProto) returns (DoPreUpgradeResponseProto);
322
323  rpc doUpgrade(DoUpgradeRequestProto) returns (DoUpgradeResponseProto);
324
325  rpc doFinalize(DoFinalizeRequestProto) returns (DoFinalizeResponseProto);
326
327  rpc canRollBack(CanRollBackRequestProto) returns (CanRollBackResponseProto);
328
329  rpc doRollback(DoRollbackRequestProto) returns (DoRollbackResponseProto);
330
331  rpc getJournalState(GetJournalStateRequestProto) returns (GetJournalStateResponseProto);
332
333  rpc newEpoch(NewEpochRequestProto) returns (NewEpochResponseProto);
334
335  rpc format(FormatRequestProto) returns (FormatResponseProto);
336
337  rpc journal(JournalRequestProto) returns (JournalResponseProto);
338
339  rpc heartbeat(HeartbeatRequestProto) returns (HeartbeatResponseProto);
340
341  rpc startLogSegment(StartLogSegmentRequestProto)
342      returns (StartLogSegmentResponseProto);
343
344  rpc finalizeLogSegment(FinalizeLogSegmentRequestProto)
345      returns (FinalizeLogSegmentResponseProto);
346
347  rpc purgeLogs(PurgeLogsRequestProto)
348      returns (PurgeLogsResponseProto);
349
350  rpc getEditLogManifest(GetEditLogManifestRequestProto)
351      returns (GetEditLogManifestResponseProto);
352
353  rpc prepareRecovery(PrepareRecoveryRequestProto)
354      returns (PrepareRecoveryResponseProto);
355
356  rpc acceptRecovery(AcceptRecoveryRequestProto)
357      returns (AcceptRecoveryResponseProto);
358}
359