/** * @param cctx Cache context. * @param e Entry. */ private void handleBackupEntry(final GridCacheContext cctx, CacheContinuousQueryEntry e) { if (internal || e.updateCounter() == -1L || nodeLeft) // Skip internal query and expire entries. return; CacheContinuousQueryEventBuffer buf = partitionBuffer(cctx, e.partition()); buf.processEntry(e.copyWithDataReset(), true); }
/** * @param res Current result. * @param batch Current batch. * @param backup Backup entry flag. * @return New result. */ @Nullable private Object processPending(@Nullable Object res, Batch batch, boolean backup) { if (pending.floorKey(batch.endCntr) != null) { for (Map.Entry<Long, CacheContinuousQueryEntry> p : pending.headMap(batch.endCntr, true).entrySet()) { long cntr = p.getKey(); assert cntr <= batch.endCntr; if (pending.remove(p.getKey()) != null) { if (cntr < batch.startCntr) res = addResult(res, p.getValue(), backup); else res = batch.processEntry0(res, p.getKey(), p.getValue(), backup); } } } return res; }
/** * @param topVer Current event topology version. * @return Current batch. */ @Nullable private Batch initBatch(AffinityTopologyVersion topVer) { Batch batch = curBatch.get(); if (batch != null) return batch; for (;;) { long curCntr = currentPartitionCounter(); if (curCntr == -1) return null; batch = new Batch(curCntr + 1, 0L, new CacheContinuousQueryEntry[BUF_SIZE], topVer); if (curBatch.compareAndSet(null, batch)) return batch; batch = curBatch.get(); if (batch != null) return batch; } }
batch = initBatch(entry.topologyVersion()); batch = batch0; res = processPending(res, batch, backup); batch0 = initBatch(entry.topologyVersion());
long filtered = b.currentFiltered(); Object o = entries.get(i); Object res = b.processEntry((CacheContinuousQueryEntry)o, false);
/** {@inheritDoc} */ @Override public void onNodeLeft() { nodeLeft = true; for (Map.Entry<Integer, CacheContinuousQueryEventBuffer> bufE : entryBufs.entrySet()) { CacheContinuousQueryEventBuffer buf = bufE.getValue(); buf.flushOnExchange(); } }
/** * @param e Entry to process. * @param backup Backup entry flag. * @return Collected entries to pass to listener (single entry or entries list). */ @Nullable Object processEntry(CacheContinuousQueryEntry e, boolean backup) { return process0(e.updateCounter(), e, backup); }
batch = initBatch(entry.topologyVersion()); batch = batch0; res = processPending(res, batch, backup); batch0 = initBatch(entry.topologyVersion());
/** {@inheritDoc} */ @Override public void onNodeLeft() { nodeLeft = true; for (Map.Entry<Integer, CacheContinuousQueryEventBuffer> bufE : entryBufs.entrySet()) { CacheContinuousQueryEventBuffer buf = bufE.getValue(); buf.flushOnExchange(); } }
/** * @param e Entry to process. * @param backup Backup entry flag. * @return Collected entries to pass to listener (single entry or entries list). */ @Nullable Object processEntry(CacheContinuousQueryEntry e, boolean backup) { return process0(e.updateCounter(), e, backup); }
@Override public Object call() throws Exception { barrier.await(); Object o; while ((o = q.poll()) != null) { Object res = b.processEntry((CacheContinuousQueryEntry)o, false); if (res != null) { if (res instanceof CacheContinuousQueryEntry) act0.put(((CacheContinuousQueryEntry)res).updateCounter(), (CacheContinuousQueryEntry)res); else { for (CacheContinuousQueryEntry e : ((List<CacheContinuousQueryEntry>)res)) act0.put(e.updateCounter(), e); } } } return null; } }, threads, "test");
/** * @param res Current result. * @param batch Current batch. * @param backup Backup entry flag. * @return New result. */ @Nullable private Object processPending(@Nullable Object res, Batch batch, boolean backup) { if (pending.floorKey(batch.endCntr) != null) { for (Map.Entry<Long, CacheContinuousQueryEntry> p : pending.headMap(batch.endCntr, true).entrySet()) { long cntr = p.getKey(); assert cntr <= batch.endCntr; if (pending.remove(p.getKey()) != null) { if (cntr < batch.startCntr) res = addResult(res, p.getValue(), backup); else res = batch.processEntry0(res, p.getKey(), p.getValue(), backup); } } } return res; }
/** * @param topVer Current event topology version. * @return Current batch. */ @Nullable private Batch initBatch(AffinityTopologyVersion topVer) { Batch batch = curBatch.get(); if (batch != null) return batch; for (;;) { long curCntr = currentPartitionCounter(); if (curCntr == -1) return null; batch = new Batch(curCntr + 1, 0L, new CacheContinuousQueryEntry[BUF_SIZE], topVer); if (curBatch.compareAndSet(null, batch)) return batch; batch = curBatch.get(); if (batch != null) return batch; } }
/** * @param cctx Cache context. * @param e Entry. * @return Entry. */ private Object handleEntry(final GridCacheContext cctx, CacheContinuousQueryEntry e) { assert e != null; assert entryBufs != null; if (internal) { if (e.isFiltered()) return null; else return e; } // Initial query entry. // This events should be fired immediately. if (e.updateCounter() == -1L) return e; CacheContinuousQueryEventBuffer buf = partitionBuffer(cctx, e.partition()); return buf.processEntry(e, false); }
/** * @param cctx Cache context. * @param e Entry. */ private void handleBackupEntry(final GridCacheContext cctx, CacheContinuousQueryEntry e) { if (internal || e.updateCounter() == -1L || nodeLeft) // Skip internal query and expire entries. return; CacheContinuousQueryEventBuffer buf = partitionBuffer(cctx, e.partition()); buf.processEntry(e.copyWithDataReset(), true); }
/** * @param cctx Cache context. * @param e Entry. * @return Entry. */ private Object handleEntry(final GridCacheContext cctx, CacheContinuousQueryEntry e) { assert e != null; assert entryBufs != null; if (internal) { if (e.isFiltered()) return null; else return e; } // Initial query entry. // This events should be fired immediately. if (e.updateCounter() == -1L) return e; CacheContinuousQueryEventBuffer buf = partitionBuffer(cctx, e.partition()); return buf.processEntry(e, false); }