markusthoemmes commented on a change in pull request #2833: MesosContainerFactory URL: https://github.com/apache/incubator-openwhisk/pull/2833#discussion_r151351810
########## File path: common/scala/src/main/scala/whisk/core/mesos/MesosContainerFactory.scala ########## @@ -0,0 +1,121 @@ +/* + * 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.mesos + +import akka.actor.ActorSystem +import akka.pattern.ask +import com.adobe.api.platform.runtime.mesos.MesosClient +import com.adobe.api.platform.runtime.mesos.Subscribe +import com.adobe.api.platform.runtime.mesos.SubscribeComplete +import com.adobe.api.platform.runtime.mesos.Teardown +import scala.concurrent.Await +import scala.concurrent.ExecutionContext +import scala.concurrent.Future +import scala.concurrent.duration._ +import whisk.common.Logging +import whisk.common.TransactionId +import whisk.core.WhiskConfig +import whisk.core.containerpool.Container +import whisk.core.containerpool.ContainerFactory +import whisk.core.containerpool.ContainerFactoryProvider +import whisk.core.entity.ByteSize +import whisk.core.entity.ExecManifest +import whisk.core.entity.InstanceId +import whisk.core.entity.UUID + +class MesosContainerFactory(config: WhiskConfig, + actorSystem: ActorSystem, + logging: Logging, + parameters: Map[String, Set[String]]) + extends ContainerFactory { + + val subscribeTimeout = 30.seconds + + //init mesos framework: + implicit val as: ActorSystem = actorSystem + implicit val ec: ExecutionContext = actorSystem.dispatcher + + val akkaConfig = actorSystem.settings.config + //mesos master url to subscribe the framework to + val mesosMaster = akkaConfig.getString("whisk.mesos.master-url") + //public mesos url where developers can browse logs (till there is way to delegate log retrieval to an external system) + val mesosMasterPublic = akkaConfig.getString("whisk.mesos.master-url-public") + + logging.info(this, s"subscribing to mesos master at ${mesosMaster}") + + val mesosClientActor = actorSystem.actorOf( + MesosClient + .props("whisk-containerfactory-" + UUID(), "whisk-containerfactory-framework", mesosMaster, "*", 0.minutes)) + + //subscribe mesos actor to mesos event stream + //TODO: handle subscribe failure + mesosClientActor + .ask(Subscribe)(subscribeTimeout) + .mapTo[SubscribeComplete] + .onComplete(complete => { + logging.info(this, "subscribe completed successfully...") + }) + + override def createContainer(tid: TransactionId, + name: String, + actionImage: ExecManifest.ImageName, + userProvidedImage: Boolean, + memory: ByteSize)(implicit config: WhiskConfig, logging: Logging): Future[Container] = { + implicit val transid = tid + val image = if (userProvidedImage) { + logging.info(this, "using public image") + actionImage.publicImageName + } else { + logging.info(this, "using local image") Review comment: Aren't those 2 debug logs? ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
