@ Override public CompletableFuture < Void > restoreSnapshot ( String snapshotName , boolean takeFailSafeSnapshot ) { CompletableFuture < Void > future = new CompletableFuture <> ( ) ; listSnapshots ( Pattern . compile ( snapshotName ) ) . whenComplete ( ( snapshotDescriptions , err ) -> { if ( err != null ) { future . completeExceptionally ( err ) ; return ; } final TableName tableName = snapshotExists ( snapshotName , snapshotDescriptions ) ; if ( tableName == null ) { future . completeExceptionally ( new RestoreSnapshotException ( "Unable to find the table name for snapshot=" + snapshotName ) ) ; return ; } tableExists ( tableName ) . whenComplete ( ( exists , err2 ) -> { if ( err2 != null ) { future . completeExceptionally ( err2 ) ; } else if ( ! exists ) { // if table does not exist, then just clone snapshot into new table. completeConditionalOnFuture ( future , cloneSnapshot ( snapshotName , tableName ) ) ; } else { isTableDisabled ( tableName ) . whenComplete ( ( disabled , err4 ) -> { if ( err4 != null ) { future . completeExceptionally ( err4 ) ; } else if ( ! disabled ) { future . completeExceptionally ( new TableNotDisabledException ( tableName ) ) ; } else { completeConditionalOnFuture ( future , restoreSnapshot ( snapshotName , takeFailSafeSnapshot ) ) ; } } ) ; } } ) ; } ) ; return future ; }
Restore the specified snapshot on the original table .