Skip to content

Commit

Permalink
CB-5424 QM cleanup job (#2987)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov authored Oct 15, 2024
1 parent 67c54d2 commit 21fe547
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,12 @@ public WSEventController getEventController() {
public boolean isEnvironmentVariablesAccessible() {
return false;
}

protected void closeResource(String name, Runnable closeFunction) {
try {
closeFunction.run();
} catch (Exception e) {
log.error("Failed close " + name, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/
package io.cloudbeaver.model.app;

import io.cloudbeaver.server.WebServerPreferenceStore;
import org.jkiss.code.NotNull;

import java.util.Map;

/**
* Web server configuration.
* Contains only server configuration properties.
Expand All @@ -27,4 +32,12 @@ default String getRootURI() {
return "";
}

/**
* @return the setting values that will be used in {@link WebServerPreferenceStore}
*/
@NotNull
default Map<String, Object> getProductSettings() {
return Map.of();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,20 @@
*/
package io.cloudbeaver.server;

import io.cloudbeaver.utils.WebAppUtils;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.impl.preferences.AbstractPreferenceStore;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;

import java.io.IOException;
import java.util.Map;

public class CBPreferenceStore extends AbstractPreferenceStore {
@NotNull
private final CBPlatform cbPlatform;
public class WebServerPreferenceStore extends AbstractPreferenceStore {
private final DBPPreferenceStore parentStore;

public CBPreferenceStore(
@NotNull CBPlatform cbPlatform,
public WebServerPreferenceStore(
@NotNull DBPPreferenceStore parentStore
) {
this.cbPlatform = cbPlatform;
this.parentStore = parentStore;
}

Expand Down Expand Up @@ -188,7 +185,7 @@ public void save() throws IOException {
}

private Map<String, Object> productConf() {
var app = cbPlatform.getApplication();
return app.getProductConfiguration();
var app = WebAppUtils.getWebApplication();
return app.getServerConfiguration().getProductSettings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class CBPlatform extends BaseGQLPlatform {
@Nullable
private static GQLApplicationAdapter application = null;

private CBPreferenceStore preferenceStore;
private WebServerPreferenceStore preferenceStore;
protected final List<DBPDriver> applicableDrivers = new ArrayList<>();

public static CBPlatform getInstance() {
Expand All @@ -77,7 +77,7 @@ public static void setApplication(@NotNull GQLApplicationAdapter application) {
protected synchronized void initialize() {
long startTime = System.currentTimeMillis();
log.info("Initialize web platform...: ");
this.preferenceStore = new CBPreferenceStore(this, WebPlatformActivator.getInstance().getPreferences());
this.preferenceStore = new WebServerPreferenceStore(WebPlatformActivator.getInstance().getPreferences());
super.initialize();
refreshApplicableDrivers();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.app.DBPPlatform;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.PeriodicJob;

public class SessionStateJob extends PeriodicSystemJob {
public class SessionStateJob extends PeriodicJob {
private static final Log log = Log.getLog(SessionStateJob.class);
private static final int PERIOD_MS = 30_000; // once per 30 seconds
private final WebSessionManager sessionManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.app.DBPPlatform;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.PeriodicJob;

/**
* WebSessionMonitorJob
*/
public class WebSessionMonitorJob extends PeriodicSystemJob {
public class WebSessionMonitorJob extends PeriodicJob {
private static final Log log = Log.getLog(WebSessionMonitorJob.class);
private static final int MONITOR_INTERVAL = 10000; // once per 10 seconds
private final WebSessionManager sessionManager;
Expand Down

0 comments on commit 21fe547

Please sign in to comment.