From 0d947bc3b357e3a875bbe740ed007f54d83a9389 Mon Sep 17 00:00:00 2001 From: tkellner Date: Tue, 10 Dec 2013 16:16:22 +0000 Subject: Increase BindingProcessor timeout to 5 min, make configurable git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1245 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../bku/binding/BindingProcessorManagerImpl.java | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'bkucommon/src/main') 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 44f95602..ef911e0b 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 @@ -43,6 +43,7 @@ import org.apache.commons.configuration.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.gv.egiz.bku.conf.MoccaConfigurationFacade; import at.gv.egiz.bku.jmx.ComponentMXBean; import at.gv.egiz.bku.jmx.ComponentState; import at.gv.egiz.bku.slcommands.SLCommandInvoker; @@ -56,16 +57,14 @@ import at.gv.egiz.stal.STALFactory; */ public class BindingProcessorManagerImpl implements BindingProcessorManager, ComponentMXBean { - public static long DEFAULT_MAX_ACCEPTED_AGE = 2 * 60 * 1000; + public static long DEFAULT_MAX_ACCEPTED_AGE = 5 * 60 * 1000; // 5 Minutes public static int DEFAULT_CLEAN_UP_INTERVAL = 60; - private final Logger log = LoggerFactory.getLogger(BindingProcessorManagerImpl.class); + private final static Logger log = LoggerFactory.getLogger(BindingProcessorManagerImpl.class); private List factories = Collections.emptyList(); - private Configuration configuration; - private STALFactory stalFactory; private SLCommandInvoker commandInvoker; @@ -77,7 +76,21 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com private int cleanUpInterval = DEFAULT_CLEAN_UP_INTERVAL; - private long maxAcceptedAge = DEFAULT_MAX_ACCEPTED_AGE; + private long maxAcceptedAge = -1; + + public final ConfigurationFacade configurationFacade = new ConfigurationFacade(); + + public class ConfigurationFacade implements MoccaConfigurationFacade { + + private Configuration configuration; + + public static final String BINDING_PROCESSOR_TIMEOUT = "BindingProcessorTimeout"; + + public long getBindingProcessorTimeout() { + return configuration.getLong(BINDING_PROCESSOR_TIMEOUT, DEFAULT_MAX_ACCEPTED_AGE); + } + + } private ScheduledExecutorService cleanUpService = Executors .newSingleThreadScheduledExecutor(); @@ -91,14 +104,14 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com * @return the configuration */ public Configuration getConfiguration() { - return configuration; + return configurationFacade.configuration; } /** * @param configuration the configuration to set */ public void setConfiguration(Configuration configuration) { - this.configuration = configuration; + configurationFacade.configuration = configuration; } /** @@ -158,7 +171,8 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com * @return the current maximum inactive time of a BindingProcessor */ public long getMaxAcceptedAge() { - return maxAcceptedAge; + return maxAcceptedAge < 0 ? + configurationFacade.getBindingProcessorTimeout() : maxAcceptedAge; } /** @@ -322,7 +336,9 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager, Com } if ((System.currentTimeMillis() - bindingProcessor .getLastAccessTime().getTime()) > getMaxAcceptedAge()) { - toBeRemoved.add(bindingProcessor.getId()); + Id id = bindingProcessor.getId(); + toBeRemoved.add(id); + log.debug("Removing BindingProcessor {} for exceeding {}ms", id, getMaxAcceptedAge()); } } for (Id id : toBeRemoved) { -- cgit v1.2.3