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;
}
});
}
Aggregations