/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public int size() { try { GridCacheQueueHeader hdr = (GridCacheQueueHeader)cache.get(queueKey); checkRemoved(hdr); return hdr.size(); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public Iterator<T> iterator() { try { GridCacheQueueHeader hdr = (GridCacheQueueHeader)cache.get(queueKey); checkRemoved(hdr); return new QueueIterator(hdr); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Nullable @Override public T peek() throws IgniteException { try { while (true) { GridCacheQueueHeader hdr = (GridCacheQueueHeader)cache.get(queueKey); checkRemoved(hdr); if (hdr.empty()) return null; T val = (T)cache.get(itemKey(hdr.head())); if (val == null) // Header might have been polled. Retry. continue; return val; } } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void clear(int batchSize) throws IgniteException { A.ensure(batchSize >= 0, "Batch size cannot be negative: " + batchSize); try { Object obj = cache.invoke(queueKey, new ClearProcessor(id)).get(); if (obj == null) return; IgniteBiTuple<Long, Long> t = obj instanceof BinaryObject ? ((BinaryObject)obj).deserialize() : (IgniteBiTuple<Long, Long>)obj; checkRemoved(t.get1()); removeKeys(cache, id, queueName, collocated, t.get1(), t.get2(), batchSize); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public Iterator<T> iterator() { try { GridCacheQueueHeader hdr = (GridCacheQueueHeader)cache.get(queueKey); checkRemoved(hdr); return new QueueIterator(hdr); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public int size() { try { GridCacheQueueHeader hdr = (GridCacheQueueHeader)cache.get(queueKey); checkRemoved(hdr); return hdr.size(); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Nullable @Override public T peek() throws IgniteException { try { while (true) { GridCacheQueueHeader hdr = (GridCacheQueueHeader)cache.get(queueKey); checkRemoved(hdr); if (hdr.empty()) return null; T val = (T)cache.get(itemKey(hdr.head())); if (val == null) // Header might have been polled. Retry. continue; return val; } } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void clear(int batchSize) throws IgniteException { A.ensure(batchSize >= 0, "Batch size cannot be negative: " + batchSize); try { IgniteBiTuple<Long, Long> t = (IgniteBiTuple<Long, Long>)cache.invoke(queueKey, new ClearProcessor(id)).get(); if (t == null) return; checkRemoved(t.get1()); removeKeys(cache, id, queueName, collocated, t.get1(), t.get2(), batchSize); } catch (IgniteCheckedException e) { throw U.convertException(e); } }