Merge branch 'master' into dev

This commit is contained in:
Axel Uhl
2013-01-26 01:13:02 +01:00
3 changed files with 22 additions and 6 deletions
@@ -6,9 +6,11 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import com.sap.sailing.util.impl.SmartFutureCache.UpdateInterval;
@@ -171,7 +173,9 @@ public class SmartFutureCache<K, V, U extends UpdateInterval<U>> {
public SmartFutureCache(CacheUpdater<K, V, U> cacheUpdateComputer, String nameForLocks) {
this.ongoingRecalculations = new ConcurrentHashMap<K, FutureTaskWithCancelBlocking<V, U>>();
this.cache = new ConcurrentHashMap<K, V>();
this.recalculator = Executors.newSingleThreadExecutor();
this.recalculator = new ThreadPoolExecutor(/* corePoolSize */ 0,
/* maximumPoolSize */ 1, /* keepAliveTime */ 60, TimeUnit.SECONDS,
/* workQueue */ new LinkedBlockingQueue<Runnable>());
this.cacheUpdateComputer = cacheUpdateComputer;
this.locksForKeys = new ConcurrentHashMap<K, NamedReentrantReadWriteLock>();
this.nameForLocks = nameForLocks;
@@ -11,14 +11,16 @@ import java.util.WeakHashMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import com.sap.sailing.domain.base.Mark;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.base.Fleet;
import com.sap.sailing.domain.base.Mark;
import com.sap.sailing.domain.base.RaceColumn;
import com.sap.sailing.domain.base.RaceColumnListener;
import com.sap.sailing.domain.base.Waypoint;
@@ -186,7 +188,11 @@ public class LeaderboardDTOCache {
this.waitForLatestAnalyses = waitForLatestAnalyses;
// if the leaderboard becomes weakly referenced and eventually GCed, then so can the cached results for it
this.leaderboardCache = new WeakHashMap<Leaderboard, Map<Util.Pair<TimePoint, Collection<String>>, FutureTask<LeaderboardDTO>>>();
this.computeLeadearboardByNameExecutor = Executors.newFixedThreadPool(10*Runtime.getRuntime().availableProcessors());
this.computeLeadearboardByNameExecutor =
new ThreadPoolExecutor(/* corePoolSize */ 0,
/* maximumPoolSize */ 10*Runtime.getRuntime().availableProcessors(),
/* keepAliveTime */ 60, TimeUnit.SECONDS,
/* workQueue */ new LinkedBlockingQueue<Runnable>());
this.invalidationListenersPerLeaderboard = new WeakHashMap<Leaderboard, Map<TrackedRace, Set<CacheInvalidationListener>>>();
this.raceColumnListeners = new WeakHashMap<Leaderboard, RaceColumnListener>();
this.scoreCorrectionListeners = new WeakHashMap<Leaderboard, CacheInvalidationUponScoreCorrectionListener>();
@@ -29,7 +29,10 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -317,7 +320,10 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
tractracMongoObjectFactory = com.sap.sailing.domain.tractracadapter.persistence.MongoObjectFactory.INSTANCE;
swissTimingFactory = SwissTimingFactory.INSTANCE;
countryCodeFactory = com.sap.sailing.domain.common.CountryCodeFactory.INSTANCE;
executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
executor = new ThreadPoolExecutor(/* corePoolSize */ 0,
/* maximumPoolSize */ Runtime.getRuntime().availableProcessors(),
/* keepAliveTime */ 60, TimeUnit.SECONDS,
/* workQueue */ new LinkedBlockingQueue<Runnable>());
raceDetailsExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
leaderboardByNameLiveUpdaters = new HashMap<String, LiveLeaderboardUpdater>();
leaderboardDTOCacheWaitingForLatestAnalysis = new LeaderboardDTOCache(this, /* waitForLatestAnalyses */ true);