Github user pwendell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/300#discussion_r11721384
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/receiver/NetworkReceiverExecutor.scala
 ---
    @@ -0,0 +1,190 @@
    +/*
    + * 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.streaming.receiver
    +
    +import java.nio.ByteBuffer
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.apache.spark.{Logging, SparkConf}
    +import org.apache.spark.storage.StreamBlockId
    +import java.util.concurrent.CountDownLatch
    +import scala.concurrent._
    +import ExecutionContext.Implicits.global
    +
    +/**
    + * Abstract class that is responsible for executing a NetworkReceiver in 
the worker.
    + * It provides all the necessary interfaces for handling the data received 
by the receiver.
    + */
    +private[streaming] abstract class NetworkReceiverExecutor(
    +    receiver: NetworkReceiver[_],
    +    conf: SparkConf
    +  ) extends Logging {
    +
    +
    +  /** Enumeration to identify current state of the StreamingContext */
    +  object NetworkReceiverState extends Enumeration {
    +    type CheckpointState = Value
    +    val Initialized, Started, Stopped = Value
    +  }
    +  import NetworkReceiverState._
    +
    +  // Attach the executor to the receiver
    +  receiver.attachExecutor(this)
    +
    +  /** Receiver id */
    +  protected val receiverId = receiver.receiverId
    +
    +  /** Message associated with the stopping of the receiver */
    +  protected var stopMessage = ""
    +
    +  /** Exception associated with the stopping of the receiver */
    +  protected var stopException: Throwable = null
    +
    +  /** Has the receiver been marked for stop. */
    +  private val stopLatch = new CountDownLatch(1)
    +
    +  /** Time between a receiver is stopped */
    +  private val restartDelay = 
conf.getInt("spark.streaming.receiverRestartDelay", 2000)
    +
    +  /** State of the receiver */
    +  private[streaming] var receiverState = Initialized
    +
    +  /** Push a single data item to backend data store. */
    +  def pushSingle(data: Any)
    +
    +  /** Push a byte buffer to backend data store. */
    +  def pushBytes(
    +      bytes: ByteBuffer,
    +      optionalMetadata: Option[Any],
    +      optionalBlockId: Option[StreamBlockId]
    +    )
    +
    +  /** Push an iterator of objects as a block to backend data store. */
    +  def pushIterator(
    +      iterator: Iterator[_],
    +      optionalMetadata: Option[Any],
    +      optionalBlockId: Option[StreamBlockId]
    +    )
    +
    +  /** Push an ArrayBuffer of object as a block to back data store. */
    --- End diff --
    
    of objects


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to