/** * List child files for specified file ID possibly skipping existing transaction. * * @param fileId File to list child files for. * @param skipTx Whether to skip existing transaction. * @return Directory listing for the specified file.* * @throws IgniteCheckedException If failed. */ private Map<String, IgfsListingEntry> directoryListing(IgniteUuid fileId, boolean skipTx) throws IgniteCheckedException { assert fileId != null; IgfsEntryInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) : getInfo(fileId); return info == null ? Collections.<String, IgfsListingEntry>emptyMap() : info.listing(); }
/** {@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 IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args) throws EntryProcessorException { IgfsEntryInfo info = IgfsUtils.createDirectory( entry.getKey(), null, props, accessTime, modificationTime ); if (childName != null) info = info.listing(Collections.singletonMap(childName, childEntry)); entry.setValue(info); return info; }
/** {@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; }
@Override public Collection<IgfsPath> call() throws Exception { if (log.isDebugEnabled()) log.debug("List directory: " + path); IgfsMode mode = resolveMode(path); Collection<IgfsPath> files = new HashSet<>(); if (mode != PRIMARY) { assert secondaryFs != null; try { Collection<IgfsPath> children = secondaryFs.listPaths(path); files.addAll(children); if (mode == PROXY || !modeRslvr.hasPrimaryChild(path)) return files; } catch (Exception e) { U.error(log, "List paths in DUAL mode failed [path=" + path + ']', e); throw e; } } IgfsEntryInfo info = primaryInfoForListing(path); if (info != null) { // Perform the listing. for (String child : info.listing().keySet()) files.add(new IgfsPath(path, child)); } else if (mode == PRIMARY) throw new IgfsPathNotFoundException("Failed to list paths (path not found): " + path); return files; } });
String part = pathIds.part(lastLockedIdx + 1); if (lastLockedInfo.listing().containsKey(part)) return true;
assert info.isDirectory(); final Map<String, IgfsListingEntry> listing = info.listing();
for (Map.Entry<String, IgfsListingEntry> entry : info.listing().entrySet()) { IgniteUuid fileId = entry.getValue().fileId();
IgfsListingEntry childEntry = parentInfo.listing().get(name);
for (Map.Entry<String, IgfsListingEntry> e : info.listing().entrySet()) { IgfsEntryInfo childInfo = meta.info(e.getValue().fileId());
Map<String, IgfsListingEntry> listing = info.listing();
/** * 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; }
return new IgfsDeleteResult(false, null); transferEntry(parentInfo.listing().get(victimName), parentId, victimName, trashId, trashName);
fileId + ']')); IgfsListingEntry srcEntry = srcInfo.listing().get(srcFileName);
IgfsListingEntry srcEntry = srcParentInfo.listing().get(srcName);
/** @throws Exception If failed. */ @Test public void testCreate() throws Exception { IgfsPath path = path("/file"); try (IgfsOutputStream os = igfs.create(path, false)) { assert os != null; IgfsFileImpl info = (IgfsFileImpl)igfs.info(path); for (int i = 0; i < nodesCount(); i++) { IgfsEntryInfo fileInfo = (IgfsEntryInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(), null); assertNotNull(fileInfo); assertNotNull(fileInfo.listing()); } } finally { igfs.delete(path("/"), true); } }