Search in sources :

Example 1 with SchemaIndexCacheVisitor

use of org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitor in project ignite by apache.

the class GridQueryProcessor method processIndexOperationLocal.

/**
     * Process index operation.
     *
     * @param op Operation.
     * @param type Type descriptor.
     * @param depId Cache deployment ID.
     * @param cancelTok Cancel token.
     * @throws SchemaOperationException If failed.
     */
public void processIndexOperationLocal(SchemaAbstractOperation op, QueryTypeDescriptorImpl type, IgniteUuid depId, SchemaIndexOperationCancellationToken cancelTok) throws SchemaOperationException {
    if (log.isDebugEnabled())
        log.debug("Started local index operation [opId=" + op.id() + ']');
    String cacheName = op.cacheName();
    GridCacheAdapter cache = ctx.cache().internalCache(cacheName);
    if (cache == null || !F.eq(depId, cache.context().dynamicDeploymentId()))
        throw new SchemaOperationException(SchemaOperationException.CODE_CACHE_NOT_FOUND, cacheName);
    try {
        if (op instanceof SchemaIndexCreateOperation) {
            SchemaIndexCreateOperation op0 = (SchemaIndexCreateOperation) op;
            QueryIndexDescriptorImpl idxDesc = QueryUtils.createIndexDescriptor(type, op0.index());
            SchemaIndexCacheVisitor visitor = new SchemaIndexCacheVisitorImpl(this, cache.context(), cacheName, op0.tableName(), cancelTok);
            idx.dynamicIndexCreate(op0.schemaName(), op0.tableName(), idxDesc, op0.ifNotExists(), visitor);
        } else if (op instanceof SchemaIndexDropOperation) {
            SchemaIndexDropOperation op0 = (SchemaIndexDropOperation) op;
            idx.dynamicIndexDrop(op0.schemaName(), op0.indexName(), op0.ifExists());
        } else
            throw new SchemaOperationException("Unsupported operation: " + op);
    } catch (Exception e) {
        if (e instanceof SchemaOperationException)
            throw (SchemaOperationException) e;
        else
            throw new SchemaOperationException("Schema change operation failed: " + e.getMessage(), e);
    }
}
Also used : SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) SchemaIndexCacheVisitor(org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitor) SchemaIndexCreateOperation(org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation) SchemaIndexCacheVisitorImpl(org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorImpl) SchemaIndexDropOperation(org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexDropOperation) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) SQLException(java.sql.SQLException) CacheException(javax.cache.CacheException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException) GridClosureException(org.apache.ignite.internal.util.lang.GridClosureException)

Aggregations

SQLException (java.sql.SQLException)1 CacheException (javax.cache.CacheException)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)1 GridCacheAdapter (org.apache.ignite.internal.processors.cache.GridCacheAdapter)1 SchemaIndexCacheVisitor (org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitor)1 SchemaIndexCacheVisitorImpl (org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorImpl)1 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)1 SchemaIndexCreateOperation (org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation)1 SchemaIndexDropOperation (org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexDropOperation)1 GridClosureException (org.apache.ignite.internal.util.lang.GridClosureException)1