Examples of GridGgfsFileInfo


Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

     * @return First qualified file info.
     * @throws GridException If failed to get file for fragmentizer.
     */
    private GridGgfsFileInfo fileForFragmentizer0(GridUuid parentId, Collection<GridUuid> exclude)
        throws GridException {
        GridGgfsFileInfo info = info(parentId);

        // Check if file was concurrently deleted.
        if (info == null)
            return null;

        assert info.isDirectory();

        Map<String, GridGgfsListingEntry> listing = info.listing();

        for (GridGgfsListingEntry entry : listing.values()) {
            if (entry.isFile()) {
                GridGgfsFileInfo fileInfo = info(entry.fileId());

                if (fileInfo != null) {
                    if (!exclude.contains(fileInfo.id()) &&
                        fileInfo.fileMap() != null &&
                        !fileInfo.fileMap().ranges().isEmpty())
                        return fileInfo;
                }
            }
            else {
                GridGgfsFileInfo fileInfo = fileForFragmentizer0(entry.fileId(), exclude);

                if (fileInfo != null)
                    return fileInfo;
            }
        }
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

     * @throws GridException If failed.
     */
    private Map<String, GridGgfsListingEntry> directoryListing(GridUuid fileId, boolean skipTx) throws GridException {
        assert fileId != null;

        GridGgfsFileInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singletonList(fileId)).get(fileId) :
            id2InfoPrj.get(fileId);

        return info == null ? Collections.<String, GridGgfsListingEntry>emptyMap() : info.listing();
    }
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

                newFileInfo + ']');

        validTxState(true);

        // Lock only parent file ID.
        GridGgfsFileInfo parentInfo = info(parentId);

        assert validTxState(true);

        if (parentInfo == null)
            throw new GridGgfsFileNotFoundException("Failed to lock parent directory (not found): " + parentId);

        if (!parentInfo.isDirectory())
            throw new GridGgfsInvalidPathException("Parent file is not a directory: " + parentInfo);

        Map<String, GridGgfsListingEntry> parentListing = parentInfo.listing();

        assert parentListing != null;

        GridGgfsListingEntry entry = parentListing.get(fileName);
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

        // Lock file ID and parent IDs for this transaction.
        Map<GridUuid, GridGgfsFileInfo> infoMap = lockIds(srcParentId, fileId, destParentId);

        validTxState(true);

        GridGgfsFileInfo srcInfo = infoMap.get(srcParentId);

        if (srcInfo == null)
            throw new GridGgfsFileNotFoundException("Failed to lock source directory (not found?)" +
                " [srcParentId=" + srcParentId + ']');

        if (!srcInfo.isDirectory())
            throw new GridGgfsInvalidPathException("Source is not a directory: " + srcInfo);

        GridGgfsFileInfo destInfo = infoMap.get(destParentId);

        if (destInfo == null)
            throw new GridGgfsFileNotFoundException("Failed to lock destination directory (not found?)" +
                " [destParentId=" + destParentId + ']');

        if (!destInfo.isDirectory())
            throw new GridGgfsInvalidPathException("Destination is not a directory: " + destInfo);

        GridGgfsFileInfo fileInfo = infoMap.get(fileId);

        if (fileInfo == null)
            throw new GridGgfsFileNotFoundException("Failed to lock target file (not found?) [fileId=" +
                fileId + ']');
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

                    if (parentId != null)
                        lockIds(parentId, fileId, TRASH_ID);
                    else
                        lockIds(fileId, TRASH_ID);

                    GridGgfsFileInfo fileInfo = removeIfEmptyNonTx(parentId, fileName, fileId, path, rmvLocked);

                    tx.commit();

                    delWorker.signal();
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

        if (log.isDebugEnabled())
            log.debug("Remove file: [parentId=" + parentId + ", fileName= " + fileName + ", fileId=" + fileId + ']');

        // Safe gets because locks are obtained in removeIfEmpty.
        GridGgfsFileInfo fileInfo = id2InfoPrj.get(fileId);
        GridGgfsFileInfo parentInfo = id2InfoPrj.get(parentId);

        if (fileInfo == null || parentInfo == null) {
            if (parentInfo != null) { // fileInfo == null
                GridGgfsListingEntry entry = parentInfo.listing().get(fileName);

                // If file info does not exists but listing entry exists, throw inconsistent exception.
                if (entry != null && entry.fileId().equals(fileId))
                    throw new GridException("Failed to remove file (file system is in inconsistent state) " +
                        "[fileInfo=" + fileInfo + ", fileName=" + fileName + ", fileId=" + fileId + ']');
            }

            return null; // Parent directory or removed file cannot be locked (not found?).
        }

        assert parentInfo.isDirectory();

        if (!rmvLocked && fileInfo.lockId() != null)
            throw new GridGgfsException("Failed to remove file (file is opened for writing) [fileName=" +
                fileName + ", fileId=" + fileId + ", lockId=" + fileInfo.lockId() + ']');

        // Validate own directory listing.
        if (fileInfo.isDirectory()) {
            Map<String, GridGgfsListingEntry> listing = fileInfo.listing();

            if (!F.isEmpty(listing))
                throw new GridGgfsDirectoryNotEmptyException("Failed to remove file (directory is not empty)" +
                    " [fileId=" + fileId + ", listing=" + listing + ']');
        }

        // Validate file in the parent listing.
        GridGgfsListingEntry listingEntry = parentInfo.listing().get(fileName);

        if (listingEntry == null || !listingEntry.fileId().equals(fileId))
            return null;

        // Actual remove.
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

        if (parentId == null) {
            // Handle special case when we deleting root directory.
            assert ROOT_ID.equals(id);

            GridGgfsFileInfo rootInfo = id2InfoPrj.get(ROOT_ID);

            if (rootInfo == null)
                return null; // Root was never created.

            // Ensure trash directory existence.
            if (id2InfoPrj.get(TRASH_ID) == null)
                id2InfoPrj.put(TRASH_ID, new GridGgfsFileInfo(TRASH_ID));

            Map<String, GridGgfsListingEntry> rootListing = rootInfo.listing();

            if (!rootListing.isEmpty()) {
                GridUuid[] lockIds = new GridUuid[rootInfo.listing().size()];

                int i = 0;

                for (GridGgfsListingEntry entry : rootInfo.listing().values())
                    lockIds[i++] = entry.fileId();

                // Lock children IDs in correct order.
                lockIds(lockIds);

                // Construct new info and move locked entries from root to it.
                Map<String, GridGgfsListingEntry> transferListing = new HashMap<>();

                transferListing.putAll(rootListing);

                GridGgfsFileInfo newInfo = new GridGgfsFileInfo(transferListing);

                id2InfoPrj.put(newInfo.id(), newInfo);

                // Add new info to trash listing.
                id2InfoPrj.transform(TRASH_ID, new UpdateListing(newInfo.id().toString(),
                    new GridGgfsListingEntry(newInfo), false));

                // Remove listing entries from root.
                for (Map.Entry<String, GridGgfsListingEntry> entry : transferListing.entrySet())
                    id2InfoPrj.transform(ROOT_ID, new UpdateListing(entry.getKey(), entry.getValue(), true));

                resId = newInfo.id();
            }
            else
                resId = null;
        }
        else {
            // Ensure trash directory existence.
            if (id2InfoPrj.get(TRASH_ID) == null)
                id2InfoPrj.put(TRASH_ID, new GridGgfsFileInfo(TRASH_ID));

            moveNonTx(id, name, parentId, id.toString(), TRASH_ID);

            resId = id;
        }
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

                    for (GridGgfsListingEntry entry : listing.values())
                        allIds[i++] = entry.fileId();

                    Map<GridUuid, GridGgfsFileInfo> locks = lockIds(allIds);

                    GridGgfsFileInfo parentInfo = locks.get(parentId);

                    // Ensure parent is still in place.
                    if (parentInfo != null) {
                        Map<String, GridGgfsListingEntry> newListing =
                            new HashMap<>(parentInfo.listing().size(), 1.0f);

                        newListing.putAll(parentInfo.listing());

                        // Remove child entries if possible.
                        for (Map.Entry<String, GridGgfsListingEntry> entry : listing.entrySet()) {
                            GridUuid entryId = entry.getValue().fileId();

                            GridGgfsFileInfo entryInfo = locks.get(entryId);

                            if (entryInfo != null) {
                                // Delete only files or empty folders.
                                if (entryInfo.isFile() || entryInfo.isDirectory() && entryInfo.listing().isEmpty()) {
                                    id2InfoPrj.remove(entryId);

                                    newListing.remove(entry.getKey());

                                    res.add(entryId);
                                }
                            }
                            else {
                                // Entry was deleted concurrently.
                                newListing.remove(entry.getKey());

                                res.add(entryId);
                            }
                        }

                        // Update parent listing.
                        id2InfoPrj.putx(parentId, new GridGgfsFileInfo(newListing, parentInfo));
                    }

                    tx.commit();

                    return res;
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

                    Map<GridUuid, GridGgfsFileInfo> infos = lockIds(parentId, id);

                    // Proceed only in case both parent and child exist.
                    if (infos.containsKey(parentId) && infos.containsKey(id)) {
                        GridGgfsFileInfo parentInfo = infos.get(parentId);

                        assert parentInfo != null;

                        GridGgfsListingEntry listingEntry = parentInfo.listing().get(name);

                        if (listingEntry != null)
                            id2InfoPrj.transform(parentId, new UpdateListing(name, listingEntry, true));

                        id2InfoPrj.remove(id);
View Full Code Here

Examples of org.gridgain.grid.kernal.processors.ggfs.GridGgfsFileInfo

     * @throws GridException If operation failed.
     */
    public Collection<GridUuid> pendingDeletes() throws GridException {
        if (busyLock.enterBusy()) {
            try {
                GridGgfsFileInfo trashInfo = id2InfoPrj.get(TRASH_ID);

                if (trashInfo != null) {
                    Map<String, GridGgfsListingEntry> listing = trashInfo.listing();

                    if (listing != null && !listing.isEmpty()) {
                        return F.viewReadOnly(listing.values(), new GridClosure<GridGgfsListingEntry, GridUuid>() {
                            @Override public GridUuid apply(GridGgfsListingEntry e) {
                                return e.fileId();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.