Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename requirement part names #7

Merged
merged 2 commits into from
Nov 17, 2014
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ class ConductorController(uri: Uri, connectTimeout: Timeout, httpIO: ActorRef)
val bodyParts =
Source(
List(
FormData.BodyPart.Strict("nr-of-cpus", loadBundle.nrOfCpus.toString),
FormData.BodyPart.Strict("memory-space", loadBundle.memory.toString),
FormData.BodyPart.Strict("disk-space", loadBundle.diskSpace.toString),
FormData.BodyPart.Strict("nrOfCpus", loadBundle.nrOfCpus.toString),
FormData.BodyPart.Strict("memory", loadBundle.memory.toString),
FormData.BodyPart.Strict("diskSpace", loadBundle.diskSpace.toString),
FormData.BodyPart.Strict("roles", loadBundle.roles.mkString(" ")),
fileBodyPart("bundle", filename(loadBundle.bundle), publisher(loadBundle.bundle))
) ++
Expand All @@ -197,7 +197,7 @@ class ConductorController(uri: Uri, connectTimeout: Timeout, httpIO: ActorRef)
response <- request(HttpRequest(PUT, s"/bundles/${startBundle.bundleId}?scale=${startBundle.scale}"), connection)
body <- Unmarshal(response.entity).to[String]
} yield bodyOrThrow(response, body)
pendingResponse pipeTo sender()
pendingResponse.pipeTo(sender())
}

private def stopBundle(stopBundle: StopBundle): Unit = {
Expand All @@ -207,7 +207,7 @@ class ConductorController(uri: Uri, connectTimeout: Timeout, httpIO: ActorRef)
response <- request(HttpRequest(PUT, s"/bundles/${stopBundle.bundleId}?scale=0"), connection)
body <- Unmarshal(response.entity).to[String]
} yield bodyOrThrow(response, body)
pendingResponse pipeTo sender()
pendingResponse.pipeTo(sender())
}

private def unloadBundle(unloadBundle: UnloadBundle): Unit = {
Expand All @@ -217,7 +217,7 @@ class ConductorController(uri: Uri, connectTimeout: Timeout, httpIO: ActorRef)
response <- request(HttpRequest(DELETE, s"/bundles/${unloadBundle.bundleId}"), connection)
body <- Unmarshal(response.entity).to[String]
} yield bodyOrThrow(response, body)
pendingResponse pipeTo sender()
pendingResponse.pipeTo(sender())
}

private def fetchBundleFlow(originalSender: ActorRef): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.typesafe.reactiveruntime.console.Console
import com.typesafe.sbt.bundle.SbtBundle
import com.typesafe.sbt.packager.Keys._
import org.scalactic.{Accumulation, Bad, Good, One, Or}
import play.api.libs.json.{JsString, Json}
import sbt.Keys._
import sbt._
import sbt.complete.DefaultParsers._
Expand All @@ -32,7 +33,7 @@ object Import {

object ReactiveRuntimeKeys {
val nrOfCpus = SettingKey[Double]("rr-nr-of-cpus", "The number of cpus required to run the bundle.")
val memory = SettingKey[Long]("rr-memory-space", "The amount of memory required to run the bundle.")
val memory = SettingKey[Long]("rr-memory", "The amount of memory required to run the bundle.")
val diskSpace = SettingKey[Long]("rr-disk-space", "The amount of disk space required to host an expanded bundle and configuration.")
val roles = SettingKey[Set[String]]("rr-roles", "The types of node in the cluster that this bundle can be deployed to.")

Expand Down Expand Up @@ -126,9 +127,14 @@ object SbtReactiveRuntime extends AutoPlugin {
val response = (conductor ? request).mapTo[String]
Await.ready(response, conductorLoadTimeout.value.duration)
response.value.get match {
case Success(bundleId) =>
streams.value.log.info(s"Upload completed. Use 'startBundle $bundleId' to start.")
bundleId
case Success(s) =>
Json.parse(s) \ "bundleId" match {
case JsString(bundleId) =>
streams.value.log.info(s"Upload completed. Use 'startBundle $bundleId' to start.")
bundleId
case other =>
sys.error(s"Unexpected response: $other")
}
case Failure(e) =>
sys.error(s"Problem loading the bundle: ${e.getMessage}")
}
Expand Down Expand Up @@ -231,12 +237,12 @@ object SbtReactiveRuntime extends AutoPlugin {

// We will get an exception if there is no actor representing the conductor - which is a good thing because
// there needs to be and it is probably because the plugin has been mis-configured.
private def withWatchdog[T](state: State)(block: (ActorRef) => T): T =
private def withWatchdog[T](state: State)(block: ActorRef => T): T =
block(state.get(conductorAttrKey).get)

// We will get an exception if there is no known actor system - which is a good thing because
// there absolutely has to be at this point.
private def withActorSystem[T](state: State)(block: (ActorSystem) => T): T =
private def withActorSystem[T](state: State)(block: ActorSystem => T): T =
block(state.get(actorSystemAttrKey).get)

private def withActorClassloader[A](f: => A): A = {
Expand Down