296 lines
11 KiB
Java
Raw Normal View History

2021-02-01 14:31:20 +09:00
/*
* ******************************************************************************
* *
* *
* * This program and the accompanying materials are made available under the
* * terms of the Apache License, Version 2.0 which is available at
* * https://www.apache.org/licenses/LICENSE-2.0.
* *
2021-02-01 17:47:29 +09:00
* * See the NOTICE file distributed with this work for additional
* * information regarding copyright ownership.
2021-02-01 14:31:20 +09:00
* * 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.
* *
* * SPDX-License-Identifier: Apache-2.0
* *****************************************************************************
*/
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
package org.deeplearning4j.ui;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import lombok.extern.slf4j.Slf4j;
import org.deeplearning4j.BaseDL4JTest;
Refactor packages to fix split package issues (#411) * Refactor nd4j-common: org.nd4j.* -> org.nd4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * Fix CUDA (missed nd4j-common package refactoring changes) Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-kryo: org.nd4j -> org.nd4j.kryo Signed-off-by: Alex Black <blacka101@gmail.com> * Fix nd4j-common for deeplearning4j-cuda Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-grppc-client: org.nd4j.graph -> org.nd4j.remote.grpc Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-common: org.deeplearning4.* -> org.deeplearning4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-core: org.deeplearning4j.* -> org.deeplearning.core.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-cuda: org.deeplearning4j.nn.layers.* -> org.deeplearning4j.cuda.* Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-nlp-*: org.deeplearning4.text.* -> org.deeplearning4j.nlp.(language).* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-ui-model: org.deeplearning4j.ui -> org.deeplearning4j.ui.model Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-spark-inference-{server/model/client}: org.datavec.spark.transform -> org.datavec.spark.inference.{server/model/client} Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-jdbc: org.datavec.api -> org.datavec.jdbc Signed-off-by: Alex Black <blacka101@gmail.com> * Delete org.deeplearning4j.datasets.iterator.impl.MultiDataSetIteratorAdapter in favor of (essentially identical) org.nd4j.linalg.dataset.adapter.MultiDataSetIteratorAdapter Signed-off-by: Alex Black <blacka101@gmail.com> * ND4S fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-common-tests: org.nd4j.* -> org.nd4j.common.tests Signed-off-by: Alex Black <blacka101@gmail.com> * Trigger CI Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * #8878 Ignore CUDA tests on modules with 'nd4j-native under cuda' issue Signed-off-by: Alex Black <blacka101@gmail.com> * Fix bad imports in tests Signed-off-by: Alex Black <blacka101@gmail.com> * Add ignore on test (already failing) due to #8882 Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Additional import fixes Signed-off-by: Alex Black <blacka101@gmail.com>
2020-04-29 11:19:26 +10:00
import org.deeplearning4j.core.storage.StatsStorage;
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.layers.DenseLayer;
import org.deeplearning4j.nn.conf.layers.OutputLayer;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.nn.weights.WeightInit;
import org.deeplearning4j.optimize.listeners.ScoreIterationListener;
import org.deeplearning4j.ui.api.UIServer;
Refactor packages to fix split package issues (#411) * Refactor nd4j-common: org.nd4j.* -> org.nd4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * Fix CUDA (missed nd4j-common package refactoring changes) Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-kryo: org.nd4j -> org.nd4j.kryo Signed-off-by: Alex Black <blacka101@gmail.com> * Fix nd4j-common for deeplearning4j-cuda Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-grppc-client: org.nd4j.graph -> org.nd4j.remote.grpc Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-common: org.deeplearning4.* -> org.deeplearning4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-core: org.deeplearning4j.* -> org.deeplearning.core.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-cuda: org.deeplearning4j.nn.layers.* -> org.deeplearning4j.cuda.* Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-nlp-*: org.deeplearning4.text.* -> org.deeplearning4j.nlp.(language).* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-ui-model: org.deeplearning4j.ui -> org.deeplearning4j.ui.model Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-spark-inference-{server/model/client}: org.datavec.spark.transform -> org.datavec.spark.inference.{server/model/client} Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-jdbc: org.datavec.api -> org.datavec.jdbc Signed-off-by: Alex Black <blacka101@gmail.com> * Delete org.deeplearning4j.datasets.iterator.impl.MultiDataSetIteratorAdapter in favor of (essentially identical) org.nd4j.linalg.dataset.adapter.MultiDataSetIteratorAdapter Signed-off-by: Alex Black <blacka101@gmail.com> * ND4S fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-common-tests: org.nd4j.* -> org.nd4j.common.tests Signed-off-by: Alex Black <blacka101@gmail.com> * Trigger CI Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * #8878 Ignore CUDA tests on modules with 'nd4j-native under cuda' issue Signed-off-by: Alex Black <blacka101@gmail.com> * Fix bad imports in tests Signed-off-by: Alex Black <blacka101@gmail.com> * Add ignore on test (already failing) due to #8882 Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Additional import fixes Signed-off-by: Alex Black <blacka101@gmail.com>
2020-04-29 11:19:26 +10:00
import org.deeplearning4j.ui.model.stats.StatsListener;
import org.deeplearning4j.ui.model.storage.InMemoryStatsStorage;
import org.junit.jupiter.api.AfterAll;
2021-03-16 11:57:24 +09:00
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
import org.nd4j.linalg.activations.Activation;
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
Refactor packages to fix split package issues (#411) * Refactor nd4j-common: org.nd4j.* -> org.nd4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * Fix CUDA (missed nd4j-common package refactoring changes) Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-kryo: org.nd4j -> org.nd4j.kryo Signed-off-by: Alex Black <blacka101@gmail.com> * Fix nd4j-common for deeplearning4j-cuda Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-grppc-client: org.nd4j.graph -> org.nd4j.remote.grpc Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-common: org.deeplearning4.* -> org.deeplearning4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-core: org.deeplearning4j.* -> org.deeplearning.core.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-cuda: org.deeplearning4j.nn.layers.* -> org.deeplearning4j.cuda.* Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-nlp-*: org.deeplearning4.text.* -> org.deeplearning4j.nlp.(language).* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-ui-model: org.deeplearning4j.ui -> org.deeplearning4j.ui.model Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-spark-inference-{server/model/client}: org.datavec.spark.transform -> org.datavec.spark.inference.{server/model/client} Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-jdbc: org.datavec.api -> org.datavec.jdbc Signed-off-by: Alex Black <blacka101@gmail.com> * Delete org.deeplearning4j.datasets.iterator.impl.MultiDataSetIteratorAdapter in favor of (essentially identical) org.nd4j.linalg.dataset.adapter.MultiDataSetIteratorAdapter Signed-off-by: Alex Black <blacka101@gmail.com> * ND4S fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-common-tests: org.nd4j.* -> org.nd4j.common.tests Signed-off-by: Alex Black <blacka101@gmail.com> * Trigger CI Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * #8878 Ignore CUDA tests on modules with 'nd4j-native under cuda' issue Signed-off-by: Alex Black <blacka101@gmail.com> * Fix bad imports in tests Signed-off-by: Alex Black <blacka101@gmail.com> * Add ignore on test (already failing) due to #8882 Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Additional import fixes Signed-off-by: Alex Black <blacka101@gmail.com>
2020-04-29 11:19:26 +10:00
import org.nd4j.common.function.Function;
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
import org.nd4j.linalg.learning.config.Sgd;
import org.nd4j.linalg.lossfunctions.LossFunctions;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.concurrent.CountDownLatch;
2021-03-16 11:57:24 +09:00
import static org.junit.jupiter.api.Assertions.*;
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
@Slf4j
//@Ignore
@Timeout(600)
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public class TestVertxUIManual extends BaseDL4JTest {
@AfterAll
public void shutdownServer() throws InterruptedException {
UIServer.getInstance().stop();
}
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
@Test
//@Ignore
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUI() throws Exception {
VertxUIServer uiServer = (VertxUIServer) UIServer.getInstance();
assertEquals(9000, uiServer.getPort());
Thread.sleep(3000_000);
uiServer.stop();
}
@Test
//@Ignore
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUISequentialSessions() throws Exception {
UIServer uiServer = UIServer.getInstance();
StatsStorage ss = null;
for (int session = 0; session < 3; session++) {
if (ss != null) {
uiServer.detach(ss);
}
ss = new InMemoryStatsStorage();
uiServer.attach(ss);
int numInputs = 4;
int outputNum = 3;
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.activation(Activation.TANH)
.weightInit(WeightInit.XAVIER)
.updater(new Sgd(0.03))
.l2(1e-4)
.list()
.layer(0, new DenseLayer.Builder().nIn(numInputs).nOut(3)
.build())
.layer(1, new DenseLayer.Builder().nIn(3).nOut(3)
.build())
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
.activation(Activation.SOFTMAX)
.nIn(3).nOut(outputNum).build())
.build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
net.setListeners(new StatsListener(ss), new ScoreIterationListener(1));
DataSetIterator iter = new IrisDataSetIterator(150, 150);
for (int i = 0; i < 100; i++) {
net.fit(iter);
}
Thread.sleep(5_000);
}
}
@Test
//@Ignore
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUIServerStop() throws Exception {
UIServer uiServer = UIServer.getInstance(true, null);
assertTrue(uiServer.isMultiSession());
assertFalse(uiServer.isStopped());
long sleepMilliseconds = 30_000;
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer.stop();
assertTrue(uiServer.isStopped());
log.info("UI server is stopped. Waiting {} ms before starting new UI server.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer = UIServer.getInstance(false, null);
assertFalse(uiServer.isMultiSession());
assertFalse(uiServer.isStopped());
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer.stop();
assertTrue(uiServer.isStopped());
}
@Test
//@Ignore
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUIServerStopAsync() throws Exception {
UIServer uiServer = UIServer.getInstance(true, null);
assertTrue(uiServer.isMultiSession());
assertFalse(uiServer.isStopped());
long sleepMilliseconds = 30_000;
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
CountDownLatch latch = new CountDownLatch(1);
Promise<Void> promise = Promise.promise();
promise.future().compose(
success -> Future.future(prom -> latch.countDown()),
failure -> Future.future(prom -> latch.countDown())
);
uiServer.stopAsync(promise);
latch.await();
assertTrue(uiServer.isStopped());
log.info("UI server is stopped. Waiting {} ms before starting new UI server.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer = UIServer.getInstance(false, null);
assertFalse(uiServer.isMultiSession());
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer.stop();
}
@Test
//@Ignore
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUIAutoAttachDetach() throws Exception {
long detachTimeoutMillis = 15_000;
AutoDetachingStatsStorageProvider statsProvider = new AutoDetachingStatsStorageProvider(detachTimeoutMillis);
UIServer uIServer = UIServer.getInstance(true, statsProvider);
statsProvider.setUIServer(uIServer);
InMemoryStatsStorage ss = null;
for (int session = 0; session < 3; session++) {
int layerSize = session + 4;
ss = new InMemoryStatsStorage();
String sessionId = Integer.toString(session);
statsProvider.put(sessionId, ss);
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
.layer(0, new DenseLayer.Builder().activation(Activation.TANH).nIn(4).nOut(layerSize).build())
.layer(1, new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MCXENT)
.activation(Activation.SOFTMAX).nIn(layerSize).nOut(3).build())
.build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
StatsListener statsListener = new StatsListener(ss, 1);
statsListener.setSessionID(sessionId);
net.setListeners(statsListener, new ScoreIterationListener(1));
uIServer.attach(ss);
DataSetIterator iter = new IrisDataSetIterator(150, 150);
for (int i = 0; i < 20; i++) {
net.fit(iter);
}
assertTrue(uIServer.isAttached(ss));
uIServer.detach(ss);
assertFalse(uIServer.isAttached(ss));
/*
* Visiting /train/:sessionId to auto-attach StatsStorage
*/
String sessionUrl = trainingSessionUrl(uIServer.getAddress(), sessionId);
HttpURLConnection conn = (HttpURLConnection) new URL(sessionUrl).openConnection();
conn.connect();
assertEquals(HttpResponseStatus.OK.code(), conn.getResponseCode());
assertTrue(uIServer.isAttached(ss));
}
Thread.sleep(detachTimeoutMillis + 60_000);
assertFalse(uIServer.isAttached(ss));
}
/**
* Get URL-encoded URL for training session on given server address
* @param serverAddress server address
* @param sessionId session ID
* @return URL
* @throws UnsupportedEncodingException if the used encoding is not supported
*/
private static String trainingSessionUrl(String serverAddress, String sessionId)
throws UnsupportedEncodingException {
return String.format("%s/train/%s", serverAddress, URLEncoder.encode(sessionId, "UTF-8"));
}
/**
* StatsStorage provider with automatic detaching of StatsStorage after a timeout
* @author Tamas Fenyvesi
*/
private static class AutoDetachingStatsStorageProvider implements Function<String, StatsStorage> {
HashMap<String, InMemoryStatsStorage> storageForSession = new HashMap<>();
UIServer uIServer;
long autoDetachTimeoutMillis;
public AutoDetachingStatsStorageProvider(long autoDetachTimeoutMillis) {
this.autoDetachTimeoutMillis = autoDetachTimeoutMillis;
}
public void put(String sessionId, InMemoryStatsStorage statsStorage) {
storageForSession.put(sessionId, statsStorage);
}
public void setUIServer(UIServer uIServer) {
this.uIServer = uIServer;
}
@Override
public StatsStorage apply(String sessionId) {
StatsStorage statsStorage = storageForSession.get(sessionId);
if (statsStorage != null) {
new Thread(() -> {
try {
log.info("Waiting to detach StatsStorage (session ID: {})" +
" after {} ms ", sessionId, autoDetachTimeoutMillis);
Thread.sleep(autoDetachTimeoutMillis);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
log.info("Auto-detaching StatsStorage (session ID: {}) after {} ms.",
sessionId, autoDetachTimeoutMillis);
uIServer.detach(statsStorage);
log.info(" To re-attach StatsStorage of training session, visit {}/train/{}",
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
uIServer.getAddress(), sessionId);
}
}).start();
}
return statsStorage;
}
}
}