added configs for fetching live hover data to allow users to customize the behaviour

This commit is contained in:
Martin Lippert
2019-11-19 14:41:37 +01:00
parent 560128a0bb
commit f8dd7929fd
10 changed files with 81 additions and 12 deletions

View File

@@ -32,6 +32,10 @@ public class BootJavaConfig implements InitializingBean {
public static final boolean LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED_DEFAULT = true;
public static final int LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY_DEFAULT = 5000;
public static final int LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO_DEFAULT = 10;
public static final int LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS_DEFAULT = 3;
//TODO: Consider changing this to something that raises Spring application events.
// I.e. like described in here: https://www.baeldung.com/spring-events
@@ -54,6 +58,16 @@ public class BootJavaConfig implements InitializingBean {
return delay != null ? delay.intValue() : LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY_DEFAULT;
}
public int getLiveInformationFetchDataMaxRetryCount() {
Integer delay = settings.getInt("boot-java", "live-information", "fetch-data", "max-retries");
return delay != null ? delay.intValue() : LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO_DEFAULT;
}
public int getLiveInformationFetchDataRetryDelayInSeconds() {
Integer delay = settings.getInt("boot-java", "live-information", "fetch-data", "retry-delay-in-seconds");
return delay != null ? delay.intValue() : LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS_DEFAULT;
}
public boolean isSpringXMLSupportEnabled() {
Boolean enabled = settings.getBoolean("boot-java", "support-spring-xml-config", "on");
return enabled != null && enabled.booleanValue();

View File

@@ -199,6 +199,10 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
liveProcessTracker.setDelay(config.getLiveInformationAutomaticTrackingDelay());
liveProcessTracker.setTrackingEnabled(config.isLiveInformationAutomaticTrackingEnabled());
// live information data fetch params
liveDataService.setMaxRetryCount(config.getLiveInformationFetchDataMaxRetryCount());
liveDataService.setRetryDelayInSeconds(config.getLiveInformationFetchDataRetryDelayInSeconds());
// live change detection watchdog
if (config.isChangeDetectionEnabled()) {
liveChangeDetectionWatchdog.enableHighlights();

View File

@@ -39,8 +39,7 @@ public class SpringProcessConnectorOverJMX implements SpringProcessConnector {
private final String jmxURL;
private final String urlScheme;
private final String port;
final private String projectName;
private final String projectName;
// not final, might be updated with data from JMX process, if not initially set
private String processID;

View File

@@ -18,6 +18,7 @@ import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.languageserver.ProgressTask;
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
/**
@@ -27,9 +28,6 @@ public class SpringProcessConnectorService {
private static final Logger log = LoggerFactory.getLogger(SpringProcessConnectorService.class);
private static final int RETRY_MAX_NO = 10;
private static final int RETRY_DELAY_IN_SECONDS = 3;
private final SpringProcessLiveDataProvider liveDataProvider;
private final ScheduledThreadPoolExecutor scheduler;
@@ -41,6 +39,8 @@ public class SpringProcessConnectorService {
private final ProgressService progressService;
private int progressIdKey = 0;
private int maxRetryCount;
private int retryDelayInSeconds;
public SpringProcessConnectorService(ProgressService progressService, SpringProcessLiveDataProvider liveDataProvider) {
this.liveDataProvider = liveDataProvider;
@@ -49,6 +49,9 @@ public class SpringProcessConnectorService {
this.connectedSuccess = new ConcurrentHashMap<>();
this.progressService = progressService == null ? ProgressService.NO_PROGRESS : progressService;
this.maxRetryCount = BootJavaConfig.LIVE_INFORMATION_FETCH_DATA_RETRY_MAX_NO_DEFAULT;
this.retryDelayInSeconds = BootJavaConfig.LIVE_INFORMATION_FETCH_DATA_RETRY_DELAY_IN_SECONDS_DEFAULT;
this.connectorListener = new SpringProcessConnectionChangeListener() {
@Override
public void connectionClosed(String processKey) {
@@ -57,6 +60,14 @@ public class SpringProcessConnectorService {
};
}
public void setMaxRetryCount(int maxRetryCount) {
this.maxRetryCount = maxRetryCount;
}
public void setRetryDelayInSeconds(int retryDelayInSeconds) {
this.retryDelayInSeconds = retryDelayInSeconds;
}
public void connectProcess(String processKey, SpringProcessConnector connector) {
log.info("connect to process: " + processKey);
@@ -130,8 +141,8 @@ public class SpringProcessConnectorService {
catch (Exception e) {
log.info("problem occured during process connect", e);
if (retryNo < RETRY_MAX_NO) {
scheduleConnect(connectProgressTask, processKey, connector, RETRY_DELAY_IN_SECONDS, TimeUnit.SECONDS, retryNo + 1);
if (retryNo < maxRetryCount) {
scheduleConnect(connectProgressTask, processKey, connector, retryDelayInSeconds, TimeUnit.SECONDS, retryNo + 1);
} else {
connectProgressTask.progressDone();
}
@@ -149,8 +160,8 @@ public class SpringProcessConnectorService {
catch (Exception e) {
log.info("problem occured during process disconnect", e);
if (retryNo < RETRY_MAX_NO) {
scheduleDisconnect(processKey, connector, RETRY_DELAY_IN_SECONDS, TimeUnit.SECONDS, retryNo + 1);
if (retryNo < maxRetryCount) {
scheduleDisconnect(processKey, connector, retryDelayInSeconds, TimeUnit.SECONDS, retryNo + 1);
}
}
}, delay, unit);
@@ -183,8 +194,8 @@ public class SpringProcessConnectorService {
log.info("problem occured during process live data refresh", e);
if (retryNo < RETRY_MAX_NO) {
scheduleRefresh(refreshProgressTask, processKey, connector, RETRY_DELAY_IN_SECONDS, TimeUnit.SECONDS,
if (retryNo < maxRetryCount) {
scheduleRefresh(refreshProgressTask, processKey, connector, retryDelayInSeconds, TimeUnit.SECONDS,
retryNo + 1);
}
else {