CoreSyncOperation getSyncOperation(FileInfo dirInfo, FileInfo fileInfo, String path, boolean valid) throws Exception{ long adjustedCapacity = fileInfo.getDirOffset()*CrailConstants.DIRECTORY_RECORD + CrailConstants.DIRECTORY_RECORD; dirInfo.setCapacity(Math.max(dirInfo.getCapacity(), adjustedCapacity)); CoreDirectory dirFile = new CoreDirectory(this, dirInfo, CrailUtils.getParent(path)); DirectoryOutputStream stream = dirFile.getDirectoryOutputStream(); DirectoryRecord record = new DirectoryRecord(valid, path); Future<CrailResult> future = stream.writeRecord(record, fileInfo.getDirOffset()); CoreSyncOperation syncOperation = new CoreSyncOperation(stream, future); return syncOperation; } }
public void setFileInfo(FileInfo fileInfo){ this.fd = fileInfo.getFd(); this.type = fileInfo.getType(); this.dirOffset = fileInfo.getDirOffset(); this.capacity.set(fileInfo.getCapacity()); this.token = fileInfo.getToken(); this.modificationTime = fileInfo.getModificationTime(); }
throw new IOException(RpcErrors.messages[renameRes.getError()]); if (renameRes.getDstParent().getCapacity() < renameRes.getDstFile().getDirOffset() + CrailConstants.DIRECTORY_RECORD){ LOG.info("rename: parent capacity does not match dst file offset, capacity " + renameRes.getDstParent().getCapacity() + ", offset " + renameRes.getDstFile().getDirOffset()); getBlockCache(srcParent.getFd()).put(CoreSubOperation.createKey(srcParent.getFd(), srcFile.getDirOffset()), srcBlock); BlockInfo dirBlock = renameRes.getDstBlock(); getBlockCache(dstDir.getFd()).put(CoreSubOperation.createKey(dstDir.getFd(), dstFile.getDirOffset()), dirBlock);
if (fileInfo.getDirOffset() >= 0){ BlockInfo dirBlock = fileRes.getDirBlock(); getBlockCache(dirInfo.getFd()).put(CoreSubOperation.createKey(dirInfo.getFd(), fileInfo.getDirOffset()), dirBlock); CoreSyncOperation syncOperation = getSyncOperation(dirInfo, fileInfo, path, true); node.addSyncOperation(syncOperation);
response.setDstBlock(dstBlock); if (response.getDstParent().getCapacity() < response.getDstFile().getDirOffset() + CrailConstants.DIRECTORY_RECORD){ LOG.info("rename: parent capacity does not match dst file offset, capacity " + response.getDstParent().getCapacity() + ", offset " + response.getDstFile().getDirOffset() + ", capacity " + dstParent.getCapacity() + ", offset " + dstFile.getDirOffset());