Skip to content

Commit

Permalink
#3047 Fixed multiple generation of event with the same error in Meta…
Browse files Browse the repository at this point in the history
… Data Point:

 - Added EVENT_TYPE_RECURSIVE_ERROR;
  • Loading branch information
Limraj committed Nov 15, 2024
1 parent 6e98fff commit 01011ce
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 13 deletions.
18 changes: 18 additions & 0 deletions src/com/serotonin/mango/rt/dataSource/meta/MetaDataSourceRT.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class MetaDataSourceRT extends DataSourceRT {
public static final int EVENT_TYPE_CONTEXT_POINT_DISABLED = 1;
public static final int EVENT_TYPE_SCRIPT_ERROR = 2;
public static final int EVENT_TYPE_RESULT_TYPE_ERROR = 3;
public static final int EVENT_TYPE_RECURSIVE_ERROR = 4;

private final List<DataPointRT> points = new CopyOnWriteArrayList<DataPointRT>();
@Deprecated(since = "2.8.0")
Expand Down Expand Up @@ -111,6 +112,15 @@ public void raiseScriptError(long runtime, DataPointRT dataPoint, LocalizableMes
.getVO().getName(), message), dataPoint);
}

public void raiseRecursiveError(long runtime, DataPointRT dataPoint, LocalizableMessage message) {
if(isNone(EVENT_TYPE_RECURSIVE_ERROR)) {
setUnreliableDataPoint(dataPoint);
return;
}
raiseEvent(EVENT_TYPE_RECURSIVE_ERROR, runtime, true, new LocalizableMessage("event.meta.recursiveError", dataPoint
.getVO().getName(), message), dataPoint);
}

public void raiseContextError(long runtime, DataPointRT dataPoint, LocalizableMessage message) {
if(isNone(EVENT_TYPE_CONTEXT_POINT_DISABLED)) {
setUnreliableDataPoint(dataPoint);
Expand All @@ -127,6 +137,14 @@ public void returnToNormalScript(long runtime, DataPointRT dataPoint) {
returnToNormal(EVENT_TYPE_SCRIPT_ERROR, runtime, dataPoint);
}

public void returnToNormalRecursive(long runtime, DataPointRT dataPoint) {
if(isNone(EVENT_TYPE_RECURSIVE_ERROR)) {
resetUnreliableDataPoint(dataPoint);
return;
}
returnToNormal(EVENT_TYPE_RECURSIVE_ERROR, runtime, dataPoint);
}

public void returnToNormalContext(long runtime, DataPointRT dataPoint) {
if(isNone(EVENT_TYPE_CONTEXT_POINT_DISABLED)) {
resetUnreliableDataPoint(dataPoint);
Expand Down
12 changes: 10 additions & 2 deletions src/com/serotonin/mango/rt/dataSource/meta/MetaPointLocatorRT.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ private void execute(long runtime, List<Integer> sourceIds, boolean initializeMo
}

if (count > MAX_RECURSION) {
handleScriptError(runtime, dataPoint, new LocalizableMessage("event.meta.recursionFailure"));
handleRecursiveError(runtime, dataPoint, new LocalizableMessage("event.meta.recursionFailure"));
String msg = MessageFormat.format("Recursion failure: exceeded MAX_RECURSION: expected <= {0} but was {1}, Context: {2}",
String.valueOf(MAX_RECURSION), count, generateContext(dataPoint, dataSource));
LOG.warn(msg);
return;
} else {
returnToNormal(runtime, dataPoint);
returnToNormalRecursive(runtime, dataPoint);
}

sourceIds.add(dataPoint.getId());
Expand Down Expand Up @@ -370,6 +370,10 @@ protected void doUpdate(PointValueTime pvt, DataPointRT dataPoint) {
returnToNormal(System.currentTimeMillis(), dataPoint);
}

protected void handleRecursiveError(long runtime, DataPointRT dataPoint, LocalizableMessage message) {
dataSource.raiseRecursiveError(runtime, dataPoint, message);
}

protected void handleScriptError(long runtime, DataPointRT dataPoint, LocalizableMessage message) {
dataSource.raiseScriptError(runtime, dataPoint, message);
}
Expand All @@ -382,6 +386,10 @@ protected void returnToNormal(long runtime, DataPointRT dataPoint) {
dataSource.returnToNormalScript(runtime, dataPoint);
}

protected void returnToNormalRecursive(long runtime, DataPointRT dataPoint) {
dataSource.returnToNormalRecursive(runtime, dataPoint);
}

protected void returnToNormalContext(long runtime, DataPointRT dataPoint) {
dataSource.returnToNormalContext(runtime, dataPoint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ protected void addEventTypes(List<EventTypeVO> ets) {
new LocalizableMessage("event.ds.scriptError")));
ets.add(createEventType(MetaDataSourceRT.EVENT_TYPE_RESULT_TYPE_ERROR, new LocalizableMessage(
"event.ds.resultType")));
ets.add(createEventType(MetaDataSourceRT.EVENT_TYPE_RECURSIVE_ERROR, new LocalizableMessage(
"event.ds.recursiveError")));
}

private static final ExportCodes EVENT_CODES = new ExportCodes();
static {
EVENT_CODES.addElement(MetaDataSourceRT.EVENT_TYPE_CONTEXT_POINT_DISABLED, "CONTEXT_POINT_DISABLED");
EVENT_CODES.addElement(MetaDataSourceRT.EVENT_TYPE_SCRIPT_ERROR, "SCRIPT_ERROR");
EVENT_CODES.addElement(MetaDataSourceRT.EVENT_TYPE_RESULT_TYPE_ERROR, "RESULT_TYPE_ERROR");
EVENT_CODES.addElement(MetaDataSourceRT.EVENT_TYPE_RECURSIVE_ERROR, "RECURSIVE_ERROR");
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion webapp-resources/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3365,4 +3365,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3368,4 +3368,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3408,4 +3408,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3493,4 +3493,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3362,4 +3362,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_lu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3381,4 +3381,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3483,4 +3483,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3505,4 +3505,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3520,4 +3520,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3516,4 +3516,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}
4 changes: 3 additions & 1 deletion webapp-resources/messages_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3468,4 +3468,6 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom CSS has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
event.ds.recursiveError=Recursive Error
event.meta.recursiveError=Recursive error in point "{0}": {1}

0 comments on commit 01011ce

Please sign in to comment.