summaryrefslogtreecommitdiff
path: root/bkucommon
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-06-04 12:49:28 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-06-04 12:49:28 +0000
commit05f743f601a30eac884e2e1819c34c1ebefd4d98 (patch)
treefeed8a7e4d028c523d249ded69f5912f8a847cbf /bkucommon
parent67b5c14dd29c3ac9c33b6a0e67cf4ddee4573efe (diff)
downloadmocca-05f743f601a30eac884e2e1819c34c1ebefd4d98.tar.gz
mocca-05f743f601a30eac884e2e1819c34c1ebefd4d98.tar.bz2
mocca-05f743f601a30eac884e2e1819c34c1ebefd4d98.zip
Fix BindingProcessor cleanup
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1184 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'bkucommon')
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/AbstractBindingProcessor.java2
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java48
2 files changed, 39 insertions, 11 deletions
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<Id, BindingProcessorFuture> submittedFutures = Collections
.synchronizedMap(new HashMap<Id, BindingProcessorFuture>());
-
- 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
*/
@@ -141,6 +141,34 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com
}
/**
+ * @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());
}
}