HBASE-16646 Enhance LoadIncrementalHFiles API to accept store file paths as input - addendum adheres to original cleanup logic
This commit is contained in:
parent
348eb2834a
commit
08d9a2b662
|
@ -333,6 +333,26 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
|
|||
doBulkLoad(hfofDir, admin, table, regionLocator, false);
|
||||
}
|
||||
|
||||
void cleanup(Admin admin, Deque<LoadQueueItem> queue, ExecutorService pool,
|
||||
SecureBulkLoadClient secureClient) throws IOException {
|
||||
fsDelegationToken.releaseDelegationToken();
|
||||
if (bulkToken != null && secureClient != null) {
|
||||
secureClient.cleanupBulkLoad(admin.getConnection(), bulkToken);
|
||||
}
|
||||
if (pool != null) {
|
||||
pool.shutdown();
|
||||
}
|
||||
if (!queue.isEmpty()) {
|
||||
StringBuilder err = new StringBuilder();
|
||||
err.append("-------------------------------------------------\n");
|
||||
err.append("Bulk load aborted with some files not yet loaded:\n");
|
||||
err.append("-------------------------------------------------\n");
|
||||
for (LoadQueueItem q : queue) {
|
||||
err.append(" ").append(q.hfilePath).append('\n');
|
||||
}
|
||||
LOG.error(err);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Perform a bulk load of the given directory into the given
|
||||
* pre-existing table. This method is not threadsafe.
|
||||
|
@ -352,12 +372,20 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
|
|||
// LQI queue does not need to be threadsafe -- all operations on this queue
|
||||
// happen in this thread
|
||||
Deque<LoadQueueItem> queue = new LinkedList<>();
|
||||
ExecutorService pool = null;
|
||||
SecureBulkLoadClient secureClient = null;
|
||||
try {
|
||||
prepareHFileQueue(map, table, queue, silence);
|
||||
if (queue.isEmpty()) {
|
||||
LOG.warn("Bulk load operation did not get any files to load");
|
||||
return;
|
||||
}
|
||||
performBulkLoad(admin, table, regionLocator, queue);
|
||||
pool = createExecutorService();
|
||||
secureClient = new SecureBulkLoadClient(table.getConfiguration(), table);
|
||||
performBulkLoad(admin, table, regionLocator, queue, pool, secureClient);
|
||||
} finally {
|
||||
cleanup(admin, queue, pool, secureClient);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,6 +420,9 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
|
|||
// LQI queue does not need to be threadsafe -- all operations on this queue
|
||||
// happen in this thread
|
||||
Deque<LoadQueueItem> queue = new LinkedList<>();
|
||||
ExecutorService pool = null;
|
||||
SecureBulkLoadClient secureClient = null;
|
||||
try {
|
||||
prepareHFileQueue(hfofDir, table, queue, validateHFile, silence);
|
||||
|
||||
if (queue.isEmpty()) {
|
||||
|
@ -400,16 +431,17 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
|
|||
"subdirectories that correspond to column family names?");
|
||||
return;
|
||||
}
|
||||
performBulkLoad(admin, table, regionLocator, queue);
|
||||
pool = createExecutorService();
|
||||
secureClient = new SecureBulkLoadClient(table.getConfiguration(), table);
|
||||
performBulkLoad(admin, table, regionLocator, queue, pool, secureClient);
|
||||
} finally {
|
||||
cleanup(admin, queue, pool, secureClient);
|
||||
}
|
||||
}
|
||||
|
||||
void performBulkLoad(final Admin admin, Table table, RegionLocator regionLocator,
|
||||
Deque<LoadQueueItem> queue) throws IOException {
|
||||
ExecutorService pool = createExecutorService();
|
||||
|
||||
SecureBulkLoadClient secureClient = new SecureBulkLoadClient(table.getConfiguration(), table);
|
||||
|
||||
try {
|
||||
Deque<LoadQueueItem> queue, ExecutorService pool,
|
||||
SecureBulkLoadClient secureClient) throws IOException {
|
||||
int count = 0;
|
||||
|
||||
if(isSecureBulkLoadEndpointAvailable()) {
|
||||
|
@ -457,24 +489,6 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
|
|||
// that we can atomically pull out the groups we want to retry.
|
||||
}
|
||||
|
||||
} finally {
|
||||
fsDelegationToken.releaseDelegationToken();
|
||||
if(bulkToken != null) {
|
||||
secureClient.cleanupBulkLoad(admin.getConnection(), bulkToken);
|
||||
}
|
||||
pool.shutdown();
|
||||
if (!queue.isEmpty()) {
|
||||
StringBuilder err = new StringBuilder();
|
||||
err.append("-------------------------------------------------\n");
|
||||
err.append("Bulk load aborted with some files not yet loaded:\n");
|
||||
err.append("-------------------------------------------------\n");
|
||||
for (LoadQueueItem q : queue) {
|
||||
err.append(" ").append(q.hfilePath).append('\n');
|
||||
}
|
||||
LOG.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (!queue.isEmpty()) {
|
||||
throw new RuntimeException("Bulk load aborted with some files not yet loaded."
|
||||
+ "Please check log for more details.");
|
||||
|
|
Loading…
Reference in New Issue