com.datastax.spark.connector.demo.streaming

NodeGuardian

class NodeGuardian extends Actor with Assertions with Logging

The NodeGuardian actor is the root supervisor of this simple Akka application's ActorSystem node that you might deploy across a cluster.

Being an Akka supervisor actor, it would normally orchestrate its children and any fault tolerance policies. For a simple demo no policies are employed save that embedded, in the Akka actor API.

Demo data for a simple but classic WordCount:

val data = immutable.Set("words ", "may ", "count ")

The NodeGuardian spins up three child actors (not in this order):

1. Streamer A simple Akka actor which extends com.datastax.spark.connector.streaming.TypedStreamingActor and ultimately implements a Spark Receiver. This simple receiver calls

Receiver.pushBlock[T: ClassTag](data: T)

when messages of type String (for simplicity of a demo), are received. This would typically be data in some custom envelope of a Scala case class that is Serializable.

2. Sender A simple Akka actor which generates a pre-set number of random tuples based on initial input data noted above, and sends each random tuple to the Streamer. The random messages are generated and sent to the stream every millisecond, with an initial wait of 2 milliseconds.

3. Reporter A simple Akka actor which when created, starts a scheduled task which runs every millisecond. This task simply checks whether the expected data has been successfully submitted to and stored in Cassandra. Once the successful assertion can be made, it signals its supervisor, the NodeGuardian, that the work is completed and expected state successfully verified. It does this by calling the following on the StreamingContext (ssc) to know when the expected number of entries has been streamed to Spark, and scale (the number of messages sent to the stream), computed, and saved to Cassandra:

val rdd = ssc.cassandraTable[WordCount](keyspaceName, tableName).select("word", "count")
rdd.collect.nonEmpty && rdd.map(_.count).reduce(_ + _) == scale * 2

Where data represents the 3 words we computed, we assert the expected three columns were created:

assert(rdd.collect.length == data.size)
Linear Supertypes
Logging, Assertions, Actor, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. NodeGuardian
  2. Logging
  3. Assertions
  4. Actor
  5. AnyRef
  6. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new NodeGuardian(ssc: StreamingContext, settings: SparkCassandraSettings, tableName: String, data: Set[String])

    ssc

    the Spark StreamingContext

    settings

    the SparkCassandraSettings from config

    tableName

    the Cassandra table name to use

    data

    the demo data for a simple WordCount

Type Members

  1. type Receive = PartialFunction[Any, Unit]

    Definition Classes
    Actor

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (NodeGuardian, B)

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to ArrowAssoc[NodeGuardian] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def awaitCond(p: ⇒ Boolean, max: Duration, interval: Duration, message: String): Unit

    Definition Classes
    Assertions
  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. implicit val context: ActorContext

    Definition Classes
    Actor
  12. def ensuring(cond: (NodeGuardian) ⇒ Boolean, msg: ⇒ Any): NodeGuardian

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to Ensuring[NodeGuardian] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: (NodeGuardian) ⇒ Boolean): NodeGuardian

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to Ensuring[NodeGuardian] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean, msg: ⇒ Any): NodeGuardian

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to Ensuring[NodeGuardian] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean): NodeGuardian

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to Ensuring[NodeGuardian] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  20. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  21. def getSparkClassLoader: ClassLoader

    Definition Classes
    Logging
  22. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  23. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  24. def isTraceEnabled(): Boolean

    Attributes
    protected
    Definition Classes
    Logging
  25. def log: Logger

    Attributes
    protected
    Definition Classes
    Logging
  26. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  27. def logDebug(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  28. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  29. def logError(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  30. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  31. def logInfo(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  32. def logName: String

    Attributes
    protected
    Definition Classes
    Logging
  33. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  34. def logTrace(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  35. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  36. def logWarning(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  37. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  38. final def notify(): Unit

    Definition Classes
    AnyRef
  39. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  40. def now: FiniteDuration

    Definition Classes
    Assertions
  41. def postRestart(reason: Throwable): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  42. def postStop(): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  43. def preRestart(reason: Throwable, message: Option[Any]): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  44. def preStart(): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  45. def receive: akka.actor.Actor.Receive

    Definition Classes
    NodeGuardian → Actor
  46. def remainingOr(duration: FiniteDuration): FiniteDuration

    Definition Classes
    Assertions
  47. def remainingOrDefault: FiniteDuration

    Definition Classes
    Assertions
  48. implicit final val self: ActorRef

    Definition Classes
    Actor
  49. final def sender: ActorRef

    Definition Classes
    Actor
  50. def shutdown(): Unit

    Stops the ActorSystem, the Spark StreamingContext and its underlying Spark system.

  51. def supervisorStrategy: SupervisorStrategy

    Definition Classes
    Actor
  52. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  53. implicit val timeout: Timeout

  54. def toString(): String

    Definition Classes
    AnyRef → Any
  55. def unhandled(message: Any): Unit

    Definition Classes
    Actor
  56. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  59. def [B](y: B): (NodeGuardian, B)

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to ArrowAssoc[NodeGuardian] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is shadowed by one or more members in this class.
    To access this member you can use a type ascription:
    (nodeGuardian: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is shadowed by one or more members in this class.
    To access this member you can use a type ascription:
    (nodeGuardian: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: NodeGuardian

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to ArrowAssoc[NodeGuardian] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (nodeGuardian: ArrowAssoc[NodeGuardian]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: NodeGuardian

    Implicit information
    This member is added by an implicit conversion from NodeGuardian to Ensuring[NodeGuardian] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (nodeGuardian: Ensuring[NodeGuardian]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from Logging

Inherited from Assertions

Inherited from Actor

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from NodeGuardian to StringAdd

Inherited by implicit conversion any2stringfmt from NodeGuardian to StringFormat

Inherited by implicit conversion any2ArrowAssoc from NodeGuardian to ArrowAssoc[NodeGuardian]

Inherited by implicit conversion any2Ensuring from NodeGuardian to Ensuring[NodeGuardian]

Ungrouped