mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(iot): release rule capacity when worker evaluation ends (#6272)
Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
1 parent
9790b5fe46
commit
433ab5aefc
2 files changed
+105
-13
No files matched your search
@@ -757,19 +757,33 @@ public class IotMqttBrokerService implements Resettable {
|
||||
}
|
||||
return;
|
||||
}
|
||||
ruleWorker.executeBlocking(() -> {
|
||||
if (ruleState.get() == admitted) {
|
||||
rules.run();
|
||||
}
|
||||
return null;
|
||||
}, false).onComplete(result -> {
|
||||
if (pendingRuleEvaluations.decrementAndGet() == 0) {
|
||||
ruleEvaluationsThrottled.set(false);
|
||||
}
|
||||
if (result.failed()) {
|
||||
LOG.warnv(result.cause(), "IoT rule evaluation for topic {0} failed", topic);
|
||||
}
|
||||
});
|
||||
AtomicBoolean released = new AtomicBoolean();
|
||||
try {
|
||||
ruleWorker.executeBlocking(() -> {
|
||||
try {
|
||||
if (ruleState.get() == admitted) {
|
||||
rules.run();
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
releaseRuleEvaluation(released);
|
||||
}
|
||||
}, false).onComplete(result -> {
|
||||
releaseRuleEvaluation(released);
|
||||
if (result.failed()) {
|
||||
LOG.warnv(result.cause(), "IoT rule evaluation for topic {0} failed", topic);
|
||||
}
|
||||
});
|
||||
} catch (RuntimeException dispatchFailure) {
|
||||
releaseRuleEvaluation(released);
|
||||
throw dispatchFailure;
|
||||
}
|
||||
}
|
||||
|
||||
private void releaseRuleEvaluation(AtomicBoolean released) {
|
||||
if (released.compareAndSet(false, true) && pendingRuleEvaluations.decrementAndGet() == 0) {
|
||||
ruleEvaluationsThrottled.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void fanOut(String topic, byte[] payload, boolean retained) {
|
||||
|
||||
Reference in new issue
Block a user