/** * Constructor. * * @param fileInfo File info to construct listing entry from. */ public IgfsListingEntry(IgfsEntryInfo fileInfo) { id = fileInfo.id(); dir = fileInfo.isDirectory(); }
/** {@inheritDoc} */ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) throws EntryProcessorException { IgfsEntryInfo fileInfo = e.getValue(); assert fileInfo.isDirectory(); Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing()); // Modify listing in-place. IgfsListingEntry entry = listing.remove(oldName); if (entry == null) throw new IgniteException("Directory listing doesn't contain expected entry: " + oldName); IgfsListingEntry replacedEntry = listing.put(newName, entry); if (replacedEntry != null) throw new IgniteException("Entry with new name already exists [name=" + newName + ", entry=" + replacedEntry + ']'); e.setValue(fileInfo.listing(listing)); return null; }
/** {@inheritDoc} */ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) throws EntryProcessorException { IgfsEntryInfo fileInfo = e.getValue(); assert fileInfo.isDirectory(); Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing()); // Modify listing in-place. IgfsListingEntry oldEntry = listing.get(name); if (oldEntry == null) throw new IgniteException("Directory listing doesn't contain expected entry: " + name); listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory())); e.setValue(fileInfo.listing(listing)); return null; }
/** {@inheritDoc} */ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) throws EntryProcessorException { IgfsEntryInfo fileInfo = e.getValue(); assert fileInfo != null; assert fileInfo.isDirectory(); Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing()); IgfsListingEntry oldEntry = listing.get(fileName); if (oldEntry == null || !oldEntry.fileId().equals(fileId)) throw new IgniteException("Directory listing doesn't contain expected file" + " [listing=" + listing + ", fileName=" + fileName + "]"); // Modify listing in-place. listing.remove(fileName); e.setValue(fileInfo.listing(listing)); return null; }
/** {@inheritDoc} */ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) { IgfsEntryInfo fileInfo = e.getValue(); assert fileInfo != null && fileInfo.isDirectory() : fileInfo; Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing()); // Modify listing in-place. IgfsListingEntry oldEntry = listing.put(fileName, entry); if (oldEntry != null && !oldEntry.fileId().equals(entry.fileId())) { throw new IgniteException("Directory listing contains unexpected file" + " [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry + ", oldEntry=" + oldEntry + ']'); } e.setValue(fileInfo.listing(listing)); return null; }
assert entryInfo.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(entryInfo.lockId());
return false; assert victim.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(victim.lockId()) : " isDir: " + victim.isDirectory() + ", lockId: " + victim.lockId();
assert info.isDirectory();
private IgfsEntryInfo createFileAndGetInfo(String path) throws IgniteCheckedException { IgfsPath p = path(path); IgfsEntryInfo res = mgr.create(p, null, false, 400, null, false, null, null).info(); assert res != null; assert !res.isDirectory(); return res; }
return null; assert info.isDirectory();
private IgfsEntryInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException { IgfsPath p = path(path); mgr.mkdirs(p, IgfsImpl.DFLT_DIR_META); IgniteUuid id = mgr.fileId(p); IgfsEntryInfo info = mgr.info(id); assert info.isDirectory(); return info; }
" [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']'); if (oldInfo.isDirectory() != newInfo.isDirectory()) throw fsException("Failed to update file info (file types differ)" + " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
" [srcParentId=" + srcParentId + ']')); if (!srcInfo.isDirectory()) throw fsException(new IgfsPathIsNotDirectoryException("Source is not a directory: " + srcInfo)); " [destParentId=" + destParentId + ']')); if (!destInfo.isDirectory()) throw fsException(new IgfsPathIsNotDirectoryException("Destination is not a directory: " + destInfo));
/** * Add file into file system structure. Do not create new transaction expecting that the one already exists. * * @param parentId Parent file ID. * @param fileName File name in the parent's listing. * @param newFileInfo File info to store in the parent's listing. * @return File id already stored in meta cache or {@code null} if passed file info was stored. * @throws IgniteCheckedException If failed. */ private IgniteUuid putIfAbsentNonTx(IgniteUuid parentId, String fileName, IgfsEntryInfo newFileInfo) throws IgniteCheckedException { if (log.isDebugEnabled()) log.debug("Locking parent id [parentId=" + parentId + ", fileName=" + fileName + ", newFileInfo=" + newFileInfo + ']'); validTxState(true); // Lock only parent file ID. IgfsEntryInfo parentInfo = info(parentId); if (parentInfo == null) throw fsException(new IgfsPathNotFoundException("Failed to lock parent directory (not found): " + parentId)); if (!parentInfo.isDirectory()) throw fsException(new IgfsPathIsNotDirectoryException("Parent file is not a directory: " + parentInfo)); IgfsListingEntry childEntry = parentInfo.listing().get(fileName); if (childEntry != null) return childEntry.fileId(); createNewEntry(newFileInfo, parentId, fileName); return null; }
if (lockInfos.get(pathIds.lastExistingId()).isDirectory()) return false; else
/** * Constructs directory info. * * @param path Path. * @param info Entry info. * @param globalGrpBlockSize Global group block size. */ public IgfsFileImpl(IgfsPath path, IgfsEntryInfo info, long globalGrpBlockSize) { A.notNull(path, "path"); A.notNull(info, "info"); this.path = path; fileId = info.id(); flags = IgfsUtils.flags(info.isDirectory(), info.isFile()); if (info.isFile()) { blockSize = info.blockSize(); len = info.length(); grpBlockSize = info.affinityKey() == null ? globalGrpBlockSize : info.length() == 0 ? globalGrpBlockSize : info.length(); } props = info.properties(); if (props == null) props = Collections.emptyMap(); accessTime = info.accessTime(); modificationTime = info.modificationTime(); }
false/*overwrite*/, bufSize, (short)0, 0, null, infos, pendingEvts, outT1); else { if (info.isDirectory()) throw fsException("Failed to open output stream to the file in the " + "secondary file system because the path points to a directory: " + path);
if (info.isDirectory()) { if (!deleteDirectoryContents(trashId, id)) return false;
/** * Constructor. * * @param fileInfo File info to construct listing entry from. */ public IgfsListingEntry(IgfsEntryInfo fileInfo) { id = fileInfo.id(); dir = fileInfo.isDirectory(); }
/** {@inheritDoc} */ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) throws EntryProcessorException { IgfsEntryInfo fileInfo = e.getValue(); assert fileInfo.isDirectory(); Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing()); // Modify listing in-place. IgfsListingEntry oldEntry = listing.get(name); if (oldEntry == null) throw new IgniteException("Directory listing doesn't contain expected entry: " + name); listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory())); e.setValue(fileInfo.listing(listing)); return null; }