You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cb...@apache.org on 2017/06/22 13:58:05 UTC
[incubator-openwhisk] 03/03: Adjust pause grace to a less dangerous
value
This is an automated email from the ASF dual-hosted git repository.
cbickel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit c9768ea96e9561ee42f4a2b7795afa46cc6b6e0a
Author: Markus Thoemmes <ma...@de.ibm.com>
AuthorDate: Thu Jun 22 08:32:10 2017 +0200
Adjust pause grace to a less dangerous value
---
.../whisk/core/containerpool/ContainerProxy.scala | 17 ++++++++-------
.../containerpool/test/ContainerProxyTests.scala | 24 +++++++++++-----------
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala b/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
index 796624b..55c7999 100644
--- a/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
+++ b/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
@@ -91,21 +91,18 @@ case object ActivationCompleted
* @param factory a function generating a Container
* @param sendActiveAck a function sending the activation via active ack
* @param storeActivation a function storing the activation in a persistent store
+ * @param unusedTimeout time after which the container is automatically thrown away
+ * @param pauseGrace time to wait for new work before pausing the container
*/
class ContainerProxy(
factory: (TransactionId, String, ImageName, Boolean, ByteSize) => Future[Container],
sendActiveAck: (TransactionId, WhiskActivation) => Future[Any],
- storeActivation: (TransactionId, WhiskActivation) => Future[Any]) extends FSM[ContainerState, ContainerData] with Stash {
+ storeActivation: (TransactionId, WhiskActivation) => Future[Any],
+ unusedTimeout: FiniteDuration,
+ pauseGrace: FiniteDuration) extends FSM[ContainerState, ContainerData] with Stash {
implicit val ec = context.system.dispatcher
val logging = new AkkaLogging(context.system.log)
- // The container is destroyed after this period of time
- val unusedTimeout = 10.minutes
-
- // The container is not paused for this period of time
- // after an activation has finished successfully
- val pauseGrace = 1.second
-
startWith(Uninitialized, NoData())
when(Uninitialized) {
@@ -384,7 +381,9 @@ class ContainerProxy(
object ContainerProxy {
def props(factory: (TransactionId, String, ImageName, Boolean, ByteSize) => Future[Container],
ack: (TransactionId, WhiskActivation) => Future[Any],
- store: (TransactionId, WhiskActivation) => Future[Any]) = Props(new ContainerProxy(factory, ack, store))
+ store: (TransactionId, WhiskActivation) => Future[Any],
+ unusedTimeout: FiniteDuration = 10.minutes,
+ pauseGrace: FiniteDuration = 50.milliseconds) = Props(new ContainerProxy(factory, ack, store, unusedTimeout, pauseGrace))
// Needs to be thread-safe as it's used by multiple proxies concurrently.
private val containerCount = new Counter
diff --git a/tests/src/test/scala/whisk/core/containerpool/test/ContainerProxyTests.scala b/tests/src/test/scala/whisk/core/containerpool/test/ContainerProxyTests.scala
index a49c766..f7a7e12 100644
--- a/tests/src/test/scala/whisk/core/containerpool/test/ContainerProxyTests.scala
+++ b/tests/src/test/scala/whisk/core/containerpool/test/ContainerProxyTests.scala
@@ -148,7 +148,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val container = new TestContainer
val factory = createFactory(Future.successful(container))
- val machine = childActorOf(ContainerProxy.props(factory, createAcker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, createAcker, store, pauseGrace = timeout))
registerCallback(machine)
preWarm(machine)
@@ -164,7 +164,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
preWarm(machine)
@@ -196,7 +196,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
preWarm(machine)
@@ -220,7 +220,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
preWarm(machine)
@@ -246,7 +246,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
run(machine, Uninitialized)
@@ -268,7 +268,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.failed(new Exception()))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
machine ! Run(action, message)
expectMsg(Transition(machine, Uninitialized, Running))
@@ -297,7 +297,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
machine ! Run(action, message)
expectMsg(Transition(machine, Uninitialized, Running))
@@ -326,7 +326,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
machine ! Run(action, message)
expectMsg(Transition(machine, Uninitialized, Running))
@@ -355,7 +355,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
run(machine, Uninitialized) // first run an activation
timeout(machine) // times out Ready state so container suspends
@@ -387,7 +387,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
run(machine, Uninitialized)
timeout(machine) // times out Ready state so container suspends
@@ -418,7 +418,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
// Start running the action
@@ -466,7 +466,7 @@ class ContainerProxyTests extends TestKit(ActorSystem("ContainerProxys"))
val factory = createFactory(Future.successful(container))
val acker = createAcker
- val machine = childActorOf(ContainerProxy.props(factory, acker, store))
+ val machine = childActorOf(ContainerProxy.props(factory, acker, store, pauseGrace = timeout))
registerCallback(machine)
run(machine, Uninitialized)
timeout(machine)
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.