Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Reorganized sample code and began rewriting the User Guide, with changes to affected documents #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Binary file removed deploy.enc
Binary file not shown.
37 changes: 37 additions & 0 deletions examples/adapter/spark/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
jdk:
- oraclejdk8

branches:
only:
- newSerializeDocs

sudo:
false
language:
- scala
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
before_install:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then ./deploy.prep; fi
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then eval `ssh-agent`; fi
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then ssh-add deploy; fi
before_script:
- pip install --user sphinx
- pip install --user sphinx_rtd_theme
script:
- .travis/compile-all.sh $TRAVIS_SCALA_VERSION
- .travis/test-core.sh $TRAVIS_SCALA_VERSION
- .travis/test-leveldb.sh $TRAVIS_SCALA_VERSION
- .travis/test-crdt.sh $TRAVIS_SCALA_VERSION
- .travis/test-stream.sh $TRAVIS_SCALA_VERSION
- .travis/test-spark.sh $TRAVIS_SCALA_VERSION
- .travis/test-vertx.sh $TRAVIS_SCALA_VERSION
- find $HOME/.sbt -name "*.lock" | xargs rm
- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm
after_success:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ]; then .travis/publish-all.sh $TRAVIS_SCALA_VERSION; fi
scala:
- 2.11.8
- 2.12.0
6 changes: 6 additions & 0 deletions examples/adapter/spark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Eventuate Apache Spark Adapter Example

[![Build Status](https://travis-ci.org/mslinn/eventuate.svg?branch=newSerializeDocs)](https://travis-ci.org/mslinn/eventuate)

This project runs the Scala sample code for the Eventuate
[Apache Spark Adapter](http://rbmhtechnology.github.io/eventuate/adapters/vertx.html).
88 changes: 88 additions & 0 deletions examples/adapter/spark/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
organization := "com.micronautics"

name := "eventuate-spark-adapter-example"

version := "0.2.0"

scalaVersion := "2.11.8" // Apache Spark does not support Scala 2.12 yet

scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-target:jvm-1.8",
"-unchecked",
"-Ywarn-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-unused",
"-Ywarn-value-discard",
"-Xfuture",
"-Xlint"
)

scalacOptions in (Compile, doc) ++= baseDirectory.map {
(bd: File) => Seq[String](
"-sourcepath", bd.getAbsolutePath,
"-doc-source-url", "https://github.com/mslinn/eventuate/tree/master€{FILE_PATH}.scala"
)
}.value

javacOptions ++= Seq(
"-Xlint:deprecation",
"-Xlint:unchecked",
"-source", "1.8",
"-target", "1.8",
"-g:vars"
)

resolvers += "Eventuate Releases" at "https://dl.bintray.com/rbmhtechnology/maven"

val akkaVer = "2.4.17" // Specify the Akka version so we get the latest
val evVer = "0.8.1"
val log4jVer = "2.5"
val sparkVer = "1.6.1"

libraryDependencies ++= Seq(
//"com.rbmhtechnology" %% "eventuate-adapter-stream" % evVer withSources(),
//"com.rbmhtechnology" %% "eventuate-adapter-vertx" % evVer withSources(),
"com.rbmhtechnology" %% "eventuate-adapter-spark" % evVer withSources(),
"com.rbmhtechnology" %% "eventuate-core" % evVer withSources(),
//"com.rbmhtechnology" %% "eventuate-crdt" % evVer withSources(),
//"com.rbmhtechnology" %% "eventuate-log-cassandra" % evVer withSources(),
"com.rbmhtechnology" %% "eventuate-log-leveldb" % evVer withSources(),
"com.typesafe.akka" %% "akka-actor" % akkaVer withSources(),
"com.typesafe.akka" %% "akka-protobuf" % akkaVer withSources(),
"com.typesafe.akka" %% "akka-remote" % akkaVer withSources(),
"com.typesafe.akka" %% "akka-slf4j" % akkaVer withSources(),
"com.typesafe.akka" %% "akka-stream" % akkaVer withSources(),
"org.apache.logging.log4j" % "log4j-core" % log4jVer withSources(),
"org.apache.spark" %% "spark-core" % sparkVer withSources(),
"org.apache.spark" %% "spark-sql" % sparkVer withSources(),
"org.apache.spark" %% "spark-streaming" % sparkVer withSources(),
"org.fusesource.leveldbjni" % "leveldbjni-all" % "1.8" withSources(),
//
"org.scalatest" %% "scalatest" % "3.0.1" % Test withSources(),
"junit" % "junit" % "4.12" % Test
)

parallelExecution in Test := false
fork in Test := true
fork in Runtime := true

logLevel := Level.Warn

// Only show warnings and errors on the screen for compilations.
// This applies to both test:compile and compile and is Info by default
logLevel in compile := Level.Warn

// Level.INFO is needed to see detailed output when running tests
logLevel in test := Level.Info

// define the statements initially evaluated when entering 'console', 'console-quick', but not 'console-project'
initialCommands in console := """import akka.actor._
|import com.rbmhtechnology.eventuate.EventsourcedActor
|import scala.util._
|""".stripMargin

cancelable := true
1 change: 1 addition & 0 deletions examples/adapter/spark/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.13
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
akka {
actor.provider = "akka.remote.RemoteActorRefProvider"

// See http://doc.akka.io/docs/akka/current/scala/logging.html#slf4j-scala
event-handlers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "ERROR"
stdout-loglevel = INFO

remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "127.0.0.1"
port = 2552
}
}

loglevel = "ERROR"
}

eventuate.log.write-batch-size = 3
Expand Down
33 changes: 33 additions & 0 deletions examples/adapter/spark/src/main/scala/com/Util.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2015 - 2017 Red Bull Media House GmbH <http://www.redbullmediahouse.com> and Mike Slinn - all rights reserved.
*
* Licensed 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 sapi

import akka.actor.ActorSystem

object Util {
// Pause for messages to be displayed before shutting down Akka
def pauseThenStop(seconds: Int = 1)(implicit system: ActorSystem): Unit = {
import scala.concurrent.duration._
import system.dispatcher
import scala.language.postfixOps
system.scheduler.scheduleOnce(seconds seconds) {
system.terminate()
()
}
()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@ object SparkBatchAdapterExample extends App {

sparkContext.stop()
system.terminate()

sapi.Util.pauseThenStop()
System.exit(0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ object SparkStreamAdapterExample extends App {
case "exit" =>
sparkStreamingContext.stop(stopSparkContext = true)
system.terminate()
()

case line =>
writer.write(Seq(line))
prompt()
Expand Down
37 changes: 37 additions & 0 deletions examples/adapter/stream/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
jdk:
- oraclejdk8

branches:
only:
- newSerializeDocs

sudo:
false
language:
- scala
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
before_install:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then ./deploy.prep; fi
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then eval `ssh-agent`; fi
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then ssh-add deploy; fi
before_script:
- pip install --user sphinx
- pip install --user sphinx_rtd_theme
script:
- .travis/compile-all.sh $TRAVIS_SCALA_VERSION
- .travis/test-core.sh $TRAVIS_SCALA_VERSION
- .travis/test-leveldb.sh $TRAVIS_SCALA_VERSION
- .travis/test-crdt.sh $TRAVIS_SCALA_VERSION
- .travis/test-stream.sh $TRAVIS_SCALA_VERSION
- .travis/test-spark.sh $TRAVIS_SCALA_VERSION
- .travis/test-vertx.sh $TRAVIS_SCALA_VERSION
- find $HOME/.sbt -name "*.lock" | xargs rm
- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm
after_success:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ]; then .travis/publish-all.sh $TRAVIS_SCALA_VERSION; fi
scala:
- 2.11.8
- 2.12.0
6 changes: 6 additions & 0 deletions examples/adapter/stream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Eventuate Streaming Adapter Example

[![Build Status](https://travis-ci.org/mslinn/eventuate.svg?branch=newSerializeDocs)](https://travis-ci.org/mslinn/eventuate)

This project runs the Scala sample code for the Eventuate
[Streaming Adapter](http://rbmhtechnology.github.io/eventuate/adapters/stream.html#event-source).
76 changes: 76 additions & 0 deletions examples/adapter/stream/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
organization := "com.micronautics"

name := "eventuate-stream-adapter-example"

version := "0.2.0"

scalaVersion := "2.12.1"

scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-target:jvm-1.8",
"-unchecked",
"-Ywarn-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-unused",
"-Ywarn-value-discard",
"-Xfuture",
"-Xlint"
)

scalacOptions in (Compile, doc) ++= baseDirectory.map {
(bd: File) => Seq[String](
"-sourcepath", bd.getAbsolutePath,
"-doc-source-url", "https://github.com/mslinn/eventuate/tree/master€{FILE_PATH}.scala"
)
}.value

javacOptions ++= Seq(
"-Xlint:deprecation",
"-Xlint:unchecked",
"-source", "1.8",
"-target", "1.8",
"-g:vars"
)

resolvers += "Eventuate Releases" at "https://dl.bintray.com/rbmhtechnology/maven"

val evVer = "0.8.1"

libraryDependencies ++= Seq(
"com.rbmhtechnology" %% "eventuate-adapter-stream" % evVer withSources(),
// "com.rbmhtechnology" %% "eventuate-adapter-vertx" % evVer withSources(),
// "com.rbmhtechnology" %% "eventuate-adapter-spark" % evVer withSources(),
"com.rbmhtechnology" %% "eventuate-core" % evVer withSources(),
// "com.rbmhtechnology" %% "eventuate-crdt" % evVer withSources(),
// "com.rbmhtechnology" %% "eventuate-log-cassandra" % evVer withSources(),
"com.rbmhtechnology" %% "eventuate-log-leveldb" % evVer withSources(),
"org.fusesource.leveldbjni" % "leveldbjni-all" % "1.8" withSources(),
//
"org.scalatest" %% "scalatest" % "3.0.1" % Test withSources(),
"junit" % "junit" % "4.12" % Test
)

parallelExecution in Test := false
fork in Test := true
fork in Runtime := true

logLevel := Level.Warn

// Only show warnings and errors on the screen for compilations.
// This applies to both test:compile and compile and is Info by default
logLevel in compile := Level.Warn

// Level.INFO is needed to see detailed output when running tests
logLevel in test := Level.Info

// define the statements initially evaluated when entering 'console', 'console-quick', but not 'console-project'
initialCommands in console := """import akka.actor._
|import com.rbmhtechnology.eventuate.EventsourcedActor
|import scala.util._
|""".stripMargin

cancelable := true
1 change: 1 addition & 0 deletions examples/adapter/stream/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.13
12 changes: 12 additions & 0 deletions examples/adapter/stream/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
akka {
log-dead-letters = off

log-dead-letters-during-shutdown = off

persistence {
journal {
plugin = "akka.persistence.journal.leveldb"
leveldb.native = off
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ object DurableEventProcessorExample1 extends App with DurableEventLogs {
// (b-1,2)
// (c-1,3)
//#

sapi.Util.pauseThenStop()
}

object DurableEventProcessorExample2 extends App with DurableEventLogs {
Expand Down Expand Up @@ -118,6 +120,8 @@ object DurableEventProcessorExample2 extends App with DurableEventLogs {

graph.run()
//#

sapi.Util.pauseThenStop()
}

object DurableEventProcessorExample3 extends App with DurableEventLogs {
Expand All @@ -132,4 +136,6 @@ object DurableEventProcessorExample3 extends App with DurableEventLogs {
.map(event => (event.payload, event.localSequenceNr))
.runForeach(println)
//#

sapi.Util.pauseThenStop()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@
package com.rbmhtechnology.example.stream

//# durable-event-source-1
import akka.actor.ActorRef
import akka.stream.scaladsl.Source
import com.rbmhtechnology.eventuate.DurableEvent
import com.rbmhtechnology.eventuate.adapter.stream.DurableEventSource

//#
object DurableEventSourceExample extends DurableEventLogs {
object DurableEventSourceExample extends App with DurableEventLogs {
//# durable-event-source-1
val source1 = Source.fromGraph(DurableEventSource(logA))
val source1: Source[DurableEvent, ActorRef] =
Source.fromGraph(DurableEventSource(logA))
//#
//# durable-event-source-2
val source2 = Source.fromGraph(DurableEventSource(
logA, fromSequenceNr = 12414, aggregateId = Some("user-17")))
val source2: Source[DurableEvent, ActorRef] =
Source.fromGraph(DurableEventSource(
logA,
fromSequenceNr = 12414, aggregateId = Some("user-17"))
)
//#

sapi.Util.pauseThenStop()
}
Loading