ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [3/7] incubator-ignite git commit: ignite-45: wip
Date Tue, 13 Jan 2015 15:21:53 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/5190b121
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5190b121
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5190b121

Branch: refs/heads/ignite-1
Commit: 5190b12171bec52727fd40f6c69c8a3c5ac1112f
Parents: b03a483
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri Jan 9 17:47:52 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Fri Jan 9 17:47:52 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteCacheManager.java   | 32 ++++++++++++++------
 .../apache/ignite/IgniteCachingProvider.java    |  7 +++--
 .../org/gridgain/grid/cache/GridCacheEntry.java |  3 +-
 .../processors/cache/GridCacheEntryImpl.java    |  8 +++++
 .../cache/GridCacheEvictionEntry.java           |  8 +++++
 .../cache/GridCacheFilterEvaluationEntry.java   |  8 +++++
 .../cache/query/GridCacheQueryManager.java      |  8 +++++
 .../GridCacheContinuousQueryEntry.java          |  8 +++++
 .../cache/eviction/GridCacheMockEntry.java      |  8 +++++
 9 files changed, 78 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/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 a7dab9b..2f0073f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
@@ -36,17 +36,22 @@ public class IgniteCacheManager implements CacheManager {
     private final ClassLoader clsLdr;
 
     /** */
+    private final Properties props;
+
+    /** */
     private final AtomicBoolean closed = new AtomicBoolean();
 
     /**
      * @param uri Uri.
      * @param cachingProvider Caching provider.
      * @param clsLdr Class loader.
+     * @param props
      */
-    public IgniteCacheManager(URI uri, CachingProvider cachingProvider, ClassLoader clsLdr)
{
+    public IgniteCacheManager(URI uri, CachingProvider cachingProvider, ClassLoader clsLdr,
Properties props) {
         this.uri = uri;
         this.cachingProvider = cachingProvider;
         this.clsLdr = clsLdr;
+        this.props = props;
     }
 
     /** {@inheritDoc} */
@@ -66,7 +71,7 @@ public class IgniteCacheManager implements CacheManager {
 
     /** {@inheritDoc} */
     @Override public Properties getProperties() {
-        return null;
+        return props;
     }
 
     /** {@inheritDoc} */
@@ -86,12 +91,15 @@ public class IgniteCacheManager implements CacheManager {
         if (cacheCfg instanceof GridCacheConfiguration) {
             String cfgCacheName = ((GridCacheConfiguration)cacheCfg).getName();
 
-            if (cfgCacheName != null && !cacheName.equals(cfgCacheName))
-                throw new IllegalArgumentException();
-
-            cacheCfg = (C)new GridCacheConfiguration((CompleteConfiguration)cacheCfg);
+            if (cfgCacheName != null) {
+                if (!cacheName.equals(cfgCacheName))
+                    throw new IllegalArgumentException();
+            }
+            else {
+                cacheCfg = (C)new GridCacheConfiguration((CompleteConfiguration)cacheCfg);
 
-            ((GridCacheConfiguration)cacheCfg).setName(cacheName);
+                ((GridCacheConfiguration)cacheCfg).setName(cacheName);
+            }
         }
 
         Ignite ignite;
@@ -176,7 +184,9 @@ public class IgniteCacheManager implements CacheManager {
 
     /** {@inheritDoc} */
     @Override public Iterable<String> getCacheNames() {
-        ensureNotClosed();
+        if (isClosed())
+            return Collections.emptySet(); // javadoc of #getCacheNames() says that IllegalStateException
should be
+                                           // thrown but CacheManagerTest.close_cachesEmpty()
require empty collection.
 
         String[] resArr;
 
@@ -184,7 +194,7 @@ public class IgniteCacheManager implements CacheManager {
             resArr = igniteMap.keySet().toArray(new String[igniteMap.keySet().size()]);
         }
 
-        return Arrays.asList(resArr);
+        return Collections.unmodifiableCollection(Arrays.asList(resArr));
     }
 
     /**
@@ -221,6 +231,8 @@ public class IgniteCacheManager implements CacheManager {
 
     /** {@inheritDoc} */
     @Override public void enableManagement(String cacheName, boolean enabled) {
+        ensureNotClosed();
+
         if (cacheName == null)
             throw new NullPointerException();
 
@@ -229,6 +241,8 @@ public class IgniteCacheManager implements CacheManager {
 
     /** {@inheritDoc} */
     @Override public void enableStatistics(String cacheName, boolean enabled) {
+        ensureNotClosed();
+
         if (cacheName == null)
             throw new NullPointerException();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/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 e67434e..ecc0560 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
@@ -45,6 +45,9 @@ public class IgniteCachingProvider implements CachingProvider {
     }
 
     /** */
+    public static final Properties DFLT_PROPS = new Properties();
+
+    /** */
     private final Map<ClassLoader, Map<URI, IgniteCacheManager>> cacheManagers
= new WeakHashMap<>();
 
     /** {@inheritDoc} */
@@ -67,7 +70,7 @@ public class IgniteCachingProvider implements CachingProvider {
             IgniteCacheManager mgr = uriMap.get(uri);
 
             if (mgr == null || mgr.isClosed()) {
-                mgr = new IgniteCacheManager(uri, this, clsLdr);
+                mgr = new IgniteCacheManager(uri, this, clsLdr, props);
 
                 uriMap.put(uri, mgr);
             }
@@ -88,7 +91,7 @@ public class IgniteCachingProvider implements CachingProvider {
 
     /** {@inheritDoc} */
     @Override public Properties getDefaultProperties() {
-        return null;
+        return DFLT_PROPS;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java
index d494903..cae7c47 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java
@@ -15,6 +15,7 @@ import org.apache.ignite.transactions.*;
 import org.gridgain.grid.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.*;
 import java.util.*;
 import java.util.Map.*;
 
@@ -79,7 +80,7 @@ import java.util.Map.*;
  * @param <K> Key type.
  * @param <V> Value type.
  */
-public interface GridCacheEntry<K, V> extends Map.Entry<K, V>, GridMetadataAware
{
+public interface GridCacheEntry<K, V> extends Map.Entry<K, V>, GridMetadataAware,
Cache.Entry<K, V> {
     /**
      * Cache projection to which this entry belongs. Note that entry and its
      * parent projections have same flags and filters.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEntryImpl.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEntryImpl.java
index c910df2..19ff5b6 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEntryImpl.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEntryImpl.java
@@ -734,6 +734,14 @@ public class GridCacheEntryImpl<K, V> implements GridCacheEntry<K,
V>, Externali
     }
 
     /** {@inheritDoc} */
+    @Override public <T> T unwrap(Class<T> clazz) {
+        if(clazz.isAssignableFrom(getClass()))
+            return clazz.cast(this);
+
+        throw new IllegalArgumentException();
+    }
+
+    /** {@inheritDoc} */
     @Override public int hashCode() {
         return key.hashCode();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionEntry.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionEntry.java
index e81f637..42958eb 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionEntry.java
@@ -481,6 +481,14 @@ public class GridCacheEvictionEntry<K, V> implements GridCacheEntry<K,
V>, Exter
     }
 
     /** {@inheritDoc} */
+    @Override public <T> T unwrap(Class<T> clazz) {
+        if(clazz.isAssignableFrom(getClass()))
+            return clazz.cast(this);
+
+        throw new IllegalArgumentException();
+    }
+
+    /** {@inheritDoc} */
     @Override public int hashCode() {
         return cached.key().hashCode();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheFilterEvaluationEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheFilterEvaluationEntry.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheFilterEvaluationEntry.java
index 9e5644a..4b5cf9d 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheFilterEvaluationEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheFilterEvaluationEntry.java
@@ -413,6 +413,14 @@ public class GridCacheFilterEvaluationEntry<K, V> implements GridCacheEntry<K,
V
     }
 
     /** {@inheritDoc} */
+    @Override public <T> T unwrap(Class<T> clazz) {
+        if(clazz.isAssignableFrom(getClass()))
+            return clazz.cast(this);
+
+        throw new IllegalArgumentException();
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheFilterEvaluationEntry.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryManager.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryManager.java
index 588cac1..ce94ddb 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryManager.java
@@ -2863,6 +2863,14 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         @Override public <V> boolean replaceMeta(String name, V curVal, V newVal) {
             throw new UnsupportedOperationException();
         }
+
+        /** {@inheritDoc} */
+        @Override public <T> T unwrap(Class<T> clazz) {
+            if(clazz.isAssignableFrom(getClass()))
+                return clazz.cast(this);
+
+            throw new IllegalArgumentException();
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryEntry.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryEntry.java
index 991573b..bf35bf9 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryEntry.java
@@ -678,6 +678,14 @@ public class GridCacheContinuousQueryEntry<K, V> implements GridCacheEntry<K,
V>
     }
 
     /** {@inheritDoc} */
+    @Override public <T> T unwrap(Class<T> clazz) {
+        if(clazz.isAssignableFrom(getClass()))
+            return clazz.cast(this);
+
+        throw new IllegalArgumentException();
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeExternal(ObjectOutput out) throws IOException {
         boolean b = keyBytes != null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5190b121/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheMockEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheMockEntry.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheMockEntry.java
index 6827e66..90e89e6 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheMockEntry.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheMockEntry.java
@@ -343,6 +343,14 @@ public class GridCacheMockEntry<K, V> extends GridMetadataAwareAdapter
implement
     }
 
     /** {@inheritDoc} */
+    @Override public <T> T unwrap(Class<T> clazz) {
+        if(clazz.isAssignableFrom(getClass()))
+            return clazz.cast(this);
+
+        throw new IllegalArgumentException();
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheMockEntry.class, this);
     }


Mime
View raw message