You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by gv...@apache.org on 2020/03/10 11:12:40 UTC

[ignite] 02/02: fix after merge

This is an automated email from the ASF dual-hosted git repository.

gvvinblade pushed a commit to branch ignite-12248
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit d678c1d3d51b78ca7ed21521e357c123d7f51be5
Author: Igor Seliverstov <gv...@gmail.com>
AuthorDate: Tue Mar 10 14:10:51 2020 +0300

    fix after merge
---
 .../query/calcite/exec/ExecutionServiceImpl.java   | 24 +++---
 .../query/calcite/exec/QueryCancelGroup.java       | 92 ----------------------
 .../calcite/metadata/PartitionServiceImpl.java     |  1 -
 .../query/calcite/prepare/PlanningContext.java     | 30 +++----
 .../calcite/serialize/ReceiverPhysicalRel.java     |  1 -
 5 files changed, 19 insertions(+), 129 deletions(-)

diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java
index 353bda9..3c2f4eb 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java
@@ -435,7 +435,6 @@ public class ExecutionServiceImpl extends AbstractService implements ExecutionSe
             .query(query)
             .parameters(params)
             .topologyVersion(topologyVersion())
-            .cancelGroup(cancelGroup(qryCtx))
             .logger(log)
             .build();
     }
@@ -675,22 +674,19 @@ public class ExecutionServiceImpl extends AbstractService implements ExecutionSe
 
         running.put(queryId, info);
 
-        if (pctx.cancelGroup() == null || pctx.cancelGroup().add(info))
-            return;
-
-        running.remove(queryId);
+        GridQueryCancel queryCancel = pctx.queryCancel();
 
-        throw new IgniteSQLException(QueryCancelledException.ERR_MSG, IgniteQueryErrorCode.QUERY_CANCELED);
-    }
-
-    /** */
-    private QueryCancelGroup cancelGroup(@Nullable QueryContext qryCtx) {
-        GridQueryCancel cancel;
+        if (queryCancel == null)
+            return;
 
-        if (qryCtx == null || (cancel = qryCtx.unwrap(GridQueryCancel.class)) == null)
-            return null;
+        try {
+            queryCancel.add(info);
+        }
+        catch (QueryCancelledException e) {
+            running.remove(queryId);
 
-        return new QueryCancelGroup(cancel, failureProcessor());
+            throw new IgniteSQLException(e.getMessage(), IgniteQueryErrorCode.QUERY_CANCELED);
+        }
     }
 
     /** */
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/QueryCancelGroup.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/QueryCancelGroup.java
deleted file mode 100644
index 6e2573a..0000000
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/QueryCancelGroup.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.query.calcite.exec;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.ignite.cache.query.QueryCancelledException;
-import org.apache.ignite.failure.FailureContext;
-import org.apache.ignite.failure.FailureType;
-import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
-import org.apache.ignite.internal.processors.failure.FailureProcessor;
-import org.apache.ignite.internal.processors.query.GridQueryCancel;
-import org.apache.ignite.internal.processors.query.IgniteSQLException;
-import org.apache.ignite.internal.processors.query.QueryCancellable;
-
-/** */
-public final class QueryCancelGroup implements QueryCancellable {
-    /** */
-    private final FailureProcessor failureProcessor;
-
-    /** */
-    private final Set<QueryCancellable> queries;
-
-    /** */
-    private boolean cancelled;
-
-    /** */
-    public QueryCancelGroup(GridQueryCancel cancel, FailureProcessor failureProcessor) {
-        this.failureProcessor = failureProcessor;
-
-        queries = new HashSet<>();
-
-        register(cancel);
-    }
-
-    /**
-     * Adds a cancellable to the group.
-     *
-     * @param query Query cancellable object.
-     * @return {@code false} if query was cancelled before this call.
-     */
-    public synchronized boolean add(QueryCancellable query) {
-        if (cancelled)
-            return false;
-
-        boolean res = queries.add(query);
-
-        assert res;
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public synchronized void doCancel() {
-        cancelled = true;
-
-        try {
-            for (QueryCancellable query : queries)
-                query.doCancel();
-        }
-        catch (Exception e) {
-            failureProcessor.process(new FailureContext(FailureType.CRITICAL_ERROR, e));
-
-            throw e;
-        }
-    }
-
-    /** */
-    private void register(GridQueryCancel cancel) {
-        try {
-            cancel.set(this);
-        }
-        catch (QueryCancelledException e) {
-            throw new IgniteSQLException(QueryCancelledException.ERR_MSG, IgniteQueryErrorCode.QUERY_CANCELED);
-        }
-    }
-}
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/PartitionServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/PartitionServiceImpl.java
index 2b8e35d..4c01d8d 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/PartitionServiceImpl.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/PartitionServiceImpl.java
@@ -24,7 +24,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.query.calcite.util.AbstractService;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 
-
 /**
  *
  */
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlanningContext.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlanningContext.java
index 0824040..937e6cc 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlanningContext.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlanningContext.java
@@ -35,11 +35,10 @@ import org.apache.calcite.tools.FrameworkConfig;
 import org.apache.calcite.tools.Frameworks;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.query.GridQueryCancel;
 import org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor;
-import org.apache.ignite.internal.processors.query.calcite.exec.QueryCancelGroup;
 import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * Planning context.
@@ -79,7 +78,7 @@ public final class PlanningContext implements Context {
     private final AffinityTopologyVersion topologyVersion;
 
     /** */
-    private final QueryCancelGroup cancelGroup;
+    private final GridQueryCancel queryCancel;
 
     /** */
     private final IgniteLogger logger;
@@ -100,18 +99,19 @@ public final class PlanningContext implements Context {
      * Private constructor, used by a builder.
      */
     private PlanningContext(FrameworkConfig config, Context parentContext, UUID localNodeId, UUID originatingNodeId,
-        String query, Object[] parameters, AffinityTopologyVersion topologyVersion, IgniteLogger logger, QueryCancelGroup cancelGroup) {
+        String query, Object[] parameters, AffinityTopologyVersion topologyVersion, IgniteLogger logger) {
         this.localNodeId = localNodeId;
         this.originatingNodeId = originatingNodeId;
         this.query = query;
         this.parameters = parameters;
         this.topologyVersion = topologyVersion;
         this.logger = logger;
-        this.cancelGroup = cancelGroup;
 
         this.parentContext = Contexts.chain(parentContext, config.getContext());
         // link frameworkConfig#context() to this.
         this.config = Frameworks.newConfigBuilder(config).context(this).build();
+
+        queryCancel = unwrap(GridQueryCancel.class);
     }
 
     /**
@@ -157,10 +157,10 @@ public final class PlanningContext implements Context {
     }
 
     /**
-     * @return Query cancel group.
+     * @return Query cancel.
      */
-    public QueryCancelGroup cancelGroup() {
-        return cancelGroup;
+    public GridQueryCancel queryCancel() {
+        return queryCancel;
     }
 
     /**
@@ -319,9 +319,6 @@ public final class PlanningContext implements Context {
         /** */
         private IgniteLogger logger;
 
-        /** */
-        private QueryCancelGroup cancelGroup;
-
         /**
          * @param localNodeId Local node ID.
          * @return Builder for chaining.
@@ -395,22 +392,13 @@ public final class PlanningContext implements Context {
         }
 
         /**
-         * @param cancelGroup Query cancel group.
-         * @return Builder for chaining.
-         */
-        public Builder cancelGroup(@Nullable QueryCancelGroup cancelGroup) {
-            this.cancelGroup = cancelGroup;
-            return this;
-        }
-
-        /**
          * Builds planner context.
          *
          * @return Planner context.
          */
         public PlanningContext build() {
             return new PlanningContext(frameworkConfig, parentContext, localNodeId, originatingNodeId, query,
-                parameters, topologyVersion, logger, cancelGroup);
+                parameters, topologyVersion, logger);
         }
     }
 }
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/serialize/ReceiverPhysicalRel.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/serialize/ReceiverPhysicalRel.java
index 113ef3c..ffe0ba3 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/serialize/ReceiverPhysicalRel.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/serialize/ReceiverPhysicalRel.java
@@ -31,7 +31,6 @@ import org.apache.calcite.rel.RelFieldCollation;
 import org.apache.ignite.internal.processors.query.calcite.exec.exp.type.DataType;
 import org.apache.ignite.internal.processors.query.calcite.rel.IgniteReceiver;
 
-
 /**
  * Describes {@link IgniteReceiver}.
  */