@Test public void generateClientBlockInfoTest() { BlockInfo tInfo = new BlockInfo(new InodeFile("t", 100, 0, Constants.DEFAULT_BLOCK_SIZE_BYTE, System.currentTimeMillis()), 300, 800); tInfo.addLocation(15, new NetAddress("abc", 1)); tInfo.addLocation(22, new NetAddress("def", 2)); tInfo.addLocation(29, new NetAddress("gh", 3)); ClientBlockInfo clientBlockInfo = tInfo.generateClientBlockInfo(); Assert.assertEquals((long) Constants.DEFAULT_BLOCK_SIZE_BYTE * 300, clientBlockInfo.offset); Assert.assertEquals(800, clientBlockInfo.length); Assert.assertEquals(3, clientBlockInfo.locations.size()); }
public synchronized ClientBlockInfo generateClientBlockInfo() { ClientBlockInfo ret = new ClientBlockInfo(); ret.blockId = BLOCK_ID; ret.offset = OFFSET; ret.length = LENGTH; ret.locations = getLocations(); return ret; }
BlockInfo { public synchronized ClientBlockInfo generateClientBlockInfo() { ClientBlockInfo ret = new ClientBlockInfo(); ret.blockId = BLOCK_ID; ret.offset = OFFSET; ret.length = LENGTH; ret.locations = getLocations(); return ret; } }
BlockInfo { public synchronized ClientBlockInfo generateClientBlockInfo() { ClientBlockInfo ret = new ClientBlockInfo(); ret.blockId = BLOCK_ID; ret.offset = OFFSET; ret.length = LENGTH; ret.locations = getLocations(); return ret; } BlockInfo(InodeFile inodeFile, int blockIndex, long length); }
BlockInfo { public synchronized ClientBlockInfo generateClientBlockInfo() { ClientBlockInfo ret = new ClientBlockInfo(); ret.blockId = BLOCK_ID; ret.offset = OFFSET; ret.length = LENGTH; ret.locations = getLocations(); return ret; } BlockInfo(InodeFile inodeFile, int blockIndex, long length); static long computeBlockId(int inodeId, int blockIndex); static int computeBlockIndex(long blockId); static int computeInodeId(long blockId); synchronized void addLocation(long workerId, NetAddress workerAddress); synchronized ClientBlockInfo generateClientBlockInfo(); synchronized List<Pair<Long, Long>> getBlockIdWorkerIdPairs(); synchronized InodeFile getInodeFile(); synchronized List<NetAddress> getLocations(); synchronized boolean isInMemory(); synchronized void removeLocation(long workerId); @Override synchronized String toString(); }
BlockInfo { public synchronized ClientBlockInfo generateClientBlockInfo() { ClientBlockInfo ret = new ClientBlockInfo(); ret.blockId = BLOCK_ID; ret.offset = OFFSET; ret.length = LENGTH; ret.locations = getLocations(); return ret; } BlockInfo(InodeFile inodeFile, int blockIndex, long length); static long computeBlockId(int inodeId, int blockIndex); static int computeBlockIndex(long blockId); static int computeInodeId(long blockId); synchronized void addLocation(long workerId, NetAddress workerAddress); synchronized ClientBlockInfo generateClientBlockInfo(); synchronized List<Pair<Long, Long>> getBlockIdWorkerIdPairs(); synchronized InodeFile getInodeFile(); synchronized List<NetAddress> getLocations(); synchronized boolean isInMemory(); synchronized void removeLocation(long workerId); @Override synchronized String toString(); final int BLOCK_INDEX; final long BLOCK_ID; final long OFFSET; final long LENGTH; }