BlockListAsLongs implements Iterable<BlockReportReplica> { abstract public long[] getBlockListAsLongs();  static BlockListAsLongs decodeBuffer(final int numBlocks,
      final ByteString blocksBuf); static BlockListAsLongs decodeBuffers(final int numBlocks,
      final List<ByteString> blocksBufs); static BlockListAsLongs decodeLongs(List<Long> blocksList); static BlockListAsLongs encode(
      final Collection<? extends Replica> replicas); static Builder builder(); abstract int getNumberOfBlocks(); abstract ByteString getBlocksBuffer(); List<ByteString> getBlocksBuffers(); abstract long[] getBlockListAsLongs(); abstract Iterator<BlockReportReplica> iterator(); static BlockListAsLongs EMPTY; }
@Test public void testEmptyReport() { BlockListAsLongs blocks = checkReport(); assertArrayEquals( new long[] { 0, 0, -1, -1, -1 }, blocks.getBlockListAsLongs()); }
@Test public void testFinalized() { BlockListAsLongs blocks = checkReport( new FinalizedReplica(b1, null, null)); assertArrayEquals( new long[] { 1, 0, 1, 11, 111, -1, -1, -1 }, blocks.getBlockListAsLongs()); }
@Test public void testUc() { BlockListAsLongs blocks = checkReport( new ReplicaBeingWritten(b1, null, null, null)); assertArrayEquals( new long[] { 0, 1, -1, -1, -1, 1, 11, 111, ReplicaState.RBW.getValue() }, blocks.getBlockListAsLongs()); }
@Test public void testMix() { BlockListAsLongs blocks = checkReport( new FinalizedReplica(b1, null, null), new FinalizedReplica(b2, null, null), new ReplicaBeingWritten(b3, null, null, null), new ReplicaWaitingToBeRecovered(b4, null, null)); assertArrayEquals( new long[] { 2, 2, 1, 11, 111, 2, 22, 222, -1, -1, -1, 3, 33, 333, ReplicaState.RBW.getValue(), 4, 44, 444, ReplicaState.RWR.getValue() }, blocks.getBlockListAsLongs()); }