@Test(expected = SuspectedFileSizeException.class) public void inodeRepeatedLengthSetTest() throws SuspectedFileSizeException, BlockInfoException { InodeFile inodeFile = new InodeFile("testFile1", 1, 0, 1000, System.currentTimeMillis()); inodeFile.setLength(100); inodeFile.setLength(200); }
public synchronized void setLength(long length) throws SuspectedFileSizeException, BlockInfoException { if (isComplete()) { throw new SuspectedFileSizeException("InodeFile length was set previously."); } if (length < 0) { throw new SuspectedFileSizeException("InodeFile new length " + length + " is illegal."); } mLength = 0; while (length >= BLOCK_SIZE_BYTE) { addBlock(new BlockInfo(this, mBlocks.size(), BLOCK_SIZE_BYTE)); length -= BLOCK_SIZE_BYTE; } if (length > 0) { addBlock(new BlockInfo(this, mBlocks.size(), (int) length)); } mIsComplete = true; }
InodeFile extends Inode { public synchronized void setLength(long length) throws SuspectedFileSizeException, BlockInfoException { if (isComplete()) { throw new SuspectedFileSizeException("InodeFile length was set previously."); } if (length < 0) { throw new SuspectedFileSizeException("InodeFile new length " + length + " is illegal."); } mLength = 0; while (length >= BLOCK_SIZE_BYTE) { addBlock(new BlockInfo(this, mBlocks.size(), BLOCK_SIZE_BYTE)); length -= BLOCK_SIZE_BYTE; } if (length > 0) { addBlock(new BlockInfo(this, mBlocks.size(), (int) length)); } mIsComplete = true; } }
InodeFile extends Inode { public synchronized void setLength(long length) throws SuspectedFileSizeException, BlockInfoException { if (isComplete()) { throw new SuspectedFileSizeException("InodeFile length was set previously."); } if (length < 0) { throw new SuspectedFileSizeException("InodeFile new length " + length + " is illegal."); } mLength = 0; while (length >= BLOCK_SIZE_BYTE) { addBlock(new BlockInfo(this, mBlocks.size(), BLOCK_SIZE_BYTE)); length -= BLOCK_SIZE_BYTE; } if (length > 0) { addBlock(new BlockInfo(this, mBlocks.size(), (int) length)); } mIsComplete = true; } InodeFile(String name, int id, int parentId, long blockSizeByte, long creationTimeMs); }
InodeFile extends Inode { public synchronized void setLength(long length) throws SuspectedFileSizeException, BlockInfoException { if (isComplete()) { throw new SuspectedFileSizeException("InodeFile length was set previously."); } if (length < 0) { throw new SuspectedFileSizeException("InodeFile new length " + length + " is illegal."); } mLength = 0; while (length >= BLOCK_SIZE_BYTE) { addBlock(new BlockInfo(this, mBlocks.size(), BLOCK_SIZE_BYTE)); length -= BLOCK_SIZE_BYTE; } if (length > 0) { addBlock(new BlockInfo(this, mBlocks.size(), (int) length)); } mIsComplete = true; } InodeFile(String name, int id, int parentId, long blockSizeByte, long creationTimeMs); synchronized void addBlock(BlockInfo blockInfo); synchronized void addLocation(int blockIndex, long workerId, NetAddress workerAddress); @Override ClientFileInfo generateClientFileInfo(String path); long getBlockIdBasedOnOffset(long offset); synchronized List<Long> getBlockIds(); synchronized List<Pair<Long, Long>> getBlockIdWorkerIdPairs(); List<BlockInfo> getBlockList(); synchronized List<NetAddress> getBlockLocations(int blockIndex); long getBlockSizeByte(); synchronized String getUfsPath(); synchronized ClientBlockInfo getClientBlockInfo(int blockIndex); synchronized List<ClientBlockInfo> getClientBlockInfos(); synchronized int getDependencyId(); synchronized long getLength(); synchronized long getNewBlockId(); synchronized int getNumberOfBlocks(); synchronized boolean hasCheckpointed(); synchronized boolean isCache(); synchronized boolean isComplete(); synchronized boolean isFullyInMemory(); synchronized void removeLocation(int blockIndex, long workerId); synchronized void setCache(boolean cache); synchronized void setUfsPath(String ufsPath); synchronized void setComplete(); synchronized void setComplete(boolean complete); synchronized void setDependencyId(int dependencyId); synchronized void setLength(long length); @Override String toString(); @Override synchronized void writeImage(ObjectWriter objWriter, DataOutputStream dos); }
InodeFile extends Inode { public synchronized void setLength(long length) throws SuspectedFileSizeException, BlockInfoException { if (isComplete()) { throw new SuspectedFileSizeException("InodeFile length was set previously."); } if (length < 0) { throw new SuspectedFileSizeException("InodeFile new length " + length + " is illegal."); } mLength = 0; while (length >= BLOCK_SIZE_BYTE) { addBlock(new BlockInfo(this, mBlocks.size(), BLOCK_SIZE_BYTE)); length -= BLOCK_SIZE_BYTE; } if (length > 0) { addBlock(new BlockInfo(this, mBlocks.size(), (int) length)); } mIsComplete = true; } InodeFile(String name, int id, int parentId, long blockSizeByte, long creationTimeMs); synchronized void addBlock(BlockInfo blockInfo); synchronized void addLocation(int blockIndex, long workerId, NetAddress workerAddress); @Override ClientFileInfo generateClientFileInfo(String path); long getBlockIdBasedOnOffset(long offset); synchronized List<Long> getBlockIds(); synchronized List<Pair<Long, Long>> getBlockIdWorkerIdPairs(); List<BlockInfo> getBlockList(); synchronized List<NetAddress> getBlockLocations(int blockIndex); long getBlockSizeByte(); synchronized String getUfsPath(); synchronized ClientBlockInfo getClientBlockInfo(int blockIndex); synchronized List<ClientBlockInfo> getClientBlockInfos(); synchronized int getDependencyId(); synchronized long getLength(); synchronized long getNewBlockId(); synchronized int getNumberOfBlocks(); synchronized boolean hasCheckpointed(); synchronized boolean isCache(); synchronized boolean isComplete(); synchronized boolean isFullyInMemory(); synchronized void removeLocation(int blockIndex, long workerId); synchronized void setCache(boolean cache); synchronized void setUfsPath(String ufsPath); synchronized void setComplete(); synchronized void setComplete(boolean complete); synchronized void setDependencyId(int dependencyId); synchronized void setLength(long length); @Override String toString(); @Override synchronized void writeImage(ObjectWriter objWriter, DataOutputStream dos);  }