Skip to content

Commit

Permalink
Remove GuardedBy annotations, now that inodepath is used
Browse files Browse the repository at this point in the history
  • Loading branch information
gpang committed May 16, 2016
1 parent be6d3c6 commit f0bd7fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 40 deletions.
Expand Up @@ -110,7 +110,6 @@
import java.util.Set; import java.util.Set;
import java.util.concurrent.Future; import java.util.concurrent.Future;


import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.NotThreadSafe; import javax.annotation.concurrent.NotThreadSafe;


/** /**
Expand All @@ -124,26 +123,21 @@ public final class FileSystemMaster extends AbstractMaster {
private final BlockMaster mBlockMaster; private final BlockMaster mBlockMaster;


/** This manages the file system inode structure. This must be journaled. */ /** This manages the file system inode structure. This must be journaled. */
@GuardedBy("itself")
private final InodeTree mInodeTree; private final InodeTree mInodeTree;


/** This manages the file system mount points. */ /** This manages the file system mount points. */
@GuardedBy("mInodeTree")
private final MountTable mMountTable; private final MountTable mMountTable;


/** Map from worker to the files to persist on that worker. Used by async persistence service. */ /** Map from worker to the files to persist on that worker. Used by async persistence service. */
@GuardedBy("mInodeTree")
private final Map<Long, Set<Long>> mWorkerToAsyncPersistFiles; private final Map<Long, Set<Long>> mWorkerToAsyncPersistFiles;


/** This maintains inodes with ttl set, for the for the ttl checker service to use. */ /** This maintains inodes with ttl set, for the for the ttl checker service to use. */
@GuardedBy("mInodeTree")
private final TtlBucketList mTtlBuckets = new TtlBucketList(); private final TtlBucketList mTtlBuckets = new TtlBucketList();


/** This generates unique directory ids. This must be journaled. */ /** This generates unique directory ids. This must be journaled. */
private final InodeDirectoryIdGenerator mDirectoryIdGenerator; private final InodeDirectoryIdGenerator mDirectoryIdGenerator;


/** This checks user permissions on different operations. */ /** This checks user permissions on different operations. */
@GuardedBy("mInodeTree")
private final PermissionChecker mPermissionChecker; private final PermissionChecker mPermissionChecker;


/** List of paths to always keep in memory. */ /** List of paths to always keep in memory. */
Expand Down Expand Up @@ -404,7 +398,6 @@ public FileInfo getFileInfo(AlluxioURI path)
* @return the {@link FileInfo} for the given inode * @return the {@link FileInfo} for the given inode
* @throws FileDoesNotExistException if the file does not exist * @throws FileDoesNotExistException if the file does not exist
*/ */
@GuardedBy("mInodeTree")
private FileInfo getFileInfoInternal(InodePath inodePath) throws FileDoesNotExistException { private FileInfo getFileInfoInternal(InodePath inodePath) throws FileDoesNotExistException {
Inode<?> inode = inodePath.getInode(); Inode<?> inode = inodePath.getInode();
AlluxioURI path = inodePath.getUri(); AlluxioURI path = inodePath.getUri();
Expand Down Expand Up @@ -604,7 +597,6 @@ long completeFileAndJournal(InodePath inodePath, CompleteFileOptions options)
* @throws InvalidFileSizeException if an invalid file size is encountered * @throws InvalidFileSizeException if an invalid file size is encountered
* @throws FileAlreadyCompletedException if the file has already been completed * @throws FileAlreadyCompletedException if the file has already been completed
*/ */
@GuardedBy("mInodeTree")
void completeFileInternal(List<Long> blockIds, InodePath inodePath, long length, long opTimeMs) void completeFileInternal(List<Long> blockIds, InodePath inodePath, long length, long opTimeMs)
throws FileDoesNotExistException, InvalidPathException, InvalidFileSizeException, throws FileDoesNotExistException, InvalidPathException, InvalidFileSizeException,
FileAlreadyCompletedException { FileAlreadyCompletedException {
Expand All @@ -631,7 +623,6 @@ void completeFileInternal(List<Long> blockIds, InodePath inodePath, long length,
* @throws InvalidFileSizeException if an invalid file size is encountered * @throws InvalidFileSizeException if an invalid file size is encountered
* @throws FileAlreadyCompletedException if the file has already been completed * @throws FileAlreadyCompletedException if the file has already been completed
*/ */
@GuardedBy("mInodeTree")
private void completeFileFromEntry(CompleteFileEntry entry) private void completeFileFromEntry(CompleteFileEntry entry)
throws InvalidPathException, InvalidFileSizeException, FileAlreadyCompletedException { throws InvalidPathException, InvalidFileSizeException, FileAlreadyCompletedException {
try (InodePath inodePath = mInodeTree try (InodePath inodePath = mInodeTree
Expand Down Expand Up @@ -713,7 +704,6 @@ long createFileAndJournal(InodePath inodePath, CreateFileOptions options)
* @throws FileDoesNotExistException if the parent of the path does not exist and the recursive * @throws FileDoesNotExistException if the parent of the path does not exist and the recursive
* option is false * option is false
*/ */
@GuardedBy("mInodeTree")
InodeTree.CreatePathResult createFileInternal(InodePath inodePath, CreateFileOptions options) InodeTree.CreatePathResult createFileInternal(InodePath inodePath, CreateFileOptions options)
throws InvalidPathException, FileAlreadyExistsException, BlockInfoException, IOException, throws InvalidPathException, FileAlreadyExistsException, BlockInfoException, IOException,
FileDoesNotExistException { FileDoesNotExistException {
Expand Down Expand Up @@ -767,7 +757,6 @@ public long reinitializeFile(AlluxioURI path, long blockSizeBytes, long ttl)
/** /**
* @param entry the entry to use * @param entry the entry to use
*/ */
@GuardedBy("mInodeTree")
private void resetBlockFileFromEntry(ReinitializeFileEntry entry) { private void resetBlockFileFromEntry(ReinitializeFileEntry entry) {
try (InodePath inodePath = mInodeTree try (InodePath inodePath = mInodeTree
.lockFullInodePath(new AlluxioURI(entry.getPath()), InodeTree.LockMode.WRITE)) { .lockFullInodePath(new AlluxioURI(entry.getPath()), InodeTree.LockMode.WRITE)) {
Expand Down Expand Up @@ -878,7 +867,6 @@ long deleteAndJournal(InodePath inodePath, boolean recursive)
/** /**
* @param entry the entry to use * @param entry the entry to use
*/ */
@GuardedBy("mInodeTree")
private void deleteFromEntry(DeleteFileEntry entry) { private void deleteFromEntry(DeleteFileEntry entry) {
MasterContext.getMasterSource().incDeletePathOps(1); MasterContext.getMasterSource().incDeletePathOps(1);
try (InodePath inodePath = mInodeTree try (InodePath inodePath = mInodeTree
Expand All @@ -900,7 +888,6 @@ private void deleteFromEntry(DeleteFileEntry entry) {
* @throws FileDoesNotExistException if a non-existent file is encountered * @throws FileDoesNotExistException if a non-existent file is encountered
* @throws IOException if an I/O error is encountered * @throws IOException if an I/O error is encountered
*/ */
@GuardedBy("mInodeTree")
private boolean deleteRecursiveInternal(InodePath inodePath, boolean replayed, long opTimeMs) private boolean deleteRecursiveInternal(InodePath inodePath, boolean replayed, long opTimeMs)
throws FileDoesNotExistException, IOException { throws FileDoesNotExistException, IOException {
try { try {
Expand All @@ -925,7 +912,6 @@ private boolean deleteRecursiveInternal(InodePath inodePath, boolean replayed, l
* @throws IOException if an I/O error is encountered * @throws IOException if an I/O error is encountered
* @throws DirectoryNotEmptyException if recursive is false and the file is a nonempty directory * @throws DirectoryNotEmptyException if recursive is false and the file is a nonempty directory
*/ */
@GuardedBy("mInodeTree")
boolean deleteInternal(InodePath inodePath, boolean recursive, boolean replayed, boolean deleteInternal(InodePath inodePath, boolean recursive, boolean replayed,
long opTimeMs) throws FileDoesNotExistException, IOException, DirectoryNotEmptyException { long opTimeMs) throws FileDoesNotExistException, IOException, DirectoryNotEmptyException {
// TODO(jiri): A crash after any UFS object is deleted and before the delete operation is // TODO(jiri): A crash after any UFS object is deleted and before the delete operation is
Expand Down Expand Up @@ -1031,7 +1017,6 @@ public List<FileBlockInfo> getFileBlockInfoList(AlluxioURI path)
* @return a list of {@link FileBlockInfo} for all the blocks of the given inode * @return a list of {@link FileBlockInfo} for all the blocks of the given inode
* @throws InvalidPathException if the path of the given file is invalid * @throws InvalidPathException if the path of the given file is invalid
*/ */
@GuardedBy("mInodeTree")
private List<FileBlockInfo> getFileBlockInfoListInternal(InodePath inodePath) private List<FileBlockInfo> getFileBlockInfoListInternal(InodePath inodePath)
throws InvalidPathException, FileDoesNotExistException { throws InvalidPathException, FileDoesNotExistException {
InodeFile file = inodePath.getInodeFile(); InodeFile file = inodePath.getInodeFile();
Expand All @@ -1053,7 +1038,6 @@ private List<FileBlockInfo> getFileBlockInfoListInternal(InodePath inodePath)
* @return a new {@link FileBlockInfo} for the block * @return a new {@link FileBlockInfo} for the block
* @throws InvalidPathException if the mount table is not able to resolve the file * @throws InvalidPathException if the mount table is not able to resolve the file
*/ */
@GuardedBy("mInodeTree")
private FileBlockInfo generateFileBlockInfo(InodePath inodePath, BlockInfo blockInfo) private FileBlockInfo generateFileBlockInfo(InodePath inodePath, BlockInfo blockInfo)
throws InvalidPathException, FileDoesNotExistException { throws InvalidPathException, FileDoesNotExistException {
InodeFile file = inodePath.getInodeFile(); InodeFile file = inodePath.getInodeFile();
Expand Down Expand Up @@ -1416,7 +1400,6 @@ long renameAndJournal(InodePath srcInodePath, InodePath dstInodePath)
* @throws InvalidPathException if an invalid path is encountered * @throws InvalidPathException if an invalid path is encountered
* @throws IOException if an I/O error is encountered * @throws IOException if an I/O error is encountered
*/ */
@GuardedBy("mInodeTree")
void renameInternal(InodePath srcInodePath, InodePath dstInodePath, boolean replayed, void renameInternal(InodePath srcInodePath, InodePath dstInodePath, boolean replayed,
long opTimeMs) throws FileDoesNotExistException, InvalidPathException, IOException { long opTimeMs) throws FileDoesNotExistException, InvalidPathException, IOException {
Inode<?> srcInode = srcInodePath.getInode(); Inode<?> srcInode = srcInodePath.getInode();
Expand Down Expand Up @@ -1457,7 +1440,6 @@ void renameInternal(InodePath srcInodePath, InodePath dstInodePath, boolean repl
/** /**
* @param entry the entry to use * @param entry the entry to use
*/ */
@GuardedBy("mInodeTree")
private void renameFromEntry(RenameEntry entry) { private void renameFromEntry(RenameEntry entry) {
MasterContext.getMasterSource().incRenamePathOps(1); MasterContext.getMasterSource().incRenamePathOps(1);
// Determine the srcPath and dstPath // Determine the srcPath and dstPath
Expand Down Expand Up @@ -1489,7 +1471,6 @@ private void renameFromEntry(RenameEntry entry) {
* @return list of inodes which were marked as persisted * @return list of inodes which were marked as persisted
* @throws FileDoesNotExistException if a non-existent file is encountered * @throws FileDoesNotExistException if a non-existent file is encountered
*/ */
@GuardedBy("mInodeTree")
private List<Inode<?>> propagatePersistedInternal(InodePath inodePath, boolean replayed) private List<Inode<?>> propagatePersistedInternal(InodePath inodePath, boolean replayed)
throws FileDoesNotExistException { throws FileDoesNotExistException {
Inode<?> inode = inodePath.getInode(); Inode<?> inode = inodePath.getInode();
Expand Down Expand Up @@ -1570,7 +1551,6 @@ public boolean free(AlluxioURI path, boolean recursive)
* @param recursive if true, and the file is a directory, all descendants will be freed * @param recursive if true, and the file is a directory, all descendants will be freed
* @return true if the file was freed * @return true if the file was freed
*/ */
@GuardedBy("mInodeTree")
private boolean freeInternal(InodePath inodePath, boolean recursive) private boolean freeInternal(InodePath inodePath, boolean recursive)
throws FileDoesNotExistException { throws FileDoesNotExistException {
Inode<?> inode = inodePath.getInode(); Inode<?> inode = inodePath.getInode();
Expand Down Expand Up @@ -1784,7 +1764,6 @@ long loadMetadataAndJournal(InodePath inodePath, boolean recursive)
* @throws AccessControlException if permission checking fails * @throws AccessControlException if permission checking fails
* @throws FileDoesNotExistException if the path does not exist * @throws FileDoesNotExistException if the path does not exist
*/ */
@GuardedBy("mInodeTree")
private long loadDirectoryMetadataAndJournal(InodePath inodePath, boolean recursive) private long loadDirectoryMetadataAndJournal(InodePath inodePath, boolean recursive)
throws FileAlreadyExistsException, FileDoesNotExistException, InvalidPathException, throws FileAlreadyExistsException, FileDoesNotExistException, InvalidPathException,
AccessControlException, IOException { AccessControlException, IOException {
Expand All @@ -1804,7 +1783,6 @@ private long loadDirectoryMetadataAndJournal(InodePath inodePath, boolean recurs
* *
* @param inodePath the {@link InodePath} to load the metadata for * @param inodePath the {@link InodePath} to load the metadata for
*/ */
@GuardedBy("mInodeTree")
private long loadMetadataIfNotExistAndJournal(InodePath inodePath) { private long loadMetadataIfNotExistAndJournal(InodePath inodePath) {
if (!inodePath.fullPathExists()) { if (!inodePath.fullPathExists()) {
try { try {
Expand Down Expand Up @@ -1909,7 +1887,6 @@ long mountAndJournal(InodePath inodePath, AlluxioURI ufsPath, MountOptions optio
* @throws InvalidPathException if an invalid path is encountered * @throws InvalidPathException if an invalid path is encountered
* @throws IOException if an I/O exception occurs * @throws IOException if an I/O exception occurs
*/ */
@GuardedBy("mInodeTree")
void mountFromEntry(AddMountPointEntry entry) void mountFromEntry(AddMountPointEntry entry)
throws FileAlreadyExistsException, InvalidPathException, IOException { throws FileAlreadyExistsException, InvalidPathException, IOException {
AlluxioURI alluxioURI = new AlluxioURI(entry.getAlluxioPath()); AlluxioURI alluxioURI = new AlluxioURI(entry.getAlluxioPath());
Expand All @@ -1930,7 +1907,6 @@ void mountFromEntry(AddMountPointEntry entry)
* @throws InvalidPathException if an invalid path is encountered * @throws InvalidPathException if an invalid path is encountered
* @throws IOException if an I/O exception occurs * @throws IOException if an I/O exception occurs
*/ */
@GuardedBy("mInodeTree")
void mountInternal(InodePath inodePath, AlluxioURI ufsPath, MountOptions options) void mountInternal(InodePath inodePath, AlluxioURI ufsPath, MountOptions options)
throws FileAlreadyExistsException, InvalidPathException, IOException { throws FileAlreadyExistsException, InvalidPathException, IOException {
AlluxioURI alluxioPath = inodePath.getUri(); AlluxioURI alluxioPath = inodePath.getUri();
Expand Down Expand Up @@ -2036,7 +2012,6 @@ long unmountAndJournal(InodePath inodePath)
* @throws InvalidPathException if an invalid path is encountered * @throws InvalidPathException if an invalid path is encountered
* @throws FileDoesNotExistException if path does not exist * @throws FileDoesNotExistException if path does not exist
*/ */
@GuardedBy("mInodeTree")
private void unmountFromEntry(DeleteMountPointEntry entry) private void unmountFromEntry(DeleteMountPointEntry entry)
throws InvalidPathException, FileDoesNotExistException { throws InvalidPathException, FileDoesNotExistException {
AlluxioURI alluxioURI = new AlluxioURI(entry.getAlluxioPath()); AlluxioURI alluxioURI = new AlluxioURI(entry.getAlluxioPath());
Expand All @@ -2052,7 +2027,6 @@ private void unmountFromEntry(DeleteMountPointEntry entry)
* @return true if successful, false otherwise * @return true if successful, false otherwise
* @throws InvalidPathException if an invalied path is encountered * @throws InvalidPathException if an invalied path is encountered
*/ */
@GuardedBy("mInodeTree")
private boolean unmountInternal(InodePath inodePath) throws InvalidPathException { private boolean unmountInternal(InodePath inodePath) throws InvalidPathException {
return mMountTable.delete(inodePath.getUri()); return mMountTable.delete(inodePath.getUri());
} }
Expand Down Expand Up @@ -2148,25 +2122,26 @@ long setAttributeAndJournal(InodePath inodePath, SetAttributeOptions options,
tempInodePath.setDescendant(inode, mInodeTree.getPath(inode)); tempInodePath.setDescendant(inode, mInodeTree.getPath(inode));
List<Inode<?>> persistedInodes = setAttributeInternal(tempInodePath, opTimeMs, options); List<Inode<?>> persistedInodes = setAttributeInternal(tempInodePath, opTimeMs, options);
journalPersistedInodes(persistedInodes); journalPersistedInodes(persistedInodes);
journalSetAttribute(inode.getId(), opTimeMs, options); journalSetAttribute(tempInodePath, opTimeMs, options);
} }
} }
} }
List<Inode<?>> persistedInodes = setAttributeInternal(inodePath, opTimeMs, options); List<Inode<?>> persistedInodes = setAttributeInternal(inodePath, opTimeMs, options);
journalPersistedInodes(persistedInodes); journalPersistedInodes(persistedInodes);
return journalSetAttribute(targetInode.getId(), opTimeMs, options); return journalSetAttribute(inodePath, opTimeMs, options);
} }


/** /**
* @param fileId the file id to use * @param inodePath the file path to use
* @param opTimeMs the operation time (in milliseconds) * @param opTimeMs the operation time (in milliseconds)
* @param options the method options * @param options the method options
* @return the flush counter for journaling * @return the flush counter for journaling
* @throws FileDoesNotExistException if path does not exist
*/ */
@GuardedBy("mInodeTree") private long journalSetAttribute(InodePath inodePath, long opTimeMs,
private long journalSetAttribute(long fileId, long opTimeMs, SetAttributeOptions options) { SetAttributeOptions options) throws FileDoesNotExistException {
SetAttributeEntry.Builder builder = SetAttributeEntry.Builder builder =
SetAttributeEntry.newBuilder().setId(fileId).setOpTimeMs(opTimeMs); SetAttributeEntry.newBuilder().setId(inodePath.getInode().getId()).setOpTimeMs(opTimeMs);
if (options.getPinned() != null) { if (options.getPinned() != null) {
builder.setPinned(options.getPinned()); builder.setPinned(options.getPinned());
} }
Expand Down Expand Up @@ -2271,7 +2246,6 @@ public FileSystemCommand workerHeartbeat(long workerId, List<Long> persistedFile
* @return list of inodes which were marked as persisted * @return list of inodes which were marked as persisted
* @throws FileDoesNotExistException * @throws FileDoesNotExistException
*/ */
@GuardedBy("mInodeTree")
List<Inode<?>> setAttributeInternal(InodePath inodePath, long opTimeMs, List<Inode<?>> setAttributeInternal(InodePath inodePath, long opTimeMs,
SetAttributeOptions options) SetAttributeOptions options)
throws FileDoesNotExistException { throws FileDoesNotExistException {
Expand Down Expand Up @@ -2323,7 +2297,6 @@ List<Inode<?>> setAttributeInternal(InodePath inodePath, long opTimeMs,
* @param entry the entry to use * @param entry the entry to use
* @throws FileDoesNotExistException if the file does not exist * @throws FileDoesNotExistException if the file does not exist
*/ */
@GuardedBy("mInodeTree")
private void setAttributeFromEntry(SetAttributeEntry entry) throws FileDoesNotExistException { private void setAttributeFromEntry(SetAttributeEntry entry) throws FileDoesNotExistException {
SetAttributeOptions options = SetAttributeOptions.defaults(); SetAttributeOptions options = SetAttributeOptions.defaults();
if (entry.hasPinned()) { if (entry.hasPinned()) {
Expand Down
Expand Up @@ -32,7 +32,6 @@
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;


import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.NotThreadSafe; import javax.annotation.concurrent.NotThreadSafe;


/** /**
Expand Down Expand Up @@ -78,7 +77,6 @@ public PermissionChecker(InodeTree inodeTree) {
* @throws AccessControlException if permission checking fails * @throws AccessControlException if permission checking fails
* @throws InvalidPathException if the path is invalid * @throws InvalidPathException if the path is invalid
*/ */
@GuardedBy("mInodeTree")
public void checkParentPermission(FileSystemAction action, InodePath inodePath) public void checkParentPermission(FileSystemAction action, InodePath inodePath)
throws AccessControlException, InvalidPathException { throws AccessControlException, InvalidPathException {
if (!mPermissionCheckEnabled) { if (!mPermissionCheckEnabled) {
Expand Down Expand Up @@ -114,7 +112,6 @@ public void checkParentPermission(FileSystemAction action, InodePath inodePath)
* @throws AccessControlException if permission checking fails * @throws AccessControlException if permission checking fails
* @throws InvalidPathException if the path is invalid * @throws InvalidPathException if the path is invalid
*/ */
@GuardedBy("mInodeTree")
public void checkPermission(FileSystemAction action, InodePath inodePath) public void checkPermission(FileSystemAction action, InodePath inodePath)
throws AccessControlException, InvalidPathException { throws AccessControlException, InvalidPathException {
if (!mPermissionCheckEnabled) { if (!mPermissionCheckEnabled) {
Expand All @@ -140,7 +137,6 @@ public void checkPermission(FileSystemAction action, InodePath inodePath)
* @throws AccessControlException if permission checking fails * @throws AccessControlException if permission checking fails
* @throws InvalidPathException if the path is invalid * @throws InvalidPathException if the path is invalid
*/ */
@GuardedBy("mInodeTree")
public void checkSetAttributePermission(InodePath inodePath, boolean superuserRequired, public void checkSetAttributePermission(InodePath inodePath, boolean superuserRequired,
boolean ownerRequired) throws AccessControlException, InvalidPathException { boolean ownerRequired) throws AccessControlException, InvalidPathException {
if (!mPermissionCheckEnabled) { if (!mPermissionCheckEnabled) {
Expand Down Expand Up @@ -196,7 +192,6 @@ private List<String> getGroups(String user) throws AccessControlException {
* @throws AccessControlException if permission checking fails * @throws AccessControlException if permission checking fails
* @throws InvalidPathException if the path is invalid * @throws InvalidPathException if the path is invalid
*/ */
@GuardedBy("mInodeTree")
private void checkOwner(InodePath inodePath) private void checkOwner(InodePath inodePath)
throws AccessControlException, InvalidPathException { throws AccessControlException, InvalidPathException {
// collects inodes info on the path // collects inodes info on the path
Expand Down
Expand Up @@ -90,7 +90,7 @@ public enum LockMode {
private InodeDirectory mRoot = null; private InodeDirectory mRoot = null;


/** Mount table manages the file system mount points. */ /** Mount table manages the file system mount points. */
private MountTable mMountTable; private final MountTable mMountTable;


private final IndexedSet.FieldIndex<Inode<?>> mIdIndex = new IndexedSet.FieldIndex<Inode<?>>() { private final IndexedSet.FieldIndex<Inode<?>> mIdIndex = new IndexedSet.FieldIndex<Inode<?>>() {
@Override @Override
Expand Down

0 comments on commit f0bd7fa

Please sign in to comment.