Browse Source

version up and fix code

sxend 9 years ago
parent
commit
2baf0a4723

+ 2 - 3
frameworks/Scala/akka-http/build.sbt

@@ -9,9 +9,8 @@ scalaVersion := "2.11.7"
 resolvers += "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/"
 
 libraryDependencies ++= Seq(
-  "com.typesafe.akka" %% "akka-http-core-experimental" % "2.0-M2",
-  "com.typesafe.akka" %% "akka-http-experimental" % "2.0-M2",
-  "com.typesafe.akka" %% "akka-http-spray-json-experimental" % "2.0-M2",
+  "com.typesafe.akka" %% "akka-http-experimental" % "2.4.2",
+  "com.typesafe.akka" %% "akka-http-spray-json-experimental" % "2.4.2",
   "mysql" % "mysql-connector-java" % "5.1.35",
   "org.apache.commons" % "commons-dbcp2" % "2.1",
   "org.scalatra.scalate" %% "scalate-core" % "1.7.0",

+ 1 - 1
frameworks/Scala/akka-http/project/build.properties

@@ -1 +1 @@
-sbt.version=0.13.8
+sbt.version=0.13.11

+ 3 - 11
frameworks/Scala/akka-http/src/main/scala/com/typesafe/akka/http/benchmark/Bootstrap.scala

@@ -2,9 +2,8 @@ package com.typesafe.akka.http.benchmark
 
 import akka.actor.ActorSystem
 import akka.http.scaladsl.Http
-import akka.http.scaladsl.server.{Route, RoutingLog, RoutingSettings}
+import akka.http.scaladsl.server.Route
 import akka.stream.ActorMaterializer
-import akka.stream.scaladsl.Sink._
 import com.typesafe.config.Config
 
 trait Bootstrap {
@@ -23,15 +22,8 @@ class BenchmarkBootstrap(components: {
 
   override def run(): Unit = {
 
-    implicit val routingLog = RoutingLog(system.log)
+    implicit val system = ActorSystem()
     implicit val materializer = ActorMaterializer()
-    implicit val settings = RoutingSettings.default(system)
-    val handler = Route.asyncHandler(components.route)
-    val server = Http(components.system).bind(config.getString("akka.http.benchmark.host"), config.getInt("akka.http.benchmark.port"))
-    server.to {
-      foreach { connection =>
-        connection.handleWithAsyncHandler(handler)
-      }
-    }.run()
+    Http().bindAndHandle(components.route, config.getString("akka.http.benchmark.host"), config.getInt("akka.http.benchmark.port"))
   }
 }

+ 1 - 1
frameworks/Scala/akka-http/src/main/scala/com/typesafe/akka/http/benchmark/handlers/DbHandler.scala

@@ -35,7 +35,7 @@ class DbHandler(components: {
   def response = {
     val id = randomGenerator.next
     dataStore.findOne(id).map {
-      record => new HttpResponse(StatusCodes.OK, entity = HttpEntity(record.toResponse.toJson.toString()).withContentType(`application/json`.withCharset(`UTF-8`)))
+      record => new HttpResponse(StatusCodes.OK, entity = HttpEntity(record.toResponse.toJson.toString()).withContentType(`application/json`))
     }
   }
 

+ 1 - 1
frameworks/Scala/akka-http/src/main/scala/com/typesafe/akka/http/benchmark/handlers/JsonHandler.scala

@@ -20,7 +20,7 @@ class JsonHandler(components: {
   }
 
   def response = {
-    new HttpResponse(StatusCodes.OK, entity = HttpEntity(Response("Hello, World!").toJson.toString()).withContentType(`application/json`.withCharset(`UTF-8`)))
+    new HttpResponse(StatusCodes.OK, entity = HttpEntity(Response("Hello, World!").toJson.toString()).withContentType(`application/json`))
   }
 }
 

+ 1 - 1
frameworks/Scala/akka-http/src/main/scala/com/typesafe/akka/http/benchmark/handlers/QueriesHandler.scala

@@ -54,7 +54,7 @@ class QueriesHandler(components: {
         id => dataStore.findOne(id)
       }
     }.map {
-      worlds => new HttpResponse(StatusCodes.OK, entity = HttpEntity(worlds.toList.map(_.toResponse).toJson.toString()).withContentType(`application/json`.withCharset(`UTF-8`)))
+      worlds => new HttpResponse(StatusCodes.OK, entity = HttpEntity(worlds.toList.map(_.toResponse).toJson.toString()).withContentType(`application/json`))
     }
 
   }

+ 1 - 1
frameworks/Scala/akka-http/src/main/scala/com/typesafe/akka/http/benchmark/handlers/UpdatesHandler.scala

@@ -52,7 +52,7 @@ class UpdatesHandler(components: {
     }.flatMap {
       worlds => Future.sequence(worlds.map(world => dataStore.updateOne(world.id, world.randomNumber).map(_ => world)))
     }.map {
-      worlds => new HttpResponse(StatusCodes.OK, entity = HttpEntity(worlds.map(_.toResponse).toJson.toString()).withContentType(`application/json`.withCharset(`UTF-8`)))
+      worlds => new HttpResponse(StatusCodes.OK, entity = HttpEntity(worlds.map(_.toResponse).toJson.toString()).withContentType(`application/json`))
     }
   }
 }