我的意圖是使用Akka創建應用程序。一旦我意識到我需要創建一些Web服務,我決定使用Spray。使用Spark(MLlib)和Spray:如何整合兩者?
這個應用程序需要一個分類器,所以我在Spark上用MLlib構建了一個原型。現在我需要了解如何將Spark與Spray集成。具體來說,我需要得到
1.這是創建星火語境
2.如何使火花背景下可見的演員
我假設我要創建而引導星火背景下,最好的辦法該應用程序,所以我修改了GitHub的示例中的代碼,該示例適用於沒有Spark集成的Spray應用程序。因此,我實例化演員
14/10/11 22:12:32 ERROR actor.OneForOneStrategy: exception during creation
akka.actor.ActorInitializationException: exception during creation
我改變原來代碼標有//$$$ $$$
trait Core {
protected implicit def system: ActorSystem
// $$$ SparkContext in the trait $$$
protected implicit def sc: SparkContext
}
/**
* This trait implements ``Core`` by starting the required
* ``ActorSystem`` and registering the
* termination handler to stop the system when the JVM exits.
*/
trait BootedCore extends Core with Api {
def system: ActorSystem = ActorSystem("activator-akka-spray")
def actorRefFactory: ActorRefFactory = system
// $$$ Initializing SparkContext $$$
def sc = new SparkContext("local[2]", "naivebayes")
val rootService = system.actorOf(Props(new RoutedHttpService(routes)))
IO(Http)(system) ! Http.Bind(rootService, "0.0.0.0", port = 9010)
/**
* Construct the ActorSystem we will use in our application
*/
//protected implicit val system : ActorSystem
/**
* Ensure that the constructed ActorSystem is shut
* down when the JVM shuts down
*/
sys.addShutdownHook(system.shutdown())
}
/**
* This trait contains the actors that make up our application;
* it can be mixed in with
* ``BootedCore`` for running code or ``TestKit``
* for unit and integration tests.
*/
trait CoreActors {
this: Core =>
//$$$ passing the context to the actor $$$
val classifier = system.actorOf(Props(classOf[ClassifierActor], sc))
}
能否請你說明你是如何解決這個問題的(git回購會很棒,但即使版本也會有所幫助) - 我遇到了同樣的問題。我嘗試與val akkaVersion =「2.3.9」 val sprayVersion =「1.2-20130727」 val sparkVersion =「1.2.1」但包括火花瓶後,我得到像java.lang.NoSuchMethodError錯誤:akka.actor .Props $。適用(Lscala/Function0;)拉卡/演員/道具; – 2015-05-01 02:36:08
我剛剛更新了以前的帖子。希望它有幫助 – Max 2015-05-01 13:25:07
你有上面的git回購嗎?我正在做類似的工作 - 將Spark與Spark整合在一起,我不知道如何去做。謝謝 – 2016-11-01 16:48:24