You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/05/19 16:43:08 UTC
incubator-ignite git commit: # GG-9614 review wip
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-gg-9614 a765d2a80 -> cae4175ee
# GG-9614 review wip
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/cae4175e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/cae4175e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/cae4175e
Branch: refs/heads/ignite-gg-9614
Commit: cae4175eed6cea1784a9bc544ce7622ce911c970
Parents: a765d2a
Author: ptupitsyn <pt...@gridgain.com>
Authored: Tue May 19 17:11:30 2015 +0300
Committer: ptupitsyn <pt...@gridgain.com>
Committed: Tue May 19 17:11:30 2015 +0300
----------------------------------------------------------------------
.../internal/GridEventConsumeHandler.java | 29 +++++++++++----
.../interop/GridInteropEventFilter.java | 38 +++++++++++++++++++
.../interop/GridInteropLocalEventListener.java | 28 ++++++++++++++
.../interop/GridLifecycleAwareEventFilter.java | 39 --------------------
.../GridLifecycleAwareLocalEventListener.java | 29 ---------------
.../eventstorage/GridEventStorageManager.java | 10 ++---
6 files changed, 93 insertions(+), 80 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cae4175e/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index c63b50d..5478c87 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -125,8 +125,8 @@ class GridEventConsumeHandler implements GridContinuousHandler {
if (filter != null)
ctx.resource().injectGeneric(filter);
- if (filter instanceof GridLifecycleAwareEventFilter)
- ((GridLifecycleAwareEventFilter)filter).initialize(ctx.grid());
+ if (filter instanceof GridInteropEventFilter)
+ ((GridInteropEventFilter)filter).initialize(ctx);
final boolean loc = nodeId.equals(ctx.localNodeId());
@@ -193,12 +193,27 @@ class GridEventConsumeHandler implements GridContinuousHandler {
if (lsnr != null)
ctx.event().removeLocalEventListener(lsnr, types);
- // TODO: Not safe. Exception thrown from filter close will tiled in not-closed cb.
- if (filter instanceof GridLifecycleAwareEventFilter)
- ((GridLifecycleAwareEventFilter)filter).close();
+ RuntimeException err = null;
- if (cb instanceof GridLifecycleAwareLocalEventListener)
- ((GridLifecycleAwareLocalEventListener)cb).close();
+ try {
+ if (filter instanceof GridInteropEventFilter)
+ ((GridInteropEventFilter)filter).close();
+ }
+ catch(RuntimeException ex) {
+ err = ex;
+ }
+
+ try {
+ if (cb instanceof GridInteropLocalEventListener)
+ ((GridInteropLocalEventListener)cb).close();
+ }
+ catch (RuntimeException ex) {
+ if (err == null)
+ err = ex;
+ }
+
+ if (err != null)
+ throw err;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cae4175e/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropEventFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropEventFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropEventFilter.java
new file mode 100644
index 0000000..44e18ce
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropEventFilter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.interop;
+
+import org.apache.ignite.*;
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.lang.*;
+
+/**
+ * Special version of predicate for events with initialize/close callbacks.
+ */
+public interface GridInteropEventFilter<E extends Event> extends IgnitePredicate<E> {
+ /**
+ * Initializes the filter.
+ */
+ public void initialize(GridKernalContext ctx);
+
+ /**
+ * Closes the filter.
+ */
+ public void close();
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cae4175e/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropLocalEventListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropLocalEventListener.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropLocalEventListener.java
new file mode 100644
index 0000000..47d99e5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/GridInteropLocalEventListener.java
@@ -0,0 +1,28 @@
+/*
+ * 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.interop;
+
+/**
+ * Special version of listener for events with close callbacks.
+ */
+public interface GridInteropLocalEventListener {
+ /**
+ * Closes the listener.
+ */
+ public void close();
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cae4175e/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareEventFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareEventFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareEventFilter.java
deleted file mode 100644
index c54954c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareEventFilter.java
+++ /dev/null
@@ -1,39 +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.interop;
-
-import org.apache.ignite.*;
-import org.apache.ignite.events.*;
-import org.apache.ignite.lang.*;
-
-/**
- * Special version of predicate for events with initialize/close callbacks.
- */
-// TODO: Rename to GridInterop*.
-public interface GridLifecycleAwareEventFilter<E extends Event> extends IgnitePredicate<E> {
- /**
- * Initializes the filter.
- */
- // TODO: Accept GridContext, not Ignite.
- public void initialize(Ignite ignite);
-
- /**
- * Closes the filter.
- */
- public void close();
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cae4175e/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareLocalEventListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareLocalEventListener.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareLocalEventListener.java
deleted file mode 100644
index aac8bbf..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/GridLifecycleAwareLocalEventListener.java
+++ /dev/null
@@ -1,29 +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.interop;
-
-/**
- * Special version of listener for events with close callbacks.
- */
-// TODO: Rename to GridInterop*.
-public interface GridLifecycleAwareLocalEventListener {
- /**
- * Closes the listener.
- */
- public void close();
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cae4175e/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index fc26bab..0b366b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -655,8 +655,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
{
IgnitePredicate p = ((UserListenerWrapper)lsnr).listener();
- if (p instanceof GridLifecycleAwareLocalEventListener)
- ((GridLifecycleAwareLocalEventListener)p).close();
+ if (p instanceof GridInteropLocalEventListener)
+ ((GridInteropLocalEventListener)p).close();
}
return found;
@@ -761,10 +761,10 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
public <T extends Event> Collection<T> localEvents(IgnitePredicate<T> p) {
assert p != null;
- if (p instanceof GridLifecycleAwareEventFilter) {
- GridLifecycleAwareEventFilter p0 = (GridLifecycleAwareEventFilter)p;
+ if (p instanceof GridInteropEventFilter) {
+ GridInteropEventFilter p0 = (GridInteropEventFilter)p;
- p0.initialize(ctx.grid());
+ p0.initialize(ctx);
try {
return getSpi().localEvents(p0);