[GitHub] tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer

2017-09-06 Thread git
tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r137322300
 
 

 ##
 File path: 
tests/src/test/scala/whisk/core/database/test/CouchDBStoreProviderTests.scala
 ##
 @@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package whisk.core.database.test
+
+import common.StreamLogging
+import common.WskActorSystem
+import org.junit.runner.RunWith
+import org.scalatest.FlatSpec
+import org.scalatest.Matchers
+import org.scalatest.junit.JUnitRunner
+import whisk.core.WhiskConfig
+import whisk.core.WhiskConfig._
+import whisk.core.database.ArtifactStoreProvider
+import whisk.core.entity.WhiskActivation
+import whisk.spi.SpiLoader
+
+@RunWith(classOf[JUnitRunner])
+class CouchDBStoreProviderTests extends FlatSpec
+with Matchers
+with WskActorSystem
+with StreamLogging {
+val config = new WhiskConfig(Map(
+dbProvider -> "CouchDB",
+dbProtocol -> "http",
+dbUsername -> "fake",
+dbPassword -> "fake",
+dbHost -> "fake",
+dbPort -> "1234",
+dbActivations -> "activations_fake"))
+
+
+val artifactStoreProvider = SpiLoader.get[ArtifactStoreProvider]()
+val store1FirstLoad = 
artifactStoreProvider.makeStore[WhiskActivation](config, _.dbActivations)
+val store1SecondLoad = 
artifactStoreProvider.makeStore[WhiskActivation](config, _.dbActivations)
+
+behavior of "CouchDBStoreProvider"
+override def afterAll() {
+println("Shutting down store connections")
+store1FirstLoad.shutdown()
+//do not need to shutdown the second loaded store, but we'll do it 
anyways since clients may do that also
+store1SecondLoad.shutdown()
+super.afterAll()
+}
+it should "load the same store from config for a specific artifact type" 
in {
+store1FirstLoad shouldBe store1SecondLoad
+}
 
 Review comment:
   Sure; merged the SpiInstanceCaching to this PR; added test for different 
names -> different instances; will add general test for SpiInstanceCaching
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer

2017-09-06 Thread git
tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r137322300
 
 

 ##
 File path: 
tests/src/test/scala/whisk/core/database/test/CouchDBStoreProviderTests.scala
 ##
 @@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package whisk.core.database.test
+
+import common.StreamLogging
+import common.WskActorSystem
+import org.junit.runner.RunWith
+import org.scalatest.FlatSpec
+import org.scalatest.Matchers
+import org.scalatest.junit.JUnitRunner
+import whisk.core.WhiskConfig
+import whisk.core.WhiskConfig._
+import whisk.core.database.ArtifactStoreProvider
+import whisk.core.entity.WhiskActivation
+import whisk.spi.SpiLoader
+
+@RunWith(classOf[JUnitRunner])
+class CouchDBStoreProviderTests extends FlatSpec
+with Matchers
+with WskActorSystem
+with StreamLogging {
+val config = new WhiskConfig(Map(
+dbProvider -> "CouchDB",
+dbProtocol -> "http",
+dbUsername -> "fake",
+dbPassword -> "fake",
+dbHost -> "fake",
+dbPort -> "1234",
+dbActivations -> "activations_fake"))
+
+
+val artifactStoreProvider = SpiLoader.get[ArtifactStoreProvider]()
+val store1FirstLoad = 
artifactStoreProvider.makeStore[WhiskActivation](config, _.dbActivations)
+val store1SecondLoad = 
artifactStoreProvider.makeStore[WhiskActivation](config, _.dbActivations)
+
+behavior of "CouchDBStoreProvider"
+override def afterAll() {
+println("Shutting down store connections")
+store1FirstLoad.shutdown()
+//do not need to shutdown the second loaded store, but we'll do it 
anyways since clients may do that also
+store1SecondLoad.shutdown()
+super.afterAll()
+}
+it should "load the same store from config for a specific artifact type" 
in {
+store1FirstLoad shouldBe store1SecondLoad
+}
 
 Review comment:
   Sure; merge the SpiInstanceCaching to this PR; added test for different 
names -> different instances; will add general test for SpiInstanceCaching
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer

2017-09-06 Thread git
tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r137320221
 
 

 ##
 File path: 
tests/src/test/scala/whisk/core/database/test/CouchDBStoreProviderTests.scala
 ##
 @@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package whisk.core.database.test
+
+import common.StreamLogging
+import common.WskActorSystem
+import org.junit.runner.RunWith
+import org.scalatest.FlatSpec
+import org.scalatest.Matchers
+import org.scalatest.junit.JUnitRunner
+import whisk.core.WhiskConfig
+import whisk.core.WhiskConfig._
+import whisk.core.database.ArtifactStoreProvider
+import whisk.core.entity.WhiskActivation
+import whisk.spi.SpiLoader
+
+@RunWith(classOf[JUnitRunner])
+class CouchDBStoreProviderTests extends FlatSpec
+with Matchers
+with WskActorSystem
+with StreamLogging {
 
 Review comment:
   WhiskConfig requires `(implicit val logging: Logging)` - looks like 
StreamLogging is what most tests do. Please advise.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer

2017-09-06 Thread git
tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r137318837
 
 

 ##
 File path: 
common/scala/src/main/scala/whisk/core/database/CouchDbStoreProvider.scala
 ##
 @@ -18,16 +18,18 @@
 package whisk.core.database
 
 import akka.actor.ActorSystem
+import scala.collection.mutable
 import spray.json.RootJsonFormat
 import whisk.common.Logging
 import whisk.core.WhiskConfig
 import whisk.spi.Dependencies
-import whisk.spi.SpiFactory
+import whisk.spi.SingletonSpiFactory
 
 /**
  * A CouchDB implementation of ArtifactStoreProvider
  */
 class CouchDbStoreProvider extends ArtifactStoreProvider {
+private val stores =  mutable.Map [String, CouchDbRestStore[_]]()
 
 Review comment:
   replaced this with SpiInstanceCaching (with TrieMap) 
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer

2017-08-10 Thread git
tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r132442155
 
 

 ##
 File path: 
common/scala/src/main/scala/whisk/core/database/CouchDbStoreProvider.scala
 ##
 @@ -18,16 +18,18 @@
 package whisk.core.database
 
 import akka.actor.ActorSystem
+import scala.collection.mutable
 import spray.json.RootJsonFormat
 import whisk.common.Logging
 import whisk.core.WhiskConfig
 import whisk.spi.Dependencies
-import whisk.spi.SpiFactory
+import whisk.spi.SingletonSpiFactory
 
 /**
  * A CouchDB implementation of ArtifactStoreProvider
  */
 class CouchDbStoreProvider extends ArtifactStoreProvider {
+protected[database] val stores =  mutable.Map [String, 
CouchDbRestStore[_]]()
 
 Review comment:
   yes
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer

2017-08-08 Thread git
tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r131931484
 
 

 ##
 File path: 
core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerService.scala
 ##
 @@ -77,16 +82,32 @@ trait LoadBalancer {
  */
 def publish(action: ExecutableWhiskAction, msg: 
ActivationMessage)(implicit transid: TransactionId): 
Future[Future[Either[ActivationId, WhiskActivation]]]
 
+/**
+ * Return a message indicating the health of the containers and/or 
container pool in general
+ * @return a Future[String] representing the heal response that will be 
sent to the client
+ */
+def getHealthResponse: Future[String]
 
 Review comment:
   done
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer

2017-08-08 Thread git
tysonnorris commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r131931453
 
 

 ##
 File path: 
common/scala/src/main/scala/whisk/core/database/CouchDbStoreProvider.scala
 ##
 @@ -36,10 +38,17 @@ class CouchDbStoreProvider extends ArtifactStoreProvider {
 require(config.dbProvider == "Cloudant" || config.dbProvider == 
"CouchDB", "Unsupported db.provider: " + config.dbProvider)
 assume(Set(config.dbProtocol, config.dbHost, config.dbPort, 
config.dbUsername, config.dbPassword, name(config)).forall(_.nonEmpty), "At 
least one expected property is missing")
 
-new CouchDbRestStore[D](config.dbProtocol, config.dbHost, 
config.dbPort.toInt, config.dbUsername, config.dbPassword, name(config))
+val storeName = name(config)
+stores.get(storeName) match {
 
 Review comment:
   great thanks!
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services