Skip to content
Closed
Changes from all commits
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 @@ -63,7 +63,8 @@ class TwitterReceiver(
storageLevel: StorageLevel
) extends Receiver[Status](storageLevel) with Logging {

private var twitterStream: TwitterStream = _
@volatile private var twitterStream: TwitterStream = _
@volatile private var stopped = false

def onStart() {
try {
Expand All @@ -78,7 +79,9 @@ class TwitterReceiver(
def onScrubGeo(l: Long, l1: Long) {}
def onStallWarning(stallWarning: StallWarning) {}
def onException(e: Exception) {
restart("Error receiving tweets", e)
if (!stopped) {
restart("Error receiving tweets", e)
}
}
})

Expand All @@ -91,12 +94,14 @@ class TwitterReceiver(
}
setTwitterStream(newTwitterStream)
logInfo("Twitter receiver started")
stopped = false
} catch {
case e: Exception => restart("Error starting Twitter stream", e)
}
}

def onStop() {
stopped = true
setTwitterStream(null)
logInfo("Twitter receiver stopped")
}
Expand Down