@Test public void noRoot() { Iterator<Journal.JournalEntry> iterator = new InodeTreeBufferedIterator(mInodeStore, null); Assert.assertFalse(iterator.hasNext()); }
@Override public boolean hasNext() { if (mNextElements.size() == 1 && mNextElements.peekFirst().getSequenceNumber() == TERMINATION_SEQ) { return false; } if (mNextElements.size() > 0) { return true; } while (true) { if (!mBufferingActive.get() && mEntryBuffer.size() == 0) { return false; } try { if (0 == mEntryBuffer.drainTo(mNextElements)) { Journal.JournalEntry entry; while (mBufferingActive.get() || mEntryBuffer.size() > 0) { entry = mEntryBuffer.poll(30, TimeUnit.SECONDS); if (entry != null) { mNextElements.addLast(entry); break; } } } if (mNextElements.size() == 1) { return mNextElements.peekLast().getSequenceNumber() != TERMINATION_SEQ; } else { return mNextElements.size() > 0; } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw new RuntimeException("Thread interrupted while taking an entry from buffer."); } } }
InodeTreeBufferedIterator implements Iterator<Journal.JournalEntry> { @Override public boolean hasNext() { if (mNextElements.size() == 1 && mNextElements.peekFirst().getSequenceNumber() == TERMINATION_SEQ) { return false; } if (mNextElements.size() > 0) { return true; } while (true) { if (!mBufferingActive.get() && mEntryBuffer.size() == 0) { return false; } try { if (0 == mEntryBuffer.drainTo(mNextElements)) { Journal.JournalEntry entry; while (mBufferingActive.get() || mEntryBuffer.size() > 0) { entry = mEntryBuffer.poll(30, TimeUnit.SECONDS); if (entry != null) { mNextElements.addLast(entry); break; } } } if (mNextElements.size() == 1) { return mNextElements.peekLast().getSequenceNumber() != TERMINATION_SEQ; } else { return mNextElements.size() > 0; } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw new RuntimeException("Thread interrupted while taking an entry from buffer."); } } } }
InodeTreeBufferedIterator implements Iterator<Journal.JournalEntry> { @Override public boolean hasNext() { if (mNextElements.size() == 1 && mNextElements.peekFirst().getSequenceNumber() == TERMINATION_SEQ) { return false; } if (mNextElements.size() > 0) { return true; } while (true) { if (!mBufferingActive.get() && mEntryBuffer.size() == 0) { return false; } try { if (0 == mEntryBuffer.drainTo(mNextElements)) { Journal.JournalEntry entry; while (mBufferingActive.get() || mEntryBuffer.size() > 0) { entry = mEntryBuffer.poll(30, TimeUnit.SECONDS); if (entry != null) { mNextElements.addLast(entry); break; } } } if (mNextElements.size() == 1) { return mNextElements.peekLast().getSequenceNumber() != TERMINATION_SEQ; } else { return mNextElements.size() > 0; } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw new RuntimeException("Thread interrupted while taking an entry from buffer."); } } } InodeTreeBufferedIterator(InodeStore inodeStore, InodeDirectory rootInode); }
InodeTreeBufferedIterator implements Iterator<Journal.JournalEntry> { @Override public boolean hasNext() { if (mNextElements.size() == 1 && mNextElements.peekFirst().getSequenceNumber() == TERMINATION_SEQ) { return false; } if (mNextElements.size() > 0) { return true; } while (true) { if (!mBufferingActive.get() && mEntryBuffer.size() == 0) { return false; } try { if (0 == mEntryBuffer.drainTo(mNextElements)) { Journal.JournalEntry entry; while (mBufferingActive.get() || mEntryBuffer.size() > 0) { entry = mEntryBuffer.poll(30, TimeUnit.SECONDS); if (entry != null) { mNextElements.addLast(entry); break; } } } if (mNextElements.size() == 1) { return mNextElements.peekLast().getSequenceNumber() != TERMINATION_SEQ; } else { return mNextElements.size() > 0; } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw new RuntimeException("Thread interrupted while taking an entry from buffer."); } } } InodeTreeBufferedIterator(InodeStore inodeStore, InodeDirectory rootInode); @Override boolean hasNext(); @Override Journal.JournalEntry next(); @Override void remove(); }
InodeTreeBufferedIterator implements Iterator<Journal.JournalEntry> { @Override public boolean hasNext() { if (mNextElements.size() == 1 && mNextElements.peekFirst().getSequenceNumber() == TERMINATION_SEQ) { return false; } if (mNextElements.size() > 0) { return true; } while (true) { if (!mBufferingActive.get() && mEntryBuffer.size() == 0) { return false; } try { if (0 == mEntryBuffer.drainTo(mNextElements)) { Journal.JournalEntry entry; while (mBufferingActive.get() || mEntryBuffer.size() > 0) { entry = mEntryBuffer.poll(30, TimeUnit.SECONDS); if (entry != null) { mNextElements.addLast(entry); break; } } } if (mNextElements.size() == 1) { return mNextElements.peekLast().getSequenceNumber() != TERMINATION_SEQ; } else { return mNextElements.size() > 0; } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw new RuntimeException("Thread interrupted while taking an entry from buffer."); } } } InodeTreeBufferedIterator(InodeStore inodeStore, InodeDirectory rootInode); @Override boolean hasNext(); @Override Journal.JournalEntry next(); @Override void remove();  }