-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ixaxaar
committed
Apr 6, 2015
1 parent
4d09b7e
commit 054c133
Showing
8 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# app { | ||
|
||
app-name = "app" | ||
spark.checkpoint.dir = "./tmp" | ||
|
||
akka { | ||
loglevel = "INFO" | ||
loggers = ["akka.event.slf4j.Slf4jLogger"] | ||
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" | ||
logger-startup-timeout = 60s | ||
log-dead-letters = off | ||
log-dead-letters-during-shutdown = off | ||
|
||
actor { | ||
provider = "akka.cluster.ClusterActorRefProvider" | ||
default-dispatcher { | ||
# Throughput for default Dispatcher, set to 1 for as fair as possible | ||
throughput = 10 | ||
} | ||
# serializers.kryo = "com.twitter.chill.akka.AkkaSerializer" | ||
# serialization-bindings."scala.Product" = kryo | ||
} | ||
remote { | ||
log-remote-lifecycle-events = off | ||
netty.tcp { | ||
hostname = "127.0.0.1" | ||
port = 0 | ||
} | ||
} | ||
|
||
cluster { | ||
seed-nodes = [ | ||
"akka.tcp://[email protected]:9001", | ||
"akka.tcp://[email protected]:9002"] | ||
|
||
auto-down-unreachable-after = 10s | ||
log-info = on | ||
gossip-interval = 5s | ||
publish-stats-interval = 10s | ||
auto-down-unreachable-after = 10s | ||
metrics.gossip-interval = 10s | ||
metrics.collect-interval = 10s | ||
} | ||
} | ||
|
||
spark { | ||
# # The Spark master host. Set first by environment if exists. Then system, then config. | ||
# # Options: spark://host1:port1,host2:port2 | ||
# # - "local" to run locally with one thread, | ||
# # - local[4]" to run locally with 4 cores | ||
# # - the master IP/hostname to run on a Spark standalone cluster | ||
# # - if not set, defaults to "local[*]" to run with enough threads | ||
# # Supports optional HA failover for more than one: host1,host2.. | ||
# # which is used to inform: spark://host1:port1,host2:port2 | ||
master = "local" | ||
# # cleaner.ttl = ${?SPARK_CLEANER_TTL} | ||
|
||
# # The batch interval must be set based on the latency requirements | ||
# # of your application and available cluster resources. | ||
# # streaming.batch.interval = ${?SPARK_STREAMING_BATCH_INTERVAL} | ||
} | ||
|
||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
package com.app | ||
|
||
import com.common.Events._ | ||
import com.spark.Events._ | ||
|
||
object Events { | ||
// | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.app | ||
|
||
import com.common.Settings._ | ||
import com.scalding.Settings._ | ||
|
||
object Settings { | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.app | ||
|
||
import akka.actor.{Actor, ActorLogging, Props, ActorRef} | ||
import scala.util.Random | ||
import scala.collection.immutable.Vector | ||
|
||
import org.apache.spark.SparkContext | ||
import org.apache.spark.sql.SQLContext | ||
import org.apache.spark.mllib.regression.LinearRegressionWithSGD | ||
import org.apache.spark.mllib.regression.LabeledPoint | ||
import org.apache.spark.mllib.linalg.Vectors | ||
|
||
import com.spark._ | ||
|
||
|
||
class SparkApp(name:String) extends SparkBatch(name:String) { | ||
|
||
def createData(seed:Int, len:Int):Vector[LabeledPoint] = { | ||
val r = new Random(seed) | ||
val d = Vector.fill(len, 2)(r.nextGaussian) | ||
d.map { p => LabeledPoint(p(0), Vectors.dense(p.to[Array])) } | ||
} | ||
|
||
override def batch(spk:SparkContext, sql:SQLContext):Unit = { | ||
val dat = createData(Random.nextInt, 100) | ||
val rdd = sc.parallelize(dat) | ||
val model = LinearRegressionWithSGD.train(rdd, 100) | ||
|
||
println(s"The model has intercept $model.intercept with weights $model.weights") | ||
} | ||
} |