@Test public void setPinned() throws Exception { createPath(mTree, NESTED_URI, sNestedDirectoryContext); createPath(mTree, NESTED_FILE_URI, sNestedFileContext); assertEquals(0, mTree.getPinIdSet().size()); try ( LockedInodePath inodePath = mTree.lockFullInodePath(NESTED_URI, LockPattern.WRITE_INODE)) { mTree.setPinned(RpcContext.NOOP, inodePath, true, Collections.emptyList(), 0); } assertEquals(1, mTree.getPinIdSet().size()); try ( LockedInodePath inodePath = mTree.lockFullInodePath(NESTED_URI, LockPattern.WRITE_INODE)) { mTree.setPinned(RpcContext.NOOP, inodePath, false, Collections.emptyList(), 0); } assertEquals(0, mTree.getPinIdSet().size()); }
public void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned, List<String> mediumTypes, long opTimeMs) throws FileDoesNotExistException, InvalidPathException { Preconditions.checkState(inodePath.getLockPattern().isWrite()); Set<String> mediumSet = new HashSet<>(mediumTypes); Preconditions.checkState(checkPinningValidity(mediumSet)); Inode inode = inodePath.getInode(); mState.applyAndJournal(rpcContext, UpdateInodeEntry.newBuilder() .setId(inode.getId()) .setPinned(pinned) .addAllMediumType(mediumSet) .setLastModificationTimeMs(opTimeMs) .build()); if (inode.isDirectory()) { assert inode instanceof InodeDirectory; for (Inode child : mInodeStore.getChildren(inode.asDirectory())) { try (LockedInodePath childPath = inodePath.lockChild(child, LockPattern.WRITE_INODE)) { setPinned(rpcContext, childPath, pinned, mediumTypes, opTimeMs); } } } }
InodeTree implements DelegatingJournaled { public void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned, List<String> mediumTypes, long opTimeMs) throws FileDoesNotExistException, InvalidPathException { Preconditions.checkState(inodePath.getLockPattern().isWrite()); Set<String> mediumSet = new HashSet<>(mediumTypes); Preconditions.checkState(checkPinningValidity(mediumSet)); Inode inode = inodePath.getInode(); mState.applyAndJournal(rpcContext, UpdateInodeEntry.newBuilder() .setId(inode.getId()) .setPinned(pinned) .addAllMediumType(mediumSet) .setLastModificationTimeMs(opTimeMs) .build()); if (inode.isDirectory()) { assert inode instanceof InodeDirectory; for (Inode child : mInodeStore.getChildren(inode.asDirectory())) { try (LockedInodePath childPath = inodePath.lockChild(child, LockPattern.WRITE_INODE)) { setPinned(rpcContext, childPath, pinned, mediumTypes, opTimeMs); } } } } }
InodeTree implements DelegatingJournaled { public void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned, List<String> mediumTypes, long opTimeMs) throws FileDoesNotExistException, InvalidPathException { Preconditions.checkState(inodePath.getLockPattern().isWrite()); Set<String> mediumSet = new HashSet<>(mediumTypes); Preconditions.checkState(checkPinningValidity(mediumSet)); Inode inode = inodePath.getInode(); mState.applyAndJournal(rpcContext, UpdateInodeEntry.newBuilder() .setId(inode.getId()) .setPinned(pinned) .addAllMediumType(mediumSet) .setLastModificationTimeMs(opTimeMs) .build()); if (inode.isDirectory()) { assert inode instanceof InodeDirectory; for (Inode child : mInodeStore.getChildren(inode.asDirectory())) { try (LockedInodePath childPath = inodePath.lockChild(child, LockPattern.WRITE_INODE)) { setPinned(rpcContext, childPath, pinned, mediumTypes, opTimeMs); } } } } InodeTree(InodeStore inodeStore, ContainerIdGenerable containerIdGenerator,
      InodeDirectoryIdGenerator directoryIdGenerator, MountTable mountTable,
      InodeLockManager lockManager); }
InodeTree implements DelegatingJournaled { public void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned, List<String> mediumTypes, long opTimeMs) throws FileDoesNotExistException, InvalidPathException { Preconditions.checkState(inodePath.getLockPattern().isWrite()); Set<String> mediumSet = new HashSet<>(mediumTypes); Preconditions.checkState(checkPinningValidity(mediumSet)); Inode inode = inodePath.getInode(); mState.applyAndJournal(rpcContext, UpdateInodeEntry.newBuilder() .setId(inode.getId()) .setPinned(pinned) .addAllMediumType(mediumSet) .setLastModificationTimeMs(opTimeMs) .build()); if (inode.isDirectory()) { assert inode instanceof InodeDirectory; for (Inode child : mInodeStore.getChildren(inode.asDirectory())) { try (LockedInodePath childPath = inodePath.lockChild(child, LockPattern.WRITE_INODE)) { setPinned(rpcContext, childPath, pinned, mediumTypes, opTimeMs); } } } } InodeTree(InodeStore inodeStore, ContainerIdGenerable containerIdGenerator,
      InodeDirectoryIdGenerator directoryIdGenerator, MountTable mountTable,
      InodeLockManager lockManager); void initializeRoot(String owner, String group, Mode mode, JournalContext context); TtlBucketList getTtlBuckets(); long getInodeCount(); void setDirectChildrenLoaded(Supplier<JournalContext> context, InodeDirectory dir); long newBlock(Supplier<JournalContext> context, NewBlockEntry entry); void updateInodeFile(Supplier<JournalContext> context, UpdateInodeFileEntry entry); void updateInode(Supplier<JournalContext> context, UpdateInodeEntry entry); UpdateInodeEntry updateInodeAccessTimeNoJournal(long inodeId, long accessTime); void rename(Supplier<JournalContext> context, RenameEntry entry); void setAcl(Supplier<JournalContext> context, SetAclEntry entry); @Nullable String getRootUserName(); int getPinnedSize(); boolean inodeIdExists(long id); LockedInodePath tryLockInodePath(LockingScheme scheme); LockedInodePath lockInodePath(LockingScheme scheme); LockedInodePath lockInodePath(AlluxioURI uri, LockPattern lockPattern); LockedInodePath lockInodePath(AlluxioURI uri, LockPattern lockPattern, boolean tryLock); boolean inodePathExists(AlluxioURI uri); LockedInodePath lockFullInodePath(AlluxioURI uri, LockingScheme lockScheme); LockedInodePath lockFullInodePath(AlluxioURI uri, LockPattern lockPattern); LockedInodePath lockFullInodePath(long id, LockPattern lockPattern); InodePathPair lockInodePathPair(AlluxioURI path1, LockPattern lockPattern1,
      AlluxioURI path2, LockPattern lockPattern2); void ensureFullInodePath(LockedInodePath inodePath); AlluxioURI getPath(InodeView inode); InodeDirectory getRoot(); List<Inode> createPath(RpcContext rpcContext, LockedInodePath inodePath,
      CreatePathContext<?, ?> context); LockedInodePathList getDescendants(LockedInodePath inodePath); void deleteInode(RpcContext rpcContext, LockedInodePath inodePath, long opTimeMs); void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned,
      List<String> mediumTypes, long opTimeMs); void setReplication(RpcContext rpcContext, LockedInodePath inodePath,
      Integer replicationMax, Integer replicationMin, long opTimeMs); Set<Long> getReplicationLimitedFileIds(); Set<Long> getToBePersistedIds(); Set<Long> getPinIdSet(); InodeLockManager getInodeLockManager(); boolean isRootId(long fileId); @Override Journaled getDelegate(); void syncPersistExistingDirectory(Supplier<JournalContext> context, InodeDirectoryView dir); void syncPersistNewDirectory(MutableInodeDirectory dir); void close(); }
InodeTree implements DelegatingJournaled { public void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned, List<String> mediumTypes, long opTimeMs) throws FileDoesNotExistException, InvalidPathException { Preconditions.checkState(inodePath.getLockPattern().isWrite()); Set<String> mediumSet = new HashSet<>(mediumTypes); Preconditions.checkState(checkPinningValidity(mediumSet)); Inode inode = inodePath.getInode(); mState.applyAndJournal(rpcContext, UpdateInodeEntry.newBuilder() .setId(inode.getId()) .setPinned(pinned) .addAllMediumType(mediumSet) .setLastModificationTimeMs(opTimeMs) .build()); if (inode.isDirectory()) { assert inode instanceof InodeDirectory; for (Inode child : mInodeStore.getChildren(inode.asDirectory())) { try (LockedInodePath childPath = inodePath.lockChild(child, LockPattern.WRITE_INODE)) { setPinned(rpcContext, childPath, pinned, mediumTypes, opTimeMs); } } } } InodeTree(InodeStore inodeStore, ContainerIdGenerable containerIdGenerator,
      InodeDirectoryIdGenerator directoryIdGenerator, MountTable mountTable,
      InodeLockManager lockManager); void initializeRoot(String owner, String group, Mode mode, JournalContext context); TtlBucketList getTtlBuckets(); long getInodeCount(); void setDirectChildrenLoaded(Supplier<JournalContext> context, InodeDirectory dir); long newBlock(Supplier<JournalContext> context, NewBlockEntry entry); void updateInodeFile(Supplier<JournalContext> context, UpdateInodeFileEntry entry); void updateInode(Supplier<JournalContext> context, UpdateInodeEntry entry); UpdateInodeEntry updateInodeAccessTimeNoJournal(long inodeId, long accessTime); void rename(Supplier<JournalContext> context, RenameEntry entry); void setAcl(Supplier<JournalContext> context, SetAclEntry entry); @Nullable String getRootUserName(); int getPinnedSize(); boolean inodeIdExists(long id); LockedInodePath tryLockInodePath(LockingScheme scheme); LockedInodePath lockInodePath(LockingScheme scheme); LockedInodePath lockInodePath(AlluxioURI uri, LockPattern lockPattern); LockedInodePath lockInodePath(AlluxioURI uri, LockPattern lockPattern, boolean tryLock); boolean inodePathExists(AlluxioURI uri); LockedInodePath lockFullInodePath(AlluxioURI uri, LockingScheme lockScheme); LockedInodePath lockFullInodePath(AlluxioURI uri, LockPattern lockPattern); LockedInodePath lockFullInodePath(long id, LockPattern lockPattern); InodePathPair lockInodePathPair(AlluxioURI path1, LockPattern lockPattern1,
      AlluxioURI path2, LockPattern lockPattern2); void ensureFullInodePath(LockedInodePath inodePath); AlluxioURI getPath(InodeView inode); InodeDirectory getRoot(); List<Inode> createPath(RpcContext rpcContext, LockedInodePath inodePath,
      CreatePathContext<?, ?> context); LockedInodePathList getDescendants(LockedInodePath inodePath); void deleteInode(RpcContext rpcContext, LockedInodePath inodePath, long opTimeMs); void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned,
      List<String> mediumTypes, long opTimeMs); void setReplication(RpcContext rpcContext, LockedInodePath inodePath,
      Integer replicationMax, Integer replicationMin, long opTimeMs); Set<Long> getReplicationLimitedFileIds(); Set<Long> getToBePersistedIds(); Set<Long> getPinIdSet(); InodeLockManager getInodeLockManager(); boolean isRootId(long fileId); @Override Journaled getDelegate(); void syncPersistExistingDirectory(Supplier<JournalContext> context, InodeDirectoryView dir); void syncPersistNewDirectory(MutableInodeDirectory dir); void close(); static final long NO_PARENT; static final String ROOT_INODE_NAME; static final String ROOT_PATH; static final int PATH_TRAVERSAL_RETRIES; }