[GitHub] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477352
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,243 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{ActorRef, ActorSystem, Props}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.pattern.ask
+import akka.util.Timeout
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.yarn.YARNComponentActor.CreateContainerAsync
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json._
+
+import scala.collection.immutable.HashMap
+import scala.concurrent.{blocking, ExecutionContext, Future}
+import scala.concurrent.duration._
+import YARNJsonProtocol._
+import akka.stream.ActorMaterializer
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+object YARNContainerFactoryProvider extends ContainerFactoryProvider {
+  override def instance(actorSystem: ActorSystem,
+logging: Logging,
+config: WhiskConfig,
+instance: InvokerInstanceId,
+parameters: Map[String, Set[String]]): 
ContainerFactory =
+new YARNContainerFactory(actorSystem, logging, config, instance, 
parameters)
+}
+class YARNContainerFactory(actorSystem: ActorSystem,
+   logging: Logging,
+   config: WhiskConfig,
+   instance: InvokerInstanceId,
+   parameters: Map[String, Set[String]],
+   containerArgs: ContainerArgsConfig =
+ 
loadConfigOrThrow[ContainerArgsConfig](ConfigKeys.containerArgs),
+   yarnConfig: YARNConfig = 
loadConfigOrThrow[YARNConfig](ConfigKeys.yarn))
+extends ContainerFactory {
+
+  val images: Set[ImageName] = 
ExecManifest.runtimesManifest.runtimes.flatMap(a => a.versions.map(b => 
b.image))
+
+  //One actor of each type per image for parallelism
+  private var yarnComponentActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+  private var YARNContainerInfoActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+
+  val serviceStartTimeoutMS = 6
+  val retryWaitMS = 1000
+  val runCommand = ""
+  val version = "1.0.0"
+  val description = "OpenWhisk Action Service"
+
+  //Allows for invoker HA
+  val serviceName: String = yarnConfig.serviceName + "-" + instance.toInt
+
+  val containerStartTimeoutMS = 6
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  override def init(): Unit = {
+yarnComponentActors = images
+  .map(
 
 Review comment:
   i find this spacing a little hard to read - is this how scalafmt did it? 


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477401
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,243 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{ActorRef, ActorSystem, Props}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.pattern.ask
+import akka.util.Timeout
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.yarn.YARNComponentActor.CreateContainerAsync
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json._
+
+import scala.collection.immutable.HashMap
+import scala.concurrent.{blocking, ExecutionContext, Future}
+import scala.concurrent.duration._
+import YARNJsonProtocol._
+import akka.stream.ActorMaterializer
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+object YARNContainerFactoryProvider extends ContainerFactoryProvider {
+  override def instance(actorSystem: ActorSystem,
+logging: Logging,
+config: WhiskConfig,
+instance: InvokerInstanceId,
+parameters: Map[String, Set[String]]): 
ContainerFactory =
+new YARNContainerFactory(actorSystem, logging, config, instance, 
parameters)
+}
+class YARNContainerFactory(actorSystem: ActorSystem,
+   logging: Logging,
+   config: WhiskConfig,
+   instance: InvokerInstanceId,
+   parameters: Map[String, Set[String]],
+   containerArgs: ContainerArgsConfig =
+ 
loadConfigOrThrow[ContainerArgsConfig](ConfigKeys.containerArgs),
+   yarnConfig: YARNConfig = 
loadConfigOrThrow[YARNConfig](ConfigKeys.yarn))
+extends ContainerFactory {
+
+  val images: Set[ImageName] = 
ExecManifest.runtimesManifest.runtimes.flatMap(a => a.versions.map(b => 
b.image))
+
+  //One actor of each type per image for parallelism
+  private var yarnComponentActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+  private var YARNContainerInfoActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+
+  val serviceStartTimeoutMS = 6
+  val retryWaitMS = 1000
+  val runCommand = ""
+  val version = "1.0.0"
+  val description = "OpenWhisk Action Service"
+
+  //Allows for invoker HA
+  val serviceName: String = yarnConfig.serviceName + "-" + instance.toInt
+
+  val containerStartTimeoutMS = 6
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  override def init(): Unit = {
+yarnComponentActors = images
+  .map(
+i =>
+  (
+i,
+actorSystem.actorOf(
+  Props(new YARNComponentActor(actorSystem, logging, yarnConfig, 
serviceName, i)),
+  name = s"YARNComponentActor-${i.name}")))
+  .toMap
+YARNContainerInfoActors = images
+  .map(
+i =>
+  (
+i,
+actorSystem.actorOf(
+  Props(new YARNContainerInfoActor(actorSystem, logging, 
yarnConfig, serviceName, i)),
+  name = s"YARNComponentInfoActor-${i.name}")))
+  .toMap
+blocking {
+  implicit val timeout: 

[GitHub] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477218
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNComponentActor.scala
 ##
 @@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{Actor, ActorSystem}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.stream.ActorMaterializer
+import org.apache.openwhisk.common.Logging
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import 
org.apache.openwhisk.core.yarn.YARNComponentActor.{CreateContainerAsync, 
RemoveContainer}
+
+import scala.concurrent.ExecutionContext
+
+//Submits create command to YARN and submits decommission command to YARN
+object YARNComponentActor {
+  case object CreateContainerAsync
+  case class RemoveContainer(component_instance_name: String)
+}
+class YARNComponentActor(actorSystem: ActorSystem,
+ logging: Logging,
+ yarnConfig: YARNConfig,
+ serviceName: String,
+ imageName: ImageName)
+extends Actor {
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  var containerCount: Int = 0
+
+  def receive: PartialFunction[Any, Unit] = {
+case CreateContainerAsync =>
+  sender ! createContainerAsync
+
+case RemoveContainer(component_instance_name) =>
+  sender ! removeContainer(component_instance_name)
+
+case input =>
+  throw new IllegalArgumentException("Unknown input: " + input)
+  sender ! false
+  }
+
+  def createContainerAsync(): Unit = {
+
+logging.info(this, s"Using YARN to create a container with image 
${imageName.name}...")
+
+val body = "{\"number_of_containers\":" + (containerCount + 1) + "}"
 
 Review comment:
   this is ok although you could also use `JsObject("number_of_containers" -> 
containerCount + 1).toJson).compactPrint`


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477238
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNComponentActor.scala
 ##
 @@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{Actor, ActorSystem}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.stream.ActorMaterializer
+import org.apache.openwhisk.common.Logging
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import 
org.apache.openwhisk.core.yarn.YARNComponentActor.{CreateContainerAsync, 
RemoveContainer}
+
+import scala.concurrent.ExecutionContext
+
+//Submits create command to YARN and submits decommission command to YARN
+object YARNComponentActor {
+  case object CreateContainerAsync
+  case class RemoveContainer(component_instance_name: String)
+}
+class YARNComponentActor(actorSystem: ActorSystem,
+ logging: Logging,
+ yarnConfig: YARNConfig,
+ serviceName: String,
+ imageName: ImageName)
+extends Actor {
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  var containerCount: Int = 0
+
+  def receive: PartialFunction[Any, Unit] = {
+case CreateContainerAsync =>
+  sender ! createContainerAsync
+
+case RemoveContainer(component_instance_name) =>
+  sender ! removeContainer(component_instance_name)
+
+case input =>
+  throw new IllegalArgumentException("Unknown input: " + input)
+  sender ! false
+  }
+
+  def createContainerAsync(): Unit = {
+
+logging.info(this, s"Using YARN to create a container with image 
${imageName.name}...")
+
+val body = "{\"number_of_containers\":" + (containerCount + 1) + "}"
+val response = YARNRESTUtil.submitRequestWithAuth(
+  yarnConfig.authType,
+  HttpMethods.PUT,
+  
s"${yarnConfig.masterUrl}/app/v1/services/$serviceName/components/${imageName.name}",
+  body)
+response match {
+  case httpresponse(StatusCodes.OK, content) =>
+logging.info(this, s"Added container: ${imageName.name}. Response: 
$content")
+containerCount += 1
+
+  case httpresponse(_, _) => YARNRESTUtil.handleYARNRESTError(logging)
+}
+  }
+
+  def removeContainer(component_instance_name: String): Unit = {
+logging.info(this, s"Removing ${imageName.name} container: 
$component_instance_name ")
+if (containerCount <= 0) {
+  logging.warn(this, "Already at 0 containers")
+} else {
+  val body =
+s"""{"components":[ { "name":"${imageName.name}", 
"decommissioned_instances":["$component_instance_name"] }]}"""
 
 Review comment:
   also can be done with JsObject - ok here since there are small objects and 
clear.


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477174
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNComponentActor.scala
 ##
 @@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{Actor, ActorSystem}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.stream.ActorMaterializer
+import org.apache.openwhisk.common.Logging
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import 
org.apache.openwhisk.core.yarn.YARNComponentActor.{CreateContainerAsync, 
RemoveContainer}
+
+import scala.concurrent.ExecutionContext
+
+//Submits create command to YARN and submits decommission command to YARN
+object YARNComponentActor {
+  case object CreateContainerAsync
+  case class RemoveContainer(component_instance_name: String)
+}
+class YARNComponentActor(actorSystem: ActorSystem,
+ logging: Logging,
+ yarnConfig: YARNConfig,
+ serviceName: String,
+ imageName: ImageName)
+extends Actor {
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  var containerCount: Int = 0
 
 Review comment:
   a comment here is helpful - your explanation in the "f2f" was helpful.


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477154
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNComponentActor.scala
 ##
 @@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{Actor, ActorSystem}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.stream.ActorMaterializer
+import org.apache.openwhisk.common.Logging
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import 
org.apache.openwhisk.core.yarn.YARNComponentActor.{CreateContainerAsync, 
RemoveContainer}
+
+import scala.concurrent.ExecutionContext
+
+//Submits create command to YARN and submits decommission command to YARN
 
 Review comment:
   should this be scaladoc on the class?


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477251
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,243 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{ActorRef, ActorSystem, Props}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.pattern.ask
+import akka.util.Timeout
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.yarn.YARNComponentActor.CreateContainerAsync
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json._
+
+import scala.collection.immutable.HashMap
+import scala.concurrent.{blocking, ExecutionContext, Future}
+import scala.concurrent.duration._
+import YARNJsonProtocol._
+import akka.stream.ActorMaterializer
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+object YARNContainerFactoryProvider extends ContainerFactoryProvider {
+  override def instance(actorSystem: ActorSystem,
+logging: Logging,
+config: WhiskConfig,
+instance: InvokerInstanceId,
+parameters: Map[String, Set[String]]): 
ContainerFactory =
+new YARNContainerFactory(actorSystem, logging, config, instance, 
parameters)
+}
+class YARNContainerFactory(actorSystem: ActorSystem,
 
 Review comment:
   space between classes.


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477158
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNComponentActor.scala
 ##
 @@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{Actor, ActorSystem}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.stream.ActorMaterializer
+import org.apache.openwhisk.common.Logging
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import 
org.apache.openwhisk.core.yarn.YARNComponentActor.{CreateContainerAsync, 
RemoveContainer}
+
+import scala.concurrent.ExecutionContext
+
+//Submits create command to YARN and submits decommission command to YARN
+object YARNComponentActor {
+  case object CreateContainerAsync
+  case class RemoveContainer(component_instance_name: String)
+}
+class YARNComponentActor(actorSystem: ActorSystem,
 
 Review comment:
   space between classes  


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477190
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNComponentActor.scala
 ##
 @@ -0,0 +1,101 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{Actor, ActorSystem}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.stream.ActorMaterializer
+import org.apache.openwhisk.common.Logging
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import 
org.apache.openwhisk.core.yarn.YARNComponentActor.{CreateContainerAsync, 
RemoveContainer}
+
+import scala.concurrent.ExecutionContext
+
+//Submits create command to YARN and submits decommission command to YARN
+object YARNComponentActor {
+  case object CreateContainerAsync
+  case class RemoveContainer(component_instance_name: String)
+}
+class YARNComponentActor(actorSystem: ActorSystem,
+ logging: Logging,
+ yarnConfig: YARNConfig,
+ serviceName: String,
+ imageName: ImageName)
+extends Actor {
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  var containerCount: Int = 0
+
+  def receive: PartialFunction[Any, Unit] = {
+case CreateContainerAsync =>
+  sender ! createContainerAsync
+
+case RemoveContainer(component_instance_name) =>
+  sender ! removeContainer(component_instance_name)
+
+case input =>
+  throw new IllegalArgumentException("Unknown input: " + input)
+  sender ! false
+  }
+
+  def createContainerAsync(): Unit = {
+
 
 Review comment:
   is this line intentional?


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] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477420
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,243 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{ActorRef, ActorSystem, Props}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.pattern.ask
+import akka.util.Timeout
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.yarn.YARNComponentActor.CreateContainerAsync
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json._
+
+import scala.collection.immutable.HashMap
+import scala.concurrent.{blocking, ExecutionContext, Future}
+import scala.concurrent.duration._
+import YARNJsonProtocol._
+import akka.stream.ActorMaterializer
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+object YARNContainerFactoryProvider extends ContainerFactoryProvider {
+  override def instance(actorSystem: ActorSystem,
+logging: Logging,
+config: WhiskConfig,
+instance: InvokerInstanceId,
+parameters: Map[String, Set[String]]): 
ContainerFactory =
+new YARNContainerFactory(actorSystem, logging, config, instance, 
parameters)
+}
+class YARNContainerFactory(actorSystem: ActorSystem,
+   logging: Logging,
+   config: WhiskConfig,
+   instance: InvokerInstanceId,
+   parameters: Map[String, Set[String]],
+   containerArgs: ContainerArgsConfig =
+ 
loadConfigOrThrow[ContainerArgsConfig](ConfigKeys.containerArgs),
+   yarnConfig: YARNConfig = 
loadConfigOrThrow[YARNConfig](ConfigKeys.yarn))
+extends ContainerFactory {
+
+  val images: Set[ImageName] = 
ExecManifest.runtimesManifest.runtimes.flatMap(a => a.versions.map(b => 
b.image))
+
+  //One actor of each type per image for parallelism
+  private var yarnComponentActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+  private var YARNContainerInfoActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+
+  val serviceStartTimeoutMS = 6
+  val retryWaitMS = 1000
+  val runCommand = ""
+  val version = "1.0.0"
+  val description = "OpenWhisk Action Service"
+
+  //Allows for invoker HA
+  val serviceName: String = yarnConfig.serviceName + "-" + instance.toInt
+
+  val containerStartTimeoutMS = 6
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  override def init(): Unit = {
+yarnComponentActors = images
+  .map(
+i =>
+  (
+i,
+actorSystem.actorOf(
+  Props(new YARNComponentActor(actorSystem, logging, yarnConfig, 
serviceName, i)),
+  name = s"YARNComponentActor-${i.name}")))
+  .toMap
+YARNContainerInfoActors = images
+  .map(
+i =>
+  (
+i,
+actorSystem.actorOf(
+  Props(new YARNContainerInfoActor(actorSystem, logging, 
yarnConfig, serviceName, i)),
+  name = s"YARNComponentInfoActor-${i.name}")))
+  .toMap
+blocking {
+  implicit val timeout: 

[GitHub] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2019-02-16 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r257477541
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,243 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import akka.actor.{ActorRef, ActorSystem, Props}
+import akka.http.scaladsl.model.{HttpMethods, StatusCodes}
+import akka.pattern.ask
+import akka.util.Timeout
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.yarn.YARNComponentActor.CreateContainerAsync
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json._
+
+import scala.collection.immutable.HashMap
+import scala.concurrent.{blocking, ExecutionContext, Future}
+import scala.concurrent.duration._
+import YARNJsonProtocol._
+import akka.stream.ActorMaterializer
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+object YARNContainerFactoryProvider extends ContainerFactoryProvider {
+  override def instance(actorSystem: ActorSystem,
+logging: Logging,
+config: WhiskConfig,
+instance: InvokerInstanceId,
+parameters: Map[String, Set[String]]): 
ContainerFactory =
+new YARNContainerFactory(actorSystem, logging, config, instance, 
parameters)
+}
+class YARNContainerFactory(actorSystem: ActorSystem,
+   logging: Logging,
+   config: WhiskConfig,
+   instance: InvokerInstanceId,
+   parameters: Map[String, Set[String]],
+   containerArgs: ContainerArgsConfig =
+ 
loadConfigOrThrow[ContainerArgsConfig](ConfigKeys.containerArgs),
+   yarnConfig: YARNConfig = 
loadConfigOrThrow[YARNConfig](ConfigKeys.yarn))
+extends ContainerFactory {
+
+  val images: Set[ImageName] = 
ExecManifest.runtimesManifest.runtimes.flatMap(a => a.versions.map(b => 
b.image))
+
+  //One actor of each type per image for parallelism
+  private var yarnComponentActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+  private var YARNContainerInfoActors: Map[ImageName, ActorRef] = 
HashMap[ImageName, ActorRef]()
+
+  val serviceStartTimeoutMS = 6
+  val retryWaitMS = 1000
+  val runCommand = ""
+  val version = "1.0.0"
+  val description = "OpenWhisk Action Service"
+
+  //Allows for invoker HA
+  val serviceName: String = yarnConfig.serviceName + "-" + instance.toInt
+
+  val containerStartTimeoutMS = 6
+
+  implicit val as: ActorSystem = actorSystem
+  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val ec: ExecutionContext = actorSystem.dispatcher
+
+  override def init(): Unit = {
+yarnComponentActors = images
+  .map(
+i =>
+  (
+i,
+actorSystem.actorOf(
+  Props(new YARNComponentActor(actorSystem, logging, yarnConfig, 
serviceName, i)),
+  name = s"YARNComponentActor-${i.name}")))
+  .toMap
+YARNContainerInfoActors = images
+  .map(
+i =>
+  (
+i,
+actorSystem.actorOf(
+  Props(new YARNContainerInfoActor(actorSystem, logging, 
yarnConfig, serviceName, i)),
+  name = s"YARNComponentInfoActor-${i.name}")))
+  .toMap
+blocking {
+  implicit val timeout: 

[GitHub] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2018-11-30 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r237980462
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,476 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import java.nio.charset.StandardCharsets
+import java.security.Principal
+
+import akka.actor.ActorSystem
+import akka.http.scaladsl.model._
+import akka.stream.ActorMaterializer
+import javax.security.sasl.AuthenticationException
+import org.apache.commons.io.IOUtils
+import org.apache.http.auth.{AuthSchemeProvider, AuthScope, Credentials}
+import org.apache.http.client.CredentialsProvider
+import org.apache.http.client.config.AuthSchemes
+import org.apache.http.client.methods._
+import org.apache.http.config.RegistryBuilder
+import org.apache.http.entity.StringEntity
+import org.apache.http.impl.auth.SPNegoSchemeFactory
+import org.apache.http.impl.client.{CloseableHttpClient, HttpClients, _}
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json.{DefaultJsonProtocol, _}
+
+import scala.concurrent.{ExecutionContext, Future}
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+case class KerberosPrincipalDefinition(principal_name: Option[String], keytab: 
Option[String])
+case class YARNResponseDefinition(diagnostics: String)
+case class ConfigurationDefinition(env: Map[String, String])
+case class ArtifactDefinition(id: String, `type`: String)
+case class ResourceDefinition(cpus: Int, memory: String)
+case class ContainerDefinition(ip: Option[String],
+   bare_host: Option[String],
+   component_instance_name: String,
+   hostname: Option[String],
+   id: String,
+   launch_time: Long,
+   state: String)
+case class ComponentDefinition(name: String,
+   number_of_containers: Int,
+   launch_command: String,
+   containers: Option[List[ContainerDefinition]],
+   artifact: ArtifactDefinition,
+   resource: ResourceDefinition,
+   configuration: ConfigurationDefinition)
+case class ServiceDefinition(name: String,
+ version: Option[String],
+ description: Option[String],
+ state: String,
+ queue: Option[String],
+ components: List[ComponentDefinition],
+ kerberos_principal: 
Option[KerberosPrincipalDefinition])
+
+object YARNJsonProtocol extends DefaultJsonProtocol {
+  implicit val KerberosPrincipalDefinitionFormat: 
RootJsonFormat[KerberosPrincipalDefinition] = jsonFormat2(
+KerberosPrincipalDefinition)
+  implicit val YARNResponseDefinitionFormat: 
RootJsonFormat[YARNResponseDefinition] = jsonFormat1(
+YARNResponseDefinition)
+  implicit val configurationDefinitionFormat: 
RootJsonFormat[ConfigurationDefinition] = jsonFormat1(
+ConfigurationDefinition)
+  implicit val artifactDefinitionFormat: RootJsonFormat[ArtifactDefinition] = 
jsonFormat2(ArtifactDefinition)
+  implicit val resourceDefinitionFormat: 

[GitHub] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2018-11-30 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r237981794
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,476 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import java.nio.charset.StandardCharsets
+import java.security.Principal
+
+import akka.actor.ActorSystem
+import akka.http.scaladsl.model._
+import akka.stream.ActorMaterializer
+import javax.security.sasl.AuthenticationException
+import org.apache.commons.io.IOUtils
+import org.apache.http.auth.{AuthSchemeProvider, AuthScope, Credentials}
+import org.apache.http.client.CredentialsProvider
+import org.apache.http.client.config.AuthSchemes
+import org.apache.http.client.methods._
+import org.apache.http.config.RegistryBuilder
+import org.apache.http.entity.StringEntity
+import org.apache.http.impl.auth.SPNegoSchemeFactory
+import org.apache.http.impl.client.{CloseableHttpClient, HttpClients, _}
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json.{DefaultJsonProtocol, _}
+
+import scala.concurrent.{ExecutionContext, Future}
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+case class KerberosPrincipalDefinition(principal_name: Option[String], keytab: 
Option[String])
+case class YARNResponseDefinition(diagnostics: String)
+case class ConfigurationDefinition(env: Map[String, String])
+case class ArtifactDefinition(id: String, `type`: String)
+case class ResourceDefinition(cpus: Int, memory: String)
+case class ContainerDefinition(ip: Option[String],
+   bare_host: Option[String],
+   component_instance_name: String,
+   hostname: Option[String],
+   id: String,
+   launch_time: Long,
+   state: String)
+case class ComponentDefinition(name: String,
+   number_of_containers: Int,
+   launch_command: String,
+   containers: Option[List[ContainerDefinition]],
+   artifact: ArtifactDefinition,
+   resource: ResourceDefinition,
+   configuration: ConfigurationDefinition)
+case class ServiceDefinition(name: String,
+ version: Option[String],
+ description: Option[String],
+ state: String,
+ queue: Option[String],
+ components: List[ComponentDefinition],
+ kerberos_principal: 
Option[KerberosPrincipalDefinition])
+
+object YARNJsonProtocol extends DefaultJsonProtocol {
+  implicit val KerberosPrincipalDefinitionFormat: 
RootJsonFormat[KerberosPrincipalDefinition] = jsonFormat2(
+KerberosPrincipalDefinition)
+  implicit val YARNResponseDefinitionFormat: 
RootJsonFormat[YARNResponseDefinition] = jsonFormat1(
+YARNResponseDefinition)
+  implicit val configurationDefinitionFormat: 
RootJsonFormat[ConfigurationDefinition] = jsonFormat1(
+ConfigurationDefinition)
+  implicit val artifactDefinitionFormat: RootJsonFormat[ArtifactDefinition] = 
jsonFormat2(ArtifactDefinition)
+  implicit val resourceDefinitionFormat: 

[GitHub] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2018-11-30 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r237980039
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,476 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import java.nio.charset.StandardCharsets
+import java.security.Principal
+
+import akka.actor.ActorSystem
+import akka.http.scaladsl.model._
+import akka.stream.ActorMaterializer
+import javax.security.sasl.AuthenticationException
+import org.apache.commons.io.IOUtils
+import org.apache.http.auth.{AuthSchemeProvider, AuthScope, Credentials}
+import org.apache.http.client.CredentialsProvider
+import org.apache.http.client.config.AuthSchemes
+import org.apache.http.client.methods._
+import org.apache.http.config.RegistryBuilder
+import org.apache.http.entity.StringEntity
+import org.apache.http.impl.auth.SPNegoSchemeFactory
+import org.apache.http.impl.client.{CloseableHttpClient, HttpClients, _}
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json.{DefaultJsonProtocol, _}
+
+import scala.concurrent.{ExecutionContext, Future}
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+case class KerberosPrincipalDefinition(principal_name: Option[String], keytab: 
Option[String])
+case class YARNResponseDefinition(diagnostics: String)
+case class ConfigurationDefinition(env: Map[String, String])
+case class ArtifactDefinition(id: String, `type`: String)
+case class ResourceDefinition(cpus: Int, memory: String)
+case class ContainerDefinition(ip: Option[String],
+   bare_host: Option[String],
+   component_instance_name: String,
+   hostname: Option[String],
+   id: String,
+   launch_time: Long,
+   state: String)
+case class ComponentDefinition(name: String,
+   number_of_containers: Int,
+   launch_command: String,
+   containers: Option[List[ContainerDefinition]],
+   artifact: ArtifactDefinition,
+   resource: ResourceDefinition,
+   configuration: ConfigurationDefinition)
+case class ServiceDefinition(name: String,
+ version: Option[String],
+ description: Option[String],
+ state: String,
+ queue: Option[String],
+ components: List[ComponentDefinition],
+ kerberos_principal: 
Option[KerberosPrincipalDefinition])
+
+object YARNJsonProtocol extends DefaultJsonProtocol {
+  implicit val KerberosPrincipalDefinitionFormat: 
RootJsonFormat[KerberosPrincipalDefinition] = jsonFormat2(
+KerberosPrincipalDefinition)
+  implicit val YARNResponseDefinitionFormat: 
RootJsonFormat[YARNResponseDefinition] = jsonFormat1(
+YARNResponseDefinition)
+  implicit val configurationDefinitionFormat: 
RootJsonFormat[ConfigurationDefinition] = jsonFormat1(
+ConfigurationDefinition)
+  implicit val artifactDefinitionFormat: RootJsonFormat[ArtifactDefinition] = 
jsonFormat2(ArtifactDefinition)
+  implicit val resourceDefinitionFormat: 

[GitHub] rabbah commented on a change in pull request #4129: Adding YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop clusters.

2018-11-30 Thread GitBox
rabbah commented on a change in pull request #4129: Adding 
YARNContainerFactory. This allows OpenWhisk to run actions on Apache Hadoop 
clusters.
URL: 
https://github.com/apache/incubator-openwhisk/pull/4129#discussion_r237981086
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/yarn/YARNContainerFactory.scala
 ##
 @@ -0,0 +1,476 @@
+/*
+ * 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 org.apache.openwhisk.core.yarn
+
+import java.nio.charset.StandardCharsets
+import java.security.Principal
+
+import akka.actor.ActorSystem
+import akka.http.scaladsl.model._
+import akka.stream.ActorMaterializer
+import javax.security.sasl.AuthenticationException
+import org.apache.commons.io.IOUtils
+import org.apache.http.auth.{AuthSchemeProvider, AuthScope, Credentials}
+import org.apache.http.client.CredentialsProvider
+import org.apache.http.client.config.AuthSchemes
+import org.apache.http.client.methods._
+import org.apache.http.config.RegistryBuilder
+import org.apache.http.entity.StringEntity
+import org.apache.http.impl.auth.SPNegoSchemeFactory
+import org.apache.http.impl.client.{CloseableHttpClient, HttpClients, _}
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool._
+import org.apache.openwhisk.core.entity.ExecManifest.ImageName
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import org.apache.openwhisk.core.{ConfigKeys, WhiskConfig}
+import pureconfig.loadConfigOrThrow
+import spray.json.{DefaultJsonProtocol, _}
+
+import scala.concurrent.{ExecutionContext, Future}
+
+case class YARNConfig(masterUrl: String,
+  yarnLinkLogMessage: Boolean,
+  serviceName: String,
+  authType: String,
+  kerberosPrincipal: String,
+  kerberosKeytab: String,
+  queue: String,
+  memory: String,
+  cpus: Int)
+
+case class KerberosPrincipalDefinition(principal_name: Option[String], keytab: 
Option[String])
+case class YARNResponseDefinition(diagnostics: String)
+case class ConfigurationDefinition(env: Map[String, String])
+case class ArtifactDefinition(id: String, `type`: String)
+case class ResourceDefinition(cpus: Int, memory: String)
+case class ContainerDefinition(ip: Option[String],
+   bare_host: Option[String],
+   component_instance_name: String,
+   hostname: Option[String],
+   id: String,
+   launch_time: Long,
+   state: String)
+case class ComponentDefinition(name: String,
+   number_of_containers: Int,
+   launch_command: String,
+   containers: Option[List[ContainerDefinition]],
+   artifact: ArtifactDefinition,
+   resource: ResourceDefinition,
+   configuration: ConfigurationDefinition)
+case class ServiceDefinition(name: String,
+ version: Option[String],
+ description: Option[String],
+ state: String,
+ queue: Option[String],
+ components: List[ComponentDefinition],
+ kerberos_principal: 
Option[KerberosPrincipalDefinition])
+
+object YARNJsonProtocol extends DefaultJsonProtocol {
+  implicit val KerberosPrincipalDefinitionFormat: 
RootJsonFormat[KerberosPrincipalDefinition] = jsonFormat2(
+KerberosPrincipalDefinition)
+  implicit val YARNResponseDefinitionFormat: 
RootJsonFormat[YARNResponseDefinition] = jsonFormat1(
+YARNResponseDefinition)
+  implicit val configurationDefinitionFormat: 
RootJsonFormat[ConfigurationDefinition] = jsonFormat1(
+ConfigurationDefinition)
+  implicit val artifactDefinitionFormat: RootJsonFormat[ArtifactDefinition] = 
jsonFormat2(ArtifactDefinition)
+  implicit val resourceDefinitionFormat: