-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-28182 Create ref files using threadpool as part of merge #5487
base: branch-2
Are you sure you want to change the base?
Conversation
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please target changes on master branch first.
Configuration conf = env.getMasterConfiguration(); | ||
int numOfThreads = conf.getInt(HConstants.REGION_SPLIT_THREADS_MAX, | ||
conf.getInt(HStore.BLOCKING_STOREFILES_KEY, HStore.DEFAULT_BLOCKING_STOREFILE_COUNT)); | ||
List<Path> mergedFiles = new ArrayList<Path>(); | ||
final ExecutorService threadPool = Executors.newFixedThreadPool(numOfThreads, | ||
new ThreadFactoryBuilder().setNameFormat("StoreFileMerge-pool-%d").setDaemon(true) | ||
.setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build()); | ||
final List<Future<Path>> futures = new ArrayList<Future<Path>>(); | ||
for (RegionInfo ri : this.regionsToMerge) { | ||
HRegionFileSystem regionFs = HRegionFileSystem | ||
.openRegionFromFileSystem(env.getMasterConfiguration(), fs, tableDir, ri, false); | ||
mergedFiles.addAll(mergeStoreFiles(env, regionFs, mergeRegionFs, mergedRegion)); | ||
mergeStoreFiles(env, regionFs, mergeRegionFs, mergedRegion, threadPool, futures); | ||
} | ||
// Shutdown the pool | ||
threadPool.shutdown(); | ||
|
||
// Wait for all the tasks to finish. | ||
// When splits ran on the RegionServer, how-long-to-wait-configuration was named | ||
// hbase.regionserver.fileSplitTimeout. If set, use its value. | ||
long fileSplitTimeout = conf.getLong("hbase.master.fileSplitTimeout", | ||
conf.getLong("hbase.regionserver.fileSplitTimeout", 600000)); | ||
try { | ||
boolean stillRunning = !threadPool.awaitTermination(fileSplitTimeout, TimeUnit.MILLISECONDS); | ||
if (stillRunning) { | ||
threadPool.shutdownNow(); | ||
// wait for the thread to shutdown completely. | ||
while (!threadPool.isTerminated()) { | ||
Thread.sleep(50); | ||
} | ||
throw new IOException( | ||
"Took too long to merge the" + " files and create the references, aborting merge"); | ||
} | ||
} catch (InterruptedException e) { | ||
throw (InterruptedIOException) new InterruptedIOException().initCause(e); | ||
} | ||
|
||
for (Future<Path> future : futures) { | ||
try { | ||
Path path = future.get(); | ||
if (path != null) { | ||
mergedFiles.add(path); | ||
} | ||
} catch (InterruptedException e) { | ||
throw (InterruptedIOException) new InterruptedIOException().initCause(e); | ||
} catch (ExecutionException e) { | ||
throw new IOException(e); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole block shows lots of duplication with SplitTableRegionProcedure. We should put what's reusable in a common method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wchevreuil
Moved common code to a Util file, will it be better to move that to hbase-common module instead of hbase-server?, there is one ThreadUtil class in hadoop-common, should I be using that instead? thoughts?
2c881f6
to
85cf598
Compare
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
85cf598
to
7cdeadf
Compare
💔 -1 overall
This message was automatically generated. |
7cdeadf
to
dfbe19c
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
No description provided.