use of org.apache.ignite.internal.processors.platform.client.IgniteClientException in project ignite by apache.
the class ClientCacheSqlFieldsQueryRequest method process.
/**
* {@inheritDoc}
*/
@Override
public ClientResponse process(ClientConnectionContext ctx) {
qry.setPartitions(partitions);
if (updateBatchSize != null)
qry.setUpdateBatchSize(updateBatchSize);
ctx.incrementCursors();
try {
qry.setQueryInitiatorId(ctx.clientDescriptor());
// If cacheId is provided, we must check the cache for existence.
if (cacheId() != 0) {
DynamicCacheDescriptor desc = cacheDescriptor(ctx);
if (qry.getSchema() == null) {
String schema = QueryUtils.normalizeSchemaName(desc.cacheName(), desc.cacheConfiguration().getSqlSchema());
qry.setSchema(schema);
}
}
List<FieldsQueryCursor<List<?>>> curs = ctx.kernalContext().query().querySqlFields(qry, true, true);
assert curs.size() == 1;
FieldsQueryCursor cur = curs.get(0);
ClientCacheFieldsQueryCursor cliCur = new ClientCacheFieldsQueryCursor(cur, qry.getPageSize(), ctx);
long cursorId = ctx.resources().put(cliCur);
cliCur.id(cursorId);
return new ClientCacheSqlFieldsQueryResponse(requestId(), cliCur, cur, includeFieldNames);
} catch (Exception e) {
ctx.decrementCursors();
SecurityException securityEx = X.cause(e, SecurityException.class);
if (securityEx != null) {
throw new IgniteClientException(ClientStatus.SECURITY_VIOLATION, "Client is not authorized to perform this operation", securityEx);
}
throw e;
}
}
use of org.apache.ignite.internal.processors.platform.client.IgniteClientException in project ignite by apache.
the class ClientComputeTask method execute.
/**
* @param taskId Task ID.
* @param taskName Task name.
* @param arg Task arguments.
* @param nodeIds Nodes to run task jobs.
* @param flags Flags for task.
* @param timeout Task timeout.
*/
void execute(long taskId, String taskName, Object arg, Set<UUID> nodeIds, byte flags, long timeout) {
assert taskName != null;
this.taskId = taskId;
GridTaskProcessor task = ctx.kernalContext().task();
IgnitePredicate<ClusterNode> nodePredicate = F.isEmpty(nodeIds) ? node -> !node.isClient() : F.nodeForNodeIds(nodeIds);
task.setThreadContext(TC_SUBGRID_PREDICATE, nodePredicate);
task.setThreadContext(TC_TIMEOUT, timeout);
task.setThreadContext(TC_NO_FAILOVER, (flags & NO_FAILOVER_FLAG_MASK) != 0);
task.setThreadContext(TC_NO_RESULT_CACHE, (flags & NO_RESULT_CACHE_FLAG_MASK) != 0);
taskFut = task.execute(taskName, arg);
// Fail fast.
if (taskFut.isDone() && taskFut.error() != null)
throw new IgniteClientException(ClientStatus.FAILED, taskFut.error().getMessage());
}
use of org.apache.ignite.internal.processors.platform.client.IgniteClientException in project ignite by apache.
the class ClientTxStartRequest method process.
/**
* {@inheritDoc}
*/
@Override
public ClientResponse process(ClientConnectionContext ctx) {
GridNearTxLocal tx;
ctx.kernalContext().gateway().readLock();
try {
tx = ctx.kernalContext().cache().context().tm().newTx(false, false, null, concurrency, isolation, timeout, true, null, 0, lb, false);
} finally {
ctx.kernalContext().gateway().readUnlock();
}
try {
tx.suspend();
int txId = ctx.nextTxId();
ctx.addTxContext(new ClientTxContext(txId, tx));
return new ClientIntResponse(requestId(), txId);
} catch (Exception e) {
try {
tx.close();
} catch (Exception e1) {
e.addSuppressed(e1);
}
throw (e instanceof IgniteClientException) ? (IgniteClientException) e : new IgniteClientException(ClientStatus.FAILED, e.getMessage(), e);
}
}
Aggregations