-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Make alluxio client return block location count configurable #18448
base: master-2.x
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -288,15 +288,27 @@ public List<BlockLocationInfo> getBlockLocations(URIStatus status) | |||||
if (locations.isEmpty() && mFsContext.getPathConf(new AlluxioURI(status.getPath())) | ||||||
.getBoolean(PropertyKey.USER_UFS_BLOCK_LOCATION_ALL_FALLBACK_ENABLED)) { | ||||||
// Case 2: Fallback to add all workers to locations so some apps (Impala) won't panic. | ||||||
locations.addAll(getHostWorkerMap().values()); | ||||||
Collections.shuffle(locations); | ||||||
PropertyKey locKey = PropertyKey.USER_UFS_BLOCK_LOCATION_RETURN_LIMIT; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's rename this property key name so it better reflects what it does in the code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
int count = mFsContext.getClusterConf().getInt(locKey); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use path conf There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
if (count < 0) { | ||||||
jiacheliu3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
throw new IllegalArgumentException("Property" + locKey.getName() | ||||||
+ " should not be set to a negative number"); | ||||||
} | ||||||
jiacheliu3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
List<WorkerNetAddress> addresses = getShuffleWorkerAddressList(); | ||||||
locations.addAll(addresses.subList(0, Math.min(addresses.size(), count))); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line has many copies, you can just write an easy for loop
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||||||
} | ||||||
} | ||||||
blockLocations.add(new BlockLocationInfo(fileBlockInfo, locations)); | ||||||
} | ||||||
return blockLocations; | ||||||
} | ||||||
|
||||||
private List<WorkerNetAddress> getShuffleWorkerAddressList() throws IOException { | ||||||
List<BlockWorkerInfo> workers = mFsContext.getCachedWorkers(); | ||||||
Collections.shuffle(workers); | ||||||
return workers.stream().map(BlockWorkerInfo::getNetAddress).collect(toList()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not keep using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will remove the method and use |
||||||
} | ||||||
|
||||||
private Map<String, WorkerNetAddress> getHostWorkerMap() throws IOException { | ||||||
List<BlockWorkerInfo> workers = mFsContext.getCachedWorkers(); | ||||||
return workers.stream().collect( | ||||||
|
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.
If this situation occurs, can you directly return the default value defined here? This is more friendly to Impala's file handle cache and data cache. This is because Impala will use consistent hash to schedule data scan fragment, and random block location returns will reduce the cache hit rate.
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.
Thanks for the review. I don't quite understand the change method you are talking about, or is this what you are talking about?