Search in sources :

Example 1 with IgfsClientUpdateCallable

use of org.apache.ignite.internal.processors.igfs.client.IgfsClientUpdateCallable in project ignite by apache.

the class IgfsImpl method update.

/** {@inheritDoc} */
@Override
public IgfsFile update(final IgfsPath path, final Map<String, String> props) {
    A.notNull(path, "path");
    A.notNull(props, "props");
    A.ensure(!props.isEmpty(), "!props.isEmpty()");
    if (meta.isClient())
        return meta.runClientTask(new IgfsClientUpdateCallable(cfg.getName(), IgfsUserContext.currentUser(), path, props));
    return safeOp(new Callable<IgfsFile>() {

        @Override
        public IgfsFile call() throws Exception {
            if (log.isDebugEnabled())
                log.debug("Set file properties [path=" + path + ", props=" + props + ']');
            IgfsMode mode = resolveMode(path);
            switch(mode) {
                case PRIMARY:
                    {
                        List<IgniteUuid> fileIds = meta.idsForPath(path);
                        IgniteUuid fileId = fileIds.get(fileIds.size() - 1);
                        if (fileId != null) {
                            IgfsEntryInfo info = meta.updateProperties(fileId, props);
                            if (info != null) {
                                if (evts.isRecordable(EVT_IGFS_META_UPDATED))
                                    evts.record(new IgfsEvent(path, igfsCtx.localNode(), EVT_IGFS_META_UPDATED, props));
                                return new IgfsFileImpl(path, info, data.groupBlockSize());
                            }
                        }
                        break;
                    }
                case DUAL_ASYNC:
                case DUAL_SYNC:
                    {
                        await(path);
                        IgfsEntryInfo info = meta.updateDual(secondaryFs, path, props);
                        if (info != null)
                            return new IgfsFileImpl(path, info, data.groupBlockSize());
                        break;
                    }
                default:
                    assert mode == PROXY : "Unknown mode: " + mode;
                    IgfsFile status = secondaryFs.update(path, props);
                    return status != null ? new IgfsFileImpl(status, data.groupBlockSize()) : null;
            }
            return null;
        }
    });
}
Also used : IgfsMode(org.apache.ignite.igfs.IgfsMode) IgfsClientUpdateCallable(org.apache.ignite.internal.processors.igfs.client.IgfsClientUpdateCallable) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgfsEvent(org.apache.ignite.events.IgfsEvent) IgfsFile(org.apache.ignite.igfs.IgfsFile) IgfsPathIsDirectoryException(org.apache.ignite.igfs.IgfsPathIsDirectoryException) IgfsInvalidPathException(org.apache.ignite.igfs.IgfsInvalidPathException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgfsException(org.apache.ignite.igfs.IgfsException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 IgfsEvent (org.apache.ignite.events.IgfsEvent)1 IgfsException (org.apache.ignite.igfs.IgfsException)1 IgfsFile (org.apache.ignite.igfs.IgfsFile)1 IgfsInvalidPathException (org.apache.ignite.igfs.IgfsInvalidPathException)1 IgfsMode (org.apache.ignite.igfs.IgfsMode)1 IgfsPathIsDirectoryException (org.apache.ignite.igfs.IgfsPathIsDirectoryException)1 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)1 IgfsClientUpdateCallable (org.apache.ignite.internal.processors.igfs.client.IgfsClientUpdateCallable)1 IgniteUuid (org.apache.ignite.lang.IgniteUuid)1