/** {@inheritDoc} */ @Override public IgfsHandshakeResponse handshake(final String logDir) { return IgfsUserContext.doAs(user, new IgniteOutClosure<IgfsHandshakeResponse>() { @Override public IgfsHandshakeResponse apply() { igfs.clientLogDirectory(logDir); return new IgfsHandshakeResponse(igfs.name(), igfs.groupBlockSize(), igfs.globalSampling()); } }); }
/** * Gets owner of a secondary Fs path. * @param secFs The sec Fs. * @param p The path. * @return The owner. */ private static String getOwnerSecondary(final IgfsSecondaryFileSystem secFs, final IgfsPath p) { return IgfsUserContext.doAs(USER, new IgniteOutClosure<String>() { @Override public String apply() { return secFs.info(p).property(IgfsUtils.PROP_USER_NAME); } }); }
/** {@inheritDoc} */ @Override public IgfsModeResolver modeResolver() throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<IgfsModeResolver>() { @Override public IgfsModeResolver apply() { return ((IgfsImpl)igfs).modeResolver(); } }); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to get mode resolver because Grid is stopping"); } } }
/** * Gets owner of a IgfsEx path. * @param p The path. * @return The owner. */ private static String getOwner(final IgfsEx i, final IgfsPath p) { return IgfsUserContext.doAs(USER, new IgniteOutClosure<String>() { @Override public String apply() { IgfsFile f = i.info(p); assert f != null; return f.property(IgfsUtils.PROP_USER_NAME); } }); }
/** {@inheritDoc} */ @Override public IgfsStatus fsStatus() throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new Callable<IgfsStatus>() { @Override public IgfsStatus call() throws IgniteCheckedException { return igfs.globalSpace(); } }); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to get file system status because Grid is stopping."); } catch (IgniteCheckedException | RuntimeException | Error e) { throw e; } catch (Exception ignored) { throw new AssertionError("Must never go there."); } }
/** {@inheritDoc} */ @Override public HadoopIgfsStreamDelegate append(final IgfsPath path, final boolean create, @Nullable final Map<String, String> props) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<HadoopIgfsStreamDelegate>() { @Override public HadoopIgfsStreamDelegate apply() { IgfsOutputStream stream = igfs.append(path, bufSize, create, props); return new HadoopIgfsStreamDelegate(HadoopIgfsInProc.this, stream); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to append file because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public Collection<IgfsBlockLocation> affinity(final IgfsPath path, final long start, final long len) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<Collection<IgfsBlockLocation>>() { @Override public Collection<IgfsBlockLocation> apply() { return igfs.affinity(path, start, len); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to get affinity because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public IgfsFile info(final IgfsPath path) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<IgfsFile>() { @Override public IgfsFile apply() { return igfs.info(path); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to get file info because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public HadoopIgfsStreamDelegate create(final IgfsPath path, final boolean overwrite, final boolean colocate, final int replication, final long blockSize, @Nullable final Map<String, String> props) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<HadoopIgfsStreamDelegate>() { @Override public HadoopIgfsStreamDelegate apply() { IgfsOutputStream stream = igfs.create(path, bufSize, overwrite, colocate ? igfs.nextAffinityKey() : null, replication, blockSize, props); return new HadoopIgfsStreamDelegate(HadoopIgfsInProc.this, stream); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to findIgfsAndCreate file because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public IgfsFile update(final IgfsPath path, final Map<String, String> props) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<IgfsFile>() { @Override public IgfsFile apply() { return igfs.update(path, props); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to update file because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public IgfsPathSummary contentSummary(final IgfsPath path) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<IgfsPathSummary>() { @Override public IgfsPathSummary apply() { return igfs.summary(path); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to get content summary because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public Collection<IgfsPath> listPaths(final IgfsPath path) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<Collection<IgfsPath>>() { @Override public Collection<IgfsPath> apply() { return igfs.listPaths(path); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to list paths because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public Collection<IgfsFile> listFiles(final IgfsPath path) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<Collection<IgfsFile>>() { @Override public Collection<IgfsFile> apply() { return igfs.listFiles(path); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to list files because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public Boolean delete(final IgfsPath path, final boolean recursive) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<Boolean>() { @Override public Boolean apply() { return igfs.delete(path, recursive); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to delete path because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public Boolean rename(final IgfsPath src, final IgfsPath dest) throws IgniteCheckedException { try { IgfsUserContext.doAs(user, new IgniteOutClosure<Void>() { @Override public Void apply() { igfs.rename(src, dest); return null; } }); return true; } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to rename path because Grid is stopping: " + src); } }
/** {@inheritDoc} */ @Override public HadoopIgfsStreamDelegate open(final IgfsPath path, final int seqReadsBeforePrefetch) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<HadoopIgfsStreamDelegate>() { @Override public HadoopIgfsStreamDelegate apply() { IgfsInputStream stream = igfs.open(path, bufSize, seqReadsBeforePrefetch); return new HadoopIgfsStreamDelegate(HadoopIgfsInProc.this, stream, stream.length()); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to open file because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public Boolean mkdirs(final IgfsPath path, final Map<String, String> props) throws IgniteCheckedException { try { IgfsUserContext.doAs(user, new IgniteOutClosure<Void>() { @Override public Void apply() { igfs.mkdirs(path, props); return null; } }); return true; } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to findIgfsAndCreate directory because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public HadoopIgfsStreamDelegate open(final IgfsPath path) throws IgniteCheckedException { try { return IgfsUserContext.doAs(user, new IgniteOutClosure<HadoopIgfsStreamDelegate>() { @Override public HadoopIgfsStreamDelegate apply() { IgfsInputStream stream = igfs.open(path, bufSize); return new HadoopIgfsStreamDelegate(HadoopIgfsInProc.this, stream, stream.length()); } }); } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to open file because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public Boolean setTimes(final IgfsPath path, final long accessTime, final long modificationTime) throws IgniteCheckedException { try { IgfsUserContext.doAs(user, new IgniteOutClosure<Void>() { @Override public Void apply() { igfs.setTimes(path, modificationTime, accessTime); return null; } }); return true; } catch (IgniteException e) { throw new IgniteCheckedException(e); } catch (IllegalStateException ignored) { throw new HadoopIgfsCommunicationException("Failed to set path times because Grid is stopping: " + path); } }
/** {@inheritDoc} */ @Override public final T call() throws Exception { assert ignite != null; final IgfsEx igfs = (IgfsEx)ignite.fileSystem(igfsName); if (user != null) { return IgfsUserContext.doAs(user, new Callable<T>() { @Override public T call() throws Exception { return call0(igfs.context()); } }); } else return call0(igfs.context()); }