Skip to content
Snippets Groups Projects
Commit d5969006 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

SuperMode moved from hdbtdbArchivingServers to hdbtdbArchivingApi

Use AttrSuperMode for better analyze of why an attribute is not archived in getErrorMessageForAttribute
parent 182ec21e
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import HdbArchiver.Collector.Tools.SuperMode;
import HdbArchiver.Collector.image.Image_RO;
import HdbArchiver.Collector.scalar.BooleanScalar_RO;
import HdbArchiver.Collector.scalar.BooleanScalar_RW;
......@@ -151,10 +150,12 @@ import fr.soleil.archiving.common.api.tools.GlobalConst;
import fr.soleil.archiving.hdbtdb.api.tools.ArchivingException;
import fr.soleil.archiving.hdbtdb.api.tools.AttributeLightMode;
import fr.soleil.archiving.hdbtdb.api.tools.AttributeSupport;
import fr.soleil.archiving.hdbtdb.api.tools.mode.AttrSuperMode;
import fr.soleil.archiving.hdbtdb.api.tools.mode.SuperMode;
public final class HdbCollectorFactory {
private final Map<SuperMode, HdbCollector> tableCollector = new HashMap<SuperMode, HdbCollector>();
private final Map<SuperMode, String> collectorErrorTable = new ConcurrentHashMap<SuperMode, String>();
private final Map<AttrSuperMode, String> collectorErrorTable = new ConcurrentHashMap<AttrSuperMode, String>();
private final Logger logger;
public HdbCollectorFactory(final Logger logger) {
......@@ -196,10 +197,14 @@ public final class HdbCollectorFactory {
*/
public void createCollectorAndAddSource(final AttributeLightMode attributeLightMode, final DbProxy dbProxy)
throws ArchivingException {
if (attributeLightMode != null) {
logger.trace("createCollectorAndAddSource for " + attributeLightMode);
final SuperMode superMode = new SuperMode(attributeLightMode.getDataFormat(), attributeLightMode.getDataType(),
attributeLightMode.getWritable(), attributeLightMode.getMode());
final SuperMode superMode = new SuperMode(attributeLightMode.getDataFormat(),
attributeLightMode.getDataType(), attributeLightMode.getWritable(), attributeLightMode.getMode());
ArchivingException lastException = null;
final AttrSuperMode attrSuperMode = new AttrSuperMode(attributeLightMode.getAttribute_complete_name(),
attributeLightMode.getDataFormat(), attributeLightMode.getDataType(),
attributeLightMode.getWritable(), attributeLightMode.getMode());
synchronized (tableCollector) {
try {
HdbCollector collector = tableCollector.get(superMode);
......@@ -209,14 +214,14 @@ public final class HdbCollectorFactory {
collector.setDbProxy(dbProxy);
collector.addSource(attributeLightMode);
tableCollector.put(superMode, collector);
collectorErrorTable.remove(superMode);
collectorErrorTable.remove(attrSuperMode);
} else {
logger.trace("use existing collector " + collector.assessment());
collector.addSource(attributeLightMode);
collectorErrorTable.remove(superMode);
collectorErrorTable.remove(attrSuperMode);
}
} catch (ArchivingException e) {
collectorErrorTable.put(superMode, e.getMessage());
collectorErrorTable.put(attrSuperMode, e.getMessage());
lastException = e;
}
}
......@@ -224,14 +229,16 @@ public final class HdbCollectorFactory {
throw lastException;
}
}
}
public String getLastError(AttributeLightMode attributeLightMode) {
String result;
if (attributeLightMode == null) {
result = null;
} else {
result = collectorErrorTable.get(new SuperMode(attributeLightMode.getDataFormat(), attributeLightMode
.getDataType(), attributeLightMode.getWritable(), attributeLightMode.getMode()));
result = collectorErrorTable.get(new AttrSuperMode(attributeLightMode.getAttribute_complete_name(),
attributeLightMode.getDataFormat(), attributeLightMode.getDataType(), attributeLightMode
.getWritable(), attributeLightMode.getMode()));
}
if (result == null) {
result = "";
......
//+======================================================================
// $Source: /cvsroot/tango-cs/tango/jserver/archiving/HdbArchiver/Collector/Tools/SuperMode.java,v $
//
// Project: Tango Archiving Service
//
// Description: Java source code for the class SuperMode.
// (Chinkumo Jean) - Apr 27, 2004
//
// $Author: chinkumo $
//
// $Revision: 1.4 $
//
// $Log: SuperMode.java,v $
// Revision 1.4 2005/11/29 17:33:53 chinkumo
// no message
//
// Revision 1.3.16.3 2005/11/29 16:16:05 chinkumo
// Code reformated (pogo compatible)
//
// Revision 1.3.16.2 2005/11/15 13:46:08 chinkumo
// ...
//
// Revision 1.3.16.1 2005/09/26 08:01:20 chinkumo
// Minor changes !
//
// Revision 1.3 2005/02/04 17:10:12 chinkumo
// The trouble with the grouped stopping strategy was fixed.
//
// Revision 1.2 2005/01/26 16:38:15 chinkumo
// Ultimate synchronization before real sharing.
//
// Revision 1.1 2004/12/06 16:43:25 chinkumo
// First commit (new architecture).
//
//
// copyleft : Synchrotron SOLEIL
// L'Orme des Merisiers
// Saint-Aubin - BP 48
// 91192 GIF-sur-YVETTE CEDEX
//
//-======================================================================
package HdbArchiver.Collector.Tools;
import fr.soleil.archiving.hdbtdb.api.tools.mode.Mode;
public class SuperMode {
private int format;
private int type;
private int writable;
private Mode mode = null;
public SuperMode(int format, int type, int writable, Mode mode) {
this.format = format;
this.type = type;
this.writable = writable;
this.mode = mode;
}
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof SuperMode))
return false;
final SuperMode superMode = (SuperMode) o;
if (format != superMode.format)
return false;
if (type != superMode.type)
return false;
if (writable != superMode.writable)
return false;
if (!mode.equals(superMode.mode))
return false;
return true;
}
public int hashCode() {
int result;
result = format;
result = 29 * result + type;
result = 29 * result + writable;
result = 29 * result + mode.hashCode();
return result;
}
}
......@@ -124,7 +124,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import TdbArchiver.Collector.Tools.SuperMode;
import TdbArchiver.Collector.image.Image_RO;
import TdbArchiver.Collector.scalar.BooleanScalar;
import TdbArchiver.Collector.scalar.NumberScalar;
......@@ -141,10 +140,12 @@ import fr.soleil.archiving.common.api.tools.GlobalConst;
import fr.soleil.archiving.hdbtdb.api.tools.ArchivingException;
import fr.soleil.archiving.hdbtdb.api.tools.AttributeLightMode;
import fr.soleil.archiving.hdbtdb.api.tools.AttributeSupport;
import fr.soleil.archiving.hdbtdb.api.tools.mode.AttrSuperMode;
import fr.soleil.archiving.hdbtdb.api.tools.mode.SuperMode;
public class TdbCollectorFactory {
private final Map<SuperMode, TdbCollector> tableCollector = new HashMap<SuperMode, TdbCollector>();
private final Map<SuperMode, String> collectorErrorTable = new ConcurrentHashMap<SuperMode, String>();
private final Map<AttrSuperMode, String> collectorErrorTable = new ConcurrentHashMap<AttrSuperMode, String>();
private final Logger logger;
private String m_currentDbPath = "";
......@@ -197,6 +198,9 @@ public class TdbCollectorFactory {
final int attributePerFile) throws ArchivingException {
final SuperMode superMode = new SuperMode(attributeLightMode.getDataFormat(), attributeLightMode.getDataType(),
attributeLightMode.getWritable(), attributeLightMode.getMode());
final AttrSuperMode attrSuperMode = new AttrSuperMode(attributeLightMode.getAttribute_complete_name(),
attributeLightMode.getDataFormat(), attributeLightMode.getDataType(), attributeLightMode.getWritable(),
attributeLightMode.getMode());
TdbCollector collector = null;
ArchivingException lastException = null;
synchronized (tableCollector) {
......@@ -208,13 +212,13 @@ public class TdbCollectorFactory {
// collector.setDiaryLogger(logger);
collector.addSource(attributeLightMode, attributePerFile);
tableCollector.put(superMode, collector);
collectorErrorTable.remove(superMode);
collectorErrorTable.remove(attrSuperMode);
} else {
collector.addSource(attributeLightMode, attributePerFile);
collectorErrorTable.remove(superMode);
collectorErrorTable.remove(attrSuperMode);
}
} catch (ArchivingException e) {
collectorErrorTable.put(superMode, e.getMessage());
collectorErrorTable.put(attrSuperMode, e.getMessage());
lastException = e;
}
}
......@@ -228,8 +232,9 @@ public class TdbCollectorFactory {
if (attributeLightMode == null) {
result = null;
} else {
result = collectorErrorTable.get(new SuperMode(attributeLightMode.getDataFormat(), attributeLightMode
.getDataType(), attributeLightMode.getWritable(), attributeLightMode.getMode()));
result = collectorErrorTable.get(new AttrSuperMode(attributeLightMode.getAttribute_complete_name(),
attributeLightMode.getDataFormat(), attributeLightMode.getDataType(), attributeLightMode
.getWritable(), attributeLightMode.getMode()));
}
if (result == null) {
result = "";
......
//+======================================================================
// $Source: /cvsroot/tango-cs/tango/jserver/archiving/TdbArchiver/Collector/Tools/SuperMode.java,v $
//
// Project: Tango Archiving Service
//
// Description: Java source code for the class SuperMode.
// (Chinkumo Jean) - Apr 27, 2004
//
// $Author: chinkumo $
//
// $Revision: 1.3 $
//
// $Log: SuperMode.java,v $
// Revision 1.3 2005/11/29 17:34:14 chinkumo
// no message
//
// Revision 1.2.14.3 2005/11/29 16:15:11 chinkumo
// Code reformated (pogo compatible)
//
// Revision 1.2.14.2 2005/11/15 13:45:38 chinkumo
// ...
//
// Revision 1.2.14.1 2005/09/26 08:01:54 chinkumo
// Minor changes !
//
// Revision 1.2 2005/02/04 17:10:38 chinkumo
// The trouble with the grouped stopping strategy was fixed.
//
// Revision 1.1 2004/12/06 16:43:25 chinkumo
// First commit (new architecture).
//
// Revision 1.3 2004/09/01 15:52:05 chinkumo
// Heading was updated.
//
//
// copyleft : Synchrotron SOLEIL
// L'Orme des Merisiers
// Saint-Aubin - BP 48
// 91192 GIF-sur-YVETTE CEDEX
//
//-======================================================================
package TdbArchiver.Collector.Tools;
import fr.soleil.archiving.hdbtdb.api.tools.mode.Mode;
public class SuperMode {
private int format;
private int type;
private int writable;
private Mode mode = null;
public SuperMode(int format, int type, int writable, Mode mode) {
this.format = format;
this.type = type;
this.writable = writable;
this.mode = mode;
}
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof SuperMode))
return false;
final SuperMode superMode = (SuperMode) o;
if (format != superMode.format)
return false;
if (type != superMode.type)
return false;
if (writable != superMode.writable)
return false;
if (!mode.equals(superMode.mode))
return false;
return true;
}
public int hashCode() {
int result;
result = format;
result = 29 * result + type;
result = 29 * result + writable;
result = 29 * result + mode.hashCode();
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment