Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ abstract class DStream[T: ClassTag] (
* Return all the RDDs between 'fromTime' to 'toTime' (both included)
*/
def slice(fromTime: Time, toTime: Time): Seq[RDD[T]] = {
if (!isInitialized) {
throw new Exception(this + " has not been initialized")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you make this a SparkExcepation? All expected exceptions thrown by Spark should be SparkException.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure. One more question: There are many new Exception in DStream.scala. Is it necessary to change them to SparkExcepation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you can do it in this pr that would be great!

On Wednesday, April 16, 2014, Shixiong Zhu notifications@github.com wrote:

In
streaming/src/main/scala/org/apache/spark/streaming/dstream/DStream.scala:

@@ -725,6 +725,9 @@ abstract class DStream[T: ClassTag](* Return all the RDDs between 'fromTime' to 'toTime' %28both included)
*/
def slice(fromTime: Time, toTime: Time): Seq[RDD[T]] = {

  • if (!isInitialized) {
  •  throw new Exception(this + " has not been initialized")
    

Sure. One more question: There are many new Exception in DStream.scala.
It's necessary to change them to SparkExcepation?

Reply to this email directly or view it on GitHubhttps://github.com//pull/365/files#r11716967
.

}
if (!(fromTime - zeroTime).isMultipleOf(slideDuration)) {
logWarning("fromTime (" + fromTime + ") is not a multiple of slideDuration ("
+ slideDuration + ")")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,16 @@ class BasicOperationsSuite extends TestSuiteBase {
Thread.sleep(1000)
}

test("slice - has not been initialized") {
val ssc = new StreamingContext(conf, Seconds(1))
val input = Seq(Seq(1), Seq(2), Seq(3), Seq(4))
val stream = new TestInputStream[Int](ssc, input, 2)
val thrown = intercept[Exception] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make this SparkException as well

stream.slice(new Time(0), new Time(1000))
}
assert(thrown.getMessage.contains("has not been initialized"))
}

val cleanupTestInput = (0 until 10).map(x => Seq(x, x + 1)).toSeq

test("rdd cleanup - map and window") {
Expand Down