@@ -311,142 +311,4 @@ public static void checkForModifyTable(Configuration conf, TableDescriptor oldTa
311
311
}
312
312
}
313
313
}
314
-
315
- // should not use MigrationStoreFileTracker for new family
316
- private static void checkForNewFamily (Configuration conf , TableDescriptor table ,
317
- ColumnFamilyDescriptor family ) throws IOException {
318
- Configuration mergedConf = mergeConfigurations (conf , table , family );
319
- Class <? extends StoreFileTracker > tracker = getTrackerClass (mergedConf );
320
- if (MigrationStoreFileTracker .class .isAssignableFrom (tracker )) {
321
- throw new DoNotRetryIOException (
322
- "Should not use " + Trackers .MIGRATION + " as store file tracker for new family "
323
- + family .getNameAsString () + " of table " + table .getTableName ());
324
- }
325
- }
326
-
327
- /**
328
- * Pre check when creating a new table.
329
- * <p/>
330
- * For now, only make sure that we do not use {@link Trackers#MIGRATION} for newly created tables.
331
- * @throws IOException when there are check errors, the upper layer should fail the
332
- * {@code CreateTableProcedure}.
333
- */
334
- public static void checkForCreateTable (Configuration conf , TableDescriptor table )
335
- throws IOException {
336
- for (ColumnFamilyDescriptor family : table .getColumnFamilies ()) {
337
- checkForNewFamily (conf , table , family );
338
- }
339
- }
340
-
341
-
342
- /**
343
- * Pre check when modifying a table.
344
- * <p/>
345
- * The basic idea is when you want to change the store file tracker implementation, you should use
346
- * {@link Trackers#MIGRATION} first and then change to the destination store file tracker
347
- * implementation.
348
- * <p/>
349
- * There are several rules:
350
- * <ul>
351
- * <li>For newly added family, you should not use {@link Trackers#MIGRATION}.</li>
352
- * <li>For modifying a family:
353
- * <ul>
354
- * <li>If old tracker is {@link Trackers#MIGRATION}, then:
355
- * <ul>
356
- * <li>The new tracker is also {@link Trackers#MIGRATION}, then they must have the same src and
357
- * dst tracker.</li>
358
- * <li>The new tracker is not {@link Trackers#MIGRATION}, then the new tracker must be the dst
359
- * tracker of the old tracker.</li>
360
- * </ul>
361
- * </li>
362
- * <li>If the old tracker is not {@link Trackers#MIGRATION}, then:
363
- * <ul>
364
- * <li>If the new tracker is {@link Trackers#MIGRATION}, then the old tracker must be the src
365
- * tracker of the new tracker.</li>
366
- * <li>If the new tracker is not {@link Trackers#MIGRATION}, then the new tracker must be the same
367
- * with old tracker.</li>
368
- * </ul>
369
- * </li>
370
- * </ul>
371
- * </li>
372
- * </ul>
373
- * @throws IOException when there are check errors, the upper layer should fail the
374
- * {@code ModifyTableProcedure}.
375
- */
376
- public static void checkForModifyTable (Configuration conf , TableDescriptor oldTable ,
377
- TableDescriptor newTable ) throws IOException {
378
- for (ColumnFamilyDescriptor newFamily : newTable .getColumnFamilies ()) {
379
- ColumnFamilyDescriptor oldFamily = oldTable .getColumnFamily (newFamily .getName ());
380
- if (oldFamily == null ) {
381
- checkForNewFamily (conf , newTable , newFamily );
382
- continue ;
383
- }
384
- Configuration oldConf = mergeConfigurations (conf , oldTable , oldFamily );
385
- Configuration newConf = mergeConfigurations (conf , newTable , newFamily );
386
-
387
- Class <? extends StoreFileTracker > oldTracker = getTrackerClass (oldConf );
388
- Class <? extends StoreFileTracker > newTracker = getTrackerClass (newConf );
389
-
390
- if (MigrationStoreFileTracker .class .isAssignableFrom (oldTracker )) {
391
- Class <? extends StoreFileTracker > oldSrcTracker =
392
- MigrationStoreFileTracker .getSrcTrackerClass (oldConf );
393
- Class <? extends StoreFileTracker > oldDstTracker =
394
- MigrationStoreFileTracker .getDstTrackerClass (oldConf );
395
- if (oldTracker .equals (newTracker )) {
396
- // confirm that we have the same src tracker and dst tracker
397
- Class <? extends StoreFileTracker > newSrcTracker =
398
- MigrationStoreFileTracker .getSrcTrackerClass (newConf );
399
- if (!oldSrcTracker .equals (newSrcTracker )) {
400
- throw new DoNotRetryIOException (
401
- "The src tracker has been changed from " + getStoreFileTrackerName (oldSrcTracker )
402
- + " to " + getStoreFileTrackerName (newSrcTracker ) + " for family "
403
- + newFamily .getNameAsString () + " of table " + newTable .getTableName ());
404
- }
405
- Class <? extends StoreFileTracker > newDstTracker =
406
- MigrationStoreFileTracker .getDstTrackerClass (newConf );
407
- if (!oldDstTracker .equals (newDstTracker )) {
408
- throw new DoNotRetryIOException (
409
- "The dst tracker has been changed from " + getStoreFileTrackerName (oldDstTracker )
410
- + " to " + getStoreFileTrackerName (newDstTracker ) + " for family "
411
- + newFamily .getNameAsString () + " of table " + newTable .getTableName ());
412
- }
413
- } else {
414
- // we can only change to the dst tracker
415
- if (!newTracker .equals (oldDstTracker )) {
416
- throw new DoNotRetryIOException (
417
- "Should migrate tracker to " + getStoreFileTrackerName (oldDstTracker ) + " but got "
418
- + getStoreFileTrackerName (newTracker ) + " for family " + newFamily .getNameAsString ()
419
- + " of table " + newTable .getTableName ());
420
- }
421
- }
422
- } else {
423
- if (!oldTracker .equals (newTracker )) {
424
- // can only change to MigrationStoreFileTracker and the src tracker should be the old
425
- // tracker
426
- if (!MigrationStoreFileTracker .class .isAssignableFrom (newTracker )) {
427
- throw new DoNotRetryIOException ("Should change to " + Trackers .MIGRATION
428
- + " first when migrating from " + getStoreFileTrackerName (oldTracker ) + " for family "
429
- + newFamily .getNameAsString () + " of table " + newTable .getTableName ());
430
- }
431
- Class <? extends StoreFileTracker > newSrcTracker =
432
- MigrationStoreFileTracker .getSrcTrackerClass (newConf );
433
- if (!oldTracker .equals (newSrcTracker )) {
434
- throw new DoNotRetryIOException (
435
- "Should use src tracker " + getStoreFileTrackerName (oldTracker ) + " first but got "
436
- + getStoreFileTrackerName (newSrcTracker ) + " when migrating from "
437
- + getStoreFileTrackerName (oldTracker ) + " for family " + newFamily .getNameAsString ()
438
- + " of table " + newTable .getTableName ());
439
- }
440
- Class <? extends StoreFileTracker > newDstTracker =
441
- MigrationStoreFileTracker .getDstTrackerClass (newConf );
442
- // the src and dst tracker should not be the same
443
- if (newSrcTracker .equals (newDstTracker )) {
444
- throw new DoNotRetryIOException ("The src tracker and dst tracker are both "
445
- + getStoreFileTrackerName (newSrcTracker ) + " for family "
446
- + newFamily .getNameAsString () + " of table " + newTable .getTableName ());
447
- }
448
- }
449
- }
450
- }
451
- }
452
314
}
0 commit comments