use of com.swiftmq.impl.streams.comp.memory.RetirementCallback in project swiftmq-ce by iitsoftware.
the class CountLimit method checkTumbling.
private void checkTumbling() {
try {
if (memory.size() >= n) {
Memory retired = null;
RetirementCallback callback = memory.retirementCallback();
if (callback != null) {
retired = new HeapMemory(ctx);
retired.orderBy(memory.orderBy());
for (int i = 0; i < n; i++) {
retired.add(memory.at(i));
}
}
for (int i = 0; i < n; i++) {
memory.remove(0);
}
if (callback != null)
callback.execute(retired);
}
} catch (Exception e) {
ctx.logStackTrace(e);
}
}
use of com.swiftmq.impl.streams.comp.memory.RetirementCallback in project swiftmq-ce by iitsoftware.
the class CountLimit method checkSlidingLimit.
private void checkSlidingLimit() {
try {
if (memory.size() >= n) {
int toRemove = memory.size() + 1 - n;
Memory retired = null;
RetirementCallback callback = memory.retirementCallback();
if (callback != null) {
retired = new HeapMemory(ctx);
retired.orderBy(memory.orderBy());
for (int i = 0; i < toRemove; i++) {
retired.add(memory.at(i));
}
}
for (int i = 0; i < toRemove; i++) {
memory.remove(0);
}
if (callback != null)
callback.execute(retired);
}
} catch (Exception e) {
ctx.logStackTrace(e);
}
}
Aggregations