hazelcast

Can a distributed priority blocking queue be used (somehow) for hazelcast distributed executor services?


I can create a "standalone, normal" (ie not using Hazelcast; not distributed) executor service using a priority blocking queue by following the simple example from https://jvmaware.com/priority-queue-and-threadpool/

However, I tried to adapt the same strategy to support PRIORITIZATION of submitted tasks for Hazelcast, but couldn't get it to work. Is there a way I can pass a Hazelcast distributed priority queue to the Hazelcast executor service to use? (I tried to do ConcurrencyUtil.setDefaultAsyncExecutor(tpe); where tpe is the custom thread pool executor as described in the first link, but this did not work.


Solution

  • I don't think you can change the underlying queue implementation for IExecutorService from configuration.

    If you look at the source code that creates ExecutorService implementation

    https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/spi/impl/executionservice/impl/ExecutionServiceImpl.java#L198

    You can see that NamedThreadPoolExecutor is created with a hard coded LinkedBlockingQueue

    And the CachedExecutorServiceDelegate also has hard coded LinkedBlockingQueue https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/internal/util/executor/CachedExecutorServiceDelegate.java#L68