@Test public void testPut() { assertNotNull(blockQueueProvider); assertEquals(0, blockQueueProvider.size()); Block block = new Block(); boolean result = blockQueueProvider.put(new BlockContainer(block, BlockContainerStatus.RECEIVED)); assertTrue(result); assertEquals(1, blockQueueProvider.size()); }
public boolean put(BlockContainer blockContainer) { boolean receive = (blockContainer.getStatus() == BlockContainerStatus.RECEIVED); if (receive) { int status = BlockContainerStatus.RECEIVED; checkDownloadService(); if (!downloadService.isDownloadSuccess().isSuccess()) { status = BlockContainerStatus.DOWNLOADING; } blockContainer.setStatus(status); blockQueue.offer(blockContainer); } else { if (downloadBlockQueueHasDestory) { initDownloadQueue(); } downloadBlockQueue.offer(blockContainer); } return true; }
BlockQueueProvider { public boolean put(BlockContainer blockContainer) { boolean receive = (blockContainer.getStatus() == BlockContainerStatus.RECEIVED); if (receive) { int status = BlockContainerStatus.RECEIVED; checkDownloadService(); if (!downloadService.isDownloadSuccess().isSuccess()) { status = BlockContainerStatus.DOWNLOADING; } blockContainer.setStatus(status); blockQueue.offer(blockContainer); } else { if (downloadBlockQueueHasDestory) { initDownloadQueue(); } downloadBlockQueue.offer(blockContainer); } return true; } }
BlockQueueProvider { public boolean put(BlockContainer blockContainer) { boolean receive = (blockContainer.getStatus() == BlockContainerStatus.RECEIVED); if (receive) { int status = BlockContainerStatus.RECEIVED; checkDownloadService(); if (!downloadService.isDownloadSuccess().isSuccess()) { status = BlockContainerStatus.DOWNLOADING; } blockContainer.setStatus(status); blockQueue.offer(blockContainer); } else { if (downloadBlockQueueHasDestory) { initDownloadQueue(); } downloadBlockQueue.offer(blockContainer); } return true; } private  BlockQueueProvider(); }
BlockQueueProvider { public boolean put(BlockContainer blockContainer) { boolean receive = (blockContainer.getStatus() == BlockContainerStatus.RECEIVED); if (receive) { int status = BlockContainerStatus.RECEIVED; checkDownloadService(); if (!downloadService.isDownloadSuccess().isSuccess()) { status = BlockContainerStatus.DOWNLOADING; } blockContainer.setStatus(status); blockQueue.offer(blockContainer); } else { if (downloadBlockQueueHasDestory) { initDownloadQueue(); } downloadBlockQueue.offer(blockContainer); } return true; } private  BlockQueueProvider(); static BlockQueueProvider getInstance(); boolean put(BlockContainer blockContainer); BlockContainer get(); long size(); void clear(); }
BlockQueueProvider { public boolean put(BlockContainer blockContainer) { boolean receive = (blockContainer.getStatus() == BlockContainerStatus.RECEIVED); if (receive) { int status = BlockContainerStatus.RECEIVED; checkDownloadService(); if (!downloadService.isDownloadSuccess().isSuccess()) { status = BlockContainerStatus.DOWNLOADING; } blockContainer.setStatus(status); blockQueue.offer(blockContainer); } else { if (downloadBlockQueueHasDestory) { initDownloadQueue(); } downloadBlockQueue.offer(blockContainer); } return true; } private  BlockQueueProvider(); static BlockQueueProvider getInstance(); boolean put(BlockContainer blockContainer); BlockContainer get(); long size(); void clear();  }