-
Notifications
You must be signed in to change notification settings - Fork 8.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
HADOOP-18180. Replace use of twitter util-core with java futures #4115
Merged
steveloughran
merged 13 commits into
apache:feature-HADOOP-18028-s3a-prefetch
from
pjfanning:HADOOP-18180-remove-twitter-util
Apr 4, 2022
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d48eaa7
HADOOP-18080 replace use of twitter util-core
pjfanning 02be95b
address some review comments
pjfanning a0dd7fe
add tests
pjfanning bcab50d
missing license
pjfanning 339f47d
rename FuturePool methods
pjfanning c5b3c4b
Update ExecutorServiceFuturePool.java
pjfanning 5f9b643
Update ExecutorServiceFuturePool.java
pjfanning 915b1d3
fix indents
pjfanning 27138bd
PR review items
pjfanning 57a5ccb
use LambdaTestUtils
pjfanning 66562cc
checkstyle warnings
pjfanning ca715d4
Update ExecutorServiceFuturePool.java
pjfanning c01c7e0
try to match import order
pjfanning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/common/ExecutorServiceFuturePool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.hadoop.fs.common; | ||
|
||
import java.util.Locale; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Future; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* A FuturePool implementation backed by a java.util.concurrent.ExecutorService. | ||
* | ||
* If a piece of work has started, it cannot (currently) be cancelled. | ||
* | ||
* This class is a simplified version of <code>com.twitter:util-core_2.11</code> ExecutorServiceFuturePool | ||
* designed to avoid depending on that Scala library. One problem with using a Scala library is that many | ||
* downstream projects (eg Apache Spark) use Scala and they might want to use a different version of Scala | ||
* from the version that Hadoop chooses to use. | ||
* | ||
*/ | ||
public class ExecutorServiceFuturePool { | ||
steveloughran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private ExecutorService executor; | ||
|
||
public ExecutorServiceFuturePool(ExecutorService executor) { | ||
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. interesting q here about what service to support/integrate with here, especially for faireness in processs with many readers. created https://issues.apache.org/jira/browse/HADOOP-18186 as a followup to this. |
||
this.executor = executor; | ||
} | ||
|
||
/** | ||
* @param f function to run in future on executor pool | ||
* @return future | ||
* @throws java.util.concurrent.RejectedExecutionException can be thrown | ||
* @throws NullPointerException if f param is null | ||
*/ | ||
public Future<Void> executeFunction(final Supplier<Void> f) { | ||
return executor.submit(f::get); | ||
} | ||
|
||
/** | ||
* @param r runnable to run in future on executor pool | ||
* @return future | ||
* @throws java.util.concurrent.RejectedExecutionException can be thrown | ||
* @throws NullPointerException if r param is null | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public Future<Void> executeRunnable(final Runnable r) { | ||
return (Future<Void>) executor.submit(() -> r.run()); | ||
pjfanning marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public String toString() { | ||
return String.format(Locale.ROOT,"ExecutorServiceFuturePool(executor=%s)", executor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we need to think what we want to do here.
created https://issues.apache.org/jira/browse/HADOOP-18185