This is an automated email from the ASF dual-hosted git repository. sergeykamov pushed a commit to branch NLPCRAFT-111 in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit 20973990617c29d7d60c59f8d0c0a2b741e16277 Author: Sergey Kamov <[email protected]> AuthorDate: Tue Jan 26 12:37:42 2021 +0300 WIP. --- .../org/apache/nlpcraft/common/pool/NCThreadPoolManager.scala | 3 +-- .../apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala | 7 +++++-- .../scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala | 6 +++++- .../scala/org/apache/nlpcraft/server/query/NCQueryManager.scala | 7 +++++-- .../scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala | 7 +++++-- .../scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala | 5 ++--- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/pool/NCThreadPoolManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/pool/NCThreadPoolManager.scala index f3df18f..5a931d3 100644 --- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/pool/NCThreadPoolManager.scala +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/pool/NCThreadPoolManager.scala @@ -82,8 +82,7 @@ object NCThreadPoolManager extends NCService { } else Holder(getSystemContext, None) - ) - .context + ).context override def start(parent: Span): NCService = startScopedSpan("start", parent) { _ ⇒ ackStarting() diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala index a0824c1..e304822 100644 --- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala @@ -60,8 +60,6 @@ object NCProbeEnrichmentManager extends NCService with NCOpenCensusModelStats { // Embedded probe Java callback function. private type EMBEDDED_CB = java.util.function.Consumer[NCEmbeddedResult] - private implicit final val ec: ExecutionContext = NCThreadPoolManager.getContext("model.solver.pool") - private final val MAX_NESTED_TOKENS = 32 private final val mux = new Object() @@ -197,6 +195,11 @@ object NCProbeEnrichmentManager extends NCService with NCOpenCensusModelStats { } /** + * @return + */ + private implicit def getContext: ExecutionContext = NCThreadPoolManager.getContext("model.solver.pool") + + /** * Processes 'ask' request from probe server. * * @param srvReqId Server request ID. diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala index d5b10d3..1aae268 100644 --- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala @@ -54,7 +54,6 @@ import scala.util.{Failure, Success} object NCProbeManager extends NCService { private final val GSON = new Gson() private final val TYPE_MODEL_INFO_RESP = new TypeToken[util.HashMap[String, AnyRef]]() {}.getType - private implicit final val ec: ExecutionContext = NCThreadPoolManager.getContext("probes.communication") // Type safe and eager configuration container. private object Config extends NCConfigurable { @@ -222,6 +221,11 @@ object NCProbeManager extends NCService { } /** + * @return + */ + private implicit def getContext: ExecutionContext = NCThreadPoolManager.getContext("probes.communication") + + /** * * @param tokHash */ diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala index aff0c4b..ff0b2ce 100644 --- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala @@ -44,8 +44,6 @@ import scala.util.{Failure, Success} * Query state machine. */ object NCQueryManager extends NCService with NCIgniteInstance with NCOpenCensusServerStats { - private implicit final val ec: ExecutionContext = NCThreadPoolManager.getContext("probe.requests") - private final val MAX_WORDS = 100 @volatile private var cache: IgniteCache[String/*Server request ID*/, NCQueryStateMdo] = _ @@ -187,6 +185,11 @@ object NCQueryManager extends NCService with NCIgniteInstance with NCOpenCensusS srvReqId } } + + /** + * @return + */ + private implicit def getContext: ExecutionContext = NCThreadPoolManager.getContext("probe.requests") /** * @param srvReqId Server request ID. diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala index 6f6b146..40d3f3d 100644 --- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala @@ -54,8 +54,6 @@ class NCBasicRestApi extends NCRestApi with LazyLogging with NCOpenCensusTrace w protected final val GSON = new Gson() protected final val URL_VALIDATOR = new UrlValidator(Array("http", "https"), UrlValidator.ALLOW_LOCAL_URLS) - private implicit final val ec: ExecutionContext = NCThreadPoolManager.getContext("probes.communication") - final val API_VER = 1 final val API = "api" / s"v$API_VER" @@ -1879,6 +1877,11 @@ class NCBasicRestApi extends NCRestApi with LazyLogging with NCOpenCensusTrace w } /** + * @return + */ + private implicit def getContext: ExecutionContext = NCThreadPoolManager.getContext("probes.communication") + + /** * * @return */ diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala index 10cd3e8..5505d3c 100644 --- a/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala +++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala @@ -17,8 +17,6 @@ package org.apache.nlpcraft.examples.sql -import java.util - import com.github.difflib.text.DiffRowGenerator import com.github.vertical_blank.sqlformatter.SqlFormatter import com.google.gson.Gson @@ -26,8 +24,9 @@ import com.google.gson.reflect.TypeToken import org.apache.nlpcraft.common.ascii.NCAsciiTable import org.apache.nlpcraft.examples.sql.db.SqlServer import org.apache.nlpcraft.{NCTestContext, NCTestEnvironment} -import org.junit.jupiter.api.{AfterEach, BeforeEach, Test} +import org.junit.jupiter.api.Test +import java.util import scala.collection.JavaConverters._ import scala.compat.java8.OptionConverters.RichOptionalGeneric
