Skip to content

Commit

Permalink
Merge branch 'release/2.7.5.4' into feature/#2618_Improved_stability_…
Browse files Browse the repository at this point in the history
…for_a_large_number_of_events
  • Loading branch information
Limraj authored Jul 22, 2023
2 parents 429b19e + 1b58360 commit fb3c76d
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 43 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Semgrep
on:
workflow_dispatch: {}
pull_request: {}
push:
branches:
- 'master'
- 'develop'
- 'release/[0-9].[0-9]+.[0-9]+'
paths:
- .github/workflows/semgrep.yml
schedule:
# random HH:MM to avoid a load spike on GitHub Actions at 00:00
- cron: '17 18 * * *'
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-20.04
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
container:
image: returntocorp/semgrep
if: (github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
- run: semgrep ci
4 changes: 3 additions & 1 deletion WebContent/WEB-INF/snippet/changeContentText.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
onkeypress="if (event.keyCode==13) $('txtSet${componentId}').onclick();"/>
<a id="txtSet${componentId}" class="ptr"
onclick="mango.view.setPoint(${point.id}, '${componentId}', $('txtChange${componentId}').value);"><fmt:message key="common.set"/></a>
</br>Double click to close
<c:if test="${!hideClosingHint}" >
</br>Double click to close
</c:if>
<tag:relinquish/>
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ task clearTomcat(type: Delete) {
delete file(System.getenv("CATALINA_HOME") + "/webapps/ScadaBR.war")
}

task deployTomcat(type: Copy) {
task existsScadaLTSWarFile {
doLast {
assert file("build/libs/Scada-LTS.war").exists()
}
}

task deployTomcat(type: Copy, dependsOn: existsScadaLTSWarFile) {
from "build/libs/"
into System.getenv("CATALINA_HOME")+ "/webapps"
include('Scada-LTS.war')
Expand Down
2 changes: 1 addition & 1 deletion scadalts-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"datapointDetails.valueHistory.stats.max": "Maximum Value:",
"datapointDetails.valueHistory.stats.min": "Minimum Value:",
"datapointDetails.valueHistory.stats.sum": "Summary Value:",
"datapointDetails.valueHistory.stats.timeperiod": "Show history form",
"datapointDetails.valueHistory.stats.timeperiod": "Show history from",
"datapointDetails.valueHistory.subtitle": "History",
"datapointDetails.valueHistory.table.count": "Count",
"datapointDetails.valueHistory.table.date": "Date",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public String getSourceDescriptionKey() {
return "annotation.user";
case SetPointSource.Types.POINT_LINK:
return "annotation.pointLink";
default:
return "annotation.unknown";
}
return null;
}

public String getSourceDescriptionArgument() {
Expand Down
2 changes: 1 addition & 1 deletion src/com/serotonin/mango/web/dwr/BaseDwr.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public Map<String, Object> getDateRangeDefaults(int periodType, int period) {
}

protected String getMessage(String key) {
return I18NUtils.getMessage(getResourceBundle(), key);
return I18NUtils.getMessage(getResourceBundle(), key == null ? "" : key);
}

protected String getMessage(LocalizableMessage message) {
Expand Down
5 changes: 3 additions & 2 deletions src/com/serotonin/mango/web/dwr/DataPointDetailsDwr.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ public WatchListState getPointData() {
PointValueTime pointValue = prepareBasePointState(Integer.toString(pointVO.getId()), state, pointVO, pointRT,
model);
setPrettyTextWithoutEqual(state, pointVO, model, pointValue);
if (state.getValue() != null)
if (state.getValue() != null) {
model.put("hideClosingHint", true);
setChange(pointVO, state, pointRT, request, model, user);

}
setEvents(pointVO, user, model);
setMessages(state, request, "watchListMessages", model);

Expand Down
2 changes: 1 addition & 1 deletion src/org/scada_lts/dao/MaintenanceEventDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public MaintenanceEventVO mapRow(ResultSet rs, int rowNum) throws SQLException {
maintenanceEvent.setAlias(rs.getString(COLUMN_NAME_ALIAS));
maintenanceEvent.setAlarmLevel(rs.getInt(COLUMN_NAME_ALARM_LEVEL));
maintenanceEvent.setScheduleType(rs.getInt(COLUMN_NAME_SCHEDULE_TYPE));
maintenanceEvent.setDisabled(DAO.charToBool(COLUMN_NAME_DISABLED));
maintenanceEvent.setDisabled(DAO.charToBool(rs.getString(COLUMN_NAME_DISABLED)));
maintenanceEvent.setActiveYear(rs.getInt(COLUMN_NAME_ACTIVE_YEAR));
maintenanceEvent.setActiveMonth(rs.getInt(COLUMN_NAME_ACTIVE_MONTH));
maintenanceEvent.setActiveDay(rs.getInt(COLUMN_NAME_ACTIVE_DAY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.context.MessageSource;
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;

@Deprecated(since = "2.7.5.4")
public class CustomSQLEroorCodesTranslator extends SQLErrorCodeSQLExceptionTranslator {

@Resource
Expand Down
10 changes: 10 additions & 0 deletions src/org/scada_lts/dao/model/UserAlarmLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
package org.scada_lts.dao.model;

import com.serotonin.mango.rt.event.AlarmLevels;
import com.serotonin.mango.rt.event.EventInstance;
import com.serotonin.mango.vo.User;
import org.scada_lts.web.ws.model.AlarmLevelMessage;

/**
* Model for buffering UnsilencedAlarmLevel
Expand All @@ -43,6 +45,14 @@ public static UserAlarmLevel onlyUser(User user) {
return new UserAlarmLevel(user, AlarmLevels.NONE);
}

public static UserAlarmLevel fromEvent(User user, EventInstance eventInstance) {
return new UserAlarmLevel(user, eventInstance.getAlarmLevel());
}

public AlarmLevelMessage toAlarmLevelMessage() {
return new AlarmLevelMessage(alarmLevel);
}

public int getUserId() {
return userId;
}
Expand Down
44 changes: 21 additions & 23 deletions src/org/scada_lts/service/HighestAlarmLevelServiceWithCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,18 @@ public int getAlarmLevel(User user) {

@Override
public boolean doUpdateAlarmLevel(User user, EventInstance event, BiConsumer<User, AlarmLevelMessage> send) {
if(event.getAlarmLevel() > highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) {
this.lock.writeLock().lock();
try {
if(event.getAlarmLevel() > highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) {
highestAlarmLevelCache.putAlarmLevel(user, new UserAlarmLevel(user, event.getAlarmLevel()));
send.accept(user, new AlarmLevelMessage(event.getAlarmLevel()));
return true;
}
} finally {
this.lock.writeLock().unlock();
this.lock.writeLock().lock();
try {
UserAlarmLevel userAlarmLevel = highestAlarmLevelCache.getAlarmLevel(user);
if(event.getAlarmLevel() > userAlarmLevel.getAlarmLevel()) {
highestAlarmLevelCache.putAlarmLevel(user, UserAlarmLevel.fromEvent(user, event));
send.accept(user, AlarmLevelMessage.alarmLevelFromEvent(event));
return true;
}
return false;
} finally {
this.lock.writeLock().unlock();
}
return false;
}

@Override
Expand All @@ -90,19 +89,18 @@ public boolean doSendAlarmLevel(User user, BiConsumer<User, AlarmLevelMessage> s

@Override
public boolean doRemoveAlarmLevel(User user, EventInstance event, BiConsumer<User, AlarmLevelMessage> send) {
if(event.getAlarmLevel() == highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) {
this.lock.writeLock().lock();
try {
if (event.getAlarmLevel() == highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) {
highestAlarmLevelCache.removeAlarmLevel(user);
send.accept(user, new AlarmLevelMessage(highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()));
return true;
}
} finally {
this.lock.writeLock().unlock();
this.lock.writeLock().lock();
try {
UserAlarmLevel userAlarmLevel = highestAlarmLevelCache.getAlarmLevel(user);
if (event.getAlarmLevel() == userAlarmLevel.getAlarmLevel()) {
highestAlarmLevelCache.removeAlarmLevel(user);
send.accept(user, highestAlarmLevelCache.getAlarmLevel(user).toAlarmLevelMessage());
return true;
}
return false;
} finally {
this.lock.writeLock().unlock();
}
return false;
}

@Override
Expand All @@ -122,7 +120,7 @@ private boolean doSend(User user, BiConsumer<User, AlarmLevelMessage> send) {
try {
UserAlarmLevel alarmLevel = highestAlarmLevelCache.getAlarmLevel(user);
if(alarmLevel.getAlarmLevel() >= AlarmLevels.NONE) {
send.accept(user, new AlarmLevelMessage(alarmLevel.getAlarmLevel()));
send.accept(user, alarmLevel.toAlarmLevelMessage());
return true;
}
return false;
Expand Down
11 changes: 11 additions & 0 deletions src/org/scada_lts/web/ws/model/AlarmLevelMessage.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.scada_lts.web.ws.model;

import com.serotonin.mango.rt.event.AlarmLevels;
import com.serotonin.mango.rt.event.EventInstance;

public class AlarmLevelMessage {
private final int alarmLevel;

Expand All @@ -13,6 +16,14 @@ public static AlarmLevelMessage empty() {
return EMPTY;
}

public static AlarmLevelMessage noneAlarmLevel() {
return new AlarmLevelMessage(AlarmLevels.NONE);
}

public static AlarmLevelMessage alarmLevelFromEvent(EventInstance eventInstance) {
return new AlarmLevelMessage(eventInstance.getAlarmLevel());
}

public int getAlarmlevel() {
return alarmLevel;
}
Expand Down
3 changes: 2 additions & 1 deletion webapp-resources/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3323,4 +3323,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3326,4 +3326,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3366,4 +3366,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
5 changes: 3 additions & 2 deletions webapp-resources/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2485,8 +2485,8 @@ engUnit.86=imperial gallons per minute
engUnit.87=liters per second
engUnit.88=liters per minute
engUnit.89=us gallons per minute
engUnit.90=degrees angular
engUnit.91=degrees celsius per hour
engUnit.90=degrees angular
engUnit.92=degrees celsius per minute
engUnit.93=degrees fahrenheit per hour
engUnit.94=degrees fahrenheit per minute
Expand Down Expand Up @@ -3452,4 +3452,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3320,4 +3320,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_lu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3339,4 +3339,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3442,4 +3442,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3464,4 +3464,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3478,4 +3478,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3474,4 +3474,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknown
3 changes: 2 additions & 1 deletion webapp-resources/messages_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3427,4 +3427,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen
user.view.forceAdminTitle=The function is enforced by the Admin
validate.1to255=Must be between 1 and 255 inclusive
systemsettings.event.pendingLimit=Event Pending Limit
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache
annotation.unknown=Unknow

0 comments on commit fb3c76d

Please sign in to comment.