@@ -133,12 +133,30 @@ public boolean isParentLevelUpgraded(Ample.DataLevel level) {
133
133
Map .of (ROOT_TABLET_META_CHANGES , new Upgrader10to11 (), REMOVE_DEPRECATIONS_FOR_VERSION_3 ,
134
134
new Upgrader11to12 (), METADATA_FILE_JSON_ENCODING , new Upgrader12to13 ())));
135
135
136
+ private final ServerContext context ;
137
+ private final UpgradeProgressTracker progressTracker ;
138
+ private final PreUpgradeValidation preUpgradeValidator ;
139
+
136
140
private volatile UpgradeStatus status ;
137
141
138
- public UpgradeCoordinator () {
142
+ public UpgradeCoordinator (ServerContext context ) {
143
+ this .context = context ;
144
+ progressTracker = new UpgradeProgressTracker (context );
145
+ preUpgradeValidator = new PreUpgradeValidation ();
139
146
status = UpgradeStatus .INITIAL ;
140
147
}
141
148
149
+ public void preUpgradeValidation () {
150
+ preUpgradeValidator .validate (context );
151
+ }
152
+
153
+ public void startOrContinueUpgrade () {
154
+ // The following check will fail if an upgrade is in progress
155
+ // but the target version is not the current version of the
156
+ // software.
157
+ progressTracker .startOrContinueUpgrade ();
158
+ }
159
+
142
160
private void setStatus (UpgradeStatus status , EventCoordinator eventCoordinator ) {
143
161
UpgradeStatus oldStatus = this .status ;
144
162
this .status = status ;
@@ -156,8 +174,7 @@ private void handleFailure(Exception e) {
156
174
System .exit (1 );
157
175
}
158
176
159
- public synchronized void upgradeZookeeper (ServerContext context ,
160
- EventCoordinator eventCoordinator ) {
177
+ public synchronized void upgradeZookeeper (EventCoordinator eventCoordinator ) {
161
178
162
179
Preconditions .checkState (status == UpgradeStatus .INITIAL ,
163
180
"Not currently in a suitable state to do zookeeper upgrade %s" , status );
@@ -172,15 +189,24 @@ public synchronized void upgradeZookeeper(ServerContext context,
172
189
}
173
190
174
191
if (currentVersion < AccumuloDataVersion .get ()) {
175
- abortIfFateTransactions (context );
192
+ abortIfFateTransactions ();
193
+
194
+ final UpgradeProgress progress = progressTracker .getProgress ();
176
195
177
196
for (int v = currentVersion ; v < AccumuloDataVersion .get (); v ++) {
197
+ if (progress .getZooKeeperVersion () >= currentVersion ) {
198
+ log .info (
199
+ "ZooKeeper has already been upgraded to version {}, moving on to next upgrader" ,
200
+ currentVersion );
201
+ continue ;
202
+ }
178
203
log .info ("Upgrading Zookeeper - current version {} as step towards target version {}" , v ,
179
204
AccumuloDataVersion .get ());
180
205
var upgrader = upgraders .get (v );
181
206
Objects .requireNonNull (upgrader ,
182
207
"upgrade ZooKeeper: failed to find upgrader for version " + currentVersion );
183
208
upgrader .upgradeZookeeper (context );
209
+ progressTracker .updateZooKeeperVersion (v );
184
210
}
185
211
}
186
212
@@ -191,8 +217,7 @@ public synchronized void upgradeZookeeper(ServerContext context,
191
217
192
218
}
193
219
194
- public synchronized Future <Void > upgradeMetadata (ServerContext context ,
195
- EventCoordinator eventCoordinator ) {
220
+ public synchronized Future <Void > upgradeMetadata (EventCoordinator eventCoordinator ) {
196
221
if (status == UpgradeStatus .COMPLETE ) {
197
222
return CompletableFuture .completedFuture (null );
198
223
}
@@ -206,35 +231,51 @@ public synchronized Future<Void> upgradeMetadata(ServerContext context,
206
231
.numMaxThreads (Integer .MAX_VALUE ).withTimeOut (60L , SECONDS )
207
232
.withQueue (new SynchronousQueue <>()).build ().submit (() -> {
208
233
try {
234
+ UpgradeProgress progress = progressTracker .getProgress ();
209
235
for (int v = currentVersion ; v < AccumuloDataVersion .get (); v ++) {
236
+ if (progress .getRootVersion () >= currentVersion ) {
237
+ log .info (
238
+ "Root table has already been upgraded to version {}, moving on to next upgrader" ,
239
+ currentVersion );
240
+ continue ;
241
+ }
210
242
log .info ("Upgrading Root - current version {} as step towards target version {}" , v ,
211
243
AccumuloDataVersion .get ());
212
244
var upgrader = upgraders .get (v );
213
245
Objects .requireNonNull (upgrader ,
214
246
"upgrade root: failed to find root upgrader for version " + currentVersion );
215
247
upgraders .get (v ).upgradeRoot (context );
248
+ progressTracker .updateRootVersion (v );
216
249
}
217
250
setStatus (UpgradeStatus .UPGRADED_ROOT , eventCoordinator );
218
251
219
252
for (int v = currentVersion ; v < AccumuloDataVersion .get (); v ++) {
253
+ if (progress .getMetadataVersion () >= currentVersion ) {
254
+ log .info (
255
+ "Metadata table has already been upgraded to version {}, moving on to next upgrader" ,
256
+ currentVersion );
257
+ continue ;
258
+ }
220
259
log .info (
221
260
"Upgrading Metadata - current version {} as step towards target version {}" , v ,
222
261
AccumuloDataVersion .get ());
223
262
var upgrader = upgraders .get (v );
224
263
Objects .requireNonNull (upgrader ,
225
264
"upgrade metadata: failed to find upgrader for version " + currentVersion );
226
265
upgraders .get (v ).upgradeMetadata (context );
266
+ progressTracker .updateMetadataVersion (v );
227
267
}
228
268
setStatus (UpgradeStatus .UPGRADED_METADATA , eventCoordinator );
229
269
230
270
log .info ("Validating configuration properties." );
231
- validateProperties (context );
271
+ validateProperties ();
232
272
233
273
log .info ("Updating persistent data version." );
234
274
updateAccumuloVersion (context .getServerDirs (), context .getVolumeManager (),
235
275
currentVersion );
236
276
log .info ("Upgrade complete" );
237
277
setStatus (UpgradeStatus .COMPLETE , eventCoordinator );
278
+ progressTracker .upgradeComplete ();
238
279
} catch (Exception e ) {
239
280
handleFailure (e );
240
281
}
@@ -245,7 +286,7 @@ public synchronized Future<Void> upgradeMetadata(ServerContext context,
245
286
}
246
287
}
247
288
248
- private void validateProperties (ServerContext context ) {
289
+ private void validateProperties () {
249
290
ConfigCheckUtil .validate (context .getSiteConfiguration (), "site configuration" );
250
291
ConfigCheckUtil .validate (context .getConfiguration (), "system configuration" );
251
292
try {
@@ -312,7 +353,7 @@ public UpgradeStatus getStatus() {
312
353
*/
313
354
@ SuppressFBWarnings (value = "DM_EXIT" ,
314
355
justification = "Want to immediately stop all manager threads on upgrade error" )
315
- private void abortIfFateTransactions (ServerContext context ) {
356
+ private void abortIfFateTransactions () {
316
357
try {
317
358
// The current version of the code creates the new accumulo.fate table on upgrade, so no
318
359
// attempt is made to read it here. Attempting to read it this point would likely cause a hang
0 commit comments