private synchronized void setServletRequestsAllowed(final boolean value, PersistType persistType) throws OseeCoreException { OseeServerInfoMutable info = getApplicationServerInfo(); info.setAcceptingRequests(value); if (PersistType.ALLOW_DB_PERSIST == persistType) { dataStore.update(Collections.singleton(info)); } for (String contexts : oseeHttpServlets.keySet()) { InternalOseeHttpServlet servlets = oseeHttpServlets.get(contexts); servlets.setRequestsAllowed(value); } }
@Override public List<String> getCurrentProcesses() { List<String> processList = new ArrayList<String>(); for (String key : threadFactories.keySet()) { for (OseeServerThread thread : getThreadsFromFactory(key)) { State state = thread.getState(); if (!state.equals(State.TERMINATED)) { processList.add(thread.getName()); } } } for (String contexts : oseeHttpServlets.keySet()) { InternalOseeHttpServlet servlets = oseeHttpServlets.get(contexts); if (servlets.getState().equals(ProcessingStateEnum.BUSY)) { processList.add(servlets.getCurrentRequest()); } } return processList; }
@Override public int getNumberOfActiveThreads() { int totalProcesses = 0; for (String contexts : oseeHttpServlets.keySet()) { InternalOseeHttpServlet servlet = oseeHttpServlets.get(contexts); if (servlet.getState().isBusy()) { totalProcesses++; } } for (String key : threadFactories.keySet()) { for (OseeServerThread thread : getThreadsFromFactory(key)) { State state = thread.getState(); if (State.TERMINATED != state) { totalProcesses++; } } } return totalProcesses; }
@Override public void register(String context, OseeHttpServlet servlet) { InternalOseeHttpServlet internalServlet = servlet; internalServlet.setRequestsAllowed(getApplicationServerInfo().isAcceptingRequests()); this.oseeHttpServlets.put(context, internalServlet); }