From e7f0239c3f1cd7b24c5b4518f4779d7b43bd1fb7 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Wed, 29 Jan 2014 15:33:33 -0500 Subject: [PATCH] Added some concurency properties to prevent the build failing on a meager build server. --- src/main/resources/default.properties | 4 ++++ src/main/scala/com/sothr/imagetools/ConcurrentEngine.scala | 3 ++- src/main/scala/com/sothr/imagetools/util/PropertiesEnum.scala | 3 +++ src/test/resources/default.properties | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/resources/default.properties b/src/main/resources/default.properties index 148f5b2..975c5cb 100644 --- a/src/main/resources/default.properties +++ b/src/main/resources/default.properties @@ -8,6 +8,10 @@ app.log.debug=false app.log.info=false app.log.error=true +#Concurrency Settings +app.engine.concurrent.similarity.limit=20 +app.engine.concurrent.processing.limit=10 + #Default Image Settings #images must be 90% similar image.differenceThreshold=0.90 diff --git a/src/main/scala/com/sothr/imagetools/ConcurrentEngine.scala b/src/main/scala/com/sothr/imagetools/ConcurrentEngine.scala index 5263ca5..71ba775 100644 --- a/src/main/scala/com/sothr/imagetools/ConcurrentEngine.scala +++ b/src/main/scala/com/sothr/imagetools/ConcurrentEngine.scala @@ -9,6 +9,7 @@ import akka.util.Timeout import java.util.concurrent.TimeUnit import scala.collection.mutable.{MutableList, HashSet} import com.sothr.imagetools.image.{SimilarImages, ImageFilter, Image} +import com.sothr.imagetools.util.{PropertiesEnum, PropertiesService} import scala.concurrent.{Await, blocking, Future} import java.lang.Thread import scala.concurrent.ExecutionContext.Implicits.global @@ -114,7 +115,7 @@ class ConcurrentEngine extends Engine with grizzled.slf4j.Logging { class ConcurrentEngineController extends Actor with ActorLogging { val imageCache = AppConfig.cacheManager.getCache("images") - val numOfRouters = 10 + val numOfRouters = PropertiesService.get(PropertiesEnum.ConcurrentProcessingLimit.toString).toInt val router = context.actorOf(Props[ConcurrentEngineActor].withRouter(SmallestMailboxRouter(nrOfInstances = numOfRouters))) var images:MutableList[Image] = new MutableList[Image]() diff --git a/src/main/scala/com/sothr/imagetools/util/PropertiesEnum.scala b/src/main/scala/com/sothr/imagetools/util/PropertiesEnum.scala index 47e9b48..0ccb433 100644 --- a/src/main/scala/com/sothr/imagetools/util/PropertiesEnum.scala +++ b/src/main/scala/com/sothr/imagetools/util/PropertiesEnum.scala @@ -8,6 +8,9 @@ object PropertiesEnum extends Enumeration { val LogInfo = Value("app.log.info") val LogError = Value("app.log.error") val Timed = Value("app.timed") + //default engine concurrency settings + val ConcurrentSimiliartyLimit = Value("app.engine.concurrent.similarity.limit") + val ConcurrentProcessingLimit = Value("app.engine.concurrent.processing.limit") //default image settings val ImageDifferenceThreshold = Value("image.differenceThreshold") val HashPrecision = Value("image.hash.precision") diff --git a/src/test/resources/default.properties b/src/test/resources/default.properties index c1f03b9..ea08b83 100644 --- a/src/test/resources/default.properties +++ b/src/test/resources/default.properties @@ -8,6 +8,10 @@ app.log.debug=true app.log.info=true app.log.error=true +#Concurrency Settings +app.engine.concurrent.similarity.limit=2 +app.engine.concurrent.processing.limit=2 + #Default Image Settings #images must be 90% similar image.differenceThreshold=0.90