|
|
|
@ -210,14 +210,14 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
|
|
|
|
public boolean isRequiresScheduledReevaluation() { |
|
|
|
long now = System.currentTimeMillis(); |
|
|
|
long cfCheckIntervalMillis = TimeUnit.SECONDS.toMillis(systemContext.getCfCheckInterval()); |
|
|
|
if (calculatedField.getConfiguration() instanceof EntityAggregationCalculatedFieldConfiguration entityAggregationConfig) { |
|
|
|
Watermark watermark = entityAggregationConfig.getWatermark(); |
|
|
|
if (watermark != null && watermark.getDuration() > 0) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
long intervalEndTs = entityAggregationConfig.getInterval().getCurrentIntervalEndTs(); |
|
|
|
if (now + cfCheckIntervalMillis >= intervalEndTs) { |
|
|
|
long intervalDurationMillis = entityAggregationConfig.getInterval().getCurrentIntervalDurationMillis(); |
|
|
|
if (now - lastReevaluationTs >= intervalDurationMillis) { |
|
|
|
lastReevaluationTs = now; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -225,7 +225,7 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
if (calculatedField.getConfiguration() instanceof AlarmCalculatedFieldConfiguration) { |
|
|
|
long reevaluationIntervalMillis = TimeUnit.SECONDS.toMillis(systemContext.getAlarmRulesReevaluationInterval()); |
|
|
|
if (requiresScheduledReevaluation) { |
|
|
|
if (now + cfCheckIntervalMillis >= lastReevaluationTs + reevaluationIntervalMillis) { |
|
|
|
if (now - lastReevaluationTs >= reevaluationIntervalMillis) { |
|
|
|
lastReevaluationTs = now; |
|
|
|
return true; |
|
|
|
} |
|
|
|
@ -618,8 +618,8 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
return true; |
|
|
|
} |
|
|
|
if (calculatedField.getConfiguration() instanceof SimpleCalculatedFieldConfiguration thisConfig |
|
|
|
&& other.calculatedField.getConfiguration() instanceof SimpleCalculatedFieldConfiguration otherConfig |
|
|
|
&& thisConfig.isUseLatestTs() != otherConfig.isUseLatestTs()) { |
|
|
|
&& other.calculatedField.getConfiguration() instanceof SimpleCalculatedFieldConfiguration otherConfig |
|
|
|
&& thisConfig.isUseLatestTs() != otherConfig.isUseLatestTs()) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
if (cfType == CalculatedFieldType.ALARM) { |
|
|
|
@ -638,12 +638,12 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
return true; |
|
|
|
} |
|
|
|
if (calculatedField.getConfiguration() instanceof RelatedEntitiesAggregationCalculatedFieldConfiguration thisConfig |
|
|
|
&& other.getCalculatedField().getConfiguration() instanceof RelatedEntitiesAggregationCalculatedFieldConfiguration otherConfig |
|
|
|
&& (thisConfig.getDeduplicationIntervalInSec() != otherConfig.getDeduplicationIntervalInSec() || !thisConfig.getMetrics().equals(otherConfig.getMetrics()))) { |
|
|
|
&& other.getCalculatedField().getConfiguration() instanceof RelatedEntitiesAggregationCalculatedFieldConfiguration otherConfig |
|
|
|
&& (thisConfig.getDeduplicationIntervalInSec() != otherConfig.getDeduplicationIntervalInSec() || !thisConfig.getMetrics().equals(otherConfig.getMetrics()))) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
if (calculatedField.getConfiguration() instanceof EntityAggregationCalculatedFieldConfiguration thisConfig |
|
|
|
&& other.getCalculatedField().getConfiguration() instanceof EntityAggregationCalculatedFieldConfiguration otherConfig) { |
|
|
|
&& other.getCalculatedField().getConfiguration() instanceof EntityAggregationCalculatedFieldConfiguration otherConfig) { |
|
|
|
boolean metricsChanged = thisConfig.getMetrics().equals(otherConfig.getMetrics()); |
|
|
|
boolean watermarkChanged = thisConfig.getWatermark().equals(otherConfig.getWatermark()); |
|
|
|
return metricsChanged || watermarkChanged; |
|
|
|
@ -679,7 +679,7 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
|
|
|
|
private boolean hasGeofencingZoneGroupConfigurationChanges(CalculatedFieldCtx other) { |
|
|
|
if (calculatedField.getConfiguration() instanceof GeofencingCalculatedFieldConfiguration thisConfig |
|
|
|
&& other.calculatedField.getConfiguration() instanceof GeofencingCalculatedFieldConfiguration otherConfig) { |
|
|
|
&& other.calculatedField.getConfiguration() instanceof GeofencingCalculatedFieldConfiguration otherConfig) { |
|
|
|
return !thisConfig.getZoneGroups().equals(otherConfig.getZoneGroups()); |
|
|
|
} |
|
|
|
return false; |
|
|
|
@ -687,7 +687,7 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
|
|
|
|
private boolean hasRelatedEntitiesAggregationConfigurationChanges(CalculatedFieldCtx other) { |
|
|
|
if (calculatedField.getConfiguration() instanceof RelatedEntitiesAggregationCalculatedFieldConfiguration thisConfig |
|
|
|
&& other.calculatedField.getConfiguration() instanceof RelatedEntitiesAggregationCalculatedFieldConfiguration otherConfig) { |
|
|
|
&& other.calculatedField.getConfiguration() instanceof RelatedEntitiesAggregationCalculatedFieldConfiguration otherConfig) { |
|
|
|
return !thisConfig.getRelation().equals(otherConfig.getRelation()); |
|
|
|
} |
|
|
|
return false; |
|
|
|
@ -695,7 +695,7 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
|
|
|
|
private boolean hasEntityAggregationConfigurationChanges(CalculatedFieldCtx other) { |
|
|
|
if (calculatedField.getConfiguration() instanceof EntityAggregationCalculatedFieldConfiguration thisConfig |
|
|
|
&& other.calculatedField.getConfiguration() instanceof EntityAggregationCalculatedFieldConfiguration otherConfig) { |
|
|
|
&& other.calculatedField.getConfiguration() instanceof EntityAggregationCalculatedFieldConfiguration otherConfig) { |
|
|
|
return !thisConfig.getInterval().equals(otherConfig.getInterval()); |
|
|
|
} |
|
|
|
return false; |
|
|
|
@ -720,7 +720,7 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
yield true; |
|
|
|
} |
|
|
|
yield geofencingState.getLastDynamicArgumentsRefreshTs() < |
|
|
|
System.currentTimeMillis() - scheduledUpdateIntervalMillis; |
|
|
|
System.currentTimeMillis() - scheduledUpdateIntervalMillis; |
|
|
|
} |
|
|
|
default -> false; |
|
|
|
}; |
|
|
|
@ -764,10 +764,10 @@ public class CalculatedFieldCtx implements Closeable { |
|
|
|
@Override |
|
|
|
public String toString() { |
|
|
|
return "CalculatedFieldCtx{" + |
|
|
|
"cfId=" + cfId + |
|
|
|
", cfType=" + cfType + |
|
|
|
", entityId=" + entityId + |
|
|
|
'}'; |
|
|
|
"cfId=" + cfId + |
|
|
|
", cfType=" + cfType + |
|
|
|
", entityId=" + entityId + |
|
|
|
'}'; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|