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

ofuks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0106748  [DLAB-2032] Turn off autocomplete if receiving available lib 
list fails
0106748 is described below

commit 010674823568f239d2402ac741ebdbee62c1fcf2
Author: Oleh Fuks <olegfuk...@gmail.com>
AuthorDate: Tue Sep 8 14:58:37 2020 +0300

    [DLAB-2032] Turn off autocomplete if receiving available lib list fails
---
 .../epam/dlab/backendapi/domain/ExploratoryLibCache.java  | 12 +++++++-----
 .../epam/dlab/backendapi/domain/ExploratoryLibList.java   | 15 +++++++++++++--
 .../backendapi/resources/callback/LibraryCallback.java    |  4 ++--
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibCache.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibCache.java
index 3c768ad..a33756f 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibCache.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibCache.java
@@ -137,6 +137,7 @@ public class ExploratoryLibCache implements Managed, 
Runnable {
                        libs = cache.get(cacheKey);
                        if (libs.isUpdateNeeded() && !libs.isUpdating()) {
                                libs.setUpdating();
+                               libs.setExpiredTime();
                                requestLibList(userInfo, userInstance, 
cacheKey);
                        }
                }
@@ -158,13 +159,14 @@ public class ExploratoryLibCache implements Managed, 
Runnable {
        }
 
        /**
-        * Remove the list of libraries for docker image from cache.
+        * Set updating library list to false
         *
-        * @param imageName docker image name
+        * @param groupName group name
         */
-       public void removeLibList(String imageName) {
+       public void updateLibListStatus(String groupName) {
                synchronized (cache) {
-                       cache.remove(imageName);
+                       ExploratoryLibList exploratoryLibList = 
cache.get(groupName);
+                       exploratoryLibList.setNotUpdating();
                }
        }
 
@@ -178,7 +180,7 @@ public class ExploratoryLibCache implements Managed, 
Runnable {
        private void requestLibList(UserInfo userInfo, UserInstanceDTO 
userInstance, String group) {
                try {
 
-                       LOGGER.debug("Ask docker for the list of libraries for 
user {} and exploratory {} computational {}",
+                       LOGGER.info("Ask docker for the list of libraries for 
user {} and exploratory {} computational {}",
                                        userInfo.getName(), 
userInstance.getExploratoryId(),
                                        userInstance.getResources());
 
diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibList.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibList.java
index b5a8d95..f264c78 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibList.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/domain/ExploratoryLibList.java
@@ -145,8 +145,7 @@ public class ExploratoryLibList {
                                        log.info("Update {} group with lib 
group {} with {} libraries", this.group, groupName, (group != null) ? 
group.size() : null);
                                        libs.put(groupName, new 
TreeMap<>(group));
                                }
-                               expiredTimeMillis = System.currentTimeMillis() 
+ EXPIRED_TIMEOUT_MILLIS;
-                               accessTimeMillis = System.currentTimeMillis();
+                               setExpiredTime();
                                updating = false;
                        }
                } catch (IOException e) {
@@ -154,6 +153,11 @@ public class ExploratoryLibList {
                }
        }
 
+       public void setExpiredTime() {
+               expiredTimeMillis = System.currentTimeMillis() + 
EXPIRED_TIMEOUT_MILLIS;
+               accessTimeMillis = System.currentTimeMillis();
+       }
+
        /**
         * Search and return the list of libraries for name's prefix 
<b>startWith</b>.
         *
@@ -214,6 +218,13 @@ public class ExploratoryLibList {
        }
 
        /**
+        * Set updating to false.
+        */
+       public void setNotUpdating() {
+               updating = Boolean.FALSE;
+       }
+
+       /**
         * Return <b>true</b> if the update in progress.
         */
        public boolean isUpdating() {
diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/callback/LibraryCallback.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/callback/LibraryCallback.java
index 53684e6..63af14b 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/callback/LibraryCallback.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/callback/LibraryCallback.java
@@ -85,8 +85,8 @@ public class LibraryCallback {
                requestId.checkAndRemove(dto.getRequestId());
                try {
                        if (UserInstanceStatus.FAILED == 
UserInstanceStatus.of(dto.getStatus())) {
-                               log.warn("Request for the list of libraries 
fails: {}", dto.getErrorMessage());
-                               
ExploratoryLibCache.getCache().removeLibList(dto.getGroup());
+                               log.warn("Request for the list of libraries for 
{} fails: {}", dto.getGroup(), dto.getErrorMessage());
+                               
ExploratoryLibCache.getCache().updateLibListStatus(dto.getGroup());
                        } else {
                                
ExploratoryLibCache.getCache().updateLibList(dto.getGroup(), dto.getLibs());
                        }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to