ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject incubator-ignite git commit: # Fix org.jsr107.tck.CacheTest test
Date Wed, 11 Feb 2015 14:41:19 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/sprint-1 db8b4c7eb -> 8083d9a25


# Fix org.jsr107.tck.CacheTest test


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

Branch: refs/heads/sprint-1
Commit: 8083d9a25e85a68f292a18281ce0c2bf452af6a7
Parents: db8b4c7
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Wed Feb 11 17:40:48 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Feb 11 17:40:48 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/cache/CacheManager.java   | 15 +++++++++------
 .../internal/processors/cache/CacheEntryImpl.java    |  6 +++---
 .../internal/processors/cache/IgniteCacheProxy.java  |  6 +++++-
 3 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8083d9a2/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
index 7ac45be..fc8c52e 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
@@ -57,6 +57,9 @@ public class CacheManager implements javax.cache.CacheManager {
     /** */
     private final AtomicBoolean closed = new AtomicBoolean();
 
+    /** */
+    private final AtomicInteger mgrIdx = new AtomicInteger();
+
     /**
      * @param uri Uri.
      * @param cachingProvider Caching provider.
@@ -128,7 +131,7 @@ public class CacheManager implements javax.cache.CacheManager {
 
             if (uri.equals(cachingProvider.getDefaultURI())) {
                 IgniteConfiguration cfg = new IgniteConfiguration();
-                cfg.setGridName("grid-for-" + cacheName);
+                cfg.setGridName(mgrIdx.incrementAndGet() + "-grid-for-" + cacheName);
 
                 cfg.setCacheConfiguration(new CacheConfiguration((CompleteConfiguration)cacheCfg));
 
@@ -346,20 +349,20 @@ public class CacheManager implements javax.cache.CacheManager {
      * @param name cache name.
      */
     public void registerCacheObject(MBeanServer mBeanServer, Object mxbean, String name,
String objectName) {
-        ObjectName registeredObjectName = getObjectName(name, objectName);
+        ObjectName registeredObjName = getObjectName(name, objectName);
 
         try {
-            if (!isRegistered(mBeanServer, registeredObjectName))
+            if (!isRegistered(mBeanServer, registeredObjName))
                 if (objectName.equals(CACHE_CONFIGURATION))
                     mBeanServer.registerMBean(new IgniteStandardMXBean((CacheMXBean)mxbean,
CacheMXBean.class),
-                        registeredObjectName);
+                        registeredObjName);
                 else
                     mBeanServer.registerMBean(
                         new IgniteStandardMXBean((CacheStatisticsMXBean)mxbean, CacheStatisticsMXBean.class),
-                        registeredObjectName);
+                        registeredObjName);
         }
         catch (Exception e) {
-            throw new CacheException("Failed to register MBean: " + registeredObjectName,
e);
+            throw new CacheException("Failed to register MBean: " + registeredObjName, e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8083d9a2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
index e609cd1..e22b34a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
@@ -51,10 +51,10 @@ public class CacheEntryImpl<K, V> implements Cache.Entry<K, V>
{
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T unwrap(Class<T> cls) {
-        if (!cls.equals(getClass()))
-            throw new IllegalArgumentException("Unwrapping to class is not supported: " +
cls);
+        if(cls.isAssignableFrom(getClass()))
+            return cls.cast(this);
 
-        return (T)this;
+        throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8083d9a2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index b8581e7..0ee919c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -31,6 +31,7 @@ import org.apache.ignite.mxbean.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
+import javax.cache.CacheManager;
 import javax.cache.configuration.*;
 import javax.cache.expiry.*;
 import javax.cache.integration.*;
@@ -868,7 +869,10 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
     /** {@inheritDoc} */
     @Override public void close() {
         // TODO IGNITE-45 (Support start/close/destroy cache correctly)
-        getCacheManager().destroyCache(getName());
+        CacheManager cacheMgr = getCacheManager();
+
+        if (cacheMgr != null) // cacheMgr == null means cache is closed.
+            cacheMgr.destroyCache(getName());
     }
 
     /** {@inheritDoc} */


Mime
View raw message