Skip to content

Commit

Permalink
Rpc endpoint recreation (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyaghma authored Nov 13, 2020
1 parent 20cf64c commit e627c87
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ import org.apache.spark.internal.Logging
import org.apache.spark.streaming.StreamingContext
import org.apache.spark.streaming.api.java.{ JavaInputDStream, JavaStreamingContext }
import org.apache.spark.streaming.eventhubs.EventHubsDirectDStream
import org.apache.spark.{ SparkContext, TaskContext }
import org.apache.spark.{ SparkContext, SparkEnv, TaskContext }
import org.apache.spark.rpc.RpcEndpointRef
import org.apache.spark.SparkEnv
import org.apache.spark.util.RpcUtils

/**
* Helper to create Direct DStreams which consume events from Event Hubs.
Expand All @@ -53,12 +53,21 @@ object EventHubsUtils extends Logging {

private def createRpcEndpoint() = {
if (partitionPerformanceReceiverRef == null) {
// RPC endpoint for partition performance communication in the driver
val partitionsStatusTracker = PartitionsStatusTracker.getPartitionStatusTracker
val partitionPerformanceReceiver: PartitionPerformanceReceiver =
new PartitionPerformanceReceiver(SparkEnv.get.rpcEnv, partitionsStatusTracker)
partitionPerformanceReceiverRef = SparkEnv.get.rpcEnv
.setupEndpoint(PartitionPerformanceReceiver.ENDPOINT_NAME, partitionPerformanceReceiver)
try {
partitionPerformanceReceiverRef = RpcUtils.makeDriverRef(
PartitionPerformanceReceiver.ENDPOINT_NAME,
SparkEnv.get.conf,
SparkEnv.get.rpcEnv)
logInfo(
s"There is an existing partitionPerformanceReceiverRef on the driver, use that one rather than creating a new one")
} catch {
case e: Exception =>
val partitionsStatusTracker = PartitionsStatusTracker.getPartitionStatusTracker
val partitionPerformanceReceiver: PartitionPerformanceReceiver =
new PartitionPerformanceReceiver(SparkEnv.get.rpcEnv, partitionsStatusTracker)
partitionPerformanceReceiverRef = SparkEnv.get.rpcEnv
.setupEndpoint(PartitionPerformanceReceiver.ENDPOINT_NAME, partitionPerformanceReceiver)
}
}
}

Expand Down

0 comments on commit e627c87

Please sign in to comment.