use of org.apache.ignite.internal.igfs.common.IgfsMessage in project ignite by apache.
the class IgfsIpcHandler method handleAsync.
/** {@inheritDoc} */
@Override
public IgniteInternalFuture<IgfsMessage> handleAsync(final IgfsClientSession ses, final IgfsMessage msg, final DataInput in) {
try {
// Even if will be closed right after this call, response write error will be ignored.
if (stopping)
return null;
final IgfsIpcCommand cmd = msg.command();
IgniteInternalFuture<IgfsMessage> fut;
switch(cmd) {
// Execute not-blocking command synchronously in worker thread.
case WRITE_BLOCK:
case MAKE_DIRECTORIES:
case LIST_FILES:
case LIST_PATHS:
{
fut = executeSynchronously(ses, cmd, msg, in);
break;
}
// Execute command asynchronously in pool.
default:
{
try {
final GridFutureAdapter<IgfsMessage> fut0 = new GridFutureAdapter<>();
pool.execute(new Runnable() {
@Override
public void run() {
try {
fut0.onDone(execute(ses, cmd, msg, in));
} catch (Exception e) {
fut0.onDone(e);
}
}
});
fut = fut0;
} catch (RejectedExecutionException ignored) {
fut = executeSynchronously(ses, cmd, msg, in);
}
}
}
// Pack result object into response format.
return fut;
} catch (Exception e) {
return new GridFinishedFuture<>(e);
}
}
Aggregations