Search in sources :

Example 6 with SchemaProposeDiscoveryMessage

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

the class GridQueryProcessor method startIndexOperationDistributed.

/**
     * Start distributed index change operation.
     *
     * @param op Operation.
     * @return Future.
     */
private IgniteInternalFuture<?> startIndexOperationDistributed(SchemaAbstractOperation op) {
    SchemaOperationClientFuture fut = new SchemaOperationClientFuture(op.id());
    SchemaOperationClientFuture oldFut = schemaCliFuts.put(op.id(), fut);
    assert oldFut == null;
    try {
        ctx.discovery().sendCustomEvent(new SchemaProposeDiscoveryMessage(op));
        if (log.isDebugEnabled())
            log.debug("Sent schema propose discovery message [opId=" + op.id() + ", op=" + op + ']');
        boolean disconnected0;
        synchronized (stateMux) {
            disconnected0 = disconnected;
        }
        if (disconnected0) {
            fut.onDone(new SchemaOperationException("Client node is disconnected (operation result is unknown)."));
            schemaCliFuts.remove(op.id());
        }
    } catch (Exception e) {
        if (e instanceof SchemaOperationException)
            fut.onDone(e);
        else {
            fut.onDone(new SchemaOperationException("Failed to start schema change operation due to " + "unexpected exception [opId=" + op.id() + ", op=" + op + ']', e));
        }
        schemaCliFuts.remove(op.id());
    }
    return fut;
}
Also used : SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException) SchemaProposeDiscoveryMessage(org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage) SchemaOperationClientFuture(org.apache.ignite.internal.processors.query.schema.SchemaOperationClientFuture) 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)

Example 7 with SchemaProposeDiscoveryMessage

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

the class GridQueryProcessor method onSchemaProposeDiscovery0.

/**
     * Process schema propose message from discovery thread (or from cache start routine).
     *
     * @param msg Message.
     * @return {@code True} if exchange should be triggered.
     */
private boolean onSchemaProposeDiscovery0(SchemaProposeDiscoveryMessage msg) {
    UUID opId = msg.operation().id();
    synchronized (stateMux) {
        if (disconnected) {
            if (log.isDebugEnabled())
                log.debug("Processing discovery schema propose message, but node is disconnected (will ignore) " + "[opId=" + opId + ", msg=" + msg + ']');
            return false;
        }
        if (log.isDebugEnabled())
            log.debug("Processing discovery schema propose message [opId=" + opId + ", msg=" + msg + ']');
        // Put message to active operations set.
        SchemaProposeDiscoveryMessage oldDesc = activeProposals.put(msg.operation().id(), msg);
        assert oldDesc == null;
        // Create schema operation and either trigger it immediately from exchange thread or append to already
        // running operation.
        SchemaOperation schemaOp = new SchemaOperation(msg);
        String schemaName = msg.schemaName();
        SchemaOperation prevSchemaOp = schemaOps.get(schemaName);
        if (prevSchemaOp != null) {
            prevSchemaOp = prevSchemaOp.unwind();
            if (log.isDebugEnabled())
                log.debug("Schema change is enqueued and will be executed after previous operation is completed " + "[opId=" + opId + ", prevOpId=" + prevSchemaOp.id() + ']');
            prevSchemaOp.next(schemaOp);
            return false;
        } else {
            schemaOps.put(schemaName, schemaOp);
            return exchangeReady;
        }
    }
}
Also used : SchemaProposeDiscoveryMessage(org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage) UUID(java.util.UUID)

Aggregations

SchemaProposeDiscoveryMessage (org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage)7 UUID (java.util.UUID)3 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)2 SchemaOperationClientFuture (org.apache.ignite.internal.processors.query.schema.SchemaOperationClientFuture)2 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)2 SQLException (java.sql.SQLException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)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 SchemaExchangeWorkerTask (org.apache.ignite.internal.processors.query.schema.SchemaExchangeWorkerTask)1 SchemaNodeLeaveExchangeWorkerTask (org.apache.ignite.internal.processors.query.schema.SchemaNodeLeaveExchangeWorkerTask)1 SchemaOperationManager (org.apache.ignite.internal.processors.query.schema.SchemaOperationManager)1 SchemaOperationWorker (org.apache.ignite.internal.processors.query.schema.SchemaOperationWorker)1 SchemaAbstractDiscoveryMessage (org.apache.ignite.internal.processors.query.schema.message.SchemaAbstractDiscoveryMessage)1 SchemaFinishDiscoveryMessage (org.apache.ignite.internal.processors.query.schema.message.SchemaFinishDiscoveryMessage)1 SchemaAbstractOperation (org.apache.ignite.internal.processors.query.schema.operation.SchemaAbstractOperation)1 GridClosureException (org.apache.ignite.internal.util.lang.GridClosureException)1 IgniteUuid (org.apache.ignite.lang.IgniteUuid)1