/** * List child files for specified file ID. * * @param fileId File to list child files for. * @return Directory listing for the specified file. * @throws GridException If failed. */ public Map<String, GridGgfsListingEntry> directoryListing(GridUuid fileId) throws GridException { if (busyLock.enterBusy()) { try { return directoryListing(fileId, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get directory listing because Grid is stopping: " + fileId); }
if (!meta.exists(fileInfo.id())) data.delete(fileInfo);
/** * Gets next file for fragmentizer to be processed. * * @param exclude File IDs to exclude (the ones that are currently being processed). * @return File ID to process or {@code null} if there are no such files. * @throws GridException In case of error. */ @Nullable private GridGgfsFileInfo fileForFragmentizer(Collection<GridUuid> exclude) throws GridException { return fragmentizerEnabled ? ggfsCtx.meta().fileForFragmentizer(exclude) : null; }
/** * Gets file ID for specified path. * * @param path Path. * @return File ID for specified path or {@code null} if such file doesn't exist. * @throws GridException If failed. */ @Nullable public GridUuid fileId(GridGgfsPath path) throws GridException { if (busyLock.enterBusy()) { try { assert validTxState(false); return fileId(path, false); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get file ID because Grid is stopping: " + path); }
try { GridGgfsFileInfo info = info(fileId(path)); return synchronizeAndExecute(task, fs, false, path);
GridGgfsSecondaryOutputStreamDescriptor desc = meta.appendDual(secondaryFs, path, bufSize); List<GridUuid> ids = meta.fileIds(path); GridGgfsFileInfo info = meta.info(ids.get(ids.size() - 1)); mode == PRIMARY), props); GridUuid oldId = meta.putIfAbsent(parentId, path.name(), info); info = meta.info(oldId); throw new GridGgfsInvalidPathException("Failed to open file (not a file): " + path); info = meta.lock(info.id());
meta.mkdirsDual(secondaryFs, path, props); List<GridUuid> ids = meta.fileIds(path); List<String> components = path.components(); GridUuid oldId = meta.putIfAbsent(parentId, fileName, fileInfo); GridGgfsFileInfo stored = meta.info(meta.fileId(parentId, fileName));
GridGgfsSecondaryOutputStreamDescriptor desc = meta.createDual(secondaryFs, path, simpleCreate, props, overwrite, bufSize, (short)replication, groupBlockSize(), affKey); mkdirs(parent, props); List<GridUuid> ids = meta.fileIds(path); GridUuid oldId = meta.putIfAbsent(parentId, fileName, info); path); GridGgfsFileInfo oldInfo = meta.info(oldId); evts.record(new GridGgfsEvent(path, localNode(), EVT_GGFS_FILE_CREATED)); info = meta.lock(info.id());
pathIds.add(fileIds(path)); Map<GridUuid, GridGgfsFileInfo> idToInfo = lockIds(lockArr); if (!entry.getValue().equals(fileId(entry.getKey(), true))) { changed = true; List<GridUuid> newIds = fileIds(paths[i], true); infos.put(path, info(pathToId.get(path))); infos.put(parentPath, info(pathToId.get(parentPath))); assert pathToId.get(firstParentPath) != null; GridGgfsFileInfo info = synchronize(fs, firstParentPath, idToInfo.get(pathToId.get(firstParentPath)), path, strict, created);
GridUuid fileId = meta.fileId(path); GridGgfsFileInfo info = meta.info(fileId); info = meta.synchronizeFileDual(secondaryFs, path);
exists = !deleted && meta.exists(fileInfo.id()); meta.unlock(fileInfo, modificationTime); meta.updateParentListingAsync(parentId, fileInfo.id(), fileName, bytes, modificationTime);
/** * Gets all file IDs for components of specified path possibly skipping existing transaction. Result cannot * be empty - there is at least root element. But each element (except the first) can be {@code null} if such * files don't exist. * * @param path Path. * @param skipTx Whether to skip existing transaction. * @return Collection of file IDs for components of specified path. * @throws GridException If failed. */ private List<GridUuid> fileIds(GridGgfsPath path, boolean skipTx) throws GridException { assert path != null; // Path components. Collection<String> components = path.components(); // Collection of file IDs for components of specified path. List<GridUuid> ids = new ArrayList<>(components.size() + 1); ids.add(ROOT_ID); // Always add root ID. GridUuid fileId = ROOT_ID; for (String s : components) { assert !s.isEmpty(); if (fileId != null) fileId = fileId(fileId, s, skipTx); ids.add(fileId); } return ids; }
/** {@inheritDoc} */ @Override public GridFuture<?> format() throws GridException { GridUuid id = meta.softDelete(null, null, ROOT_ID); if (id == null) return new GridFinishedFuture<Object>(ggfsCtx.kernalContext()); else { GridFutureAdapter<Object> fut = new GridFutureAdapter<>(ggfsCtx.kernalContext()); GridFutureAdapter<Object> oldFut = delFuts.putIfAbsent(id, fut); if (oldFut != null) return oldFut; else { if (!meta.exists(id)) { // Safety in case response message was received before we put future into collection. fut.onDone(); delFuts.remove(id, fut); } return fut; } } }
/** {@inheritDoc} */ @Override public GridFuture<?> awaitDeletesAsync() throws GridException { Collection<GridUuid> ids = meta.pendingDeletes(); if (!ids.isEmpty()) { if (log.isDebugEnabled()) log.debug("Constructing delete future for trash entries: " + ids); GridCompoundFuture<Object, Object> resFut = new GridCompoundFuture<>(ggfsCtx.kernalContext()); for (GridUuid id : ids) { GridFutureAdapter<Object> fut = new GridFutureAdapter<>(ggfsCtx.kernalContext()); GridFuture<Object> oldFut = delFuts.putIfAbsent(id, fut); if (oldFut != null) resFut.add(oldFut); else { if (meta.exists(id)) resFut.add(fut); else { fut.onDone(); delFuts.remove(id, fut); } } } resFut.markInitialized(); return resFut; } else return new GridFinishedFuture<>(ggfsCtx.kernalContext()); }
meta.softDelete(desc.parentId, desc.fileName, desc.fileId); Map<String, GridGgfsListingEntry> infoMap = meta.directoryListing(desc.fileId);
GridGgfsFileInfo info = info(parentId); GridGgfsFileInfo fileInfo = info(entry.fileId()); GridGgfsFileInfo fileInfo = fileForFragmentizer0(entry.fileId(), exclude);
exists = meta.exists(fileInfo.id()); GridGgfsFileInfo fileInfo0 = meta.updateInfo(fileInfo.id(), new ReserveSpaceClosure(space, streamRange));