You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by gi...@git.apache.org on 2017/09/14 02:22:17 UTC

[GitHub] tysonnorris commented on a change in pull request #2531: Share bookkeeping data across controllers

tysonnorris commented on a change in pull request #2531: Share bookkeeping data across controllers
URL: https://github.com/apache/incubator-openwhisk/pull/2531#discussion_r138783762
 
 

 ##########
 File path: core/controller/src/main/scala/whisk/core/loadBalancer/SharedDataService.scala
 ##########
 @@ -0,0 +1,122 @@
+/*
+ * 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.loadBalancer
+
+import akka.actor.{Actor, ActorLogging, ActorRef, Props}
+import akka.cluster.Cluster
+import akka.cluster.ClusterEvent.{InitialStateAsEvents, MemberEvent, MemberRemoved, MemberUp, UnreachableMember}
+import akka.cluster.ddata.{DistributedData, PNCounterMap, PNCounterMapKey}
+import akka.cluster.ddata.Replicator._
+import whisk.common.AkkaLogging
+import whisk.core.WhiskConfig
+import com.typesafe.config.{Config, ConfigFactory}
+
+case class IncreaseCounter(key: String, value: Long)
+case class DecreaseCounter(key: String, value: Long)
+case class ReadCounter(key: String)
+case class RemoveCounter(key: String)
+case object GetMap
+
+/**
+ * Companion object to specify actor properties from the outside, e.g. name of the shared map
+ */
+object SharedDataService {
+  val requiredProperties = Map(WhiskConfig.controllerSeedNodes -> null)
+
+  def props(storageName: String): Props = Props(new SharedDataService(storageName))
+
+  /**
+   * Add seed nodes if cluster provider is specified, otherwhise return the existing config.
+   * Parse akka seed nodes this way until either of these 2 issues is resolved:
+   * https://github.com/akka/akka/issues/23600
+   * https://github.com/typesafehub/config/issues/69
+   * @return Updated Config
+   */
+  def addAkkaSeedNodesToConf(whiskConf: WhiskConfig): Config = {
+    val conf = ConfigFactory.load()
+
+    val cluster = conf.getString("akka.actor.provider")
+
+    if (cluster == "cluster") {
+      val seedNodes = whiskConf.controllerSeedNodes
 
 Review comment:
   configuring seed nodes statically is very limiting; it would be better to make this extensible, so that various deployment types (kube, mesos) can dictate how "seed nodes" are resolved at runtime, and then init the Akka cluster explicitly AFTER seed nodes are determined (dynamically or from config): 
   ```
       val seedNodes = SeedConfigSource.getSeedNodes(config)
       Cluster(system).joinSeedNodes(seedNodes.toList)
   ```
   If you make SeedConfigSource either an SPI or a class that allows various approaches, it would enable different deployments the flexibility to register seed nodes as they see fit. 
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services