Search in sources :

Example 1 with IgniteClientException

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;
    }
}
Also used : FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) IgniteClientException(org.apache.ignite.internal.processors.platform.client.IgniteClientException) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) SecurityException(org.apache.ignite.plugin.security.SecurityException) IgniteClientException(org.apache.ignite.internal.processors.platform.client.IgniteClientException) SecurityException(org.apache.ignite.plugin.security.SecurityException)

Example 2 with IgniteClientException

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());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteClientException(org.apache.ignite.internal.processors.platform.client.IgniteClientException) GridTaskProcessor(org.apache.ignite.internal.processors.task.GridTaskProcessor)

Example 3 with IgniteClientException

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);
    }
}
Also used : IgniteClientException(org.apache.ignite.internal.processors.platform.client.IgniteClientException) ClientIntResponse(org.apache.ignite.internal.processors.platform.client.ClientIntResponse) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) IgniteClientException(org.apache.ignite.internal.processors.platform.client.IgniteClientException)

Aggregations

IgniteClientException (org.apache.ignite.internal.processors.platform.client.IgniteClientException)3 FieldsQueryCursor (org.apache.ignite.cache.query.FieldsQueryCursor)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)1 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)1 ClientIntResponse (org.apache.ignite.internal.processors.platform.client.ClientIntResponse)1 GridTaskProcessor (org.apache.ignite.internal.processors.task.GridTaskProcessor)1 SecurityException (org.apache.ignite.plugin.security.SecurityException)1