@Override public void init(InitializationContext ctx) { this.configuration = ctx.getConfiguration(); this.ctx = ctx; this.scheduler = Schedulers.from(ctx.getExecutor()); this.timeService = ctx.getTimeService(); this.semaphore = new Semaphore(Integer.MAX_VALUE, true); }
@Override public Publisher<MarshalledEntry<K, V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata) { return Flowable.defer(() -> { // Make sure that we update directories before we start iterating upon directories scanForUnknownDirectories(); return Flowable.fromIterable(openDirectories.values()); }) // We parallelize this since the loading below is blocking .parallel() .runOn(Schedulers.from(ctx.getExecutor())) .flatMap(dir -> { final Set<MarshalledEntry<K, V>> allInternalEntries = new HashSet<>(); dir.loadAllEntries(allInternalEntries, Integer.MAX_VALUE, ctx.getMarshaller()); return Flowable.fromIterable(allInternalEntries); }) .filter(me -> filter == null || filter.test(me.getKey())) .sequential(); }
@Override public void init(InitializationContext ctx) { this.configuration = ctx.getConfiguration(); this.emfRegistry = ctx.getCache().getAdvancedCache().getComponentRegistry().getGlobalComponentRegistry().getComponent(EntityManagerFactoryRegistry.class); this.marshallerEntryFactory = ctx.getMarshalledEntryFactory(); this.marshaller = ctx.getMarshaller(); this.timeService = ctx.getTimeService(); this.executorService = ctx.getExecutor(); }