You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2019/05/07 15:21:23 UTC

[ignite] 15/41: GG-17387 Minor cleanup after TX DR merge

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

amashenkov pushed a commit to branch gg-18540
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 39e77bdce45488db2396fbff35d083d0a0fffe6c
Author: Ivan Rakov <ir...@apache.org>
AuthorDate: Thu Apr 25 17:24:17 2019 +0300

    GG-17387 Minor cleanup after TX DR merge
---
 .../pagemem/wal/record/ConsistentCutRecord.java    |  2 +-
 .../cache/GridCachePartitionExchangeManager.java   | 71 +---------------------
 .../distributed/dht/preloader/ExchangeType.java    |  8 +--
 .../dht/preloader/PartitionsExchangeAware.java     | 32 +++++++++-
 .../cache/persistence/tree/BPlusTree.java          | 10 +--
 .../cache/transactions/IgniteTxManager.java        |  2 +-
 6 files changed, 44 insertions(+), 81 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/ConsistentCutRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/ConsistentCutRecord.java
index 66741fe..9b93d23 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/ConsistentCutRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/ConsistentCutRecord.java
@@ -16,7 +16,7 @@
 package org.apache.ignite.internal.pagemem.wal.record;
 
 /**
- * todo GG-13416 doc
+ * Empty record which is logged to WAL to obtain pointer to consistent cut border.
  */
 public class ConsistentCutRecord extends WALRecord {
     /** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 4750663..bcb1dc5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -1155,7 +1155,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
      * @param comp Component to be registered.
      */
     public void registerExchangeAwareComponent(PartitionsExchangeAware comp) {
-        exchangeAwareComps.add(new PartitionsExchangeAwareWrapper(comp));
+        exchangeAwareComps.add(comp);
     }
 
     /**
@@ -1164,7 +1164,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
      * @param comp Component to be registered.
      */
     public void unregisterExchangeAwareComponent(PartitionsExchangeAware comp) {
-        exchangeAwareComps.remove(new PartitionsExchangeAwareWrapper(comp));
+        exchangeAwareComps.remove(comp);
     }
 
     /**
@@ -3651,73 +3651,6 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
     }
 
     /**
-     * That wrapper class allows avoiding the propagation of the user's exceptions into the Exchange thread.
-     */
-    private class PartitionsExchangeAwareWrapper implements PartitionsExchangeAware {
-        /** */
-        private final PartitionsExchangeAware delegate;
-
-        /**
-         * Creates a new wrapper.
-         * @param delegate Delegate.
-         */
-        public PartitionsExchangeAwareWrapper(PartitionsExchangeAware delegate) {
-            this.delegate = delegate;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onInitBeforeTopologyLock(GridDhtPartitionsExchangeFuture fut) {
-            try {
-                delegate.onInitBeforeTopologyLock(fut);
-            }
-            catch (Exception e) {
-                U.warn(log, "Failed to execute exchange callback.", e);
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onInitAfterTopologyLock(GridDhtPartitionsExchangeFuture fut) {
-            try {
-                delegate.onInitAfterTopologyLock(fut);
-            }
-            catch (Exception e) {
-                U.warn(log, "Failed to execute exchange callback.", e);
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onDoneBeforeTopologyUnlock(GridDhtPartitionsExchangeFuture fut) {
-            try {
-                delegate.onDoneBeforeTopologyUnlock(fut);
-            }
-            catch (Exception e) {
-                U.warn(log, "Failed to execute exchange callback.", e);
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onDoneAfterTopologyUnlock(GridDhtPartitionsExchangeFuture fut) {
-            try {
-                delegate.onDoneAfterTopologyUnlock(fut);
-            }
-            catch (Exception e) {
-                U.warn(log, "Failed to execute exchange callback.", e);
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return delegate.hashCode();
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
-        @Override public boolean equals(Object obj) {
-            return delegate.equals(obj);
-        }
-    }
-
-    /**
      * Class to limit action count for unique objects.
      * <p>
      * NO guarantees of thread safety are provided.
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/ExchangeType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/ExchangeType.java
index f7d1e35..a80e2cf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/ExchangeType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/ExchangeType.java
@@ -16,15 +16,15 @@
 package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
 
 /**
- * todo javadoc
+ * Enumerates possible types of partition map exchange process.
  */
 public enum ExchangeType {
-    /** */
+    /** Local join of client node: used only on joining node, completed locally. */
     CLIENT,
 
-    /** */
+    /** Distributed partition map exchange, assumes distributed messaging involving coordinator node. */
     ALL,
 
-    /** */
+    /** Leave/join of another client node, completed locally. */
     NONE
 }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/PartitionsExchangeAware.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/PartitionsExchangeAware.java
index ffe5766..dd2dffb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/PartitionsExchangeAware.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/PartitionsExchangeAware.java
@@ -15,22 +15,52 @@
  */
 package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
 
+import org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager;
+
 /**
- * todo javadocs
+ * Interface which allows to subscribe a component for partition map exchange events
+ * (via {@link GridCachePartitionExchangeManager#registerExchangeAwareComponent(PartitionsExchangeAware)}).
+ * Heavy computations shouldn't be performed in listener methods: aware components will be notified
+ * synchronously from exchange thread.
+ * Runtime exceptions thrown by listener methods will trigger failure handler (as per exchange thread is critical).
+ * Please ensure that your implementation will never throw an exception if you subscribe to exchange events for
+ * non-system-critical activities.
  */
 public interface PartitionsExchangeAware {
+    /**
+     * Callback from exchange process initialization; called before topology is locked.
+     *
+     * @param fut Partition map exchange future.
+     */
     public default void onInitBeforeTopologyLock(GridDhtPartitionsExchangeFuture fut) {
         // No-op.
     }
 
+    /**
+     * Callback from exchange process initialization; called after topology is locked.
+     * Guarantees that no more data updates will be performed on local node until exchange process is completed.
+     *
+     * @param fut Partition map exchange future.
+     */
     public default void onInitAfterTopologyLock(GridDhtPartitionsExchangeFuture fut) {
         // No-op.
     }
 
+    /**
+     * Callback from exchange process completion; called before topology is unlocked.
+     * Guarantees that no updates were performed on local node since exchange process started.
+     *
+     * @param fut Partition map exchange future.
+     */
     public default void onDoneBeforeTopologyUnlock(GridDhtPartitionsExchangeFuture fut) {
         // No-op.
     }
 
+    /**
+     * Callback from exchange process completion; called after topology is unlocked.
+     *
+     * @param fut Partition map exchange future.
+     */
     public default void onDoneAfterTopologyUnlock(GridDhtPartitionsExchangeFuture fut) {
         // No-op.
     }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java
index 977d9b6..9fbd608 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java
@@ -5839,18 +5839,18 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure implements
     /**
      * Creates a new instance of {@link CorruptedTreeException}.
      *
-     * @param message Detailed error message.
+     * @param msg Detailed error message.
      * @param cause The cause.
      * @param rows Optional parameters.
      * @return New instance of {@link CorruptedTreeException}.
      */
-    private CorruptedTreeException createCorruptedTreeException(String message, Throwable cause, Object... rows) {
+    private CorruptedTreeException createCorruptedTreeException(String msg, Throwable cause, Object... rows) {
         try {
-            return new CorruptedTreeException(String.format(message, rows), cause);
+            return new CorruptedTreeException(String.format(msg, rows), cause);
         }
-        catch (Throwable t) {
+        catch (Throwable ignored) {
             // Failed to create string representation of optional parameters.
-            return new CorruptedTreeException("", cause);
+            return new CorruptedTreeException(msg + " <failed to create rows string representation>", cause);
         }
     }
 }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 9527956..798d605 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -2505,7 +2505,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
     }
 
     /**
-     *
+     * @return Tracker that is aware of pending transactions state.
      */
     public LocalPendingTransactionsTracker pendingTxsTracker() {
         return pendingTracker;