You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2017/05/31 12:27:58 UTC
[12/27] ignite git commit: IGNITE-4939 Receive event before cache
initialized fix
IGNITE-4939 Receive event before cache initialized fix
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f66c23cb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f66c23cb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f66c23cb
Branch: refs/heads/ignite-5232-1.7.2
Commit: f66c23cbb9a6f2c923ebf75c58f00afaf1c0b5f3
Parents: b48a26b
Author: Evgenii Zhuravlev <ez...@gridgain.com>
Authored: Wed May 3 17:47:45 2017 +0300
Committer: Evgenii Zhuravlev <ez...@gridgain.com>
Committed: Wed May 3 17:52:07 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 20 ++++++++++++
.../processors/cache/IgniteCacheProxyStub.java | 33 ++++++++++++++++++++
.../continuous/CacheContinuousQueryHandler.java | 3 +-
3 files changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f66c23cb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 0be2072..5a54e53 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -3346,6 +3346,26 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * @param name Cache name.
+ * @param id Cache id.
+ * @return Cache instance for given name or stub if cache not created yet, but cache descriptor exists.
+ */
+ @SuppressWarnings("unchecked")
+ public <K, V> IgniteCacheProxy<K, V> safeJcache(String name, int id) {
+ assert name != null;
+
+ IgniteCacheProxy<K, V> cache = (IgniteCacheProxy<K, V>)jCacheProxies.get(name);
+
+ if (cache == null)
+ if (cacheDescriptor(id) != null && CU.isSystemCache(name))
+ cache = new IgniteCacheProxyStub<K, V>();
+ else
+ throw new IllegalArgumentException("Cache is not configured: " + name);
+
+ return cache;
+ }
+
+ /**
* @return All configured public cache instances.
*/
public Collection<IgniteCacheProxy<?, ?>> publicCaches() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f66c23cb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyStub.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyStub.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyStub.java
new file mode 100644
index 0000000..75489ed
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyStub.java
@@ -0,0 +1,33 @@
+/*
+ * 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.cache;
+
+/**
+ * Cache proxy stub.
+ */
+public class IgniteCacheProxyStub<K, V> extends IgniteCacheProxy<K, V>{
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * Empty constructor.
+ */
+ public IgniteCacheProxyStub() {
+ // No-op.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f66c23cb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 83edab4..1a6577d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -716,7 +716,8 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
GridCacheContext<K, V> cctx = cacheContext(ctx);
- final IgniteCache cache = cctx.kernalContext().cache().jcache(cctx.name());
+ //returns stub if system cache not created yet
+ final IgniteCache cache = cctx.kernalContext().cache().safeJcache(cctx.name(), cctx.cacheId());
if (internal) {
if (e.isFiltered())