Remove automatic process tracking class

This commit is contained in:
aboyko
2024-04-21 14:28:49 -04:00
parent 131336aa58
commit f7fb0479aa
3 changed files with 0 additions and 154 deletions

View File

@@ -44,9 +44,6 @@ public class BootJavaConfig implements InitializingBean {
private static final Logger log = LoggerFactory.getLogger(BootJavaConfig.class);
public static final boolean LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED_DEFAULT = false;
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;
@@ -61,16 +58,6 @@ public class BootJavaConfig implements InitializingBean {
this.workspace = server.getWorkspaceService();
}
public boolean isLiveInformationAutomaticTrackingEnabled() {
Boolean enabled = settings.getBoolean("boot-java", "live-information", "automatic-tracking", "on");
return enabled != null ? enabled.booleanValue() : LIVE_INFORMATION_AUTOMATIC_TRACKING_ENABLED_DEFAULT;
}
public int getLiveInformationAutomaticTrackingDelay() {
Integer delay = settings.getInt("boot-java", "live-information", "automatic-tracking", "delay");
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;

View File

@@ -48,7 +48,6 @@ import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessConnec
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessConnectorService;
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveHoverUpdater;
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessTracker;
import org.springframework.ide.vscode.boot.java.requestmapping.LiveAppURLSymbolProvider;
import org.springframework.ide.vscode.boot.java.requestmapping.RequestMappingHoverProvider;
import org.springframework.ide.vscode.boot.java.requestmapping.WebfluxHandlerCodeLensProvider;
@@ -114,8 +113,6 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
private DocumentSymbolHandler docSymbolProvider;
private JdtSemanticTokensHandler semanticTokensHandler;
private SpringProcessTracker liveProcessTracker;
public BootJavaLanguageServerComponents(ApplicationContext appContext) {
this.server = appContext.getBean(SimpleLanguageServer.class);
this.serverParams = appContext.getBean(BootLanguageServerParams.class);
@@ -153,13 +150,6 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
// create and handle commands
new SpringProcessCommandHandler(server, liveDataService, liveDataLocalProcessConnector, appContext.getBeansOfType(SpringProcessConnectorRemote.class).values());
// track locally running processes and automatically connect to them if configured to do so
liveProcessTracker = new SpringProcessTracker(liveDataLocalProcessConnector, Duration.ofMillis(config.getLiveInformationAutomaticTrackingDelay()));
//
//
//
SpringSymbolIndex indexer = appContext.getBean(SpringSymbolIndex.class);
docSymbolProvider = params -> indexer.getSymbols(params.getTextDocument().getUri());
@@ -194,9 +184,6 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
log.info("update live process tracker settings - start");
// live information automatic process tracking
liveProcessTracker.setDelay(config.getLiveInformationAutomaticTrackingDelay());
liveProcessTracker.setTrackingEnabled(config.isLiveInformationAutomaticTrackingEnabled());
// live information data fetch params
liveDataService.setMaxRetryCount(config.getLiveInformationFetchDataMaxRetryCount());
liveDataService.setRetryDelayInSeconds(config.getLiveInformationFetchDataRetryDelayInSeconds());
@@ -244,12 +231,10 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
}
private void initialized() {
this.liveProcessTracker.start();
this.liveChangeDetectionWatchdog.start();
}
private void shutdown() {
this.liveProcessTracker.stop();
this.liveChangeDetectionWatchdog.shutdown();
this.cuCache.dispose();
}

View File

@@ -1,126 +0,0 @@
/*******************************************************************************
* Copyright (c) 2019, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.livehover.v2;
import java.time.Duration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
/**
* @author Martin Lippert
*/
public class SpringProcessTracker {
private static final long DELAY_MINIMUM = 1000;
private static final Logger log = LoggerFactory.getLogger(SpringProcessTracker.class);
private final SpringProcessConnectorLocal localProcessConnector;
private boolean automaticTrackingEnabled;
private Duration POLLING_INTERVAL;
private ScheduledThreadPoolExecutor timer;
private Set<String> processesAlreadySeen;
public SpringProcessTracker(SpringProcessConnectorLocal localProcessConnector, Duration pollingInterval) {
this.localProcessConnector = localProcessConnector;
this.POLLING_INTERVAL = pollingInterval != null ? pollingInterval : Duration.ofMillis(BootJavaConfig.LIVE_INFORMATION_AUTOMATIC_TRACKING_DELAY_DEFAULT);
this.automaticTrackingEnabled = false;
this.processesAlreadySeen = new HashSet<>();
}
public synchronized void setTrackingEnabled(boolean trackingEnabled) {
if (automaticTrackingEnabled != trackingEnabled) {
automaticTrackingEnabled = trackingEnabled;
if (automaticTrackingEnabled) {
start();
} else {
stop();
}
}
}
public void setDelay(long delay) {
Duration newDelay = Duration.ofMillis(Math.max(DELAY_MINIMUM, delay));
if (!newDelay.equals(POLLING_INTERVAL)) {
this.POLLING_INTERVAL = newDelay;
if (automaticTrackingEnabled) {
stop();
start();
}
}
}
public synchronized void start() {
if (!localProcessConnector.isAvailable()) {
log.error("No automatic local process tracking possible");
return;
}
if (automaticTrackingEnabled && timer == null) {
log.info("Starting SpringProcessTracker");
this.timer = new ScheduledThreadPoolExecutor(1);
this.timer.scheduleWithFixedDelay(() -> this.update(), 0, POLLING_INTERVAL.toMillis(), TimeUnit.MILLISECONDS);
}
}
public synchronized void stop() {
if (timer != null) {
log.info("Shutting down SpringProcessTracker");
timer.shutdown();
timer = null;
}
}
private void update() {
try {
SpringProcessDescriptor[] autoConnectProcesses = this.localProcessConnector
.getProcesses(true, SpringProcessStatus.AUTO_CONNECT);
Set<String> autoConnectProcessKeys = new HashSet<>();
for (SpringProcessDescriptor process : autoConnectProcesses) {
autoConnectProcessKeys.add(process.getProcessKey());
if (!processesAlreadySeen.contains(process.getProcessKey())) {
processesAlreadySeen.add(process.getProcessKey());
log.info("auto-connect to process: " + process.getProcessKey());
this.localProcessConnector.connectProcess(process);
}
}
// cleanup list of already seen processes
Iterator<String> iter = this.processesAlreadySeen.iterator();
while (iter.hasNext()) {
String processKey = iter.next();
if (!autoConnectProcessKeys.contains(processKey)) {
iter.remove();
}
}
}
catch (Throwable e) {
log.error("error searching for local processes", e);
}
}
}