Skip to content

Commit

Permalink
Apply scalaFmt (#5415)
Browse files Browse the repository at this point in the history
  • Loading branch information
style95 authored May 20, 2023
1 parent 72bb2a1 commit ba871e5
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import spray.json._
*
* @param maxConcurrentInstances the max number of concurrent activations in a single container
*/
protected[entity] class InstanceConcurrencyLimit private(val maxConcurrentInstances: Int) extends AnyVal
protected[entity] class InstanceConcurrencyLimit private (val maxConcurrentInstances: Int) extends AnyVal

protected[core] object InstanceConcurrencyLimit extends ArgNormalizer[InstanceConcurrencyLimit] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ case class IntraConcurrencyLimitConfig(min: Int, max: Int, std: Int)
*
* @param maxConcurrent the max number of concurrent activations in a single container
*/
protected[entity] class IntraConcurrencyLimit private(val maxConcurrent: Int) extends AnyVal {
protected[entity] class IntraConcurrencyLimit private (val maxConcurrent: Int) extends AnyVal {

/** It checks the namespace memory limit setting value */
@throws[ActionConcurrencyLimitException]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.apache.openwhisk.common.TransactionId
import org.apache.openwhisk.core.WhiskConfig
import org.apache.openwhisk.core.entitlement.{Collection, Privilege, Resource}
import org.apache.openwhisk.core.entitlement.Privilege.READ
import org.apache.openwhisk.core.entity.{IntraConcurrencyLimit, Identity, LogLimit, MemoryLimit, TimeLimit}
import org.apache.openwhisk.core.entity.{Identity, IntraConcurrencyLimit, LogLimit, MemoryLimit, TimeLimit}

trait WhiskLimitsApi extends Directives with AuthenticatedRouteProvider with AuthorizedRouteProvider {

Expand Down Expand Up @@ -65,8 +65,7 @@ trait WhiskLimitsApi extends Directives with AuthenticatedRouteProvider with Aut
maxActionConcurrency = Some(IntraConcurrencyLimit(user.limits.allowedMaxActionConcurrency)),
minActionConcurrency = Some(IntraConcurrencyLimit(user.limits.allowedMinActionConcurrency)),
maxParameterSize = Some(user.limits.allowedMaxParameterSize),
maxActionInstances =
Some(user.limits.concurrentInvocations.getOrElse(concurrentInvocationsSystemDefault)))
maxActionInstances = Some(user.limits.concurrentInvocations.getOrElse(concurrentInvocationsSystemDefault)))
pathEndOrSingleSlash { complete(OK, limits) }
case _ => reject //should never get here
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class LeanBalancer(config: WhiskConfig,
/** Creates an invoker for executing user actions. There is only one invoker in the lean model. */
private def makeALocalThreadedInvoker(): Unit = {
implicit val ec = ExecutionContextFactory.makeCachedThreadPoolExecutionContext()
val limitConfig: IntraConcurrencyLimitConfig = loadConfigOrThrow[IntraConcurrencyLimitConfig](ConfigKeys.concurrencyLimit)
val limitConfig: IntraConcurrencyLimitConfig =
loadConfigOrThrow[IntraConcurrencyLimitConfig](ConfigKeys.concurrencyLimit)
SpiLoader.get[InvokerProvider].instance(config, invokerName, messageProducer, poolConfig, limitConfig)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ object Invoker {
ActorSystem(name = "invoker-actor-system", defaultExecutionContext = Some(ec))
implicit val logger = new AkkaLogging(akka.event.Logging.getLogger(actorSystem, this))
val poolConfig: ContainerPoolConfig = loadConfigOrThrow[ContainerPoolConfig](ConfigKeys.containerPool)
val limitConfig: IntraConcurrencyLimitConfig = loadConfigOrThrow[IntraConcurrencyLimitConfig](ConfigKeys.concurrencyLimit)
val limitConfig: IntraConcurrencyLimitConfig =
loadConfigOrThrow[IntraConcurrencyLimitConfig](ConfigKeys.concurrencyLimit)
val tags: Seq[String] = Some(loadConfigOrThrow[String](ConfigKeys.invokerResourceTags))
.map(_.trim())
.filter(_ != "")
Expand Down Expand Up @@ -236,11 +237,12 @@ object Invoker {
* An Spi for providing invoker implementation.
*/
trait InvokerProvider extends Spi {
def instance(config: WhiskConfig,
instance: InvokerInstanceId,
producer: MessageProducer,
poolConfig: ContainerPoolConfig,
limitsConfig: IntraConcurrencyLimitConfig)(implicit actorSystem: ActorSystem, logging: Logging): InvokerCore
def instance(
config: WhiskConfig,
instance: InvokerInstanceId,
producer: MessageProducer,
poolConfig: ContainerPoolConfig,
limitsConfig: IntraConcurrencyLimitConfig)(implicit actorSystem: ActorSystem, logging: Logging): InvokerCore
}

// this trait can be used to add common implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ class InvokerReactive(
instance: InvokerInstanceId,
producer: MessageProducer,
poolConfig: ContainerPoolConfig = loadConfigOrThrow[ContainerPoolConfig](ConfigKeys.containerPool),
limitsConfig: IntraConcurrencyLimitConfig = loadConfigOrThrow[IntraConcurrencyLimitConfig](ConfigKeys.concurrencyLimit))(
implicit actorSystem: ActorSystem,
logging: Logging)
limitsConfig: IntraConcurrencyLimitConfig = loadConfigOrThrow[IntraConcurrencyLimitConfig](
ConfigKeys.concurrencyLimit))(implicit actorSystem: ActorSystem, logging: Logging)
extends InvokerCore {

implicit val ec: ExecutionContext = actorSystem.dispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class KafkaLauncher(
val t = Try {
createDir("zookeeper")
createDir("kafka")
EmbeddedKafka.startZooKeeper(FileSystems.getDefault.getPath(workDir.getPath,"zookeeper"))
EmbeddedKafka.startKafka(FileSystems.getDefault.getPath(workDir.getPath,"kafka"))
EmbeddedKafka.startZooKeeper(FileSystems.getDefault.getPath(workDir.getPath, "zookeeper"))
EmbeddedKafka.startKafka(FileSystems.getDefault.getPath(workDir.getPath, "kafka"))
}

Future
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,13 +955,7 @@ class ActionsApiTests extends ControllerTestCommon with WhiskActionsApi {
val content = WhiskActionPut(
Some(jsDefault("_")),
Some(Parameters("x", "X")),
Some(
ActionLimitsOption(
None,
None,
None,
None,
Some(InstanceConcurrencyLimit(40)))))
Some(ActionLimitsOption(None, None, None, None, Some(InstanceConcurrencyLimit(40)))))

Put(s"$collectionPath/${aname()}", content) ~> Route.seal(routes(credsWithNamespaceLimits)) ~> check {
status should be(BadRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ import akka.http.scaladsl.model.StatusCodes.{BadRequest, MethodNotAllowed, OK}
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport.sprayJsonUnmarshaller
import akka.http.scaladsl.server.Route
import org.apache.openwhisk.core.controller.WhiskLimitsApi
import org.apache.openwhisk.core.entity.{IntraConcurrencyLimit, EntityPath, LogLimit, MemoryLimit, TimeLimit, UserLimits}
import org.apache.openwhisk.core.entity.{
EntityPath,
IntraConcurrencyLimit,
LogLimit,
MemoryLimit,
TimeLimit,
UserLimits
}
import org.apache.openwhisk.core.entity.size._

import scala.concurrent.duration._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ import org.apache.kafka.common.serialization.StringDeserializer
import org.apache.openwhisk.common.{AkkaLogging, TransactionId}
import org.apache.openwhisk.core.database.{CacheInvalidationMessage, RemoteCacheInvalidation}
import org.apache.openwhisk.core.database.cosmosdb.{CosmosDBArtifactStoreProvider, CosmosDBTestSupport}
import org.apache.openwhisk.core.entity.{DocumentReader, EntityName, EntityPath, WhiskDocumentReader, WhiskEntity, WhiskEntityJsonFormat, WhiskPackage}
import org.apache.openwhisk.core.entity.{
DocumentReader,
EntityName,
EntityPath,
WhiskDocumentReader,
WhiskEntity,
WhiskEntityJsonFormat,
WhiskPackage
}
import org.junit.runner.RunWith
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.junit.JUnitRunner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import org.apache.openwhisk.core.entity.{
ActivationEntityLimit,
ActivationResponse,
ByteSize,
IntraConcurrencyLimit,
Exec,
IntraConcurrencyLimit,
LogLimit,
MemoryLimit,
TimeLimit
Expand Down Expand Up @@ -125,13 +125,13 @@ class ActionLimitsTests extends TestHelpers with WskTestHelpers with WskActorSys
case Some(l) => s"${l} (allowed)"
}
val toConcurrencyString = concurrency match {
case None => "None"
case None => "None"
case Some(IntraConcurrencyLimit.MIN_CONCURRENT) => s"${IntraConcurrencyLimit.MIN_CONCURRENT} (= min)"
case Some(IntraConcurrencyLimit.STD_CONCURRENT) => s"${IntraConcurrencyLimit.STD_CONCURRENT} (= std)"
case Some(IntraConcurrencyLimit.MAX_CONCURRENT) => s"${IntraConcurrencyLimit.MAX_CONCURRENT} (= max)"
case Some(c) if (c < IntraConcurrencyLimit.MIN_CONCURRENT) => s"${c} (< min)"
case Some(c) if (c > IntraConcurrencyLimit.MAX_CONCURRENT) => s"${c} (> max)"
case Some(c) => s"${c} (allowed)"
case Some(c) => s"${c} (allowed)"
}
val toExpectedResultString: String = if (ec == SUCCESS_EXIT) "allow" else "reject"
}
Expand Down

0 comments on commit ba871e5

Please sign in to comment.