Examples of GridGgfsFileInfo


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

     */
    private GridGgfsFileInfo resolveFileInfo(GridGgfsPath path, GridGgfsMode mode) throws GridException {
        assert path != null;
        assert mode != null;

        GridGgfsFileInfo info = null;

        switch (mode) {
            case PRIMARY:
                info = meta.info(meta.fileId(path));

                break;

            case DUAL_SYNC:
            case DUAL_ASYNC:
                info = meta.info(meta.fileId(path));

                if (info == null) {
                    GridGgfsFile status = secondaryFs.info(path);

                    if (status != null)
                        info = status.isDirectory() ? new GridGgfsFileInfo(true, status.properties()) :
                            new GridGgfsFileInfo(status.blockSize(), status.length(), null, null, false,
                            status.properties());
                }

                break;

View Full Code Here

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

    /**
     * Perform cleanup of the trash directory.
     */
    private void delete() {
        GridGgfsFileInfo info = null;

        try {
            info = meta.info(TRASH_ID);
        }
        catch (GridException e) {
            U.error(log, "Cannot obtain trash directory info.", e);
        }

        if (info != null) {
            for (Map.Entry<String, GridGgfsListingEntry> entry : info.listing().entrySet()) {
                GridUuid fileId = entry.getValue().fileId();

                if (log.isDebugEnabled())
                    log.debug("Deleting GGFS trash entry [name=" + entry.getKey() + ", fileId=" + fileId + ']');

View Full Code Here

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

    private boolean delete(String name, GridUuid id) throws GridException {
        assert name != null;
        assert id != null;

        while (true) {
            GridGgfsFileInfo info = meta.info(id);

            if (info != null) {
                if (info.isDirectory()) {
                    deleteDirectory(TRASH_ID, id);

                    if (meta.delete(TRASH_ID, name, id))
                        return true;
                }
                else {
                    assert info.isFile();

                    // Delete file content first.
                    // In case this node crashes, other node will re-delete the file.
                    data.delete(info).get();

                    boolean ret = meta.delete(TRASH_ID, name, id);

                    if (evts.isRecordable(EVT_GGFS_FILE_PURGED)) {
                        if (info.path() != null)
                            evts.record(new GridGgfsEvent(info.path(),
                                ggfsCtx.kernalContext().discovery().localNode(), EVT_GGFS_FILE_PURGED));
                        else
                            LT.warn(log, null, "Removing file without path info: " + info);
                    }
View Full Code Here

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

    private void deleteDirectory(GridUuid parentId, GridUuid id) throws GridException {
        assert parentId != null;
        assert id != null;

        while (true) {
            GridGgfsFileInfo info = meta.info(id);

            if (info != null) {
                assert info.isDirectory();

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

                if (listing.isEmpty())
                    return; // Directory is empty.

                Map<String, GridGgfsListingEntry> delListing;

                if (listing.size() <= MAX_DELETE_BATCH)
                    delListing = listing;
                else {
                    delListing = new HashMap<>(MAX_DELETE_BATCH, 1.0f);

                    int i = 0;

                    for (Map.Entry<String, GridGgfsListingEntry> entry : listing.entrySet()) {
                        delListing.put(entry.getKey(), entry.getValue());

                        if (++i == MAX_DELETE_BATCH)
                            break;
                    }
                }

                GridCompoundFuture<Object, ?> fut = new GridCompoundFuture<>(ggfsCtx.kernalContext());

                // Delegate to child folders.
                for (GridGgfsListingEntry entry : delListing.values()) {
                    if (!cancelled) {
                        if (entry.isDirectory())
                            deleteDirectory(id, entry.fileId());
                        else {
                            GridGgfsFileInfo fileInfo = meta.info(entry.fileId());

                            if (fileInfo != null) {
                                assert fileInfo.isFile();

                                fut.add(data.delete(fileInfo));
                            }
                        }
                    }
View Full Code Here

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

        if (busyLock.enterBusy()) {
            try {
                if (fileId == null)
                    return null;

                GridGgfsFileInfo info = id2InfoPrj.get(fileId);

                // Force root ID always exist in cache.
                if (info == null && ROOT_ID.equals(fileId))
                    id2InfoPrj.putxIfAbsent(ROOT_ID, info = new GridGgfsFileInfo());

                return info;
            }
            finally {
                busyLock.leaveBusy();
View Full Code Here

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

                Map<GridUuid, GridGgfsFileInfo> map = id2InfoPrj.getAll(fileIds);

                // Force root ID always exist in cache.
                if (fileIds.contains(ROOT_ID) && !map.containsKey(ROOT_ID)) {
                    GridGgfsFileInfo info = new GridGgfsFileInfo();

                    id2InfoPrj.putxIfAbsent(ROOT_ID, info);

                    map = new GridLeanMap<>(map);
View Full Code Here

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

                GridCacheTx tx = metaCache.txStart(PESSIMISTIC, REPEATABLE_READ);

                try {
                    // Lock file ID for this transaction.
                    GridGgfsFileInfo oldInfo = info(fileId);

                    if (oldInfo == null)
                        throw new GridException("Failed to lock file (file not found): " + fileId);

                    GridGgfsFileInfo newInfo = lockInfo(oldInfo);

                    boolean put = metaCache.putx(fileId, newInfo);

                    assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo + ']';
View Full Code Here

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

                if (info.lockId() != null)
                    throw new GridException("Failed to lock file (file is being concurrently written) [fileId=" +
                        info.id() + ", lockId=" + info.lockId() + ']');

                return new GridGgfsFileInfo(info, GridUuid.randomUuid(), info.modificationTime());
            }
            finally {
                busyLock.leaveBusy();
            }
        }
View Full Code Here

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

                GridCacheTx tx = metaCache.txStart(PESSIMISTIC, REPEATABLE_READ);

                try {
                    // Lock file ID for this transaction.
                    GridGgfsFileInfo oldInfo = info(fileId);

                    if (oldInfo == null)
                        throw new GridGgfsFileNotFoundException("Failed to unlock file (file not found): " + fileId);

                    if (!info.lockId().equals(oldInfo.lockId()))
                        throw new GridException("Failed to unlock file (inconsistent file lock ID) [fileId=" + fileId +
                            ", lockId=" + info.lockId() + ", actualLockId=" + oldInfo.lockId() + ']');

                    GridGgfsFileInfo newInfo = new GridGgfsFileInfo(oldInfo, null, modificationTime);

                    boolean put = metaCache.putx(fileId, newInfo);

                    assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo + ']';
View Full Code Here

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

        if (log.isDebugEnabled())
            log.debug("Locked file ids: " + keys);

        // Force root ID always exist in cache.
        if (keys.contains(ROOT_ID) && !map.containsKey(ROOT_ID)) {
            GridGgfsFileInfo info = new GridGgfsFileInfo();

            id2InfoPrj.putxIfAbsent(ROOT_ID, info);

            map = new GridLeanMap<>(map);
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.