This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-27
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-27 by this push:
     new cbcc9b7  WIP.
cbcc9b7 is described below

commit cbcc9b7c43ed2edd632adb120832a8af94ceb543
Author: Sergey Kamov <sergeyka...@apache.org>
AuthorDate: Wed Mar 25 19:59:44 2020 +0300

    WIP.
---
 .../common/nlp/core/NCNlpCoreManager.scala         |  2 +-
 .../common/nlp/dict/NCDictionaryManager.scala      |  4 +--
 .../probe/mgrs/conn/NCConnectionManager.scala      | 40 +++++++++++----------
 .../mgrs/conversation/NCConversationManager.scala  |  3 +-
 .../probe/mgrs/deploy/NCDeployManager.scala        | 15 ++++----
 .../mgrs/dialogflow/NCDialogFlowManager.scala      |  5 +--
 .../probe/mgrs/lifecycle/NCLifecycleManager.scala  | 10 +++---
 .../nlpcraft/probe/mgrs/model/NCModelManager.scala |  4 ++-
 .../probe/mgrs/nlp/NCProbeEnrichmentManager.scala  | 12 ++++---
 .../mgrs/nlp/validate/NCValidateManager.scala      |  2 +-
 .../apache/nlpcraft/server/geo/NCGeoManager.scala  |  4 +--
 .../lifecycle/NCServerLifecycleManager.scala       |  4 +--
 .../lifecycle/opencensus/NCJaegerExporter.scala    |  6 ++--
 .../opencensus/NCPrometheusExporter.scala          |  8 ++---
 .../opencensus/NCStackdriverStatsExporter.scala    |  4 +--
 .../opencensus/NCStackdriverTraceExporter.scala    |  2 +-
 .../lifecycle/opencensus/NCZipkinExporter.scala    |  8 ++---
 .../server/nlp/core/NCNlpServerManager.scala       |  6 ++--
 .../server/nlp/core/spacy/NCSpaCyNerEnricher.scala |  2 +-
 .../nlp/core/stanford/NCStanfordCoreManager.scala  |  2 +-
 .../nlp/enrichers/NCServerEnrichmentManager.scala  |  2 +-
 .../server/nlp/enrichers/date/NCDateEnricher.scala |  2 +-
 .../nlpcraft/server/probe/NCProbeManager.scala     | 41 ++++++++++++++--------
 .../nlpcraft/server/query/NCQueryManager.scala     |  4 ++-
 .../nlpcraft/server/rest/NCRestManager.scala       |  6 ++--
 .../org/apache/nlpcraft/server/sql/NCSql.scala     | 20 +++++------
 .../apache/nlpcraft/server/sql/NCSqlManager.scala  |  2 +-
 .../apache/nlpcraft/server/tx/NCTxManager.scala    |  5 +--
 .../nlpcraft/server/user/NCUserManager.scala       | 10 +++---
 29 files changed, 131 insertions(+), 104 deletions(-)

diff --git 
a/src/main/scala/org/apache/nlpcraft/common/nlp/core/NCNlpCoreManager.scala 
b/src/main/scala/org/apache/nlpcraft/common/nlp/core/NCNlpCoreManager.scala
index 6dedbbd..d8e431c 100644
--- a/src/main/scala/org/apache/nlpcraft/common/nlp/core/NCNlpCoreManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/common/nlp/core/NCNlpCoreManager.scala
@@ -29,7 +29,7 @@ object NCNlpCoreManager extends NCService {
     private final val SUPPORTED_NLP_ENGINES = Seq("opennlp", "stanford")
     
     private object Config extends NCConfigurable {
-        val engine: String = getString("nlpcraft.nlpEngine")
+        def engine: String = getString("nlpcraft.nlpEngine")
     }
     
     @volatile private var tokenizer: NCNlpTokenizer = _
diff --git 
a/src/main/scala/org/apache/nlpcraft/common/nlp/dict/NCDictionaryManager.scala 
b/src/main/scala/org/apache/nlpcraft/common/nlp/dict/NCDictionaryManager.scala
index c5bdcc7..9eafe87 100644
--- 
a/src/main/scala/org/apache/nlpcraft/common/nlp/dict/NCDictionaryManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/common/nlp/dict/NCDictionaryManager.scala
@@ -40,8 +40,8 @@ object NCDictionaryManager extends NCService {
     require(NCDictionaryType.values.forall(dictFiles.contains))
     
     // Summary dictionary for all types.
-    private var full: Set[String] = _
-    private var dicts: Map[NCDictionaryType, Set[String]] = _
+    @volatile private var full: Set[String] = _
+    @volatile private var dicts: Map[NCDictionaryType, Set[String]] = _
     
     override def start(parent: Span): NCService = startScopedSpan("start", 
parent, "dictionaries" → dictFiles.values.mkString(",")) { _ ⇒
         dicts = dictFiles.map(p ⇒ {
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
index b200b87..1094b16 100644
--- 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
@@ -49,30 +49,30 @@ object NCConnectionManager extends NCService {
     private final val PING_TIMEOUT = 5 * 1000
     
     // Internal probe GUID.
-    final val PROBE_GUID = U.genGuid()
+    @volatile private var probeGuid: String = _
     
     // Internal semaphores.
-    private val stopSem: AtomicInteger = new AtomicInteger(1)
+    @volatile private var stopSem: AtomicInteger = _
     
     private final val sysProps: Properties = System.getProperties
     private final val localHost: InetAddress = InetAddress.getLocalHost
-    private var hwAddrs: String = _
+    @volatile private var hwAddrs: String = _
     
     // Holding downlink queue.
-    private val dnLinkQueue = mutable.Queue.empty[Serializable]
+    @volatile private var dnLinkQueue: mutable.Queue[Serializable] = _
     
     // Control thread.
-    private var ctrlThread: Thread = _
-    
+    @volatile private var ctrlThread: Thread = _
+
     private object Config extends NCConfigurable {
         private final val pre = "nlpcraft.probe"
-        
-        val id: String = getString(s"$pre.id")
-        val token: String = getString(s"$pre.token")
-        val upLink: (String, Integer) = getHostPort(s"$pre.upLink")
-        val downLink: (String, Integer) = getHostPort(s"$pre.downLink")
-        val upLinkString = s"${upLink._1}:${upLink._2}"
-        val downLinkString = s"${downLink._1}:${downLink._2}"
+
+        def id: String = getString(s"$pre.id")
+        def token: String = getString(s"$pre.token")
+        def upLink: (String, Integer) = getHostPort(s"$pre.upLink")
+        def downLink: (String, Integer) = getHostPort(s"$pre.downLink")
+        def upLinkString = s"${upLink._1}:${upLink._2}"
+        def downLinkString = s"${downLink._1}:${downLink._2}"
     }
 
     /**
@@ -95,7 +95,7 @@ object NCConnectionManager extends NCService {
             span,
             "probeId" → Config.id,
             "token" → Config.token,
-            "probeGuid" → PROBE_GUID,
+            "probeGuid" → probeGuid,
             "msgType" → msg.getType,
             "msgGuid" → msg.getGuid
         )
@@ -103,7 +103,7 @@ object NCConnectionManager extends NCService {
         // Set probe identification for each message, if necessary.
         msg.setProbeToken(Config.token)
         msg.setProbeId(Config.id)
-        msg.setProbeGuid(PROBE_GUID)
+        msg.setProbeGuid(probeGuid)
     
         dnLinkQueue.synchronized {
             if (!isStopping) {
@@ -141,7 +141,7 @@ object NCConnectionManager extends NCService {
             // Probe identification.
             "PROBE_TOKEN" → Config.token,
             "PROBE_ID" → Config.id,
-            "PROBE_GUID" → PROBE_GUID
+            "PROBE_GUID" → probeGuid
         ), cryptoKey)
     
         val resp = sock.read[NCProbeMessage](cryptoKey) // Get handshake 
response.
@@ -210,7 +210,7 @@ object NCConnectionManager extends NCService {
                     // Probe identification.
                     "PROBE_TOKEN" → Config.token,
                     "PROBE_ID" → Config.id,
-                    "PROBE_GUID" → PROBE_GUID,
+                    "PROBE_GUID" → probeGuid,
         
                     // Handshake data,
                     "PROBE_API_DATE" → ver.date,
@@ -275,6 +275,10 @@ object NCConnectionManager extends NCService {
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
         require(NCCommandManager.isStarted)
         require(NCModelManager.isStarted)
+
+        probeGuid = U.genGuid()
+        dnLinkQueue = mutable.Queue.empty[Serializable]
+        stopSem = new AtomicInteger(1)
         
         val ctrlLatch = new CountDownLatch(1)
      
@@ -364,7 +368,7 @@ object NCConnectionManager extends NCService {
                     
                                             pingMsg.setProbeToken(Config.token)
                                             pingMsg.setProbeId(Config.id)
-                                            pingMsg.setProbeGuid(PROBE_GUID)
+                                            pingMsg.setProbeGuid(probeGuid)
                     
                                             dnSock.write(pingMsg, cryptoKey)
                                         }
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationManager.scala
 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationManager.scala
index 8a857bb..52c1fb8 100644
--- 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationManager.scala
@@ -36,12 +36,13 @@ object NCConversationManager extends NCService {
     private final val CHECK_PERIOD = 5.minutes.toMillis
     private final val TIMEOUT = 1.hour.toMillis
 
-    private final val convs = mutable.HashMap.empty[Key, Value]
+    @volatile private var convs: mutable.Map[Key, Value] = _
 
     @volatile private var gc: ScheduledExecutorService = _
 
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
         gc = Executors.newSingleThreadScheduledExecutor
+        convs = mutable.HashMap.empty[Key, Value]
         
         gc.scheduleWithFixedDelay(() ⇒ clearForTimeout(), CHECK_PERIOD, 
CHECK_PERIOD, TimeUnit.MILLISECONDS)
         
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index e496a92..f6a7e1d 100644
--- a/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@ -18,7 +18,7 @@
 package org.apache.nlpcraft.probe.mgrs.deploy
 
 import java.io._
-import java.util.jar.{JarInputStream ⇒ JIS}
+import java.util.jar.{JarInputStream => JIS}
 
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.common._
@@ -39,12 +39,12 @@ import scala.util.control.Exception._
   * Model deployment manager.
   */
 object NCDeployManager extends NCService with DecorateAsScala {
-    private val models = ArrayBuffer.empty[NCModel]
-    private var modelFactory: NCModelFactory = new NCBasicModelFactory
+    @volatile private var models: ArrayBuffer[NCModel] = _
+    @volatile private var modelFactory: NCModelFactory = _
     
     private final val ID_REGEX = "^[_a-zA-Z]+[a-zA-Z0-9:-_]*$"
-    
-    private object Config extends NCConfigurable {
+
+    object Config extends NCConfigurable {
         private final val pre = "nlpcraft.probe"
 
         // It should reload config.
@@ -53,7 +53,7 @@ object NCDeployManager extends NCService with DecorateAsScala 
{
         def models: Seq[String] = getStringList(s"$pre.models")
         def jarsFolder: Option[String] = getStringOpt(s"$pre.jarsFolder")
     }
-    
+
     /**
       * Gives a list of JAR files at given path.
       * 
@@ -195,6 +195,9 @@ object NCDeployManager extends NCService with 
DecorateAsScala {
     
     @throws[NCE]
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
+        modelFactory = new NCBasicModelFactory
+        models = ArrayBuffer.empty[NCModel]
+
         // Initialize model factory (if configured).
         Config.modelFactoryType match {
             case Some(mft) ⇒
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
index 6b1850d..f04cbbe 100644
--- 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
@@ -33,8 +33,8 @@ import scala.concurrent.duration._
 object NCDialogFlowManager extends NCService {
     case class Key(usrId: Long, mdlId: String)
     case class Value(intent: String, tstamp: Long)
-    
-    private val flow = mutable.HashMap.empty[Key, ArrayBuffer[Value]]
+
+    @volatile private var flow: mutable.Map[Key, ArrayBuffer[Value]] = _
     
     // Check frequency and timeout.
     private final val CHECK_PERIOD = 5.minutes.toMillis
@@ -43,6 +43,7 @@ object NCDialogFlowManager extends NCService {
     @volatile private var gc: ScheduledExecutorService = _
     
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
+        flow = mutable.HashMap.empty[Key, ArrayBuffer[Value]]
         gc = Executors.newSingleThreadScheduledExecutor
     
         gc.scheduleWithFixedDelay(() ⇒ clearForTimeout(), CHECK_PERIOD, 
CHECK_PERIOD, TimeUnit.MILLISECONDS)
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/lifecycle/NCLifecycleManager.scala
 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/lifecycle/NCLifecycleManager.scala
index 54ca1ff..4bbf8a4 100644
--- 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/lifecycle/NCLifecycleManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/lifecycle/NCLifecycleManager.scala
@@ -26,12 +26,12 @@ import org.apache.nlpcraft.model._
   * Lifecycle component manager.
   */
 object NCLifecycleManager extends NCService {
-    private var beans = Seq.empty[NCLifecycle]
-    
-    private object Config extends NCConfigurable {
-        val lifecycle: Seq[String] = getStringList("nlpcraft.probe.lifecycle")
+    @volatile private var beans: Seq[NCLifecycle] = _
+
+    object Config extends NCConfigurable {
+        def lifecycle: Seq[String] = getStringList("nlpcraft.probe.lifecycle")
     }
-    
+
     @throws[NCE]
     override def start(parent: Span = null): NCService = {
         beans = Config.lifecycle.map(U.mkObject(_).asInstanceOf[NCLifecycle])
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala
index dc2e225..a7c470a 100644
--- a/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala
@@ -43,7 +43,7 @@ object NCModelManager extends NCService with DecorateAsScala {
     private final val TOKENS_PROVIDERS_PREFIXES = Set("nlpcraft:", "google:", 
"stanford:", "opennlp:", "spacy:")
     
     // Deployed models keyed by their IDs.
-    private val models = mutable.HashMap.empty[String, NCModelDecorator]
+    @volatile private var models: mutable.Map[String, NCModelDecorator] = _
 
     // Access mutex.
     private final val mux = new Object()
@@ -81,6 +81,8 @@ object NCModelManager extends NCService with DecorateAsScala {
 
     @throws[NCE]
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { span ⇒
+        models = mutable.HashMap.empty[String, NCModelDecorator]
+
         mux.synchronized {
             NCDeployManager.getModels.foreach(addNewModel)
 
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
index 69eb11a..4a7243d 100644
--- 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
@@ -68,22 +68,24 @@ object NCProbeEnrichmentManager extends NCService with 
NCOpenCensusModelStats {
     // Embedded probe Java callback function.
     private type EMBEDDED_CB = java.util.function.Consumer[NCEmbeddedResult]
 
-    private val embeddedCbs = mutable.HashSet.empty[EMBEDDED_CB]
+    @volatile private var embeddedCbs: mutable.Set[EMBEDDED_CB] = _
 
     private object Config extends NCConfigurable {
         final private val pre = "nlpcraft.probe"
 
-        val id: String = getString(s"$pre.id")
-        val resultMaxSize: Int = getInt(s"$pre.resultMaxSizeBytes")
-    
+        def id: String = getString(s"$pre.id")
+        def resultMaxSize: Int = getInt(s"$pre.resultMaxSizeBytes")
+
         def check(): Unit =
             if (resultMaxSize <= 0)
                 abortWith(s"Value of '$pre.resultMaxSizeBytes' must be 
positive")
     }
-    
+
     Config.check()
 
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
+        embeddedCbs = mutable.HashSet.empty[EMBEDDED_CB]
+
         super.start()
     }
     
diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/validate/NCValidateManager.scala
 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/validate/NCValidateManager.scala
index 2d2a68d..76fc21a 100644
--- 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/validate/NCValidateManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/validate/NCValidateManager.scala
@@ -29,7 +29,7 @@ import org.apache.nlpcraft.probe.mgrs.NCModelDecorator
  */
 object NCValidateManager extends NCService with LazyLogging {
     // Create new language finder singleton.
-    private var langFinder: OptimaizeLangDetector = _
+    @volatile private var langFinder: OptimaizeLangDetector = _
     
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
         langFinder = new OptimaizeLangDetector()
diff --git a/src/main/scala/org/apache/nlpcraft/server/geo/NCGeoManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/geo/NCGeoManager.scala
index ba3e75a..1116ec2 100644
--- a/src/main/scala/org/apache/nlpcraft/server/geo/NCGeoManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/geo/NCGeoManager.scala
@@ -37,8 +37,8 @@ object NCGeoManager extends NCService {
     
     // Special file, the data of which are not filtered by common dictionary 
words.
     private final val SYNONYMS_MANUAL_FILES = Seq("manual.json", "states.json")
-    
-    private var model: NCGeoModel = _
+
+    @volatile private var model: NCGeoModel = _
     
     // Auxiliary words for GEO names. Example: CA state, Los Angeles city.
     private final val CITY_AUX = Seq("city", "town", "metropolis")
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/NCServerLifecycleManager.scala
 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/NCServerLifecycleManager.scala
index 24d95b8..3f3b3f1 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/NCServerLifecycleManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/NCServerLifecycleManager.scala
@@ -28,8 +28,8 @@ import org.apache.nlpcraft.common.config.NCConfigurable
 object NCServerLifecycleManager extends NCService {
     private object Config extends NCConfigurable {
         private final val prop = "nlpcraft.server.lifecycle"
-        
-        val classes: Seq[String] = getStringList(prop)
+
+        def classes: Seq[String] = getStringList(prop)
         var objects = Seq.empty[NCServerLifecycle]
     
         /**
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCJaegerExporter.scala
 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCJaegerExporter.scala
index 085b484..5394b0c 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCJaegerExporter.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCJaegerExporter.scala
@@ -26,9 +26,9 @@ import org.apache.nlpcraft.common.config.NCConfigurable
 class NCJaegerExporter extends NCBaseTraceExporter("Jaeger") {
     private object Config extends NCConfigurable {
         private val pre = "nlpcraft.server.opencensus.jaeger"
-        
-        val url = getStringOrElse(s"$pre.thriftUrl", 
"http://127.0.0.1:14268/api/traces";)
-        val svcName = getStringOrElse(s"$pre.serviceName", "nlpcraft-server")
+
+        def url = getStringOrElse(s"$pre.thriftUrl", 
"http://127.0.0.1:14268/api/traces";)
+        def svcName = getStringOrElse(s"$pre.serviceName", "nlpcraft-server")
     }
     
     override def beforeStart(): Unit = {
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCPrometheusExporter.scala
 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCPrometheusExporter.scala
index fbad821..e733ee9 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCPrometheusExporter.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCPrometheusExporter.scala
@@ -30,10 +30,10 @@ class NCPrometheusExporter extends NCServerLifecycle with 
LazyLogging {
     private object Config extends NCConfigurable {
         private val pre = "nlpcraft.server.opencensus.prometheus"
         private val hostPort = getHostPortOrElse(s"$pre.hostPort", 
"localhost", 8888)
-        
-        val namespace = getStringOrElse(s"$pre.namespace", "nlpcraft-server")
-        val host = hostPort._1
-        val port = hostPort._2
+
+        def namespace = getStringOrElse(s"$pre.namespace", "nlpcraft-server")
+        def host = hostPort._1
+        def port = hostPort._2
     }
     
     override def beforeStart(): Unit = {
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverStatsExporter.scala
 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverStatsExporter.scala
index 16fe7b9..4c00a08 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverStatsExporter.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverStatsExporter.scala
@@ -32,8 +32,8 @@ class NCStackdriverStatsExporter extends NCServerLifecycle 
with LazyLogging {
     private val pre = "nlpcraft.server.opencensus.stackdriver"
     
     private object Config extends NCConfigurable {
-        val gpi = getString(s"$pre.googleProjectId")
-        val prefix = getStringOrElse(s"$pre.metricsPrefix", 
"custom.googleapis.com/nlpcraft/server")
+        def gpi = getString(s"$pre.googleProjectId")
+        def prefix = getStringOrElse(s"$pre.metricsPrefix", 
"custom.googleapis.com/nlpcraft/server")
     }
     
     override def beforeStart(): Unit = {
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverTraceExporter.scala
 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverTraceExporter.scala
index d38473e..3e6bf6c 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverTraceExporter.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCStackdriverTraceExporter.scala
@@ -30,7 +30,7 @@ class NCStackdriverTraceExporter extends 
NCBaseTraceExporter("Stackdriver") {
     private val pre = "nlpcraft.server.opencensus.stackdriver"
     
     private object Config extends NCConfigurable {
-        val gpi = getString(s"$pre.googleProjectId")
+        def gpi = getString(s"$pre.googleProjectId")
     }
     
     override def beforeStart(): Unit = {
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCZipkinExporter.scala
 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCZipkinExporter.scala
index 6104b1b..27c59aa 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCZipkinExporter.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/lifecycle/opencensus/NCZipkinExporter.scala
@@ -26,11 +26,11 @@ import org.apache.nlpcraft.common.config.NCConfigurable
 class NCZipkinExporter extends NCBaseTraceExporter("Zipkin") {
     private object Config extends NCConfigurable {
         private val pre = "nlpcraft.server.opencensus.zipkin"
-        
-        val url = getStringOrElse(s"$pre.v2Url", 
"http://127.0.0.1:9411/api/v2/spans";)
-        val svcName = getStringOrElse(s"$pre.serviceName", "nlpcraft-server")
+
+        def url = getStringOrElse(s"$pre.v2Url", 
"http://127.0.0.1:9411/api/v2/spans";)
+        def svcName = getStringOrElse(s"$pre.serviceName", "nlpcraft-server")
     }
-    
+
     override def beforeStart(): Unit = {
         ZipkinTraceExporter.createAndRegister(ZipkinExporterConfiguration.
             builder().
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala
index b2ab86b..aad5d8e 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala
@@ -20,7 +20,7 @@ package org.apache.nlpcraft.server.nlp.core
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.common.config.NCConfigurable
 import org.apache.nlpcraft.common.nlp.core.NCNlpCoreManager
-import org.apache.nlpcraft.common.{NCE, NCService, _}
+import org.apache.nlpcraft.common.{NCService, _}
 
 import scala.collection.Seq
 
@@ -34,8 +34,8 @@ object NCNlpServerManager extends NCService {
     private object Config extends NCConfigurable {
         private final val TOKEN_PROVIDERS = Set("nlpcraft", "google", 
"stanford", "opennlp", "spacy")
         private final val prop = "nlpcraft.server.tokenProviders"
-        
-        val tokenProviders: Seq[String] = getStringList(prop)
+
+        def tokenProviders: Seq[String] = getStringList(prop)
 
         def support(name: String): Boolean = tokenProviders.contains(name)
     
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/nlp/core/spacy/NCSpaCyNerEnricher.scala
 
b/src/main/scala/org/apache/nlpcraft/server/nlp/core/spacy/NCSpaCyNerEnricher.scala
index b01c596..740e095 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/nlp/core/spacy/NCSpaCyNerEnricher.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/nlp/core/spacy/NCSpaCyNerEnricher.scala
@@ -52,7 +52,7 @@ object NCSpaCyNerEnricher extends NCService with 
NCNlpNerEnricher with NCIgniteI
     private implicit val fmt: RootJsonFormat[SpacySpan] = 
jsonFormat7(SpacySpan)
     
     private object Config extends NCConfigurable {
-        val proxyUrl = getStringOrElse("nlpcraft.server.spacy.proxy.url", 
"http://localhost:5002";)
+        def proxyUrl = getStringOrElse("nlpcraft.server.spacy.proxy.url", 
"http://localhost:5002";)
     }
 
     // NOTE: property 'vector' represented as string because Python JSON 
serialization requirements.
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordCoreManager.scala
 
b/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordCoreManager.scala
index 0b8a61a..7dd2581 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordCoreManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordCoreManager.scala
@@ -32,7 +32,7 @@ import scala.util.control.Exception.catching
   * Stanford core manager.
   */
 object NCStanfordCoreManager extends NCService with NCIgniteInstance {
-    private var stanford: StanfordCoreNLP = _
+    @volatile private var stanford: StanfordCoreNLP = _
     @volatile private var cache: IgniteCache[String, CoreDocument] = _
 
     /**
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
 
b/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
index 295a8f2..0fd6bb1 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
@@ -43,7 +43,7 @@ import scala.util.control.Exception.catching
   */
 object NCServerEnrichmentManager extends NCService with NCIgniteInstance {
     private object Config extends NCConfigurable {
-        val supportNlpCraft: Boolean = 
getStringList("nlpcraft.server.tokenProviders").contains("nlpcraft")
+        def supportNlpCraft: Boolean = 
getStringList("nlpcraft.server.tokenProviders").contains("nlpcraft")
     }
 
     private final val CUSTOM_PREFIXES = Set("google:", "opennlp:", 
"stanford:", "spacy:")
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala
 
b/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala
index 5908f1a..55b2805 100644
--- 
a/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala
@@ -38,7 +38,7 @@ import scala.collection.mutable.{LinkedHashMap ⇒ LHM}
   */
 object NCDateEnricher extends NCServerEnricher {
     private object Config extends NCConfigurable {
-        val style: NCDateFormatType = 
getObject("nlpcraft.server.datesFormatStyle", NCDateFormatType.withName)
+        def style: NCDateFormatType = 
getObject("nlpcraft.server.datesFormatStyle", NCDateFormatType.withName)
     }
 
     private type LHM_SS = LHM[String, String]
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
index f50ffb5..28b7407 100644
--- a/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
@@ -54,19 +54,22 @@ object NCProbeManager extends NCService {
     // Type safe and eager configuration container.
     private[probe] object Config extends NCConfigurable {
         final private val pre = "nlpcraft.server.probe"
-        
-        val (dnHost, dnPort) = getHostPort(s"$pre.links.downLink")
-        val (upHost, upPort) = getHostPort(s"$pre.links.upLink")
-        
-        val poolSize: Int = getInt(s"$pre.poolSize")
-        val reconnectTimeoutMs: Long = getLong(s"$pre.reconnectTimeoutMs")
-        val pingTimeoutMs: Long = getLong(s"$pre.pingTimeoutMs")
-        val soTimeoutMs: Int = getInt(s"$pre.soTimeoutMs")
+
+        def getDnHostPort = getHostPort(s"$pre.links.downLink")
+        def getUpHostPort = getHostPort(s"$pre.links.upLink")
+
+        def poolSize: Int = getInt(s"$pre.poolSize")
+        def reconnectTimeoutMs: Long = getLong(s"$pre.reconnectTimeoutMs")
+        def pingTimeoutMs: Long = getLong(s"$pre.pingTimeoutMs")
+        def soTimeoutMs: Int = getInt(s"$pre.soTimeoutMs")
     
         /**
           *
           */
         def check(): Unit = {
+            val (_, dnPort) =  getDnHostPort
+            val (_, upPort) =  getUpHostPort
+
             if (!(dnPort >= 0 && dnPort <= 65535))
                 abortWith(s"Configuration property '$pre.links.upLink' must be 
>= 0 and <= 65535: $dnPort")
             if (!(upPort >= 0 && upPort <= 65535))
@@ -127,10 +130,10 @@ object NCProbeManager extends NCService {
     private var pingSrv: Thread = _
     
     // All known probes keyed by probe key.
-    private val probes = mutable.HashMap.empty[ProbeKey, ProbeHolder]
-    private val mdls = mutable.HashMap.empty[String, NCProbeModelMdo]
+    private var probes: mutable.Map[ProbeKey, ProbeHolder] = _
+    private var mdls: mutable.Map[String, NCProbeModelMdo] = _
     // All probes pending complete handshake keyed by probe key.
-    private val pending = mutable.HashMap.empty[ProbeKey, ProbeHolder]
+    private var pending: mutable.Map[ProbeKey, ProbeHolder] = _
     
     private var pool: ExecutorService = _
     private var isStopping: AtomicBoolean = _
@@ -140,17 +143,25 @@ object NCProbeManager extends NCService {
       * @return
       */
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { span ⇒
+        probes = mutable.HashMap.empty[ProbeKey, ProbeHolder]
+        mdls = mutable.HashMap.empty[String, NCProbeModelMdo]
+        pending = mutable.HashMap.empty[ProbeKey, ProbeHolder]
+
+        val (dnHost, dnPort) = Config.getDnHostPort
+        val (upHost, upPort) =  Config.getUpHostPort
+
+
         addTags(span,
-            "uplink" → s"${Config.upHost}:${Config.upPort}",
-            "downlink" → s"${Config.dnHost}:${Config.dnPort}"
+            "uplink" → s"$upHost:$upPort",
+            "downlink" → s"$dnHost:$dnPort"
         )
     
         isStopping = new AtomicBoolean(false)
         
         pool = Executors.newFixedThreadPool(Config.poolSize)
         
-        dnSrv = startServer("Downlink", Config.dnHost, Config.dnPort, 
downLinkHandler)
-        upSrv = startServer("Uplink", Config.upHost, Config.upPort, 
upLinkHandler)
+        dnSrv = startServer("Downlink", dnHost, dnPort, downLinkHandler)
+        upSrv = startServer("Uplink", upHost, upPort, upLinkHandler)
         
         dnSrv.start()
         upSrv.start()
diff --git 
a/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala
index fa87ec5..298ff8b 100644
--- a/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala
@@ -46,11 +46,13 @@ object NCQueryManager extends NCService with 
NCIgniteInstance with NCOpenCensusS
     @volatile private var cache: IgniteCache[String/*Server request ID*/, 
NCQueryStateMdo] = _
     
     // Promises cannot be used in cache.
-    private val asyncAsks = new ConcurrentHashMap[String/*Server request ID*/, 
Promise[NCQueryStateMdo]]()
+    @volatile private var asyncAsks: ConcurrentHashMap[String, 
Promise[NCQueryStateMdo]] = _
     
     private final val MAX_WORDS = 100
     
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
+        asyncAsks = new ConcurrentHashMap[String/*Server request ID*/, 
Promise[NCQueryStateMdo]]()
+
         catching(wrapIE) {
             cache = ignite.cache[String/*Server request ID*/, 
NCQueryStateMdo]("qry-state-cache")
     
diff --git a/src/main/scala/org/apache/nlpcraft/server/rest/NCRestManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/rest/NCRestManager.scala
index 140fae0..54c9c67 100644
--- a/src/main/scala/org/apache/nlpcraft/server/rest/NCRestManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/rest/NCRestManager.scala
@@ -43,9 +43,9 @@ object NCRestManager extends NCService {
     private final object Config extends NCConfigurable {
         final private val pre = "nlpcraft.server.rest"
 
-        val host: String = getString(s"$pre.host")
-        val port: Int = getInt(s"$pre.port")
-        val apiImpl: String = getString(s"$pre.apiImpl")
+        def host: String = getString(s"$pre.host")
+        def port: Int = getInt(s"$pre.port")
+        def apiImpl: String = getString(s"$pre.apiImpl")
     
         /**
           *
diff --git a/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala 
b/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala
index 4419bac..9b4444b 100644
--- a/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/sql/NCSql.scala
@@ -58,16 +58,16 @@ object NCSql extends LazyLogging {
     // Type safe and eager settings container.
     private object Config extends NCConfigurable {
         final private val pre = "nlpcraft.server.database"
-        
-        val url: String = getString(s"$pre.jdbc.url")
-        val driver: String = getString(s"$pre.jdbc.driver")
-        val username: Option[String] = getStringOpt(s"$pre.jdbc.username")
-        val passwd: Option[String] = getStringOpt(s"$pre.jdbc.password")
-        val maxStmt: Int = getInt(s"$pre.c3p0.maxStatements")
-        val initPoolSize: Int = getInt(s"$pre.c3p0.pool.initSize")
-        val minPoolSize: Int = getInt(s"$pre.c3p0.pool.minSize")
-        val maxPoolSize: Int = getInt(s"$pre.c3p0.pool.maxSize")
-        val acqInc: Int = getInt(s"$pre.c3p0.pool.acquireIncrement")
+
+        def url: String = getString(s"$pre.jdbc.url")
+        def driver: String = getString(s"$pre.jdbc.driver")
+        def username: Option[String] = getStringOpt(s"$pre.jdbc.username")
+        def passwd: Option[String] = getStringOpt(s"$pre.jdbc.password")
+        def maxStmt: Int = getInt(s"$pre.c3p0.maxStatements")
+        def initPoolSize: Int = getInt(s"$pre.c3p0.pool.initSize")
+        def minPoolSize: Int = getInt(s"$pre.c3p0.pool.minSize")
+        def maxPoolSize: Int = getInt(s"$pre.c3p0.pool.maxSize")
+        def acqInc: Int = getInt(s"$pre.c3p0.pool.acquireIncrement")
     
         /**
           *
diff --git a/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala
index c36800a..029da00 100644
--- a/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/sql/NCSqlManager.scala
@@ -46,7 +46,7 @@ object NCSqlManager extends NCService with NCIgniteInstance {
     )
     
     private object Config extends NCConfigurable {
-        val init: Boolean = 
getBoolOpt("nlpcraft.server.database.igniteDbInitialize").getOrElse(false)
+        def init: Boolean = 
getBoolOpt("nlpcraft.server.database.igniteDbInitialize").getOrElse(false)
     }
 
     @volatile private var usersPropsSeq: IgniteAtomicSequence = _
diff --git a/src/main/scala/org/apache/nlpcraft/server/tx/NCTxManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/tx/NCTxManager.scala
index cc72b90..c368717 100644
--- a/src/main/scala/org/apache/nlpcraft/server/tx/NCTxManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/tx/NCTxManager.scala
@@ -37,8 +37,8 @@ import scala.util.control.Exception.catching
 object NCTxManager extends NCService with NCIgniteInstance {
     // Internal log switch.
     private final val LOG_TX = false
-    
-    private val cons = mutable.HashMap.empty[IgniteUuid, Connection]
+
+    @volatile private var cons: mutable.Map[IgniteUuid, Connection] = _
     
     /**
       * 
@@ -61,6 +61,7 @@ object NCTxManager extends NCService with NCIgniteInstance {
       * Starts this component.
       */
     override def start(parent: Span = null): NCService = 
startScopedSpan("start", parent) { _ ⇒
+        cons = mutable.HashMap.empty[IgniteUuid, Connection]
         itx = ignite.transactions()
 
         super.start()
diff --git a/src/main/scala/org/apache/nlpcraft/server/user/NCUserManager.scala 
b/src/main/scala/org/apache/nlpcraft/server/user/NCUserManager.scala
index 2af49db..1f9da3a 100644
--- a/src/main/scala/org/apache/nlpcraft/server/user/NCUserManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/server/user/NCUserManager.scala
@@ -63,12 +63,12 @@ object NCUserManager extends NCService with 
NCIgniteInstance {
     private object Config extends NCConfigurable {
         final private val pre = "nlpcraft.server.user"
 
-        val pwdPoolBlowup: Int = getInt(s"$pre.pwdPoolBlowup")
-        val timeoutScannerFreqMins: Int = 
getInt(s"$pre.timeoutScannerFreqMins")
-        val accessTokenExpireTimeoutMins: Int = 
getInt(s"$pre.accessTokenExpireTimeoutMins")
+        def pwdPoolBlowup: Int = getInt(s"$pre.pwdPoolBlowup")
+        def timeoutScannerFreqMins: Int = 
getInt(s"$pre.timeoutScannerFreqMins")
+        def accessTokenExpireTimeoutMins: Int = 
getInt(s"$pre.accessTokenExpireTimeoutMins")
 
-        lazy val scannerMs: Int = timeoutScannerFreqMins * 60 * 1000
-        lazy val expireMs: Int = accessTokenExpireTimeoutMins * 60 * 1000
+        def scannerMs: Int = timeoutScannerFreqMins * 60 * 1000
+        def expireMs: Int = accessTokenExpireTimeoutMins * 60 * 1000
 
         /**
           *

Reply via email to