ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject incubator-ignite git commit: # GG-9613 free resources on remote nodes
Date Wed, 15 Apr 2015 14:22:10 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-gg-9613 [created] d817a5cba


# GG-9613 free resources on remote nodes


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

Branch: refs/heads/ignite-gg-9613
Commit: d817a5cbad054a78c9d7e9e2a0b22ee6d80f5b56
Parents: 3fdc824
Author: ptupitsyn <ptupitsyn@gridgain.com>
Authored: Wed Apr 15 17:21:48 2015 +0300
Committer: ptupitsyn <ptupitsyn@gridgain.com>
Committed: Wed Apr 15 17:21:48 2015 +0300

----------------------------------------------------------------------
 .../managers/communication/GridIoManager.java   | 26 +++++++++++++++--
 .../GridMessageCloseableFilter.java             | 30 ++++++++++++++++++++
 2 files changed, 54 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d817a5cb/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index f0d595b..1ffad15 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -1383,7 +1383,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
      * @return Whether or not the lsnr was removed.
      */
     @SuppressWarnings({"deprecation", "SynchronizationOnLocalVariableOrMethodParameter"})
-    public boolean removeMessageListener(Object topic, @Nullable final GridMessageListener
lsnr) {
+    public boolean removeMessageListener(Object topic, @Nullable GridMessageListener lsnr)
{
         assert topic != null;
 
         boolean rmv = true;
@@ -1394,7 +1394,8 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         if (lsnr == null) {
             closedTopics.add(topic);
 
-            rmv = lsnrMap.remove(topic) != null;
+            lsnr = lsnrMap.remove(topic);
+            rmv = lsnr != null;
 
             Map<UUID, GridCommunicationMessageSet> map = msgSetMap.remove(topic);
 
@@ -1466,10 +1467,31 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         if (rmv && log.isDebugEnabled())
             log.debug("Removed message listener [topic=" + topic + ", lsnr=" + lsnr + ']');
 
+        if (lsnr instanceof ArrayListener)
+        {
+            for (GridMessageListener childLsnr : ((ArrayListener)lsnr).arr) {
+                closeListener(childLsnr);
+            }
+        }
+        else
+            closeListener(lsnr);
+
         return rmv;
     }
 
     /**
+     * Closes a listener, if applicable.
+     * @param lsnr Listener.
+     */
+    private void closeListener(GridMessageListener lsnr) {
+        if (lsnr instanceof GridUserMessageListener) {
+            GridUserMessageListener userLsnr = (GridUserMessageListener)lsnr;
+            if (userLsnr.predLsnr instanceof GridMessageCloseableFilter)
+                ((GridMessageCloseableFilter)userLsnr.predLsnr).onClose();
+        }
+    }
+
+    /**
      * Gets sent messages count.
      *
      * @return Sent messages count.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d817a5cb/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridMessageCloseableFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridMessageCloseableFilter.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridMessageCloseableFilter.java
new file mode 100644
index 0000000..4f84ebf
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridMessageCloseableFilter.java
@@ -0,0 +1,30 @@
+/*
+ * 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.managers.communication;
+
+import org.apache.ignite.lang.*;
+
+/**
+ * Special version of bi-predicate for messaging with close callback.
+ */
+public interface GridMessageCloseableFilter<K, V> extends IgniteBiPredicate<K, V>
{
+    /**
+     * Callback invoked when predicate is no longer needed.
+     */
+    public void onClose();
+}


Mime
View raw message