summaryrefslogtreecommitdiff
path: root/bkucommon/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'bkucommon/src/main/java/at/gv')
-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());
}
}