Пример #1
0
  @Override
  public Block write(Block block) {

    int bufferId =
        assignor.assign(block.getBlockId(), block.getPrimaryDiskId(), block.getReplicaLevel());

    BufferRegion region = getBufferRegion(bufferId, block.getReplicaLevel());

    return region.write(block);
  }
Пример #2
0
  @Override
  public List<Block> getBlocksInTheSameRegion(Block block) {

    int bufferId =
        assignor.assign(block.getBlockId(), block.getPrimaryDiskId(), block.getReplicaLevel());

    BufferRegion region = getBufferRegion(bufferId, block.getReplicaLevel());

    return region.getBufferedBlocks();
  }
Пример #3
0
  @Override
  public Block remove(Block block) {

    if (block == null) return null;

    int bufferId =
        assignor.assign(block.getBlockId(), block.getPrimaryDiskId(), block.getReplicaLevel());

    BufferRegion region = getBufferRegion(bufferId, block.getReplicaLevel());

    return region.remove(block.getBlockId());
  }
Пример #4
0
  @Override
  public List<Block> getBlocksCorrespondingToSpecifiedDisk(int diskId) {
    List<Block> result = new ArrayList<>();

    for (List<BufferRegion> regions : regionTable.values()) {
      for (BufferRegion region : regions) {
        for (Block block : region.getBufferedBlocks()) {
          if (block.getOwnerDiskId() == diskId) result.add(block);
        }
      }
    }
    return result;
  }
Пример #5
0
 @Override
 public int getMaximumBufferLengthDiskId(int overflowedBufferId, int replicaLevel) {
   BufferRegion region = getBufferRegion(overflowedBufferId, replicaLevel);
   return region.getMaximumBufferLengthDiskId();
 }