From 05f743f601a30eac884e2e1819c34c1ebefd4d98 Mon Sep 17 00:00:00 2001 From: tkellner Date: Tue, 4 Jun 2013 12:49:28 +0000 Subject: Fix BindingProcessor cleanup git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1184 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../egiz/bku/binding/AbstractBindingProcessor.java | 2 +- .../bku/binding/BindingProcessorManagerImpl.java | 48 +++++++++++++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) (limited to 'bkucommon') diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java index 237ec2de..4f6e58f4 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java @@ -116,7 +116,7 @@ public abstract class AbstractBindingProcessor implements BindingProcessor { @Override public void run() { - + updateLastAccessTime(); if (this.id != null) { MDC.put("id", this.id.toString()); } diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java index 2278bfa9..44f95602 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java @@ -74,19 +74,19 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com private Map submittedFutures = Collections .synchronizedMap(new HashMap()); - - private int cleanUpInterval = DEFAULT_CLEAN_UP_INTERVAL; - + + private int cleanUpInterval = DEFAULT_CLEAN_UP_INTERVAL; + private long maxAcceptedAge = DEFAULT_MAX_ACCEPTED_AGE; - + private ScheduledExecutorService cleanUpService = Executors .newSingleThreadScheduledExecutor(); - + public BindingProcessorManagerImpl() { - cleanUpService.scheduleAtFixedRate(new CleanUpTask(), cleanUpInterval, - cleanUpInterval, TimeUnit.SECONDS); + cleanUpService.scheduleAtFixedRate(new CleanUpTask(), getCleanUpInterval(), + getCleanUpInterval(), TimeUnit.SECONDS); } - + /** * @return the configuration */ @@ -140,6 +140,34 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com return stalFactory; } + /** + * @return the current BindingProcessor cleanup interval + */ + public int getCleanUpInterval() { + return cleanUpInterval; + } + + /** + * @param cleanUpInterval the BindingProcessor cleanup interval + */ + public void setCleanUpInterval(int cleanUpInterval) { + this.cleanUpInterval = cleanUpInterval; + } + + /** + * @return the current maximum inactive time of a BindingProcessor + */ + public long getMaxAcceptedAge() { + return maxAcceptedAge; + } + + /** + * @param maxAcceptedAge the maximum inactive time of a BindingProcessor + */ + public void setMaxAcceptedAge(long maxAcceptedAge) { + this.maxAcceptedAge = maxAcceptedAge; + } + /** * Sets the STALFactory used to create a STAL implementation for initialization of * a BindingProcessor. @@ -292,8 +320,8 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com if (!future.isDone()) { // active++; } - if ((bindingProcessor.getLastAccessTime().getTime() - System - .currentTimeMillis()) > maxAcceptedAge) { + if ((System.currentTimeMillis() - bindingProcessor + .getLastAccessTime().getTime()) > getMaxAcceptedAge()) { toBeRemoved.add(bindingProcessor.getId()); } } -- cgit v1.2.3