mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-3048 [Bug]: Lots of small files that leads to out of inodes on fil… (#1515)
* CB-3048 [Bug]: Lots of small files that leads to out of inodes on filesystem Sets the MaxInactiveInterval to the SessionHandler * CB-3048 [Bug]: Lots of small files that leads to out of inodes on filesystem Implements the use of the current CBApplication instead of CBPlatform in CBJettyServer --------- Co-authored-by: Iaroslav Emelianov <iaroslav.emelianov@dbeaver.com> Co-authored-by: dariamarutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
co-authored by
Iaroslav Emelianov
dariamarutkina
parent
e9011eb646
commit
d744f7f22c
@@ -744,7 +744,7 @@ public class CBApplication extends BaseWebApplication implements WebAuthApplicat
|
||||
|
||||
private void runWebServer() {
|
||||
log.debug("Starting Jetty server (" + serverPort + " on " + (CommonUtils.isEmpty(serverHost) ? "all interfaces" : serverHost) + ") ");
|
||||
new CBJettyServer().runServer();
|
||||
new CBJettyServer(this).runServer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+20
-3
@@ -34,6 +34,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.runtime.DBWorkbench;
|
||||
@@ -58,7 +59,10 @@ public class CBJettyServer {
|
||||
System.setProperty("org.eclipse.jetty.LEVEL", "WARN");
|
||||
}
|
||||
|
||||
public CBJettyServer() {
|
||||
private final CBApplication application;
|
||||
|
||||
public CBJettyServer(@NotNull CBApplication application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public void runServer() {
|
||||
@@ -104,7 +108,7 @@ public class CBJettyServer {
|
||||
}
|
||||
}
|
||||
|
||||
initSessionManager(server, servletContextHandler);
|
||||
initSessionManager(this.application, servletContextHandler);
|
||||
|
||||
server.setHandler(servletContextHandler);
|
||||
|
||||
@@ -154,7 +158,10 @@ public class CBJettyServer {
|
||||
}
|
||||
}
|
||||
|
||||
private void initSessionManager(Server server, ServletContextHandler servletContextHandler) {
|
||||
private void initSessionManager(
|
||||
@NotNull CBApplication application,
|
||||
@NotNull ServletContextHandler servletContextHandler
|
||||
) {
|
||||
// Init sessions persistence
|
||||
Path metadataFolder = GeneralUtils.getMetadataFolder(DBWorkbench.getPlatform().getWorkspace().getAbsolutePath());
|
||||
Path sessionCacheFolder = metadataFolder.resolve(SESSION_CACHE_DIR);
|
||||
@@ -179,6 +186,16 @@ public class CBJettyServer {
|
||||
return 1;
|
||||
}
|
||||
}*/;
|
||||
var maxIdleSeconds = application.getSessionManager().getMaxSessionIdleTime();
|
||||
int intMaxIdleSeconds;
|
||||
if (maxIdleSeconds > Integer.MAX_VALUE) {
|
||||
log.warn("Max session idle time value is greater than Integer.MAX_VALUE. Integer.MAX_VALUE will be used instead");
|
||||
intMaxIdleSeconds = Integer.MAX_VALUE;
|
||||
} else {
|
||||
intMaxIdleSeconds = (int) maxIdleSeconds;
|
||||
}
|
||||
sessionHandler.setMaxInactiveInterval(intMaxIdleSeconds);
|
||||
|
||||
DefaultSessionCache sessionCache = new DefaultSessionCache(sessionHandler);
|
||||
FileSessionDataStore sessionStore = new FileSessionDataStore();
|
||||
|
||||
|
||||
+12
-5
@@ -50,6 +50,11 @@ public class WebSessionManager {
|
||||
|
||||
private static final Log log = Log.getLog(WebSessionManager.class);
|
||||
|
||||
/**
|
||||
* In configuration mode sessions expire after a week
|
||||
*/
|
||||
private static final long CONFIGURATION_MODE_SESSION_IDLE_TIME = 60 * 60 * 1000 * 24 * 7;
|
||||
|
||||
private final CBApplication application;
|
||||
private final Map<String, BaseWebSession> sessionMap = new HashMap<>();
|
||||
|
||||
@@ -194,12 +199,14 @@ public class WebSessionManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getMaxSessionIdleTime() {
|
||||
return CBApplication.getInstance().isConfigurationMode()
|
||||
? CONFIGURATION_MODE_SESSION_IDLE_TIME
|
||||
: DBWorkbench.getPlatform(CBPlatform.class).getApplication().getMaxSessionIdleTime();
|
||||
}
|
||||
|
||||
public void expireIdleSessions() {
|
||||
long maxSessionIdleTime = DBWorkbench.getPlatform(CBPlatform.class).getApplication().getMaxSessionIdleTime();
|
||||
if (CBApplication.getInstance().isConfigurationMode()) {
|
||||
// In configuration mode sessions expire after a week
|
||||
maxSessionIdleTime = 60 * 60 * 1000 * 24 * 7;
|
||||
}
|
||||
long maxSessionIdleTime = getMaxSessionIdleTime();
|
||||
|
||||
List<BaseWebSession> expiredList = new ArrayList<>();
|
||||
synchronized (sessionMap) {
|
||||
|
||||
Reference in New Issue
Block a user