use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class IgfsImpl method setTimes.
/**
* {@inheritDoc}
*/
@Override
public void setTimes(final IgfsPath path, final long modificationTime, final long accessTime) {
A.notNull(path, "path");
if (accessTime == -1 && modificationTime == -1)
return;
if (meta.isClient()) {
meta.runClientTask(new IgfsClientSetTimesCallable(cfg.getName(), IgfsUserContext.currentUser(), path, accessTime, modificationTime));
return;
}
safeOp(new Callable<Void>() {
@Override
public Void call() throws Exception {
IgfsMode mode = resolveMode(path);
if (mode == PROXY)
secondaryFs.setTimes(path, modificationTime, accessTime);
else {
meta.updateTimes(path, modificationTime, accessTime, IgfsUtils.isDualMode(mode) ? secondaryFs : null);
}
return null;
}
});
}
use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class IgfsImpl method mkdirs.
/**
* {@inheritDoc}
*/
@Override
public void mkdirs(final IgfsPath path, @Nullable final Map<String, String> props) {
A.notNull(path, "path");
if (meta.isClient()) {
meta.runClientTask(new IgfsClientMkdirsCallable(cfg.getName(), IgfsUserContext.currentUser(), path, props));
return;
}
safeOp(new Callable<Void>() {
@Override
public Void call() throws Exception {
if (log.isDebugEnabled())
log.debug("Make directories: " + path);
IgfsMode mode = resolveMode(path);
switch(mode) {
case PRIMARY:
meta.mkdirs(path, props == null ? DFLT_DIR_META : new HashMap<>(props));
break;
case DUAL_ASYNC:
case DUAL_SYNC:
await(path);
meta.mkdirsDual(secondaryFs, path, props);
break;
case PROXY:
secondaryFs.mkdirs(path, props);
break;
}
return null;
}
});
}
use of org.apache.ignite.igfs.IgfsMode 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;
}
});
}
use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class IgfsModeResolver method writeExternal.
/**
* {@inheritDoc}
*/
@Override
public void writeExternal(ObjectOutput out) throws IOException {
U.writeEnum(out, dfltMode);
if (modes != null) {
out.writeBoolean(true);
out.writeInt(modes.size());
for (T2<IgfsPath, IgfsMode> pathMode : modes) {
assert pathMode.getKey() != null;
pathMode.getKey().writeExternal(out);
U.writeEnum(out, pathMode.getValue());
}
} else
out.writeBoolean(false);
if (!F.isEmpty(dualParentsWithPrimaryChildren)) {
out.writeBoolean(true);
out.writeInt(dualParentsWithPrimaryChildren.size());
for (IgfsPath p : dualParentsWithPrimaryChildren) p.writeExternal(out);
} else
out.writeBoolean(false);
}
use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class IgfsUtils method validateLocalIgfsConfigurations.
/**
* Validates local IGFS configurations. Compares attributes only for IGFSes with same name.
*
* @param igniteCfg Ignite config.
* @throws IgniteCheckedException If any of IGFS configurations is invalid.
*/
private static void validateLocalIgfsConfigurations(IgniteConfiguration igniteCfg) throws IgniteCheckedException {
if (igniteCfg.getFileSystemConfiguration() == null || igniteCfg.getFileSystemConfiguration().length == 0)
return;
Collection<String> cfgNames = new HashSet<>();
for (FileSystemConfiguration cfg : igniteCfg.getFileSystemConfiguration()) {
String name = cfg.getName();
if (name == null)
throw new IgniteCheckedException("IGFS name cannot be null");
if (cfgNames.contains(name))
throw new IgniteCheckedException("Duplicate IGFS name found (check configuration and " + "assign unique name to each): " + name);
CacheConfiguration ccfgData = cfg.getDataCacheConfiguration();
CacheConfiguration ccfgMeta = cfg.getMetaCacheConfiguration();
if (QueryUtils.isEnabled(ccfgData))
throw new IgniteCheckedException("IGFS data cache cannot start with enabled query indexing.");
if (QueryUtils.isEnabled(ccfgMeta))
throw new IgniteCheckedException("IGFS metadata cache cannot start with enabled query indexing.");
if (ccfgMeta.getAtomicityMode() != TRANSACTIONAL)
throw new IgniteCheckedException("IGFS metadata cache should be transactional: " + cfg.getName());
if (!(ccfgData.getAffinityMapper() instanceof IgfsGroupDataBlocksKeyMapper))
throw new IgniteCheckedException("Invalid IGFS data cache configuration (key affinity mapper class should be " + IgfsGroupDataBlocksKeyMapper.class.getSimpleName() + "): " + cfg);
IgfsIpcEndpointConfiguration ipcCfg = cfg.getIpcEndpointConfiguration();
if (ipcCfg != null) {
final int tcpPort = ipcCfg.getPort();
if (!(tcpPort >= MIN_TCP_PORT && tcpPort <= MAX_TCP_PORT))
throw new IgniteCheckedException("IGFS endpoint TCP port is out of range [" + MIN_TCP_PORT + ".." + MAX_TCP_PORT + "]: " + tcpPort);
if (ipcCfg.getThreadCount() <= 0)
throw new IgniteCheckedException("IGFS endpoint thread count must be positive: " + ipcCfg.getThreadCount());
}
boolean secondary = cfg.getDefaultMode() == IgfsMode.PROXY;
if (cfg.getPathModes() != null) {
for (Map.Entry<String, IgfsMode> mode : cfg.getPathModes().entrySet()) {
if (mode.getValue() == IgfsMode.PROXY)
secondary = true;
}
}
if (secondary && cfg.getSecondaryFileSystem() == null) {
// When working in any mode except of primary, secondary FS config must be provided.
throw new IgniteCheckedException("Grid configuration parameter invalid: " + "secondaryFileSystem cannot be null when mode is not " + IgfsMode.PRIMARY);
}
cfgNames.add(name);
}
}
Aggregations