Skip to content
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

[SPARK-3902] [SPARK-3590] Stabilize AsynRDDActions and add Java API #2760

Closed
wants to merge 8 commits into from

Conversation

JoshRosen
Copy link
Contributor

This PR adds a Java API for AsyncRDDActions and promotes the API from @Experimental to stable.

@JoshRosen
Copy link
Contributor Author

/cc's for review:

import java.util.List;
import java.util.concurrent.Future;

public interface JavaFutureAction<T> extends Future<T> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it makes sense to expose an extended version of the Java Future API to users, since there may be a number of existing libraries for consuming these standard future types.

@SparkQA
Copy link

SparkQA commented Oct 11, 2014

QA tests have started for PR 2760 at commit ff28e49.

  • This patch merges cleanly.

*/
@Experimental
def foreachAsync(f: VoidFunction[T]): FutureAction[Unit] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, my PR breaks compatibility for this experimental Java API. However, the previous version of this method hasn't been shipped in any Spark releases yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i think this is fine

@SparkQA
Copy link

SparkQA commented Oct 11, 2014

QA tests have started for PR 2760 at commit 6f8f6ac.

  • This patch merges cleanly.

@lirui-apache
Copy link

Looks great! I think it's very useful to have these async APIs in java :-)

@SparkQA
Copy link

SparkQA commented Oct 11, 2014

QA tests have finished for PR 2760 at commit ff28e49.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaFutureActionWrapper[S, T](futureAction: FutureAction[S], converter: S => T)

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21628/Test PASSed.

@SparkQA
Copy link

SparkQA commented Oct 11, 2014

QA tests have finished for PR 2760 at commit 6f8f6ac.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaFutureActionWrapper[S, T](futureAction: FutureAction[S], converter: S => T)

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21630/Test PASSed.

@JoshRosen JoshRosen changed the title [SPARK-3902] Stabilize AsynRDDActions and add Java API [SPARK-3902] [SPARK-3590] Stabilize AsynRDDActions and add Java API Oct 13, 2014
@@ -17,6 +17,7 @@

package org.apache.spark.api.java

import java.util
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an extra import?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; fixed.

@JoshRosen
Copy link
Contributor Author

@rxin I removed that extra import. Any other comments or things you'd like to discuss?

@SparkQA
Copy link

SparkQA commented Oct 14, 2014

QA tests have started for PR 2760 at commit 7a1417f.

  • This patch merges cleanly.

}

override def jobIds(): java.util.List[java.lang.Integer] = {
new java.util.ArrayList(futureAction.jobIds.map(x => new Integer(x)).asJava)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... kinda sucks you have to make the conversion manually.

I'd use Collections.unmodifiableList() and Integer.valueOf() here, though.

@SparkQA
Copy link

SparkQA commented Oct 14, 2014

QA tests have finished for PR 2760 at commit 7a1417f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaFutureActionWrapper[S, T](futureAction: FutureAction[S], converter: S => T)

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21734/
Test PASSed.

case scala.util.Success(value) => converter(value)
case Failure(exception) =>
if (isCancelled) {
throw new CancellationException("Job cancelled: ${exception.message}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing s""? I'd also use the exception as the cause of the CancellationException.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; I'll fix the s"". Unfortunately, CancellationException doesn't have a constructor that accepts a cause exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but I can do this:

val ce =  new CancellationException("Job cancelled")
ce.initCause(exception)
throw ce

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, even more succinctly:

throw new CancellationException("Job cancelled").initCause(exception)

List<Integer> data = Arrays.asList(1, 2, 3, 4, 5);
JavaRDD<Integer> rdd = sc.parallelize(data, 1);
JavaFutureAction<Long> future = rdd.map(new BuggyMapFunction<Integer>()).countAsync();
Thread.sleep(200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is necessary. The get() call below should cover this already.

@vanzin
Copy link
Contributor

vanzin commented Oct 14, 2014

HI @JoshRosen, this looks mostly good. I have some comments on the tests because I'm generally wary of tests that rely too heavily on timeouts.

@JoshRosen
Copy link
Contributor Author

Hi @vanzin,

Thanks for the review feedback. I've significantly simplified the tests and incorporated your comments.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21742/
Test FAILed.

@shaneknapp
Copy link
Contributor

Jenkins, test this please.

@SparkQA
Copy link

SparkQA commented Oct 14, 2014

QA tests have started for PR 2760 at commit e8e2867.

  • This patch merges cleanly.

JavaRDD<Integer> rdd = sc.parallelize(data, 1);
JavaFutureAction<Long> future = rdd.map(new BuggyMapFunction<Integer>()).countAsync();
try {
long count = future.get(2, TimeUnit.SECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: variable is unused.

@vanzin
Copy link
Contributor

vanzin commented Oct 14, 2014

Latest changes LGTM, thanks!

@SparkQA
Copy link

SparkQA commented Oct 14, 2014

QA tests have finished for PR 2760 at commit e8e2867.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaFutureActionWrapper[S, T](futureAction: FutureAction[S], converter: S => T)

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21743/
Test PASSed.

@SparkQA
Copy link

SparkQA commented Oct 15, 2014

QA tests have started for PR 2760 at commit c0153a5.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 15, 2014

QA tests have finished for PR 2760 at commit c0153a5.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaFutureActionWrapper[S, T](futureAction: FutureAction[S], converter: S => T)

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21754/
Test PASSed.

@SparkQA
Copy link

SparkQA commented Oct 19, 2014

QA tests have started for PR 2760 at commit 0d45fbc.

  • This patch merges cleanly.

@JoshRosen
Copy link
Contributor Author

@rxin Did you have any other feedback here? If not, I'd like to merge this.

@SparkQA
Copy link

SparkQA commented Oct 19, 2014

QA tests have finished for PR 2760 at commit 0d45fbc.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaFutureActionWrapper[S, T](futureAction: FutureAction[S], converter: S => T)

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21883/
Test PASSed.

@pwendell
Copy link
Contributor

LGTM - we discussed some details of this offline last week.

@JoshRosen
Copy link
Contributor Author

Alright, I'm going to merge this. Thanks!

@asfgit asfgit closed this in d1966f3 Oct 20, 2014
@rxin
Copy link
Contributor

rxin commented Oct 20, 2014

Reviewed again after the fact. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants