From bece2723811a23def43330c3de35d98aada929fd Mon Sep 17 00:00:00 2001 From: Gwenaelle Abeille <gwenaelle.abeille@synchrotron-soleil.fr> Date: Thu, 19 May 2011 12:19:20 +0000 Subject: [PATCH] release --- .classpath | 1 - .project | 7 - pom.xml | 2 +- .../Archiver/Collector/ArchiverCollector.java | 8 +- .../HdbArchiver/Collector/HdbCollector.java | 35 ++-- .../HdbArchiver/Collector/image/Image_RO.java | 4 +- .../Collector/scalar/BooleanScalar.java | 35 ++-- .../Collector/scalar/BooleanScalar_RO.java | 4 +- .../Collector/scalar/BooleanScalar_RW.java | 4 +- .../Collector/scalar/BooleanScalar_WO.java | 4 +- .../Collector/scalar/NumberScalar.java | 39 ++--- .../Collector/scalar/NumberScalar_RO.java | 4 +- .../Collector/scalar/NumberScalar_RW.java | 4 +- .../Collector/scalar/NumberScalar_WO.java | 4 +- .../Collector/scalar/StateScalar.java | 32 ++-- .../Collector/scalar/StateScalar_RO.java | 4 +- .../Collector/scalar/StringScalar.java | 32 ++-- .../Collector/scalar/StringScalar_RO.java | 4 +- .../Collector/scalar/StringScalar_RW.java | 4 +- .../Collector/scalar/StringScalar_WO.java | 4 +- .../spectrum/BooleanSpectrum_RO.java | 14 +- .../spectrum/BooleanSpectrum_RW.java | 15 +- .../Collector/spectrum/NumberSpectrum_RO.java | 19 +-- .../Collector/spectrum/NumberSpectrum_RW.java | 16 +- .../Collector/spectrum/StringSpectrum_RO.java | 16 +- .../Collector/spectrum/StringSpectrum_RW.java | 29 ++-- src/main/java/HdbArchiver/HdbArchiver.java | 50 +++--- .../java/TdbArchiver/Collector/DbProxy.java | 46 ++--- .../TdbArchiver/Collector/TdbCollector.java | 159 +++++------------- .../Collector/scalar/BooleanScalar.java | 14 +- .../Collector/scalar/NumberScalar.java | 14 +- .../Collector/scalar/StateScalar.java | 14 +- .../Collector/scalar/StringScalar.java | 14 +- src/main/java/TdbArchiver/TdbArchiver.java | 47 ++++-- src/test/resources/log4j.xml | 105 ------------ 35 files changed, 308 insertions(+), 499 deletions(-) delete mode 100644 src/test/resources/log4j.xml diff --git a/.classpath b/.classpath index 3f8b7611..bfbe1725 100644 --- a/.classpath +++ b/.classpath @@ -2,7 +2,6 @@ <classpath> <classpathentry kind="src" output="target/classes" path="src/main/java"/> <classpathentry excluding="**" including="**/*.java" kind="src" output="target/classes" path="src/main/resources"/> - <classpathentry kind="src" path="src/test/resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="output" path="target/classes"/> diff --git a/.project b/.project index 8449a433..a4743907 100644 --- a/.project +++ b/.project @@ -27,11 +27,4 @@ <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature> </natures> - <linkedResources> - <link> - <name>ArchivingConf</name> - <type>2</type> - <location>C:/SOLEIL_ROOT/tango-soleil-win32-5.5.8RC3/tango/bin/ArchivingConf</location> - </link> - </linkedResources> </projectDescription> diff --git a/pom.xml b/pom.xml index 25b09b53..f3237be9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ <artifactId>hdbtdbArchivingServers</artifactId> <name>hdbtdbArchivingServers</name> - <version>2.2.15</version> + <version>2.2.18</version> <scm> <connection>${scm.connection.svn.tango-cs}:archiving/server/hdbtdbArchivingServers</connection> diff --git a/src/main/java/Common/Archiver/Collector/ArchiverCollector.java b/src/main/java/Common/Archiver/Collector/ArchiverCollector.java index 16c927ee..eeb15f2d 100644 --- a/src/main/java/Common/Archiver/Collector/ArchiverCollector.java +++ b/src/main/java/Common/Archiver/Collector/ArchiverCollector.java @@ -11,7 +11,7 @@ public abstract class ArchiverCollector { // This hashtable contains the mode counters by attribute private final Map<String, ModesCounters> attributeModeCounterMap = new HashMap<String, ModesCounters>(); // Diary file - protected ILogger m_logger; + protected ILogger logger; /** * An ModeHandler is associated to each Collector to handle the archiving @@ -24,14 +24,14 @@ public abstract class ArchiverCollector { } public void setDiaryLogger(ILogger _logger) { - this.m_logger = _logger; + this.logger = _logger; } /* Allows to indicate to the collector that a new attribute must be managed */ protected synchronized void addAttribute(String name) { String lower = name.toLowerCase(); if (attributeModeCounterMap.containsKey(lower)) { - m_logger.trace(ILogger.LEVEL_WARNING, "ArchiverCollector.addAttribute : The attribute " + name + logger.trace(ILogger.LEVEL_WARNING, "ArchiverCollector.addAttribute : The attribute " + name + "already exists in the map ==> Counter Re-init"); attributeModeCounterMap.get(lower).init(); } else { @@ -71,7 +71,7 @@ public abstract class ArchiverCollector { doArchive = m_modeHandler.isDataArchivable(mc, dataType, readValueObject, lastValueObject); } catch (Exception e) { e.printStackTrace(); - this.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + "/doArchiveEvent/catch " + e + this.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + "/doArchiveEvent/catch " + e + " with the value of " + attCompleteName); } diff --git a/src/main/java/HdbArchiver/Collector/HdbCollector.java b/src/main/java/HdbArchiver/Collector/HdbCollector.java index 2cb43def..f0c4d15a 100644 --- a/src/main/java/HdbArchiver/Collector/HdbCollector.java +++ b/src/main/java/HdbArchiver/Collector/HdbCollector.java @@ -126,6 +126,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import Common.Archiver.Collector.ArchiverCollector; import HdbArchiver.HdbArchiver; @@ -151,7 +152,7 @@ public abstract class HdbCollector extends ArchiverCollector { */ protected boolean refreshing; - protected boolean isFirstValue; + protected volatile Map<String, Boolean> isFirstValueList = new ConcurrentHashMap<String, Boolean>(); /** * This parameter specify the number of time a Collector retry the archiving @@ -182,7 +183,6 @@ public abstract class HdbCollector extends ArchiverCollector { public HdbCollector(final HdbModeHandler _modeHandler) { super(_modeHandler); - isFirstValue = true; } /** @@ -211,7 +211,7 @@ public abstract class HdbCollector extends ArchiverCollector { */ public void addSource(final AttributeLightMode attributeLightMode) throws ArchivingException { - isFirstValue = true; + isFirstValueList.put(attributeLightMode.getAttribute_complete_name().toLowerCase(), true); if (HdbArchiver.isUseEvents) { addSourceForEvents(attributeLightMode); } else { @@ -236,16 +236,19 @@ public abstract class HdbCollector extends ArchiverCollector { /** * Triggers the collecting action of this HdbCollector. */ - public synchronized void startCollecting() { + protected synchronized void startCollecting() { if (!attributeList.isEmpty()) { - if (attributeList.size() == 1) { + if (!attributeList.isRefresherStarted()) { attributeList.setRefreshInterval(m_modeHandler.getRefreshInterval()); attributeList.setSynchronizedPeriod(true); attributeList.startRefresher(); refreshing = true; + logger.trace(ILogger.LEVEL_DEBUG, this.getClass() + " start refresh for " + attributeList.getSize() + + " attributes"); } else { // force a refresh for newly added attributes attributeList.refresh(); + logger.trace(ILogger.LEVEL_DEBUG, "FORCING refresh for " + this.getClass()); } } } @@ -253,14 +256,12 @@ public abstract class HdbCollector extends ArchiverCollector { /** * Stops the collecting action of this HdbCollector. */ - public synchronized void stopCollecting() { - Util.out4.println("HdbCollector.stopCollecting"); - m_logger.trace(ILogger.LEVEL_INFO, "HdbCollector.stopCollecting"); + protected synchronized void stopCollecting() { try { - if (attributeList.isEmpty()) { - attributeList.stopRefresher(); - refreshing = false; - } + logger.trace(ILogger.LEVEL_DEBUG, this.getClass() + " stop refresh on " + attributeList.getSize() + + " attributes"); + attributeList.stopRefresher(); + refreshing = false; } catch (final Exception e) { Util.out2.println("ERROR !! " + "\r\n" + "\t Origin : \t " + "HdbCollector.stopCollecting" + "\r\n" + "\t Reason : \t " + "UNKNOWN_ERROR" + "\r\n" + "\t Description : \t " + e.getMessage() + "\r\n" @@ -325,7 +326,7 @@ public abstract class HdbCollector extends ArchiverCollector { final long newTime = archivingEvent.getTimeStamp(); if (newTime == 0) { - m_logger.trace(ILogger.LEVEL_WARNING, "NOARCHIVING - received a zero timestamp for " + name + logger.trace(ILogger.LEVEL_WARNING, "NOARCHIVING - received a zero timestamp for " + name + " - tableName: " + archivingEvent.getTable_name()); return false; } @@ -335,10 +336,10 @@ public abstract class HdbCollector extends ArchiverCollector { return true; } - final boolean isAlreadyRegisteredDate = lastTimestampStack.containsDate(newTime, m_logger); - final boolean isValidDate = lastTimestampStack.validateDate(newTime, m_logger); + final boolean isAlreadyRegisteredDate = lastTimestampStack.containsDate(newTime, logger); + final boolean isValidDate = lastTimestampStack.validateDate(newTime, logger); if (isAlreadyRegisteredDate || !isValidDate) { - m_logger.trace(ILogger.LEVEL_DEBUG, "NOARCHIVING - AlreadyRegisteredDate - attribute: " + name + logger.trace(ILogger.LEVEL_DEBUG, "NOARCHIVING - AlreadyRegisteredDate - attribute: " + name + " - timestamp: " + new Timestamp(newTime)); return false; } @@ -368,7 +369,7 @@ public abstract class HdbCollector extends ArchiverCollector { return ret; } - public List<String> getAttributeList() { + public synchronized List<String> getAttributeList() { final List<String> attributeListResult = new ArrayList<String>(); final Enumeration<?> myAttList = attributeList.elements(); while (myAttList.hasMoreElements()) { diff --git a/src/main/java/HdbArchiver/Collector/image/Image_RO.java b/src/main/java/HdbArchiver/Collector/image/Image_RO.java index 2fd94e06..66efdac4 100644 --- a/src/main/java/HdbArchiver/Collector/image/Image_RO.java +++ b/src/main/java/HdbArchiver/Collector/image/Image_RO.java @@ -203,8 +203,8 @@ public class Image_RO extends HdbCollector implements IImageListener { super.setLastTimestamp(snapImageEvent_RO); } catch (final Exception e) { final String message = "Problem (ArchivingException) storing Image_RO value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { diff --git a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar.java b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar.java index 2fa92d05..3fd07321 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar.java +++ b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar.java @@ -130,7 +130,7 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal evtAdaptHMap = new HashMap<Device, TangoEventsAdapter>(); } - /* synchronized */@Override + @Override public synchronized void removeSource(final String attributeName) throws ArchivingException { Util.out2.println("BooleanScalar.removeSource"); @@ -143,20 +143,18 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal * while ( ( IBooleanScalar ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IBooleanScalar attribute = (IBooleanScalar) attributeList.get(attributeName); if (attribute != null) { attribute.removeBooleanScalarListener(this); attribute.removeErrorListener(this); attributeList.remove(attributeName); - + isFirstValueList.remove(attributeName.toLowerCase()); // informs the mother class that one new attribute must be // removed removeAttribute(attributeName); removeTimestamps(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -165,6 +163,8 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal final String desc = "Failed while executing " + this.getClass().getSimpleName() + ".removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -175,6 +175,7 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal final String attName = attributeLightMode.getAttribute_complete_name(); if (attName != null) { + stopCollecting(); final IBooleanScalar attribute = (IBooleanScalar) attributeList.add(attName); attribute.addBooleanScalarListener(this); attribute.addErrorListener(this); @@ -183,12 +184,8 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal // informs the mother class that one new attribute must be // managed addAttribute(attName); - m_logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); - startCollecting(); + logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); - } else { - m_logger.trace(ILogger.LEVEL_ERROR, "archiving not started because attribute name is null " - + attributeLightMode); } } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" @@ -203,6 +200,8 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing " + this.getClass().getSimpleName() + ".addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -361,14 +360,14 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal String attributeName = scalarEvent.getAttribute_complete_name(); try { boolean doArchive = false; - if (isFirstValue) { + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); + logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); @@ -382,8 +381,8 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal setLastValue(scalarEvent, scalarEvent.getReadValue()); } catch (final Exception e) { final String message = "Problem storing BooleanScalar value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { @@ -414,13 +413,13 @@ public abstract class BooleanScalar extends HdbCollector implements IBooleanScal final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + logger.trace(ILogger.LEVEL_ERROR, errorMess); try { processEventScalar(getNullValueScalarEvent(errorEvent, TangoConst.Tango_DEV_BOOLEAN, getWritableValue()), DEFAULT_TRY_NUMBER); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RO.java b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RO.java index f1d3cc49..cd343da0 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RO.java +++ b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RO.java @@ -139,8 +139,8 @@ public class BooleanScalar_RO extends BooleanScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in BooleanScalar_RO/booleanScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RW.java b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RW.java index 575de218..3d7d714d 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RW.java +++ b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_RW.java @@ -143,8 +143,8 @@ public class BooleanScalar_RW extends BooleanScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in BooleanScalar_RW/booleanScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_WO.java b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_WO.java index 576ab682..0035c3a6 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_WO.java +++ b/src/main/java/HdbArchiver/Collector/scalar/BooleanScalar_WO.java @@ -124,8 +124,8 @@ public class BooleanScalar_WO extends BooleanScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in BooleanScalar_WO/booleanScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar.java b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar.java index f7c32989..b29b4e3c 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar.java +++ b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar.java @@ -176,7 +176,7 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar public synchronized void removeSource(final String attributeName) throws ArchivingException { Util.out2.println("NumberScalar.removeSource"); - m_logger.trace(ILogger.LEVEL_INFO, "===> Entering " + this.getClass().getSimpleName() + ".removeSource for " + logger.trace(ILogger.LEVEL_INFO, "===> Entering " + this.getClass().getSimpleName() + ".removeSource for " + attributeName); if (HdbArchiver.isUseEvents) { @@ -188,20 +188,18 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar * while ( ( INumberScalar ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final INumberScalar attribute = (INumberScalar) attributeList.get(attributeName); if (attribute != null) { attribute.removeNumberScalarListener(this); attribute.removeErrorListener(this); attributeList.remove(attributeName); - m_logger.trace(ILogger.LEVEL_INFO, "\t The attribute was fired from the Collector list..."); + isFirstValueList.remove(attributeName.toLowerCase()); + logger.trace(ILogger.LEVEL_INFO, "\t The attribute was fired from the Collector list..."); // informs the mother class that one new attribute must be // removed removeAttribute(attributeName); removeTimestamps(attributeName); - if (attributeList.isEmpty()) { - m_logger.trace(ILogger.LEVEL_INFO, "===> StopCollecting is requested "); - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -211,8 +209,7 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar + ".removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); } finally { - m_logger.trace(ILogger.LEVEL_INFO, "===> Exiting " + this.getClass().getSimpleName() + ".removeSource for " - + attributeName); + startCollecting(); } } @@ -223,6 +220,7 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar final String attName = attributeLightMode.getAttribute_complete_name(); if (attName != null) { INumberScalar attribute = null; + stopCollecting(); attribute = (INumberScalar) attributeList.add(attName); attribute.addNumberScalarListener(this); attribute.addErrorListener(this); @@ -231,11 +229,7 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar // informs the mother class that one new attribute must be // managed addAttribute(attName); - m_logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); - startCollecting(); - } else { - m_logger.trace(ILogger.LEVEL_ERROR, "archiving not started because attribute name is null " - + attributeLightMode); + logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); } } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" @@ -249,6 +243,8 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing " + this.getClass().getSimpleName() + ".addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -419,17 +415,18 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar scalarEvent.avoidUnderFlow(); boolean doArchive = false; - if (isFirstValue) { + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown "); + logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown "); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); + } } @@ -441,8 +438,8 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar } catch (final Exception e) { e.printStackTrace(); final String message = "Problem storing NumberScalar value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { @@ -473,7 +470,7 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - super.m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + super.logger.trace(ILogger.LEVEL_ERROR, errorMess); /* Must be change because the number scalar are not only double */ try { @@ -481,7 +478,7 @@ public abstract class NumberScalar extends HdbCollector implements INumberScalar getNullValueScalarEvent(errorEvent, ((AAttribute) errorEvent.getSource()).getTangoDataType(), getWritableValue()), tryNumber); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RO.java b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RO.java index b08efa28..9f44bfd6 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RO.java +++ b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RO.java @@ -157,8 +157,8 @@ public class NumberScalar_RO extends NumberScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in NumberScalar_RO/numberScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RW.java b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RW.java index e2bc2b63..25cb3d6d 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RW.java +++ b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_RW.java @@ -182,8 +182,8 @@ public class NumberScalar_RW extends NumberScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in NumberScalar_RW/numberScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_WO.java b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_WO.java index c5b53be7..03dbd683 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_WO.java +++ b/src/main/java/HdbArchiver/Collector/scalar/NumberScalar_WO.java @@ -140,8 +140,8 @@ public class NumberScalar_WO extends NumberScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in NumberScalar_RW/numberScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/StateScalar.java b/src/main/java/HdbArchiver/Collector/scalar/StateScalar.java index a65a3bcf..401792d1 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/StateScalar.java +++ b/src/main/java/HdbArchiver/Collector/scalar/StateScalar.java @@ -80,19 +80,18 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala * while ( ( IDevStateScalar ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IDevStateScalar attribute = (IDevStateScalar) attributeList.get(attributeName); if (attribute != null) { attribute.removeDevStateScalarListener(this); attribute.removeErrorListener(this); attributeList.remove(attributeName); + isFirstValueList.remove(attributeName.toLowerCase()); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); // informs the mother class that one new attribute must be // removed removeAttribute(attributeName); removeTimestamps(attributeName); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -101,6 +100,8 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala final String desc = "Failed while executing " + this.getClass().getSimpleName() + ".removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -114,6 +115,7 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala // == // null ) // { + stopCollecting(); IDevStateScalar attribute = null; attribute = (IDevStateScalar) attributeList.add(attName); @@ -123,11 +125,7 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala // informs the mother class that one new attribute must be // managed addAttribute(attName); - m_logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); - startCollecting(); - } else { - m_logger.trace(ILogger.LEVEL_ERROR, "archiving not started because attribute name is null " - + attributeLightMode); + logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); } } catch (final ConnectionException e) { @@ -143,6 +141,8 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing " + this.getClass().getSimpleName() + ".addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -300,15 +300,15 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala String attributeName = scalarEvent.getAttribute_complete_name(); try { boolean doArchive = false; - if (isFirstValue) { + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + "attribute Counters unknown"); + logger.trace(ILogger.LEVEL_ERROR, attributeName + "attribute Counters unknown"); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); @@ -322,8 +322,8 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala setLastValue(scalarEvent, scalarEvent.getReadValue()); } catch (final Exception e) { final String message = "Problem storing StateScalar value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { @@ -358,13 +358,13 @@ public abstract class StateScalar extends HdbCollector implements IDevStateScala final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - super.m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + super.logger.trace(ILogger.LEVEL_ERROR, errorMess); try { processEventScalar(getNullValueScalarEvent(errorEvent, TangoConst.Tango_DEV_STATE, getWritableValue()), tryNumber); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/HdbArchiver/Collector/scalar/StateScalar_RO.java b/src/main/java/HdbArchiver/Collector/scalar/StateScalar_RO.java index e324e0c9..d1faeab0 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/StateScalar_RO.java +++ b/src/main/java/HdbArchiver/Collector/scalar/StateScalar_RO.java @@ -104,8 +104,8 @@ public class StateScalar_RO extends StateScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in StateScalar_RO/devStateScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/StringScalar.java b/src/main/java/HdbArchiver/Collector/scalar/StringScalar.java index 72a6154e..d11e826d 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/StringScalar.java +++ b/src/main/java/HdbArchiver/Collector/scalar/StringScalar.java @@ -82,19 +82,18 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar * while ( ( IStringScalar ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IStringScalar attribute = (IStringScalar) attributeList.get(attributeName); if (attribute != null) { attribute.removeStringScalarListener(this); attribute.removeErrorListener(this); attributeList.remove(attributeName); + isFirstValueList.remove(attributeName.toLowerCase()); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); // informs the mother class that one new attribute must be // removed removeAttribute(attributeName); removeTimestamps(attributeName); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -103,6 +102,8 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar final String desc = "Failed while executing " + this.getClass().getSimpleName() + ".removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -113,6 +114,7 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar try { final String attName = attributeLightMode.getAttribute_complete_name(); if (attName != null) { + stopCollecting(); IStringScalar attribute = null; attribute = (IStringScalar) attributeList.add(attName); @@ -122,11 +124,7 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar // informs the mother class that one new attribute must be // managed addAttribute(attName); - m_logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); - startCollecting(); - } else { - m_logger.trace(ILogger.LEVEL_ERROR, "archiving not started because attribute name is null " - + attributeLightMode); + logger.trace(ILogger.LEVEL_INFO, "add archiving for " + attName); } } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" @@ -141,6 +139,8 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing " + this.getClass().getSimpleName() + ".addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -304,15 +304,15 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar String attributeName = scalarEvent.getAttribute_complete_name(); try { boolean doArchive = false; - if (isFirstValue) { + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); + logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); @@ -326,8 +326,8 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar setLastValue(scalarEvent, scalarEvent.getReadValue()); } catch (final Exception e) { final String message = "Problem storing StringScalar value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { @@ -357,13 +357,13 @@ public abstract class StringScalar extends HdbCollector implements IStringScalar final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - super.m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + super.logger.trace(ILogger.LEVEL_ERROR, errorMess); try { processEventScalar(getNullValueScalarEvent(errorEvent, TangoConst.Tango_DEV_STRING, getWritableValue()), tryNumber); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RO.java b/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RO.java index 377865ed..b3bc30a5 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RO.java +++ b/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RO.java @@ -102,8 +102,8 @@ public class StringScalar_RO extends StringScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in StringScalar_RO/stringScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RW.java b/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RW.java index 78bcc06c..5db2cfd4 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RW.java +++ b/src/main/java/HdbArchiver/Collector/scalar/StringScalar_RW.java @@ -105,8 +105,8 @@ public class StringScalar_RW extends StringScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in StringScalar_RW/stringScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/scalar/StringScalar_WO.java b/src/main/java/HdbArchiver/Collector/scalar/StringScalar_WO.java index 889db320..ffc6cc6c 100644 --- a/src/main/java/HdbArchiver/Collector/scalar/StringScalar_WO.java +++ b/src/main/java/HdbArchiver/Collector/scalar/StringScalar_WO.java @@ -96,8 +96,8 @@ public class StringScalar_WO extends StringScalar { processEventScalar(scalarEvent, tryNumber); final String message = "Problem in StringScalar_WO/stringScalarChange"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, exE); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, exE); } } diff --git a/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RO.java b/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RO.java index 119fbf39..c7c20000 100644 --- a/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RO.java +++ b/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RO.java @@ -156,6 +156,7 @@ public class BooleanSpectrum_RO extends HdbCollector implements IBooleanSpectrum * while ( ( IBooleanSpectrum ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList.get(attributeName); if (attribute != null) { @@ -165,9 +166,6 @@ public class BooleanSpectrum_RO extends HdbCollector implements IBooleanSpectrum attributeList.remove(attributeName); removeTimestamps(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -175,6 +173,8 @@ public class BooleanSpectrum_RO extends HdbCollector implements IBooleanSpectrum final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing BooleanSpectrum_RO.removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -182,19 +182,21 @@ public class BooleanSpectrum_RO extends HdbCollector implements IBooleanSpectrum protected synchronized void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException { try { + stopCollecting(); final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList.add(attributeLightMode .getAttribute_complete_name()); attribute.addBooleanSpectrumListener(this); attribute.addErrorListener(this); Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name() + " was hired to the Collector list..."); - startCollecting(); } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" + attributeLightMode.getAttribute_complete_name() + "' as source"; final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -474,8 +476,8 @@ public class BooleanSpectrum_RO extends HdbCollector implements IBooleanSpectrum super.setLastTimestamp(snapSpectrumEvent_RO); } catch (final ArchivingException e) { final String message = "Problem (ArchivingException) storing BooleanSpectrum_RO value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { diff --git a/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RW.java b/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RW.java index 18be8e8d..7c254b2d 100644 --- a/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RW.java +++ b/src/main/java/HdbArchiver/Collector/spectrum/BooleanSpectrum_RW.java @@ -84,6 +84,7 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum * while ( ( IBooleanSpectrum ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList.get(attributeName); if (attribute != null) { @@ -92,9 +93,6 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum removeTimestamps(attributeName); attributeList.remove(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -102,6 +100,8 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -109,20 +109,21 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum protected synchronized void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException { try { - + stopCollecting(); final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList.add(attributeLightMode .getAttribute_complete_name()); attribute.addBooleanSpectrumListener(this); attribute.addErrorListener(this); Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name() + " was hired to the Collector list..."); - startCollecting(); } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" + attributeLightMode.getAttribute_complete_name() + "' as source"; final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -410,8 +411,8 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum super.setLastTimestamp(snapSpectrumEvent_RW); } catch (final ArchivingException e) { final String message = "Problem (ArchivingException) storing BooleanSpectrum_RW value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); Util.out4.println("BooleanSpectrumEvent_RW.processEventSpectrum/ArchivingException"); diff --git a/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RO.java b/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RO.java index dde45450..68dd050a 100644 --- a/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RO.java +++ b/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RO.java @@ -159,6 +159,7 @@ public class NumberSpectrum_RO extends HdbCollector implements ISpectrumListener * while ( ( INumberSpectrum ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final INumberSpectrum attribute = (INumberSpectrum) attributeList.get(attributeName); if (attribute != null) { @@ -167,9 +168,6 @@ public class NumberSpectrum_RO extends HdbCollector implements ISpectrumListener removeTimestamps(attributeName); attributeList.remove(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -177,6 +175,8 @@ public class NumberSpectrum_RO extends HdbCollector implements ISpectrumListener final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing NumberSpectrum_RO.removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -184,10 +184,7 @@ public class NumberSpectrum_RO extends HdbCollector implements ISpectrumListener protected synchronized void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException { try { - // while ( ( INumberSpectrum ) - // attributeList.get(attributeLightMode.getAttribute_complete_name()) - // == null ) - // { + stopCollecting(); final INumberSpectrum attribute = (INumberSpectrum) attributeList.add(attributeLightMode .getAttribute_complete_name()); attribute.addSpectrumListener(this); @@ -195,14 +192,14 @@ public class NumberSpectrum_RO extends HdbCollector implements ISpectrumListener Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name() + " was hired to the Collector list..."); - startCollecting(); - // } } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" + attributeLightMode.getAttribute_complete_name() + "' as source"; final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing NumberSpectrum_RO.addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -551,8 +548,8 @@ public class NumberSpectrum_RO extends HdbCollector implements ISpectrumListener super.setLastTimestamp(snapSpectrumEvent_RO); } catch (final ArchivingException e) { final String message = "Problem (ArchivingException) storing NumberSpectrum_RO value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { diff --git a/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RW.java b/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RW.java index cd0ee6bc..4fec5b6a 100644 --- a/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RW.java +++ b/src/main/java/HdbArchiver/Collector/spectrum/NumberSpectrum_RW.java @@ -84,24 +84,24 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener * while ( ( INumberSpectrum ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final INumberSpectrum attribute = (INumberSpectrum) attributeList.get(attributeName); if (attribute != null) { - attribute.removeSpectrumListener(this); attribute.removeErrorListener(this); removeTimestamps(attributeName); attributeList.remove(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); - if (attributeList.isEmpty()) { - stopCollecting(); - } } + } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName + "' from sources"; final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -113,19 +113,21 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener // attributeList.get(attributeLightMode.getAttribute_complete_name()) // == null ) // { + stopCollecting(); final INumberSpectrum attribute = (INumberSpectrum) attributeList.add(attributeLightMode .getAttribute_complete_name()); attribute.addSpectrumListener(this); attribute.addErrorListener(this); Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name() + " was hired to the Collector list..."); - startCollecting(); } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" + attributeLightMode.getAttribute_complete_name() + "' as source"; final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -468,8 +470,8 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener super.setLastTimestamp(snapSpectrumEvent_RW); } catch (final ArchivingException e) { final String message = "Problem (ArchivingException) storing NumberSpectrum_RW value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); Util.out4.println("SpectrumEvent_RW.processEventSpectrum/ArchivingException"); diff --git a/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RO.java b/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RO.java index 498f3e60..de3aa796 100644 --- a/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RO.java +++ b/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RO.java @@ -156,17 +156,14 @@ public class StringSpectrum_RO extends HdbCollector implements IStringSpectrumLi * while ( ( IStringSpectrum ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IStringSpectrum attribute = (IStringSpectrum) attributeList.get(attributeName); if (attribute != null) { - attribute.removeListener(this); attribute.removeErrorListener(this); removeTimestamps(attributeName); attributeList.remove(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -174,6 +171,8 @@ public class StringSpectrum_RO extends HdbCollector implements IStringSpectrumLi final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -181,20 +180,21 @@ public class StringSpectrum_RO extends HdbCollector implements IStringSpectrumLi protected synchronized void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException { try { - + stopCollecting(); final IStringSpectrum attribute = (IStringSpectrum) attributeList.add(attributeLightMode .getAttribute_complete_name()); attribute.addListener(this); attribute.addErrorListener(this); Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name() + " was hired to the Collector list..."); - startCollecting(); } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" + attributeLightMode.getAttribute_complete_name() + "' as source"; final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -466,8 +466,8 @@ public class StringSpectrum_RO extends HdbCollector implements IStringSpectrumLi super.setLastTimestamp(snapSpectrumEvent_RO); } catch (final ArchivingException e) { final String message = "Problem (ArchivingException) storing StringSpectrum_RO value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); try_number--; if (try_number > 0) { diff --git a/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RW.java b/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RW.java index e51bc567..f8f968c9 100644 --- a/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RW.java +++ b/src/main/java/HdbArchiver/Collector/spectrum/StringSpectrum_RW.java @@ -84,6 +84,7 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi * while ( ( IStringSpectrum ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IStringSpectrum attribute = (IStringSpectrum) attributeList.get(attributeName); if (attribute != null) { @@ -92,9 +93,6 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi removeTimestamps(attributeName); attributeList.remove(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); - if (attributeList.isEmpty()) { - stopCollecting(); - } } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -102,27 +100,30 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @Override protected void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException { try { - synchronized (attributeList) { - final IStringSpectrum attribute = (IStringSpectrum) attributeList.add(attributeLightMode - .getAttribute_complete_name()); - attribute.addListener(this); - attribute.addErrorListener(this); - Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name() - + " was hired to the Collector list..."); - startCollecting(); - } + stopCollecting(); + final IStringSpectrum attribute = (IStringSpectrum) attributeList.add(attributeLightMode + .getAttribute_complete_name()); + attribute.addListener(this); + attribute.addErrorListener(this); + Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name() + + " was hired to the Collector list..."); + } catch (final ConnectionException e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" + attributeLightMode.getAttribute_complete_name() + "' as source"; final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing Spectrum_RO.addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } @@ -400,8 +401,8 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi super.setLastTimestamp(snapSpectrumEvent_RW); } catch (final ArchivingException e) { final String message = "Problem (ArchivingException) storing StringSpectrum_RW value"; - super.m_logger.trace(ILogger.LEVEL_ERROR, message); - super.m_logger.trace(ILogger.LEVEL_ERROR, e); + super.logger.trace(ILogger.LEVEL_ERROR, message); + super.logger.trace(ILogger.LEVEL_ERROR, e); Util.out4.println("StringSpectrumEvent_RW.processEventSpectrum/ArchivingException"); diff --git a/src/main/java/HdbArchiver/HdbArchiver.java b/src/main/java/HdbArchiver/HdbArchiver.java index 101d3ffe..940806ba 100644 --- a/src/main/java/HdbArchiver/HdbArchiver.java +++ b/src/main/java/HdbArchiver/HdbArchiver.java @@ -365,6 +365,7 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.Map; import java.util.Vector; +import java.util.concurrent.Executors; import org.omg.CORBA.SystemException; import org.omg.CORBA.UserException; @@ -640,26 +641,8 @@ public class HdbArchiver extends DeviceImpl implements TangoConst { get_logger().error("ERROR : Database unconnected !!"); } else { setControlMode(safetyPeriod); - try { - final Vector<AttributeLightMode> myCurrentTasks = dbProxy.getArchiverCurrentTasks(device_name); - if (myCurrentTasks.size() > 0) { - final ArchivingMessConfig archivingMessConfig = ArchivingMessConfig.basicObjectCreation(); - for (final AttributeLightMode attributeLightMode : myCurrentTasks) { - archivingMessConfig.add(attributeLightMode); - } - launchStartArchivingTask(archivingMessConfig, false, false); - } else { - TangoStateUtils.setOn(this, archivingStatus); - } - } catch (final ArchivingException e) { - TangoStateUtils.setFault(this, e.getMessage()); - get_logger().error(e.toString()); - Util.out2.println(e.toString()); - } catch (final DevFailed devFailed) { - final String message = DBTools.getCompleteMessage(devFailed); - get_logger().error(message); - TangoStateUtils.setFault(this, message); - } + // start archiving in a thread + Executors.newSingleThreadExecutor().submit(new InitDeviceTask()); } } @@ -683,6 +666,29 @@ public class HdbArchiver extends DeviceImpl implements TangoConst { } } + private class InitDeviceTask implements Runnable { + @Override + public void run() { + try { + final Vector<AttributeLightMode> myCurrentTasks = dbProxy.getArchiverCurrentTasks(device_name); + if (myCurrentTasks.size() > 0) { + final ArchivingMessConfig archivingMessConfig = ArchivingMessConfig.basicObjectCreation(); + for (final AttributeLightMode attributeLightMode : myCurrentTasks) { + archivingMessConfig.add(attributeLightMode); + } + triggerArchiving(archivingMessConfig.toArray(), false); + } else { + TangoStateUtils.setOn(HdbArchiver.this, archivingStatus); + } + } catch (final DevFailed devFailed) { + // triggerArchiving has thrown + TangoStateUtils.setDisable(HdbArchiver.this, archivingStatus); + } catch (ArchivingException e) { + TangoStateUtils.setFault(HdbArchiver.this, e.getMessage()); + } + } + } + private class StartArchivingRunnable implements Runnable { private final ArchivingMessConfig archivingMessConfig; @@ -1003,7 +1009,6 @@ public class HdbArchiver extends DeviceImpl implements TangoConst { // ========================================================= public void trigger_archive_conf(final String[] argin) throws DevFailed { TangoStateUtils.isAllowed(this); - TangoStateUtils.setRunning(this); triggerArchiving(argin, true); } @@ -1126,6 +1131,9 @@ public class HdbArchiver extends DeviceImpl implements TangoConst { logger.trace(ILogger.LEVEL_ERROR, reason + " " + desc); archivingStatus.put(attCompleteName, false); logger.trace(ILogger.LEVEL_INFO, "KO: " + attCompleteName); + } catch (Exception e) { + e.printStackTrace(); + logger.trace(ILogger.LEVEL_ERROR, "KO " + attCompleteName + " unexpected " + e); } } diff --git a/src/main/java/TdbArchiver/Collector/DbProxy.java b/src/main/java/TdbArchiver/Collector/DbProxy.java index 6a48b6b6..9af4c7a2 100644 --- a/src/main/java/TdbArchiver/Collector/DbProxy.java +++ b/src/main/java/TdbArchiver/Collector/DbProxy.java @@ -69,6 +69,7 @@ package TdbArchiver.Collector; import java.util.Vector; +import fr.esrf.Tango.DevFailed; import fr.esrf.TangoApi.Database; import fr.esrf.TangoDs.Util; import fr.soleil.commonarchivingapi.ArchivingTools.Diary.ILogger; @@ -166,44 +167,21 @@ public class DbProxy { tableName, writable); } - public Vector<AttributeLightMode> getArchiverCurrentTasks(final String archiverName) // throws - // ArchivingException - // , DevFailed - { + public Vector<AttributeLightMode> getArchiverCurrentTasks(final String archiverName) throws DevFailed, + ArchivingException { // System.out.println("DbProxy.getArchiverCurrentTasks"); Vector<AttributeLightMode> archiverCurrentTasks; final boolean facility = manager.getFacility(); - try { - archiverCurrentTasks = manager - .getDataBase() - .getMode() - .getArchiverCurrentTasks( - (facility ? "//" + new Database().get_tango_host() + "/" : "") + archiverName); - System.out.println("Current Tasks (" + archiverCurrentTasks.size() + "): .... \n\r\t"); - for (int i = 0; i < archiverCurrentTasks.size(); i++) { - final AttributeLightMode attributeLightMode = archiverCurrentTasks.elementAt(i); - System.out.println(">>>>>>>>>>>>\t" + i + "\t<<<<<<<<<<<<"); - System.out.println("attributeLightMode.toString() : \r\n" + attributeLightMode.toString() + "\r\n"); - } - return archiverCurrentTasks; - } - /* - * catch ( ArchivingException e ) { System.err.println("ERROR !! " + - * "\r\n" + "\t Origin : \t " + "DbProxy.getArchiverCurrentTasks" + - * "\r\n" + "\t Reason : \t " + e.getClass().getName() + "\r\n" + - * "\t Description : \t " + e.getMessage() + "\r\n" + - * "\t Additional information : \t " + "Unable to get current tasks..." - * + "\r\n"); throw e; } catch ( DevFailed devFailed ) { - * Util.out2.println("ERROR !! " + "\r\n" + "\t Origin : \t " + - * "DbProxy.getArchiverCurrentTasks" + "\r\n" + "\t Reason : \t " + - * "UNKNOWN_ERROR" + "\r\n" + "\t Description : \t " + - * devFailed.getMessage() + "\r\n" + "\t Additional information : \t " + - * "" + "\r\n"); throw devFailed; } - */ - catch (final Exception e) { - e.printStackTrace(); - return null; + archiverCurrentTasks = manager.getDataBase().getMode() + .getArchiverCurrentTasks((facility ? "//" + new Database().get_tango_host() + "/" : "") + archiverName); + System.out.println("Current Tasks (" + archiverCurrentTasks.size() + "): .... \n\r\t"); + for (int i = 0; i < archiverCurrentTasks.size(); i++) { + final AttributeLightMode attributeLightMode = archiverCurrentTasks.elementAt(i); + System.out.println(">>>>>>>>>>>>\t" + i + "\t<<<<<<<<<<<<"); + System.out.println("attributeLightMode.toString() : \r\n" + attributeLightMode.toString() + "\r\n"); } + return archiverCurrentTasks; + } public void deleteOldRecords(final long time, final String[] attributeList) throws ArchivingException { diff --git a/src/main/java/TdbArchiver/Collector/TdbCollector.java b/src/main/java/TdbArchiver/Collector/TdbCollector.java index 6c57a311..e1e202f0 100644 --- a/src/main/java/TdbArchiver/Collector/TdbCollector.java +++ b/src/main/java/TdbArchiver/Collector/TdbCollector.java @@ -153,6 +153,7 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import Common.Archiver.Collector.ArchiverCollector; import TdbArchiver.Collector.Tools.FileTools; @@ -194,11 +195,8 @@ public abstract class TdbCollector extends ArchiverCollector { * This parameter specify the number of time a Collector retry the archiving * of an attribute event */ - // protected static int tryNumber = 1; protected final static int DEFAULT_TRY_NUMBER = 2; - protected KeepingThread keepingThread; - protected long keepingPeriod; private final Map<String, LimitedStack> lastTimestampStacks = new HashMap<String, LimitedStack>(); @@ -209,7 +207,7 @@ public abstract class TdbCollector extends ArchiverCollector { */ private final Map<String, Object> lastValueHashtable = new HashMap<String, Object>(); - protected boolean isFirstValue; + protected volatile Map<String, Boolean> isFirstValueList = new ConcurrentHashMap<String, Boolean>(); protected Warnable warnable; protected DbProxy dbProxy; @@ -224,7 +222,6 @@ public abstract class TdbCollector extends ArchiverCollector { final AttrWriteType writableType) { super(_modeHandler); this.writableType = writableType; - isFirstValue = true; m_currentDbPath = currentDbPath; m_currentDsPath = currentDsPath; } @@ -261,6 +258,7 @@ public abstract class TdbCollector extends ArchiverCollector { public synchronized void addSource(final AttributeLightMode attributeLightMode, final int attributePerFile) throws ArchivingException { try { + stopCollecting(); final String attName = attributeLightMode.getAttribute_complete_name(); final IEntity attribute = attributeList.add(attName); addListeners(attribute); @@ -271,23 +269,17 @@ public abstract class TdbCollector extends ArchiverCollector { addAttribute(attName); // Verify that the recording file exists final String table_name = dbProxy.getDataBase().getDbUtil().getTableName(attName); - if (filesNames.get(attName) == null) { + if (filesNames.get(attName.toLowerCase()) == null) { final FileTools myFile = new FileTools(attName, table_name, attributeLightMode.getData_format(), attributeLightMode.getWritable(), attributeLightMode.getMode().getTdbSpec().getExportPeriod(), - super.m_logger, dbProxy, m_currentDsPath, m_currentDbPath); + super.logger, dbProxy, m_currentDsPath, m_currentDbPath); myFile.setAttributePerFile(attributePerFile); - filesNames.put(attName, myFile); + filesNames.put(attName.toLowerCase(), myFile); } - isFirstValue = true; - startCollecting(); - - if (attributeList.get(attName) == null) { - super.m_logger.trace(ILogger.LEVEL_WARNING, "addSource/The first add test failed for attribute|" - + attName); - } + isFirstValueList.put(attName.toLowerCase(), true); } catch (final ConnectionException e) { - super.m_logger.trace(ILogger.LEVEL_WARNING, e); + super.logger.trace(ILogger.LEVEL_WARNING, e); final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed adding '" + attributeLightMode.getAttribute_complete_name() + "' as source"; @@ -295,9 +287,11 @@ public abstract class TdbCollector extends ArchiverCollector { final String desc = "Failed while executing BooleanScalar.addSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_WARNING, + super.logger.trace(ILogger.LEVEL_WARNING, "Unexpected exception during addSource:" + attributeLightMode.getAttribute_complete_name()); - super.m_logger.trace(ILogger.LEVEL_WARNING, e); + super.logger.trace(ILogger.LEVEL_WARNING, e); + } finally { + startCollecting(); } } @@ -318,10 +312,11 @@ public abstract class TdbCollector extends ArchiverCollector { * while ( ( IBooleanScalar ) attributeList.get(attributeName) != * null ) { */ + stopCollecting(); final IEntity attribute = attributeList.get(attributeName); if (attribute != null) { removeListeners(attribute); - + isFirstValueList.remove(attributeName.toLowerCase()); attributeList.remove(attributeName); // informs the mother class that one new attribute must be @@ -330,13 +325,9 @@ public abstract class TdbCollector extends ArchiverCollector { removeTimestamps(attributeName); Util.out4.println("\t The attribute named " + attributeName + " was fired from the Collector list..."); if (closeFile) { - filesNames.get(attributeName).closeFile(); - filesNames.remove(attributeName); + filesNames.get(attributeName.toLowerCase()).closeFile(); + filesNames.remove(attributeName.toLowerCase()); } - if (attributeList.isEmpty()) { - stopCollecting(); - } - } } catch (final Exception e) { final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName @@ -344,56 +335,55 @@ public abstract class TdbCollector extends ArchiverCollector { final String reason = GlobalConst.TANGO_COMM_EXCEPTION; final String desc = "Failed while executing BooleanScalar.removeSource() method..."; throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e); + } finally { + startCollecting(); } } public abstract void removeListeners(IEntity attribute) throws ArchivingException; public String exportFile2Db(final String attributeName) throws IOException, ArchivingException { - m_logger.trace(ILogger.LEVEL_DEBUG, "XXXXXXX FORCING export for " + attributeName); - final String result = filesNames.get(attributeName).switchFile(); - m_logger.trace(ILogger.LEVEL_DEBUG, "Export forced done for " + attributeName + " - " + result); + logger.trace(ILogger.LEVEL_DEBUG, "XXXXXXX FORCING export for " + attributeName); + final String result = filesNames.get(attributeName.toLowerCase()).switchFile(); + logger.trace(ILogger.LEVEL_DEBUG, "Export forced done for " + attributeName + " - " + result); return result; } protected void processFileScalar(final ScalarEvent scalarEvent) throws ArchivingException { String attrName = scalarEvent.getAttribute_complete_name(); - filesNames.get(attrName).processEventScalar(scalarEvent); + filesNames.get(attrName.toLowerCase()).processEventScalar(scalarEvent); } protected void processFileSpectrum(final SpectrumEvent_RO spectrumEvent) throws ArchivingException { String attrName = spectrumEvent.getAttribute_complete_name(); - filesNames.get(attrName).processEventSpectrum(spectrumEvent); + filesNames.get(attrName.toLowerCase()).processEventSpectrum(spectrumEvent); } protected void processFileSpectrum(final SpectrumEvent_RW spectrumEvent) throws ArchivingException { String attrName = spectrumEvent.getAttribute_complete_name(); - filesNames.get(attrName).processEventSpectrum(spectrumEvent); + filesNames.get(attrName.toLowerCase()).processEventSpectrum(spectrumEvent); } protected void processFileImage(final ImageEvent_RO imageEvent) throws ArchivingException { String attrName = imageEvent.getAttribute_complete_name(); - filesNames.get(attrName).processEventImage(imageEvent); + filesNames.get(attrName.toLowerCase()).processEventImage(imageEvent); } /** * Triggers the collecting action of this TdbCollector. */ - public synchronized void startCollecting() { + protected synchronized void startCollecting() { if (!attributeList.isEmpty()) { - if (attributeList.size() == 1) { + if (!attributeList.isRefresherStarted()) { attributeList.setRefreshInterval(m_modeHandler.getRefreshInterval()); attributeList.setSynchronizedPeriod(true); - // force a refresh for newly added attributes - m_logger.trace(ILogger.LEVEL_DEBUG, "start refresh for " + this.getClass()); attributeList.startRefresher(); refreshing = true; - if (keepingThread != null) { - keepingThread.start(); - } + logger.trace(ILogger.LEVEL_DEBUG, this.getClass() + " start refresh for " + attributeList.getSize() + + " attributes"); } else { // force a refresh for newly added attributes - m_logger.trace(ILogger.LEVEL_DEBUG, "FORCING refresh for " + this.getClass()); + logger.trace(ILogger.LEVEL_DEBUG, "FORCING refresh for " + this.getClass()); attributeList.refresh(); } } @@ -402,17 +392,12 @@ public abstract class TdbCollector extends ArchiverCollector { /** * Stops the collecting action of this TdbCollector. */ - public synchronized void stopCollecting() { - Util.out4.println("TdbCollector.stopCollecting"); + protected synchronized void stopCollecting() { try { - if (attributeList.isEmpty()) { - attributeList.stopRefresher(); - if (keepingThread != null) { - keepingThread.destroy(); - keepingThread = null; - } - refreshing = false; - } + logger.trace(ILogger.LEVEL_DEBUG, this.getClass() + " stop refresh on " + attributeList.getSize() + + " attributes"); + attributeList.stopRefresher(); + refreshing = false; } catch (final Exception e) { Util.out2.println("ERROR !! " + "\r\n" + "\t Origin : \t " + "TdbCollector.stopCollecting" + "\r\n" + "\t Reason : \t " + e.getClass().getName() + "\r\n" + "\t Description : \t " + e.getMessage() @@ -448,67 +433,6 @@ public abstract class TdbCollector extends ArchiverCollector { return refreshing; } - private class KeepingThread extends Thread { - long keeping_time = m_modeHandler.getMode().getTdbSpec().getKeepingPeriod(); - long sleeping_time = 10 * 60 * 1000; // Deletes records every 10 minutes - String state = "NOT RUNNING"; - - public KeepingThread() { - super("KeepingThread"); - } - - public void activate(final boolean b) { - if (b) { - state = "RUNNING"; - } else { - state = "NOT RUNNING"; - } - } - - /** - * This method is called by the system to give a Thread a chance to - * clean up before it actually exits. - */ - @Override - public void destroy() { - System.out.println("KeepingThread.destroy"); - activate(false); - interrupt(); - } - - @Override - public void run() { - System.out.println("KeepingThread.run"); - state = "RUNNING"; - while (state.equals("RUNNING")) { - try { - sleep(sleeping_time); - } catch (final InterruptedException e) { - activate(false); - /* - * System.err.println( "Reason : Unknown !!!" + - * "\r\n" + - * "Description : The thread does not want to sleep !!" + - * "\r\n" + "Origin : KeepingThread.run"); - * e.printStackTrace(); - */ - } - Util.out4.println("KeepingThread.run : Getting attribute list..."); - final AttributePolledList tmpAttributeList = attributeList; - final String[] m_attributeList = new String[tmpAttributeList.size()]; - for (int i = 0; i < m_attributeList.length; i++) { - m_attributeList[i] = ((IEntity) tmpAttributeList.getElementAt(i)).getName(); - } - try { - Util.out4.println("KeepingThread.run : Sending the attribute list to the database..."); - dbProxy.deleteOldRecords(keeping_time, m_attributeList); - } catch (final ArchivingException e) { - Util.out2.println(e.toString()); - } - } - } - } - protected void setLastTimestamp(final ArchivingEvent scalarEvent) { if (scalarEvent != null) { final String name = scalarEvent.getAttribute_complete_name(); @@ -538,7 +462,7 @@ public abstract class TdbCollector extends ArchiverCollector { final long newTime = scalarEvent.getTimeStamp(); if (newTime == 0) { - m_logger.trace(ILogger.LEVEL_WARNING, "NOARCHIVING - received a zero timestamp for " + name + logger.trace(ILogger.LEVEL_WARNING, "NOARCHIVING - received a zero timestamp for " + name + " - tableName: " + scalarEvent.getTable_name()); return false; } @@ -549,24 +473,25 @@ public abstract class TdbCollector extends ArchiverCollector { return true; } - final boolean isAlreadyRegisteredDate = lastTimestampStack.containsDate(newTime, m_logger); + final boolean isAlreadyRegisteredDate = lastTimestampStack.containsDate(newTime, logger); // System.out.println ( // "isDataArchivableTimestampWise/isAlreadyRegisteredDate/"+isAlreadyRegisteredDate); if (isAlreadyRegisteredDate) { - m_logger.trace(ILogger.LEVEL_DEBUG, "NOARCHIVING - AlreadyRegisteredDate - attribute: " + name + logger.trace(ILogger.LEVEL_DEBUG, "NOARCHIVING - AlreadyRegisteredDate - attribute: " + name + " - timestamp: " + new Timestamp(newTime)); return false; } - final boolean isValidRegisteredDate = lastTimestampStack.validateDate(newTime, m_logger); + final boolean isValidRegisteredDate = lastTimestampStack.validateDate(newTime, logger); // System.out.println ( // "isDataArchivableTimestampWise/isAlreadyRegisteredDate/"+isAlreadyRegisteredDate); if (!isValidRegisteredDate) { - m_logger.trace(ILogger.LEVEL_DEBUG, "NOARCHIVING - not ValidRegisteredDate - attribute: " + name + logger.trace(ILogger.LEVEL_DEBUG, "NOARCHIVING - not ValidRegisteredDate - attribute: " + name + " - timestamp: " + new Timestamp(newTime)); return false; } - + // m_logger.trace(ILogger.LEVEL_DEBUG, name + " timestamp OK: " + new + // Timestamp(newTime)); // System.out.println ( "isDataArchivableTimestampWise/name/3"); return true; } diff --git a/src/main/java/TdbArchiver/Collector/scalar/BooleanScalar.java b/src/main/java/TdbArchiver/Collector/scalar/BooleanScalar.java index b49a7ca9..fc736b7e 100644 --- a/src/main/java/TdbArchiver/Collector/scalar/BooleanScalar.java +++ b/src/main/java/TdbArchiver/Collector/scalar/BooleanScalar.java @@ -165,7 +165,7 @@ public class BooleanScalar extends TdbCollector implements IBooleanScalarListene } else { final String message = "event is null or empty: " + event; System.err.println(message); - m_logger.trace(ILogger.LEVEL_ERROR, message); + logger.trace(ILogger.LEVEL_ERROR, message); } } @@ -177,14 +177,14 @@ public class BooleanScalar extends TdbCollector implements IBooleanScalarListene String attributeName = scalarEvent.getAttribute_complete_name(); try { boolean doArchive = false; - if (isFirstValue) { - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + "Attribute Counters unknown"); + logger.trace(ILogger.LEVEL_ERROR, attributeName + "Attribute Counters unknown"); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); @@ -223,14 +223,14 @@ public class BooleanScalar extends TdbCollector implements IBooleanScalarListene final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + logger.trace(ILogger.LEVEL_ERROR, errorMess); try { processEventScalar( getNullValueScalarEvent(errorEvent, TangoConst.Tango_DEV_BOOLEAN, getWritableValue().value()), tryNumber); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/TdbArchiver/Collector/scalar/NumberScalar.java b/src/main/java/TdbArchiver/Collector/scalar/NumberScalar.java index e514bc00..b1993a87 100644 --- a/src/main/java/TdbArchiver/Collector/scalar/NumberScalar.java +++ b/src/main/java/TdbArchiver/Collector/scalar/NumberScalar.java @@ -206,14 +206,14 @@ public class NumberScalar extends TdbCollector implements INumberScalarListener scalarEvent.avoidUnderFlow(); boolean doArchive = false; - if (isFirstValue) { - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); + logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); @@ -354,7 +354,7 @@ public class NumberScalar extends TdbCollector implements INumberScalarListener } else { final String message = "event is null or empty: " + event; System.err.println(message); - m_logger.trace(ILogger.LEVEL_ERROR, message); + logger.trace(ILogger.LEVEL_ERROR, message); } } @@ -365,14 +365,14 @@ public class NumberScalar extends TdbCollector implements INumberScalarListener final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - super.m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + super.logger.trace(ILogger.LEVEL_ERROR, errorMess); try { processEventScalar( getNullValueScalarEvent(errorEvent, ((AAttribute) errorEvent.getSource()).getTangoDataType(), getWritableValue().value()), tryNumber); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/TdbArchiver/Collector/scalar/StateScalar.java b/src/main/java/TdbArchiver/Collector/scalar/StateScalar.java index 130ca902..faf55bee 100644 --- a/src/main/java/TdbArchiver/Collector/scalar/StateScalar.java +++ b/src/main/java/TdbArchiver/Collector/scalar/StateScalar.java @@ -55,14 +55,14 @@ public class StateScalar extends TdbCollector implements IDevStateScalarListener String attributeName = scalarEvent.getAttribute_complete_name(); try { boolean doArchive = false; - if (isFirstValue) { - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + "first value, forcing archiving"); + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); + logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); @@ -136,7 +136,7 @@ public class StateScalar extends TdbCollector implements IDevStateScalarListener } else { final String message = "event is null or empty: " + event; System.err.println(message); - m_logger.trace(ILogger.LEVEL_ERROR, message); + logger.trace(ILogger.LEVEL_ERROR, message); } } @@ -146,14 +146,14 @@ public class StateScalar extends TdbCollector implements IDevStateScalarListener final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - super.m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + super.logger.trace(ILogger.LEVEL_ERROR, errorMess); try { processEventScalar( getNullValueScalarEvent(errorEvent, TangoConst.Tango_DEV_STATE, getWritableValue().value()), DEFAULT_TRY_NUMBER); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/TdbArchiver/Collector/scalar/StringScalar.java b/src/main/java/TdbArchiver/Collector/scalar/StringScalar.java index 473aa0ab..d320b71c 100644 --- a/src/main/java/TdbArchiver/Collector/scalar/StringScalar.java +++ b/src/main/java/TdbArchiver/Collector/scalar/StringScalar.java @@ -73,15 +73,15 @@ public class StringScalar extends TdbCollector implements IStringScalarListener String attributeName = scalarEvent.getAttribute_complete_name(); try { boolean doArchive = false; - if (isFirstValue) { - m_logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); + if (isFirstValueList.get(attributeName.toLowerCase())) { doArchive = true; - isFirstValue = false; + isFirstValueList.put(attributeName.toLowerCase(), false); + logger.trace(ILogger.LEVEL_DEBUG, attributeName + " first value, forcing archiving"); } else { final ModesCounters mc = getModeCounter(attributeName); if (mc == null) { - m_logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); + logger.trace(ILogger.LEVEL_ERROR, attributeName + " Attribute Counters unknown"); } else { doArchive = doArchiveEvent(mc, scalarEvent.getData_type(), scalarEvent.getReadValue(), getLastValue(scalarEvent), attributeName); @@ -147,7 +147,7 @@ public class StringScalar extends TdbCollector implements IStringScalarListener } else { final String message = "event is null or empty: " + event; System.err.println(message); - m_logger.trace(ILogger.LEVEL_ERROR, message); + logger.trace(ILogger.LEVEL_ERROR, message); } } @@ -159,14 +159,14 @@ public class StringScalar extends TdbCollector implements IStringScalarListener final String errorMess = this.getClass().getSimpleName() + ".errorChange : Unable to read the attribute named " + errorEvent.getSource().toString(); Util.out3.println(errorMess); - super.m_logger.trace(ILogger.LEVEL_ERROR, errorMess); + super.logger.trace(ILogger.LEVEL_ERROR, errorMess); try { processEventScalar( getNullValueScalarEvent(errorEvent, TangoConst.Tango_DEV_STRING, getWritableValue().value()), tryNumber); } catch (final Exception e) { - super.m_logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + super.logger.trace(ILogger.LEVEL_ERROR, this.getClass().getSimpleName() + ".errorChange : during processEventScalar creation execp : " + e); e.printStackTrace(); } diff --git a/src/main/java/TdbArchiver/TdbArchiver.java b/src/main/java/TdbArchiver/TdbArchiver.java index 74537380..2b20d660 100644 --- a/src/main/java/TdbArchiver/TdbArchiver.java +++ b/src/main/java/TdbArchiver/TdbArchiver.java @@ -387,11 +387,13 @@ package TdbArchiver; import java.io.IOException; import java.sql.Timestamp; +import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; import java.util.Vector; +import java.util.concurrent.Executors; import org.omg.CORBA.SystemException; import org.omg.CORBA.UserException; @@ -652,24 +654,7 @@ public class TdbArchiver extends DeviceImpl implements TangoConst { TangoStateUtils.setFault(this, "database connection error"); get_logger().error("ERROR : Database unconnected !!"); } else { - try { - final Vector<AttributeLightMode> myCurrentTasks = dbProxy.getArchiverCurrentTasks(device_name); - if (myCurrentTasks != null && myCurrentTasks.size() > 0) { - final ArchivingMessConfig archivingMessConfig = ArchivingMessConfig.basicObjectCreation(); - for (int i = 0; i < myCurrentTasks.size(); i++) { - archivingMessConfig.add(myCurrentTasks.elementAt(i)); - } - - final boolean forceThreadedMode = false; - startArchiving(archivingMessConfig, forceThreadedMode, false); - } else { - TangoStateUtils.setOn(this, archivingStatus); - } - } catch (final DevFailed devFailed) { - final String message = DBTools.getCompleteMessage(devFailed); - get_logger().error(message); - TangoStateUtils.setFault(this, message); - } + Executors.newSingleThreadExecutor().submit(new InitDeviceTask()); } } @@ -708,6 +693,29 @@ public class TdbArchiver extends DeviceImpl implements TangoConst { } } + private class InitDeviceTask implements Runnable { + @Override + public void run() { + try { + final Vector<AttributeLightMode> myCurrentTasks = dbProxy.getArchiverCurrentTasks(device_name); + if (myCurrentTasks.size() > 0) { + final ArchivingMessConfig archivingMessConfig = ArchivingMessConfig.basicObjectCreation(); + for (final AttributeLightMode attributeLightMode : myCurrentTasks) { + archivingMessConfig.add(attributeLightMode); + } + triggerArchiving(archivingMessConfig.toArray(), false); + } else { + TangoStateUtils.setOn(TdbArchiver.this, archivingStatus); + } + } catch (final DevFailed devFailed) { + // triggerArchiving has thrown + TangoStateUtils.setDisable(TdbArchiver.this, archivingStatus); + } catch (ArchivingException e) { + TangoStateUtils.setFault(TdbArchiver.this, e.getMessage()); + } + } + } + private class StartArchivingRunnable implements Runnable { private final ArchivingMessConfig archivingMessConfig; private final boolean updateAMTTable; @@ -1065,6 +1073,9 @@ public class TdbArchiver extends DeviceImpl implements TangoConst { logger.trace(ILogger.LEVEL_ERROR, reason + " " + desc); archivingStatus.put(attCompleteName, false); logger.trace(ILogger.LEVEL_INFO, "KO: " + attCompleteName); + } catch (Exception e) { + e.printStackTrace(); + logger.trace(ILogger.LEVEL_ERROR, "KO " + attCompleteName + " unexpected " + e); } } diff --git a/src/test/resources/log4j.xml b/src/test/resources/log4j.xml deleted file mode 100644 index 89b5ee06..00000000 --- a/src/test/resources/log4j.xml +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - -<!-- An example log4j configuration xml file for log4jdbc --> -<!-- Logging levels are: --> -<!-- DEBUG < INFO < WARN < ERROR < FATAL --> - -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> - - <appender name="stdout-appender" class="org.apache.log4j.ConsoleAppender"> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p %c{1}: %m%n"/> - </layout> - </appender> - - <appender name="sql-appender" class="org.apache.log4j.FileAppender"> - <param name="File" value="./logs/sql.log"/> - <param name="Append" value="false"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="-----> %d{yyyy-MM-dd HH:mm:ss.SSS} <%t> %m%n%n"/> - </layout> - </appender> - - <appender name="sql-timing-appender" class="org.apache.log4j.FileAppender"> - <param name="File" value="./logs/sqltiming.log"/> - <param name="Append" value="false"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="-----> %d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%n"/> - </layout> - </appender> - - <appender name="jdbc-appender" class="org.apache.log4j.FileAppender"> - <param name="File" value="./logs/jdbc.log"/> - <param name="Append" value="false"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n"/> - </layout> - </appender> - - <appender name="jdbc-connection" class="org.apache.log4j.FileAppender"> - <param name="File" value="./logs/connection.log"/> - <param name="Append" value="false"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n"/> - </layout> - </appender> - - <!-- - The Following 5 logs can be turned on and off while the server is running - LIVE in order to trace the SQL and/or all JDBC coming out of the application. - - To turn a log on, set the level value to INFO or DEBUG (to see class name and - line number information in the log) The DEBUG setting is much more inefficient - but the output is much more useful. - - To turn off JDBC logging completely, you must set all 5 logs to a level higher - than ERROR (FATAL is suggested.) - --> - - <!-- log SQL (pre-execution) plus exceptions caused by SQL --> - <logger name="jdbc.sqlonly" additivity="false"> - <level value="debug"/> - <appender-ref ref="stdout-appender"/> - </logger> - - <!-- log SQL with timing information, post execution --> - <logger name="jdbc.sqltiming" additivity="false"> - <level value="error"/> - <appender-ref ref="stdout-appender"/> - </logger> - - <!-- only use the two logs below to trace ALL JDBC information, - NOTE: This can be very voluminous! --> - - <!-- log all jdbc calls except ResultSet calls --> - <logger name="jdbc.audit" additivity="false"> - <level value="error"/> - <appender-ref ref="stdout-appender"/> - </logger> - - <!-- log the jdbc ResultSet calls --> - <logger name="jdbc.resultset" additivity="false"> - <level value="error"/> - <appender-ref ref="stdout-appender"/> - </logger> - - <!-- log connection open/close events and dump of all open connection numbers --> - <logger name="jdbc.connection" additivity="false"> - <level value="error"/> - <appender-ref ref="stdout-appender"/> - </logger> - - <!-- this log is for internal debugging of log4jdbc, itself --> - <!-- debug logging for log4jdbc itself --> - <logger name="log4jdbc.debug" additivity="false"> - <level value="error"/> - <appender-ref ref="stdout-appender"/> - </logger> - - <!-- by default, log everything to the console with a level of WARN or higher --> - <root> - <level value="error"/> - <appender-ref ref="stdout-appender"/> - </root> -</log4j:configuration> \ No newline at end of file -- GitLab