ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: Simplified error handling in init messsage.
Date Mon, 13 Mar 2017 13:09:02 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-4565-ddl f472918f4 -> e21a2e9c9


Simplified error handling in init messsage.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e21a2e9c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e21a2e9c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e21a2e9c

Branch: refs/heads/ignite-4565-ddl
Commit: e21a2e9c99822784fbbd375af22666a58bb71fa3
Parents: f472918
Author: devozerov <vozerov@gridgain.com>
Authored: Mon Mar 13 16:08:52 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Mon Mar 13 16:08:52 2017 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProcessor.java    | 36 ++++++++++++++++-
 .../query/ddl/IndexInitDiscoveryMessage.java    | 42 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e21a2e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 8ec641a..a65b318 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -58,7 +58,9 @@ import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryType;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
+import org.apache.ignite.internal.processors.query.ddl.AbstractIndexOperation;
 import org.apache.ignite.internal.processors.query.ddl.CreateIndexOperation;
+import org.apache.ignite.internal.processors.query.ddl.DropIndexOperation;
 import org.apache.ignite.internal.processors.query.ddl.IndexAbstractDiscoveryMessage;
 import org.apache.ignite.internal.processors.query.ddl.IndexAckDiscoveryMessage;
 import org.apache.ignite.internal.processors.query.ddl.IndexInitDiscoveryMessage;
@@ -315,7 +317,39 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @param msg Message.
      */
     private void onIndexInitDiscoveryMessage(IndexInitDiscoveryMessage msg) {
-        // TODO
+        // Return message with existing error.
+        if (msg.hasError())
+            return;
+
+        // Validate.
+        idxLock.writeLock().lock();
+
+        try {
+            AbstractIndexOperation op = msg.operation();
+
+            if (op instanceof CreateIndexOperation) {
+                CreateIndexOperation op0 = (CreateIndexOperation)op;
+
+                // TODO
+            }
+            else if (op instanceof DropIndexOperation) {
+                DropIndexOperation op0 = (DropIndexOperation)op;
+
+                // TODO
+            }
+            else
+                msg.onError(ctx.localNodeId(), "Unsupported operation: " + op);
+        }
+        finally {
+            idxLock.writeLock().unlock();
+        }
+    }
+
+    /**
+     * Index operation context. Represents pending operations
+     */
+    private class IndexOperationContext {
+
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/e21a2e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/query/ddl/IndexInitDiscoveryMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/ddl/IndexInitDiscoveryMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/ddl/IndexInitDiscoveryMessage.java
index b6d3a2f..bbae107 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/ddl/IndexInitDiscoveryMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/ddl/IndexInitDiscoveryMessage.java
@@ -24,6 +24,8 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.UUID;
+
 /**
  * {@code INIT} part of a distributed index create/drop operation.
  */
@@ -35,6 +37,12 @@ public class IndexInitDiscoveryMessage extends IndexAbstractDiscoveryMessage
imp
     @GridToStringExclude
     private transient GridKernalContext ctx;
 
+    /** Node reported an error. */
+    private UUID errNodeId;
+
+    /** Error message. */
+    private String errMsg;
+
     /**
      * Constructor.
      *
@@ -61,6 +69,40 @@ public class IndexInitDiscoveryMessage extends IndexAbstractDiscoveryMessage
imp
         this.ctx = ctx;
     }
 
+    /**
+     * Set error.
+     *
+     * @param errNodeId Error node ID.
+     * @param errMsg Error message.
+     */
+    public void onError(UUID errNodeId, String errMsg) {
+        if (!hasError()) {
+            this.errNodeId = errNodeId;
+            this.errMsg = errMsg;
+        }
+    }
+
+    /**
+     * @return {@code True} if error was reported during init.
+     */
+    public boolean hasError() {
+        return errNodeId != null;
+    }
+
+    /**
+     * @return ID of the node reported an error (if any).
+     */
+    @Nullable public UUID errorNodeId() {
+        return errNodeId;
+    }
+
+    /**
+     * @return Error message (if any).
+     */
+    @Nullable public String errorMessage() {
+        return errMsg;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IndexInitDiscoveryMessage.class, this);


Mime
View raw message