/** * @return <code>true</code> if the request is still valid after polling and response should be sent back to the UI. * <code>false</code> when the polling was interrupted and the processing should be stopped immediately. */ protected boolean handlePollRequest(IUiSession uiSession, JsonRequest jsonRequest) { int curIdle = (int) ((System.currentTimeMillis() - uiSession.getLastAccessedTime()) / 1000L); int maxIdle = m_maxUserIdleTime; // Default don't wait longer than the container timeout for security reasons. However, the minimum is _not_ 0, // because that might trigger many very short polling calls until the ui session is really disposed. int pollWait = Math.max(Math.min(maxIdle - curIdle, m_pollingInterval), 3); LOG.debug("Polling begin for {} seconds", pollWait); // Blocks the current thread until: // - a model job terminates // - the max. wait time has exceeded final long startNanos = System.nanoTime(); try { uiSession.waitForBackgroundJobs(jsonRequest, pollWait); } catch (InterruptedException e) { if (LOG.isDebugEnabled()) { LOG.debug("Polling INTERRUPTED after {} ms (ignoring response)", StringUtility.formatNanos(System.nanoTime() - startNanos)); } return false; } if (LOG.isDebugEnabled()) { LOG.debug("Polling end after {} ms", StringUtility.formatNanos(System.nanoTime() - startNanos)); } return true; }
protected IUiSession createUiSession(HttpServletRequest req, HttpServletResponse resp, JsonStartupRequest jsonStartupReq) { HttpSession httpSession = req.getSession(); ISessionStore sessionStore = m_httpSessionHelper.getSessionStore(httpSession); final long startNanos = System.nanoTime(); if (LOG.isDebugEnabled()) { LOG.debug("JSON request started"); } LOG.debug("Creating new UI session...."); IUiSession uiSession = BEANS.get(IUiSession.class); uiSession.init(req, resp, jsonStartupReq); sessionStore.registerUiSession(uiSession); LOG.info("Created new UI session with ID {} in {} ms [maxIdleTime={}s, httpSession.maxInactiveInterval={}s]", uiSession.getUiSessionId(), StringUtility.formatNanos(System.nanoTime() - startNanos), m_maxUserIdleTime, req.getSession().getMaxInactiveInterval()); return uiSession; }
LOG.debug("Request completed in {} ms", StringUtility.formatNanos(System.nanoTime() - start));
/** * Pre-builds the HTML files and the referenced scripts (JS, CSS) in the HTML document. Each document is put into the * HTTP resource cache, so we don't have to build them again later. However, we have to make a few assumptions here. * Since we have no HTTP request or session at this point, we assume: * <ul> * <li>the default locale</li> * <li>the default theme</li> * <li>minifying is enabled</li> * <li>caching is enabled</li> * </ul> */ protected void buildResources() { long t0 = System.nanoTime(); List<String> files = CONFIG.getPropertyValue(UiPrebuildFilesProperty.class); IHttpResourceCache httpResourceCache = BEANS.get(GlobalHttpResourceCache.class); for (String file : files) { LOG.info("Pre-building resource '{}'...", file); try { HttpCacheObject cacheObject = loadResource(file); httpResourceCache.put(cacheObject); } catch (IOException e) { LOG.error("Failed to load resource", e); } } LOG.info("Finished pre-building of {} web resources in {} ms", files.size(), StringUtility.formatNanos(System.nanoTime() - t0)); }
LOG.debug("File upload completed in {} ms", StringUtility.formatNanos(System.nanoTime() - startNanos));
LOG.debug("JSON request completed in {} ms", StringUtility.formatNanos(System.nanoTime() - startNanos));