ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [22/50] [abbrv] incubator-ignite git commit: ignite-45: wip
Date Mon, 19 Jan 2015 14:20:59 GMT
ignite-45: 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/b03a4835
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b03a4835
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b03a4835

Branch: refs/heads/ignite-54
Commit: b03a4835cd4f6329ecab3e68e0948e579e17c99f
Parents: ef624c5
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri Jan 9 12:52:02 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Fri Jan 9 12:52:02 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteCacheManager.java   | 26 +++++++++++++++++---
 .../apache/ignite/IgniteCachingProvider.java    | 20 ++++++++++++++-
 .../processors/cache/IgniteCacheProxy.java      | 20 ++++++++++++---
 3 files changed, 57 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b03a4835/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
index 7cfeca1..a7dab9b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
@@ -77,6 +77,9 @@ public class IgniteCacheManager implements CacheManager {
         if (cacheCfg == null)
             throw new NullPointerException();
 
+        if (cacheName == null)
+            throw new NullPointerException();
+
         if (!(cacheCfg instanceof CompleteConfiguration))
             throw new UnsupportedOperationException("Configuration is not supported: " +
cacheCfg);
 
@@ -86,7 +89,7 @@ public class IgniteCacheManager implements CacheManager {
             if (cfgCacheName != null && !cacheName.equals(cfgCacheName))
                 throw new IllegalArgumentException();
 
-            cacheCfg = (C)new GridCacheConfiguration((GridCacheConfiguration)cacheCfg);
+            cacheCfg = (C)new GridCacheConfiguration((CompleteConfiguration)cacheCfg);
 
             ((GridCacheConfiguration)cacheCfg).setName(cacheName);
         }
@@ -175,13 +178,22 @@ public class IgniteCacheManager implements CacheManager {
     @Override public Iterable<String> getCacheNames() {
         ensureNotClosed();
 
-        Collection<String> res;
+        String[] resArr;
 
         synchronized (igniteMap) {
-            res = new ArrayList<>(igniteMap.keySet());
+            resArr = igniteMap.keySet().toArray(new String[igniteMap.keySet().size()]);
         }
 
-        return res;
+        return Arrays.asList(resArr);
+    }
+
+    /**
+     * @param ignite Ignite.
+     */
+    public boolean isManagedIgnite(Ignite ignite) {
+        synchronized (igniteMap) {
+            return igniteMap.values().contains(ignite);
+        }
     }
 
     /** {@inheritDoc} */
@@ -209,11 +221,17 @@ public class IgniteCacheManager implements CacheManager {
 
     /** {@inheritDoc} */
     @Override public void enableManagement(String cacheName, boolean enabled) {
+        if (cacheName == null)
+            throw new NullPointerException();
+
         throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
     @Override public void enableStatistics(String cacheName, boolean enabled) {
+        if (cacheName == null)
+            throw new NullPointerException();
+
         throw new UnsupportedOperationException();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b03a4835/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java b/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
index eab4cf9..e67434e 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
@@ -66,7 +66,7 @@ public class IgniteCachingProvider implements CachingProvider {
 
             IgniteCacheManager mgr = uriMap.get(uri);
 
-            if (mgr == null) {
+            if (mgr == null || mgr.isClosed()) {
                 mgr = new IgniteCacheManager(uri, this, clsLdr);
 
                 uriMap.put(uri, mgr);
@@ -101,6 +101,24 @@ public class IgniteCachingProvider implements CachingProvider {
         return getCacheManager(getDefaultURI(), getDefaultClassLoader());
     }
 
+    /**
+     * @param cache Cache.
+     */
+    public CacheManager findManager(IgniteCache<?,?> cache) {
+        Ignite ignite = cache.ignite();
+
+        synchronized (cacheManagers) {
+            for (Map<URI, IgniteCacheManager> map : cacheManagers.values()) {
+                for (IgniteCacheManager manager : map.values()) {
+                    if (manager.isManagedIgnite(ignite))
+                        return manager;
+                }
+            }
+        }
+
+        return null;
+    }
+
     /** {@inheritDoc} */
     @Override public void close() {
         Collection<IgniteCacheManager> mgrs = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b03a4835/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 df9bc41..7d0bf2d 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
@@ -428,8 +428,14 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter
implements
 
     /** {@inheritDoc} */
     @Override public boolean containsKey(K key) {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            return delegate.containsKey(key);
+        }
+        finally {
+            gate.leave(prev);
+        }
     }
 
     /** {@inheritDoc} */
@@ -741,8 +747,14 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter
implements
 
     /** {@inheritDoc} */
     @Override public CacheManager getCacheManager() {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
+        IgniteCachingProvider provider = (IgniteCachingProvider)Caching.getCachingProvider(
+            IgniteCachingProvider.class.getName(),
+            IgniteCachingProvider.class.getClassLoader());
+
+        if (provider == null)
+            return null;
+
+        return provider.findManager(this);
     }
 
     /** {@inheritDoc} */


Mime
View raw message