@Override public E peek() { if (isEmpty()) { return null; } return elements[start]; }
@Override public E remove() { if (isEmpty()) { throw new NoSuchElementException("queue is empty"); } final E element = elements[start]; if (null != element) { elements[start++] = null; if (start >= maxElements) { start = 0; } full = false; } return element; }
@Override public E element() { if (isEmpty()) { throw new NoSuchElementException("queue is empty"); } return peek(); }
@Override public E poll() { if (isEmpty()) { return null; } return remove(); }
if (m_memoryQueue.isEmpty())
public void flushToServer() { if (buffer.isEmpty()) { return; } List sent = new ArrayList(); try { synchronized (buffer) { while (!buffer.isEmpty()) { sent.add(buffer.remove()); } } StringBuilder result = new StringBuilder(); for (Object string : sent) { result.append(string); result.append("\n"); } consoleAppender.append(result.toString()); } catch (IOException e) { LOGGER.warn("Could not send console output to server", e); synchronized (buffer) { sent.addAll(buffer); buffer.clear(); buffer.addAll(sent); } } }
@Override protected List<DataPointEvent> get(int batchSize) if (m_memoryQueue.isEmpty()) waitForEvent();
@Override public synchronized void onBlock(BlockSummary blockSummary) { if (replayComplete) { if (onBlockBuffer.isEmpty()) { listener.onBlock(blockSummary); } else { logger.info("Replaying cached " + onBlockBuffer.size() + " blocks..."); boolean lastBlockFound = lastReplayedBlock == null || onBlockBuffer.size() < onBlockBuffer.maxSize(); for (BlockSummary block : onBlockBuffer) { if (!lastBlockFound) { lastBlockFound = FastByteComparisons.equal(block.getBlock().getHash(), lastReplayedBlock.getHash()); } else { listener.onBlock(block); } } onBlockBuffer.clear(); listener.onBlock(blockSummary); logger.info("Cache replay complete. Switching to online mode."); } } else { onBlockBuffer.add(blockSummary); } }
@Override public E peek() { if (isEmpty()) { return null; } return elements[start]; }
@Override public E remove() { if (isEmpty()) { throw new NoSuchElementException("queue is empty"); } final E element = elements[start]; if (null != element) { elements[start++] = null; if (start >= maxElements) { start = 0; } full = false; } return element; }
@Override public E poll() { if (isEmpty()) { return null; } return remove(); }
@Override public E element() { if (isEmpty()) { throw new NoSuchElementException("queue is empty"); } return peek(); }