-
Notifications
You must be signed in to change notification settings - Fork 385
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
job killing in Spark #935
Closed
Closed
job killing in Spark #935
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cbc48be
Initial commit for job killing.
rxin 1cb42e6
Properly handle job failure when the job gets killed.
rxin 37d8f37
Added a submitJob interface that returns a Future of the result.
rxin bf51568
Allow SparkContext.submitJob to submit a job for only a subset of the…
rxin 9332246
Added a hack to kill all active jobs in SparkContext.
rxin 9f8190c
Fixed a bug for zero partition in JobWaiter.
rxin 85a0dff
Made task killing work for standalone cluster schedulers.
rxin f19984d
More logging changes (task killing for local cluster doesn't work yet).
rxin 7095381
Added task killing iterator to RDDs that take inputs.
rxin c68e72b
Added comment to InterruptibleIterator.
rxin c5e4095
Wrap around cached data to InterruptibleIterator.
rxin 1d87616
Made output of CoGroup and aggregations interruptible.
rxin 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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.spark | ||
|
||
import java.util.concurrent.{ExecutionException, TimeUnit, Future} | ||
|
||
import org.apache.spark.scheduler.{JobFailed, JobSucceeded, JobWaiter} | ||
|
||
class FutureJob[T] private[spark](jobWaiter: JobWaiter[_], resultFunc: () => T) | ||
extends Future[T] { | ||
|
||
override def isDone: Boolean = jobWaiter.jobFinished | ||
|
||
override def cancel(mayInterruptIfRunning: Boolean): Boolean = { | ||
jobWaiter.kill() | ||
true | ||
} | ||
|
||
override def isCancelled: Boolean = { | ||
throw new UnsupportedOperationException | ||
} | ||
|
||
override def get(): T = { | ||
jobWaiter.awaitResult() match { | ||
case JobSucceeded => | ||
resultFunc() | ||
case JobFailed(e: Exception, _) => | ||
throw new ExecutionException(e) | ||
} | ||
} | ||
|
||
override def get(timeout: Long, unit: TimeUnit): T = { | ||
throw new UnsupportedOperationException | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
core/src/main/scala/org/apache/spark/InterruptibleIterator.scala
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,30 @@ | ||
/* | ||
* 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.spark | ||
|
||
/** | ||
* An iterator that wraps around an existing iterator to provide task killing functionality. | ||
* It works by checking the interrupted flag in TaskContext. | ||
*/ | ||
class InterruptibleIterator[+T](val context: TaskContext, val delegate: Iterator[T]) | ||
extends Iterator[T] { | ||
|
||
def hasNext: Boolean = !context.interrupted && delegate.hasNext | ||
|
||
def next(): T = delegate.next() | ||
} |
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.
Certainly not unique to this method, but this is another example of something that is publicly accessible in a SparkContext that probably shouldn't be. Is there any plan to provide a more restricted SparkContext API (for use, e.g., in the shell), or are we going to continue to assume that if we don't tell people about something, then they won't misuse it?
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.
Actually why wouldn't we want this till be accessible? It is at the same
level as runJob.
On Sep 18, 2013 9:50 AM, "Mark Hamstra" notifications@github.com wrote:
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.
That's true, and we certainly want custom RDD developers and the like to be able to access runJob etc. My question, though, is whether we really want all users of, e.g., spark-shell to be able to call runJob, submitJob, etc. directly. It's something of a question of whether spark-shell is targeted at developers (who want to be able to do anything in the repl that they could in standalone code), or whether it is targeted at end users who just want/need to be able to do the kinds of higher-level things with RDDs that we typically show in examples. Maybe the issue isn't so much that, within SparkContext itself, there needs to be another access level for methods as it is that we could use another kind of interactive tool/UI (something like iPython Notebooks, perhaps...) that doesn't have full access to all the SparkContext methods that many users shouldn't really be messing with directly.