/** * Deletes the table but does not block and wait for it be completely removed. * You can use Future.get(long, TimeUnit) to wait on the operation to complete. * It may throw ExecutionException if there was an error while executing the operation * or TimeoutException in case the wait timeout was not long enough to allow the * operation to complete. * * @param desc table descriptor for table * @param tableName name of table to delete * @throws IOException if a remote or network exception occurs * @return the result of the async delete. You can use Future.get(long, TimeUnit) * to wait on the operation to complete. */ // TODO: This should be called Async but it will break binary compatibility private Future<Void> deleteTableAsyncV2(final TableName tableName) throws IOException { DeleteTableResponse response = executeCallable( new MasterCallable<DeleteTableResponse>(getConnection()) { @Override public DeleteTableResponse call(int callTimeout) throws ServiceException { DeleteTableRequest req = RequestConverter.buildDeleteTableRequest(tableName, ng.getNonceGroup(), ng.newNonce()); return master.deleteTable(null,req); } }); return new DeleteTableFuture(this, tableName, response); }
@Override protected Void postOperationResult(final Void result, final long deadlineTs) throws IOException, TimeoutException { // Delete cached information to prevent clients from using old locations getAdmin().getConnection().clearRegionCache(tableName); LOG.info("Deleted " + tableName); return result; }
@Override protected Void waitOperationResult(final long deadlineTs) throws IOException, TimeoutException { waitTableNotFound(deadlineTs); return null; }
private void waitTableNotFound(final long deadlineTs) throws IOException, TimeoutException { waitForState(deadlineTs, new WaitForStateCallable() { @Override public boolean checkState(int tries) throws IOException { return !getAdmin().tableExists(tableName); } @Override public void throwInterruptedException() throws InterruptedIOException { throw new InterruptedIOException("Interrupted when waiting for table to be deleted"); } @Override public void throwTimeoutException(long elapsedTime) throws TimeoutException { throw new TimeoutException("Table " + tableName + " not yet deleted after " + elapsedTime + "msec"); } }); } }
@Override public Future<Void> deleteTableAsync(final TableName tableName) throws IOException { DeleteTableResponse response = executeCallable( new MasterCallable<DeleteTableResponse>(getConnection(), getRpcControllerFactory()) { @Override protected DeleteTableResponse rpcCall() throws Exception { setPriority(tableName); DeleteTableRequest req = RequestConverter.buildDeleteTableRequest(tableName, ng.getNonceGroup(),ng.newNonce()); return master.deleteTable(getRpcController(), req); } }); return new DeleteTableFuture(this, tableName, response); }
@Override public boolean checkState(int tries) throws IOException { return !getAdmin().tableExists(tableName); }
@Override protected Void waitOperationResult(final long deadlineTs) throws IOException, TimeoutException { waitTableNotFound(deadlineTs); return null; }
@Override protected Void postOperationResult(final Void result, final long deadlineTs) throws IOException, TimeoutException { // Delete cached information to prevent clients from using old locations ((ClusterConnection) getAdmin().getConnection()).clearRegionCache(getTableName()); return super.postOperationResult(result, deadlineTs); } }
@Override public Future<Void> deleteTableAsync(final TableName tableName) throws IOException { DeleteTableResponse response = executeCallable( new MasterCallable<DeleteTableResponse>(getConnection(), getRpcControllerFactory()) { Long nonceGroup = ng.getNonceGroup(); Long nonce = ng.newNonce(); @Override protected DeleteTableResponse rpcCall() throws Exception { setPriority(tableName); DeleteTableRequest req = RequestConverter.buildDeleteTableRequest(tableName, nonceGroup,nonce); return master.deleteTable(getRpcController(), req); } }); return new DeleteTableFuture(this, tableName, response); }
@Override protected Void waitOperationResult(final long deadlineTs) throws IOException, TimeoutException { waitTableNotFound(deadlineTs); return null; }
@Override protected Void postOperationResult(final Void result, final long deadlineTs) throws IOException, TimeoutException { // Delete cached information to prevent clients from using old locations ((ClusterConnection) getAdmin().getConnection()).clearRegionCache(getTableName()); return super.postOperationResult(result, deadlineTs); } }
@Override public Future<Void> deleteTableAsync(final TableName tableName) throws IOException { DeleteTableResponse response = executeCallable( new MasterCallable<DeleteTableResponse>(getConnection(), getRpcControllerFactory()) { Long nonceGroup = ng.getNonceGroup(); Long nonce = ng.newNonce(); @Override protected DeleteTableResponse rpcCall() throws Exception { setPriority(tableName); DeleteTableRequest req = RequestConverter.buildDeleteTableRequest(tableName, nonceGroup,nonce); return master.deleteTable(getRpcController(), req); } }); return new DeleteTableFuture(this, tableName, response); }
@Override protected Void postOperationResult(final Void result, final long deadlineTs) throws IOException, TimeoutException { // Delete cached information to prevent clients from using old locations ((ClusterConnection) getAdmin().getConnection()).clearRegionCache(getTableName()); return super.postOperationResult(result, deadlineTs); } }
@Override protected Void waitOperationResult(final long deadlineTs) throws IOException, TimeoutException { waitTableNotFound(deadlineTs); return null; }