Use better overflow strategy
This commit is contained in:
parent
b71f3dceed
commit
e3fcf7f74f
@ -59,6 +59,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.warp.commonutils.log.Logger;
|
||||
import org.warp.commonutils.log.LoggerFactory;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.FluxSink.OverflowStrategy;
|
||||
import reactor.core.publisher.GroupedFlux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Scheduler;
|
||||
@ -563,9 +564,9 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
requestsAvailable.release();
|
||||
});
|
||||
|
||||
try {
|
||||
luceneQueryScheduler.schedule(() -> {
|
||||
try {
|
||||
requestsAvailable.acquire();
|
||||
if (!cancelled.get()) {
|
||||
if (doDistributedPre) {
|
||||
allowOnlyQueryParsingCollectorStreamSearcher.search(indexSearcher, luceneQuery);
|
||||
@ -581,13 +582,16 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
keyFieldName,
|
||||
keyScore -> {
|
||||
try {
|
||||
if (requests.get() <= 0 && !cancelled.get()) {
|
||||
requestsAvailable.acquire();
|
||||
}
|
||||
if (cancelled.get()) {
|
||||
return HandleResult.HALT;
|
||||
}
|
||||
requests.updateAndGet(n -> n > 0 ? n - 1 : 0);
|
||||
while (requests.get() <= 0) {
|
||||
requestsAvailable.acquire();
|
||||
if (cancelled.get()) {
|
||||
return HandleResult.HALT;
|
||||
}
|
||||
}
|
||||
requests.decrementAndGet();
|
||||
sink.next(fixKeyScore(keyScore, scoreDivisor));
|
||||
return HandleResult.CONTINUE;
|
||||
} catch (Exception ex) {
|
||||
@ -599,10 +603,16 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
},
|
||||
totalHitsCount -> {
|
||||
try {
|
||||
if (requests.get() <= 0 && !cancelled.get()) {
|
||||
requestsAvailable.acquire();
|
||||
if (cancelled.get()) {
|
||||
return;
|
||||
}
|
||||
requests.updateAndGet(n -> n > 0 ? n - 1 : 0);
|
||||
while (requests.get() <= 0) {
|
||||
requestsAvailable.acquire();
|
||||
if (cancelled.get()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
requests.decrementAndGet();
|
||||
sink.next(new LLTotalHitsCount(totalHitsCount));
|
||||
} catch (Exception ex) {
|
||||
sink.error(ex);
|
||||
@ -618,7 +628,10 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
sink.error(ex);
|
||||
}
|
||||
});
|
||||
}).subscribeOn(Schedulers.boundedElastic()))));
|
||||
} catch (Exception ex) {
|
||||
sink.error(ex);
|
||||
}
|
||||
}, OverflowStrategy.ERROR).subscribeOn(Schedulers.boundedElastic()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user