mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 20:13:52 +00:00
tracing for Future.get
Change-Id: I5c0bf627c86eef180889fa769e7952de2a27afdd
This commit is contained in:
1 parent
69f46db026
commit
ca14fe33f6
23 files changed
+407
-96
No files matched your search
+1
-2
@@ -28,7 +28,6 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -605,7 +604,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
operationExecutionListeners = new ConcurrentHashMap<>();
|
||||
courseListeners = new ConcurrentHashMap<>();
|
||||
persistentRegattasForRaceIDs = new ConcurrentHashMap<>();
|
||||
Executor simulatorExecutor = ThreadPoolUtil.INSTANCE.getDefaultBackgroundTaskThreadPoolExecutor();
|
||||
final ScheduledExecutorService simulatorExecutor = ThreadPoolUtil.INSTANCE.getDefaultBackgroundTaskThreadPoolExecutor();
|
||||
// TODO: initialize smart-future-cache for simulation-results and add to simulation-service
|
||||
simulationService = SimulationServiceFactory.INSTANCE.getService(simulatorExecutor, this);
|
||||
this.raceLogReplicator = new RaceLogReplicatorAndNotifier(this);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.server.simulation;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
|
||||
@@ -8,6 +8,6 @@ public interface SimulationServiceFactory {
|
||||
|
||||
static SimulationServiceFactory INSTANCE = new SimulationServiceFactoryImpl();
|
||||
|
||||
SimulationService getService(Executor executor, RacingEventService racingEventService);
|
||||
SimulationService getService(ScheduledExecutorService executor, RacingEventService racingEventService);
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
package com.sap.sailing.server.simulation;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
|
||||
public class SimulationServiceFactoryImpl implements SimulationServiceFactory {
|
||||
|
||||
public SimulationService getService(Executor executor, RacingEventService racingEventService) {
|
||||
public SimulationService getService(ScheduledExecutorService executor, RacingEventService racingEventService) {
|
||||
return new SimulationServiceImpl(executor, racingEventService);
|
||||
}
|
||||
|
||||
|
||||
+14
-22
@@ -8,9 +8,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
@@ -59,13 +57,12 @@ import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsDurationImpl;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.util.SmartFutureCache;
|
||||
import com.sap.sse.util.impl.ThreadFactoryWithPriority;
|
||||
|
||||
public class SimulationServiceImpl implements SimulationService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SimulationService.class.getName());
|
||||
|
||||
final private Executor executor;
|
||||
final private ScheduledExecutorService executor;
|
||||
final private SmartFutureCache<LegIdentifier, SimulationResults, SmartFutureCache.EmptyUpdateInterval> cache;
|
||||
final private RacingEventService racingEventService;
|
||||
final private ScheduledExecutorService scheduler;
|
||||
@@ -73,9 +70,9 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
final private HashMap<RaceIdentifier, LegChangeListener> legListeners;
|
||||
final private long WAIT_MILLIS = 20000; // milliseconds to wait until earliest cache-update for simulation
|
||||
|
||||
public SimulationServiceImpl(Executor executor, RacingEventService racingEventService) {
|
||||
public SimulationServiceImpl(ScheduledExecutorService executor, RacingEventService racingEventService) {
|
||||
this.executor = executor;
|
||||
this.scheduler = Executors.newScheduledThreadPool(1, new ThreadFactoryWithPriority(Thread.NORM_PRIORITY, /* daemon */ true));
|
||||
this.scheduler = executor;
|
||||
this.racingEventService = racingEventService;
|
||||
if (racingEventService != null) {
|
||||
this.raceListeners = new HashMap<String, SimulationRaceListener>();
|
||||
@@ -437,31 +434,26 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
Simulator simulator = new SimulatorImpl(simulationParameters);
|
||||
Map<PathType, Path> result = new HashMap<PathType, Path>();
|
||||
|
||||
FutureTask<Path> taskOmniscient = null;
|
||||
Future<Path> taskOmniscient = null;
|
||||
if (simulationParameters.showOmniscient()) {
|
||||
// schedule omniscient task
|
||||
taskOmniscient = new FutureTask<Path>(() -> simulator.getPath(PathType.OMNISCIENT));
|
||||
executor.execute(taskOmniscient);
|
||||
taskOmniscient = executor.submit(() -> simulator.getPath(PathType.OMNISCIENT));
|
||||
}
|
||||
|
||||
FutureTask<Path> task1TurnerLeft = null;
|
||||
FutureTask<Path> task1TurnerRight = null;
|
||||
Future<Path> task1TurnerLeft = null;
|
||||
Future<Path> task1TurnerRight = null;
|
||||
if (simulationParameters.getLegType() != LegType.REACHING) {
|
||||
// schedule 1-turner tasks
|
||||
task1TurnerLeft = new FutureTask<Path>(() -> simulator.getPath(PathType.ONE_TURNER_LEFT));
|
||||
task1TurnerRight = new FutureTask<Path>(() -> simulator.getPath(PathType.ONE_TURNER_RIGHT));
|
||||
executor.execute(task1TurnerLeft);
|
||||
executor.execute(task1TurnerRight);
|
||||
task1TurnerLeft = executor.submit(() -> simulator.getPath(PathType.ONE_TURNER_LEFT));
|
||||
task1TurnerRight = executor.submit(() -> simulator.getPath(PathType.ONE_TURNER_RIGHT));
|
||||
}
|
||||
|
||||
FutureTask<Path> taskOpportunistLeft = null;
|
||||
FutureTask<Path> taskOpportunistRight = null;
|
||||
Future<Path> taskOpportunistLeft = null;
|
||||
Future<Path> taskOpportunistRight = null;
|
||||
if (simulationParameters.showOpportunist()) {
|
||||
// schedule opportunist tasks (which depend on 1-turner results)
|
||||
taskOpportunistLeft = new FutureTask<Path>(() -> simulator.getPath(PathType.OPPORTUNIST_LEFT));
|
||||
taskOpportunistRight = new FutureTask<Path>(() -> simulator.getPath(PathType.OPPORTUNIST_RIGHT));
|
||||
executor.execute(taskOpportunistLeft);
|
||||
executor.execute(taskOpportunistRight);
|
||||
taskOpportunistLeft = executor.submit(() -> simulator.getPath(PathType.OPPORTUNIST_LEFT));
|
||||
taskOpportunistRight = executor.submit(() -> simulator.getPath(PathType.OPPORTUNIST_RIGHT));
|
||||
}
|
||||
|
||||
Path path1TurnerLeft = null;
|
||||
|
||||
Reference in new issue
Block a user