Skip to content

Commit

Permalink
HWKALERTS-193 Split min-reporting-interval config (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce authored and jshaughn committed Nov 7, 2016
1 parent 0d27875 commit 678afdf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public class DroolsRulesEngineImpl implements RulesEngine {
private static final long PERF_BATCHING_THRESHOLD = 3000L; // 3 seconds
private static final long PERF_FIRING_THRESHOLD = 5000L; // 5 seconds

private int minReportingInterval;
private int minReportingIntervalData;
private int minReportingIntervalEvents;

private KieServices ks;
private KieContainer kc;
Expand All @@ -77,10 +78,15 @@ public DroolsRulesEngineImpl() {
kSession.addEventListener(new DebugRuleRuntimeEventListener());
}

minReportingInterval = new Integer(
AlertProperties.getProperty(MIN_REPORTING_INTERVAL,
MIN_REPORTING_INTERVAL_ENV,
MIN_REPORTING_INTERVAL_DEFAULT));
minReportingIntervalData = new Integer(
AlertProperties.getProperty(MIN_REPORTING_INTERVAL_DATA,
MIN_REPORTING_INTERVAL_DATA_ENV,
MIN_REPORTING_INTERVAL_DATA_DEFAULT));

minReportingIntervalEvents = new Integer(
AlertProperties.getProperty(MIN_REPORTING_INTERVAL_EVENTS,
MIN_REPORTING_INTERVAL_EVENTS_ENV,
MIN_REPORTING_INTERVAL_EVENTS_DEFAULT));
}

@Override
Expand Down Expand Up @@ -204,7 +210,7 @@ private void batchData() {
kSession.insert(d);

} else {
if ((d.getTimestamp() - previousData.getTimestamp()) < minReportingInterval) {
if ((d.getTimestamp() - previousData.getTimestamp()) < minReportingIntervalData) {
log.tracef("MinReportingInterval violation, prev: %s, removed: %s", previousData, d);
} else {
pendingData.add(d);
Expand Down Expand Up @@ -239,7 +245,7 @@ private void batchEvents() {
kSession.insert(e);

} else {
if ((e.getCtime() - previousEvent.getCtime()) < minReportingInterval) {
if ((e.getCtime() - previousEvent.getCtime()) < minReportingIntervalEvents) {
log.tracef("MinReportingInterval violation, prev: %s, removed: %s", previousEvent, e);
} else {
pendingEvents.add(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
public class IncomingDataManagerImpl implements IncomingDataManager {
private final Logger log = Logger.getLogger(IncomingDataManagerImpl.class);

private int minReportingInterval;
private int minReportingIntervalData;
private int minReportingIntervalEvents;

@Resource
private ManagedExecutorService executor;
Expand All @@ -76,10 +77,15 @@ public class IncomingDataManagerImpl implements IncomingDataManager {
@PostConstruct
public void init() {
try {
minReportingInterval = new Integer(
AlertProperties.getProperty(RulesEngine.MIN_REPORTING_INTERVAL,
RulesEngine.MIN_REPORTING_INTERVAL_ENV,
RulesEngine.MIN_REPORTING_INTERVAL_DEFAULT));
minReportingIntervalData = new Integer(
AlertProperties.getProperty(RulesEngine.MIN_REPORTING_INTERVAL_DATA,
RulesEngine.MIN_REPORTING_INTERVAL_DATA_ENV,
RulesEngine.MIN_REPORTING_INTERVAL_DATA_DEFAULT));

minReportingIntervalEvents = new Integer(
AlertProperties.getProperty(RulesEngine.MIN_REPORTING_INTERVAL_EVENTS,
RulesEngine.MIN_REPORTING_INTERVAL_EVENTS_ENV,
RulesEngine.MIN_REPORTING_INTERVAL_EVENTS_DEFAULT));
} catch (Throwable t) {
if (log.isDebugEnabled()) {
t.printStackTrace();
Expand Down Expand Up @@ -165,7 +171,7 @@ private void enforceMinReportingInterval(TreeSet<Data> orderedData) {
if (!d.same(prev)) {
prev = d;
} else {
if ((d.getTimestamp() - prev.getTimestamp()) < minReportingInterval) {
if ((d.getTimestamp() - prev.getTimestamp()) < minReportingIntervalData) {
log.tracef("MinReportingInterval violation, prev: %s, removed: %s", prev, d);
i.remove();
}
Expand All @@ -184,7 +190,7 @@ private void enforceMinReportingIntervalEvents(TreeSet<Event> orderedEvents) {
if (!e.same(prev)) {
prev = e;
} else {
if ((e.getCtime() - prev.getCtime()) < minReportingInterval) {
if ((e.getCtime() - prev.getCtime()) < minReportingIntervalEvents) {
log.tracef("MinReportingInterval violation, prev: %s, removed: %s", prev, e);
i.remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
*/
public interface RulesEngine {

String MIN_REPORTING_INTERVAL = "hawkular-alerts.min-reporting-interval";
String MIN_REPORTING_INTERVAL_ENV = "HAWKULAR_MIN_REPORTING_INTERVAL";
String MIN_REPORTING_INTERVAL_DEFAULT = "1000";
String MIN_REPORTING_INTERVAL_DATA = "hawkular-alerts.min-reporting-interval-data";
String MIN_REPORTING_INTERVAL_DATA_ENV = "HAWKULAR_MIN_REPORTING_INTERVAL_DATA";
String MIN_REPORTING_INTERVAL_DATA_DEFAULT = "1000";

String MIN_REPORTING_INTERVAL_EVENTS = "hawkular-alerts.min-reporting-interval-events";
String MIN_REPORTING_INTERVAL_EVENTS_ENV = "HAWKULAR_MIN_REPORTING_INTERVAL_EVENTS";
String MIN_REPORTING_INTERVAL_EVENTS_DEFAULT = "0";

void addGlobal(String name, Object global);

Expand Down

0 comments on commit 678afdf

Please sign in to comment.