/** * Converts a Transaction Log operation into a NamespaceNotification * object. * @param op the Transaction Log operation. * @return the NamespaceNotification object or null if the type of * the operation isn't supported to be transformed into a * NamespaceNotification. */ static NamespaceNotification createNotification(FSEditLogOp op) { switch (op.opCode) { case OP_ADD: return new NamespaceNotification(((AddOp)op).path, EventType.FILE_ADDED.getByteValue(), op.getTransactionId()); case OP_CLOSE: return new NamespaceNotification(((CloseOp)op).path, EventType.FILE_CLOSED.getByteValue(), op.getTransactionId()); case OP_DELETE: return new NamespaceNotification(((DeleteOp)op).path, EventType.NODE_DELETED.getByteValue(), op.getTransactionId()); case OP_MKDIR: return new NamespaceNotification(((MkdirOp)op).path, EventType.DIR_ADDED.getByteValue(), op.getTransactionId()); default: return null; } }
/** * Add open lease record to edit log. * Records the block locations of the last block. */ public void logOpenFile(String path, INodeFileUnderConstruction newNode, boolean toLogRpcIds) { AddOp op = AddOp.getInstance(cache.get()) .setInodeId(newNode.getId()) .setPath(path) .setReplication(newNode.getFileReplication()) .setModificationTime(newNode.getModificationTime()) .setAccessTime(newNode.getAccessTime()) .setBlockSize(newNode.getPreferredBlockSize()) .setBlocks(newNode.getBlocks()) .setPermissionStatus(newNode.getPermissionStatus()) .setClientName(newNode.getClientName()) .setClientMachine(newNode.getClientMachine()); logRpcIds(op, toLogRpcIds); logEdit(op); }
/** * Add open lease record to edit log. * Records the block locations of the last block. */ public void logOpenFile(String path, INodeFile newNode, boolean toLogRpcIds) { Preconditions.checkArgument(newNode.isUnderConstruction()); PermissionStatus permissions = newNode.getPermissionStatus(); AddOp op = AddOp.getInstance(cache.get()) .setInodeId(newNode.getId()) .setPath(path) .setReplication(newNode.getFileReplication()) .setModificationTime(newNode.getModificationTime()) .setAccessTime(newNode.getAccessTime()) .setBlockSize(newNode.getPreferredBlockSize()) .setBlocks(newNode.getBlocks()) .setPermissionStatus(permissions) .setClientName(newNode.getFileUnderConstructionFeature().getClientName()) .setClientMachine(newNode.getFileUnderConstructionFeature().getClientMachine()); AclFeature f = newNode.getAclFeature(); if (f != null) { op.setAclEntries(AclStorage.readINodeLogicalAcl(newNode)); } logRpcIds(op, toLogRpcIds); logEdit(op); }
/** * Add open lease record to edit log. * Records the block locations of the last block. */ public void logOpenFile(String path, INodeFile newNode, boolean overwrite, boolean toLogRpcIds) { Preconditions.checkArgument(newNode.isUnderConstruction()); PermissionStatus permissions = newNode.getPermissionStatus(); AddOp op = AddOp.getInstance(cache.get()) .setInodeId(newNode.getId()) .setPath(path) .setReplication(newNode.getFileReplication()) .setModificationTime(newNode.getModificationTime()) .setAccessTime(newNode.getAccessTime()) .setBlockSize(newNode.getPreferredBlockSize()) .setBlocks(newNode.getBlocks()) .setPermissionStatus(permissions) .setClientName(newNode.getFileUnderConstructionFeature().getClientName()) .setClientMachine( newNode.getFileUnderConstructionFeature().getClientMachine()) .setOverwrite(overwrite) .setStoragePolicyId(newNode.getStoragePolicyID()); AclFeature f = newNode.getAclFeature(); if (f != null) { op.setAclEntries(AclStorage.readINodeLogicalAcl(newNode)); } XAttrFeature x = newNode.getXAttrFeature(); if (x != null) { op.setXAttrs(x.getXAttrs()); } logRpcIds(op, toLogRpcIds); logEdit(op); }
/** * Add open lease record to edit log. * Records the block locations of the last block. */ public void logOpenFile(String path, INodeFile newNode, boolean overwrite, boolean toLogRpcIds) { Preconditions.checkArgument(newNode.isUnderConstruction()); PermissionStatus permissions = newNode.getPermissionStatus(); AddOp op = AddOp.getInstance(cache.get()) .setInodeId(newNode.getId()) .setPath(path) .setReplication(newNode.getFileReplication()) .setModificationTime(newNode.getModificationTime()) .setAccessTime(newNode.getAccessTime()) .setBlockSize(newNode.getPreferredBlockSize()) .setBlocks(newNode.getBlocks()) .setPermissionStatus(permissions) .setClientName(newNode.getFileUnderConstructionFeature().getClientName()) .setClientMachine( newNode.getFileUnderConstructionFeature().getClientMachine()) .setOverwrite(overwrite) .setStoragePolicyId(newNode.getLocalStoragePolicyID()); AclFeature f = newNode.getAclFeature(); if (f != null) { op.setAclEntries(AclStorage.readINodeLogicalAcl(newNode)); } XAttrFeature x = newNode.getXAttrFeature(); if (x != null) { op.setXAttrs(x.getXAttrs()); } logRpcIds(op, toLogRpcIds); logEdit(op); }
/** * Add open lease record to edit log. * Records the block locations of the last block. */ public void logOpenFile(String path, INodeFile newNode, boolean overwrite, boolean toLogRpcIds) { Preconditions.checkArgument(newNode.isUnderConstruction()); PermissionStatus permissions = newNode.getPermissionStatus(); AddOp op = AddOp.getInstance(cache.get()) .reset() .setInodeId(newNode.getId()) .setPath(path) .setReplication(newNode.getFileReplication()) .setModificationTime(newNode.getModificationTime()) .setAccessTime(newNode.getAccessTime()) .setBlockSize(newNode.getPreferredBlockSize()) .setBlocks(newNode.getBlocks()) .setPermissionStatus(permissions) .setClientName(newNode.getFileUnderConstructionFeature().getClientName()) .setClientMachine( newNode.getFileUnderConstructionFeature().getClientMachine()) .setOverwrite(overwrite) .setStoragePolicyId(newNode.getStoragePolicyID()); AclFeature f = newNode.getAclFeature(); if (f != null) { op.setAclEntries(AclStorage.readINodeLogicalAcl(newNode)); } XAttrFeature x = newNode.getXAttrFeature(); if (x != null) { op.setXAttrs(x.getXAttrs()); } logRpcIds(op, toLogRpcIds); logEdit(op); }