use of org.apache.ignite.internal.igfs.common.IgfsPathControlRequest in project ignite by apache.
the class IgfsIpcHandler method processPathControlRequest.
/**
* Processes path control request.
*
* @param ses Session.
* @param cmd Command.
* @param msg Message.
* @return Response message.
* @throws IgniteCheckedException If failed.
*/
private IgfsMessage processPathControlRequest(final IgfsClientSession ses, final IgfsIpcCommand cmd, IgfsMessage msg) throws IgniteCheckedException {
final IgfsPathControlRequest req = (IgfsPathControlRequest) msg;
if (log.isDebugEnabled())
log.debug("Processing path control request [igfsName=" + igfs.name() + ", req=" + req + ']');
final IgfsControlResponse res = new IgfsControlResponse();
final String userName = req.userName();
assert userName != null;
try {
IgfsUserContext.doAs(userName, new IgniteOutClosure<Object>() {
@Override
public Void apply() {
switch(cmd) {
case EXISTS:
res.response(igfs.exists(req.path()));
break;
case INFO:
res.response(igfs.info(req.path()));
break;
case PATH_SUMMARY:
res.response(igfs.summary(req.path()));
break;
case UPDATE:
res.response(igfs.update(req.path(), req.properties()));
break;
case RENAME:
igfs.rename(req.path(), req.destinationPath());
res.response(true);
break;
case DELETE:
res.response(igfs.delete(req.path(), req.flag()));
break;
case MAKE_DIRECTORIES:
igfs.mkdirs(req.path(), req.properties());
res.response(true);
break;
case LIST_PATHS:
res.paths(igfs.listPaths(req.path()));
break;
case LIST_FILES:
res.files(igfs.listFiles(req.path()));
break;
case SET_TIMES:
igfs.setTimes(req.path(), req.modificationTime(), req.accessTime());
res.response(true);
break;
case AFFINITY:
res.locations(igfs.affinity(req.path(), req.start(), req.length()));
break;
case OPEN_READ:
{
IgfsInputStream igfsIn = !req.flag() ? igfs.open(req.path(), bufSize) : igfs.open(req.path(), bufSize, req.sequentialReadsBeforePrefetch());
long streamId = registerResource(ses, igfsIn);
if (log.isDebugEnabled())
log.debug("Opened IGFS input stream for file read [igfsName=" + igfs.name() + ", path=" + req.path() + ", streamId=" + streamId + ", ses=" + ses + ']');
res.response(new IgfsInputStreamDescriptor(streamId, igfsIn.length()));
break;
}
case OPEN_CREATE:
{
long streamId = registerResource(ses, igfs.create(// Path.
req.path(), // Buffer size.
bufSize, // Overwrite if exists.
req.flag(), // Affinity key based on replication factor.
affinityKey(req), // Replication factor.
req.replication(), // Block size.
req.blockSize(), // File properties.
req.properties()));
if (log.isDebugEnabled())
log.debug("Opened IGFS output stream for file create [igfsName=" + igfs.name() + ", path=" + req.path() + ", streamId=" + streamId + ", ses=" + ses + ']');
res.response(streamId);
break;
}
case OPEN_APPEND:
{
long streamId = registerResource(ses, igfs.append(// Path.
req.path(), // Buffer size.
bufSize, // Create if absent.
req.flag(), // File properties.
req.properties()));
if (log.isDebugEnabled())
log.debug("Opened IGFS output stream for file append [igfsName=" + igfs.name() + ", path=" + req.path() + ", streamId=" + streamId + ", ses=" + ses + ']');
res.response(streamId);
break;
}
default:
assert false : "Unhandled path control request command: " + cmd;
break;
}
return null;
}
});
} catch (IgniteException e) {
throw new IgniteCheckedException(e);
}
if (log.isDebugEnabled())
log.debug("Finished processing path control request [igfsName=" + igfs.name() + ", req=" + req + ", res=" + res + ']');
return res;
}
use of org.apache.ignite.internal.igfs.common.IgfsPathControlRequest in project ignite by apache.
the class HadoopIgfsOutProc method update.
/** {@inheritDoc} */
@Override
public IgfsFile update(IgfsPath path, Map<String, String> props) throws IgniteCheckedException {
final IgfsPathControlRequest msg = new IgfsPathControlRequest();
msg.command(UPDATE);
msg.path(path);
msg.properties(props);
msg.userName(userName);
return io.send(msg).chain(FILE_RES).get();
}
use of org.apache.ignite.internal.igfs.common.IgfsPathControlRequest in project ignite by apache.
the class HadoopIgfsOutProc method delete.
/** {@inheritDoc} */
@Override
public Boolean delete(IgfsPath path, boolean recursive) throws IgniteCheckedException {
final IgfsPathControlRequest msg = new IgfsPathControlRequest();
msg.command(DELETE);
msg.path(path);
msg.flag(recursive);
msg.userName(userName);
return io.send(msg).chain(BOOL_RES).get();
}
use of org.apache.ignite.internal.igfs.common.IgfsPathControlRequest in project ignite by apache.
the class HadoopIgfsOutProc method setTimes.
/** {@inheritDoc} */
@Override
public Boolean setTimes(IgfsPath path, long accessTime, long modificationTime) throws IgniteCheckedException {
final IgfsPathControlRequest msg = new IgfsPathControlRequest();
msg.command(SET_TIMES);
msg.path(path);
msg.accessTime(accessTime);
msg.modificationTime(modificationTime);
msg.userName(userName);
return io.send(msg).chain(BOOL_RES).get();
}
use of org.apache.ignite.internal.igfs.common.IgfsPathControlRequest in project ignite by apache.
the class HadoopIgfsOutProc method open.
/** {@inheritDoc} */
@Override
public HadoopIgfsStreamDelegate open(IgfsPath path, int seqReadsBeforePrefetch) throws IgniteCheckedException {
final IgfsPathControlRequest msg = new IgfsPathControlRequest();
msg.command(OPEN_READ);
msg.path(path);
msg.flag(true);
msg.sequentialReadsBeforePrefetch(seqReadsBeforePrefetch);
msg.userName(userName);
IgfsInputStreamDescriptor rmtDesc = io.send(msg).chain(STREAM_DESCRIPTOR_RES).get();
return new HadoopIgfsStreamDelegate(this, rmtDesc.streamId(), rmtDesc.length());
}
Aggregations