com.datastax.spark.connector.demo

NodeGuardian

class NodeGuardian extends CounterActor with ActorLogging with Assertions

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. Verification Calls 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)
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
Assertions, ActorLogging, CounterActor, Actor, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. NodeGuardian
  2. Assertions
  3. ActorLogging
  4. CounterActor
  5. Actor
  6. AnyRef
  7. 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, data: Set[String])

    ssc

    the Spark StreamingContext

    settings

    the SparkCassandraSettings from config

    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. def aroundPostRestart(reason: Throwable): Unit

    Attributes
    protected[akka]
    Definition Classes
    Actor
  9. def aroundPostStop(): Unit

    Attributes
    protected[akka]
    Definition Classes
    Actor
  10. def aroundPreRestart(reason: Throwable, message: Option[Any]): Unit

    Attributes
    protected[akka]
    Definition Classes
    Actor
  11. def aroundPreStart(): Unit

    Attributes
    protected[akka]
    Definition Classes
    Actor
  12. def aroundReceive(receive: akka.actor.Actor.Receive, msg: Any): Unit

    Attributes
    protected[akka]
    Definition Classes
    Actor
  13. final def asInstanceOf[T0]: T0

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

    Definition Classes
    Assertions
  15. def clone(): AnyRef

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

    Definition Classes
    Actor
  17. def done: akka.actor.Actor.Receive

  18. 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
  19. 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
  20. 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
  21. 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
  22. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  25. 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()
  26. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  27. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  28. def increment(): Unit

    Attributes
    protected
    Definition Classes
    CounterActor
  29. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  30. def log: LoggingAdapter

    Definition Classes
    ActorLogging
  31. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  34. def now: FiniteDuration

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

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

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

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

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

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

    Definition Classes
    Assertions
  41. def remainingOrDefault: FiniteDuration

    Definition Classes
    Assertions
  42. val scale: Int

    Attributes
    protected
    Definition Classes
    CounterActor
  43. implicit final val self: ActorRef

    Definition Classes
    Actor
  44. final def sender(): ActorRef

    Definition Classes
    Actor
  45. def shutdown(): Unit

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

  46. def supervisorStrategy: SupervisorStrategy

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

    Definition Classes
    AnyRef
  48. implicit val timeout: Timeout

  49. def toString(): String

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

    Definition Classes
    Actor
  51. def verify(): Unit

  52. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. 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 Assertions

Inherited from ActorLogging

Inherited from CounterActor

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