You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/01/14 12:43:31 UTC
[01/12] incubator-ignite git commit: ignite-45: wip
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-53 84597ce4d -> 39946d076
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/ef624c58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ef624c58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ef624c58
Branch: refs/heads/ignite-53
Commit: ef624c58cf434469d58efa8b6e06e576e24c4a55
Parents: 180720f
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Jan 6 15:45:00 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Jan 6 15:45:00 2015 +0300
----------------------------------------------------------------------
.../services/javax.cache.spi.CachingProvider | 1 +
.../org/apache/ignite/IgniteCacheMXBean.java | 64 ++++
.../org/apache/ignite/IgniteCacheManager.java | 311 +++++++++++++++++++
.../apache/ignite/IgniteCachingProvider.java | 157 ++++++++++
.../processors/cache/IgniteCacheProxy.java | 6 +-
.../grid/cache/GridCacheConfiguration.java | 11 +-
.../org/gridgain/grid/kernal/GridGainEx.java | 2 +-
.../cache/IgniteCachingProviderSelfTest.java | 123 ++++++++
8 files changed, 670 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/modules/core/src/main/java/META-INF/services/javax.cache.spi.CachingProvider
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/META-INF/services/javax.cache.spi.CachingProvider b/modules/core/src/main/java/META-INF/services/javax.cache.spi.CachingProvider
new file mode 100644
index 0000000..eb232dc
--- /dev/null
+++ b/modules/core/src/main/java/META-INF/services/javax.cache.spi.CachingProvider
@@ -0,0 +1 @@
+org.apache.ignite.IgniteCachingProvider
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java b/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java
new file mode 100644
index 0000000..0200717
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java
@@ -0,0 +1,64 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite;
+
+import javax.cache.*;
+import javax.cache.configuration.*;
+import javax.cache.management.*;
+
+/**
+ *
+ */
+public class IgniteCacheMXBean implements CacheMXBean {
+ /** */
+ private final Cache<?, ?> cache;
+
+ /**
+ * @param cache Cache.
+ */
+ public IgniteCacheMXBean(Cache<?, ?> cache) {
+ this.cache = cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getKeyType() {
+ return cache.getConfiguration(CompleteConfiguration.class).getKeyType().getName();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getValueType() {
+ return cache.getConfiguration(CompleteConfiguration.class).getValueType().getName();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isReadThrough() {
+ return cache.getConfiguration(CompleteConfiguration.class).isReadThrough();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWriteThrough() {
+ return cache.getConfiguration(CompleteConfiguration.class).isWriteThrough();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isStoreByValue() {
+ return cache.getConfiguration(CompleteConfiguration.class).isStoreByValue();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isStatisticsEnabled() {
+ return cache.getConfiguration(CompleteConfiguration.class).isStatisticsEnabled();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isManagementEnabled() {
+ return cache.getConfiguration(CompleteConfiguration.class).isManagementEnabled();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/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
new file mode 100644
index 0000000..7cfeca1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
@@ -0,0 +1,311 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite;
+
+import org.apache.ignite.configuration.*;
+import org.gridgain.grid.cache.*;
+
+import javax.cache.*;
+import javax.cache.configuration.*;
+import javax.cache.spi.*;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ *
+ */
+public class IgniteCacheManager implements CacheManager {
+ /** */
+ private final Map<String, Ignite> igniteMap = new HashMap<>();
+
+ /** */
+ private final URI uri;
+
+ /** */
+ private final CachingProvider cachingProvider;
+
+ /** */
+ private final ClassLoader clsLdr;
+
+ /** */
+ private final AtomicBoolean closed = new AtomicBoolean();
+
+ /**
+ * @param uri Uri.
+ * @param cachingProvider Caching provider.
+ * @param clsLdr Class loader.
+ */
+ public IgniteCacheManager(URI uri, CachingProvider cachingProvider, ClassLoader clsLdr) {
+ this.uri = uri;
+ this.cachingProvider = cachingProvider;
+ this.clsLdr = clsLdr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CachingProvider getCachingProvider() {
+ return cachingProvider;
+ }
+
+ /** {@inheritDoc} */
+ @Override public URI getURI() {
+ return uri;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClassLoader getClassLoader() {
+ return clsLdr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Properties getProperties() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V, C extends Configuration<K, V>> Cache<K, V> createCache(String cacheName, C cacheCfg)
+ throws IllegalArgumentException {
+ ensureNotClosed();
+
+ if (cacheCfg == null)
+ throw new NullPointerException();
+
+ if (!(cacheCfg instanceof CompleteConfiguration))
+ throw new UnsupportedOperationException("Configuration is not supported: " + cacheCfg);
+
+ if (cacheCfg instanceof GridCacheConfiguration) {
+ String cfgCacheName = ((GridCacheConfiguration)cacheCfg).getName();
+
+ if (cfgCacheName != null && !cacheName.equals(cfgCacheName))
+ throw new IllegalArgumentException();
+
+ cacheCfg = (C)new GridCacheConfiguration((GridCacheConfiguration)cacheCfg);
+
+ ((GridCacheConfiguration)cacheCfg).setName(cacheName);
+ }
+
+ Ignite ignite;
+
+ synchronized (igniteMap) {
+ if (igniteMap.containsKey(cacheName))
+ throw new CacheException("Cache already exists [cacheName=" + cacheName + ", manager=" + uri + ']');
+
+ if (uri.equals(cachingProvider.getDefaultURI())) {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setGridName("grid-for-" + cacheName);
+
+ cfg.setCacheConfiguration(new GridCacheConfiguration((CompleteConfiguration)cacheCfg));
+
+ cfg.getCacheConfiguration()[0].setName(cacheName);
+
+ try {
+ ignite = Ignition.start(cfg);
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+ else
+ throw new UnsupportedOperationException();
+
+ igniteMap.put(cacheName, ignite);
+ }
+
+ return ignite.jcache(cacheName);
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ private <K, V> IgniteCache<K, V> findCache(String cacheName) {
+ Ignite ignite;
+
+ synchronized (igniteMap) {
+ ignite = igniteMap.get(cacheName);
+ }
+
+ if (ignite == null)
+ return null;
+
+ return ignite.jcache(cacheName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> Cache<K, V> getCache(String cacheName, Class<K> keyType, Class<V> valType) {
+ ensureNotClosed();
+
+ Cache<K, V> cache = findCache(cacheName);
+
+ if (cache != null) {
+ if(!keyType.isAssignableFrom(cache.getConfiguration(Configuration.class).getKeyType()))
+ throw new ClassCastException();
+
+ if(!valType.isAssignableFrom(cache.getConfiguration(Configuration.class).getValueType()))
+ throw new ClassCastException();
+ }
+
+ return cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> Cache<K, V> getCache(String cacheName) {
+ ensureNotClosed();
+
+ IgniteCache<K, V> cache = findCache(cacheName);
+
+ if (cache != null) {
+ if(cache.getConfiguration(Configuration.class).getKeyType() != Object.class)
+ throw new IllegalArgumentException();
+
+ if(cache.getConfiguration(Configuration.class).getValueType() != Object.class)
+ throw new IllegalArgumentException();
+ }
+
+ return cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterable<String> getCacheNames() {
+ ensureNotClosed();
+
+ Collection<String> res;
+
+ synchronized (igniteMap) {
+ res = new ArrayList<>(igniteMap.keySet());
+ }
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroyCache(String cacheName) {
+ ensureNotClosed();
+
+ if (cacheName == null)
+ throw new NullPointerException();
+
+ Ignite ignite;
+
+ synchronized (igniteMap) {
+ ignite = igniteMap.remove(cacheName);
+ }
+
+ if (ignite != null) {
+ try {
+ ignite.close();
+ }
+ catch (Exception ignored) {
+
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void enableManagement(String cacheName, boolean enabled) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void enableStatistics(String cacheName, boolean enabled) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ private void ensureNotClosed() throws IllegalStateException {
+ if (closed.get())
+ throw new IllegalStateException("Cache manager are closed [uri=" + uri + ", classLoader=" + clsLdr + ']');
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ if (closed.compareAndSet(false, true)) {
+ Ignite[] ignites;
+
+ synchronized (igniteMap) {
+ ignites = igniteMap.values().toArray(new Ignite[igniteMap.values().size()]);
+ }
+
+ for (Ignite ignite : ignites) {
+ try {
+ ignite.close();
+ }
+ catch (Exception ignored) {
+ // Ignore any exceptions according to javadoc of javax.cache.CacheManager#close()
+ }
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClosed() {
+ return closed.get();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T unwrap(Class<T> clazz) {
+ if(clazz.isAssignableFrom(getClass()))
+ return clazz.cast(this);
+
+// if(clazz.isAssignableFrom(ignite.getClass()))
+// return clazz.cast(ignite);
+
+ throw new IllegalArgumentException();
+ }
+
+// /**
+// *
+// */
+// private static class Future<T> {
+// /** */
+// private volatile T res;
+//
+// /** */
+// private volatile Throwable e;
+//
+// public T get() throws CacheException {
+// if (res == null && e == null) {
+// synchronized (this) {
+// try {
+// while (res == null && e == null)
+// wait();
+// }
+// catch (InterruptedException e) {
+// Thread.currentThread().interrupt();
+//
+// throw new RuntimeException(e);
+// }
+// }
+// }
+//
+// if (res != null)
+// return res;
+//
+// assert e != null;
+//
+// throw new CacheException(e);
+// }
+//
+// public synchronized void setException(Throwable e) {
+// this.e = e;
+//
+// notifyAll();
+// }
+//
+// public synchronized void setCacheManager(T res) {
+// assert res != null;
+//
+// this.res = res;
+//
+// notifyAll();
+// }
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/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
new file mode 100644
index 0000000..eab4cf9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
@@ -0,0 +1,157 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite;
+
+import org.gridgain.grid.kernal.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import javax.cache.configuration.*;
+import javax.cache.spi.*;
+import java.net.*;
+import java.util.*;
+
+/**
+ *
+ */
+public class IgniteCachingProvider implements CachingProvider {
+ /** */
+ private static final URI DEFAULT_URI;
+
+ static {
+ URI uri = null;
+
+ try {
+ URL dfltCfgURL = U.resolveGridGainUrl(GridGainEx.DFLT_CFG);
+ if (dfltCfgURL != null)
+ uri = dfltCfgURL.toURI();
+ }
+ catch (URISyntaxException ignored) {
+
+ }
+
+ if (uri == null)
+ uri = URI.create("ignite://default");
+
+ DEFAULT_URI = uri;
+ }
+
+ /** */
+ private final Map<ClassLoader, Map<URI, IgniteCacheManager>> cacheManagers = new WeakHashMap<>();
+
+ /** {@inheritDoc} */
+ @Override public CacheManager getCacheManager(@Nullable URI uri, ClassLoader clsLdr, Properties props) {
+ if (uri == null)
+ uri = getDefaultURI();
+
+ if (clsLdr == null)
+ clsLdr = getDefaultClassLoader();
+
+ synchronized (cacheManagers) {
+ Map<URI, IgniteCacheManager> uriMap = cacheManagers.get(clsLdr);
+
+ if (uriMap == null) {
+ uriMap = new HashMap<>();
+
+ cacheManagers.put(clsLdr, uriMap);
+ }
+
+ IgniteCacheManager mgr = uriMap.get(uri);
+
+ if (mgr == null) {
+ mgr = new IgniteCacheManager(uri, this, clsLdr);
+
+ uriMap.put(uri, mgr);
+ }
+
+ return mgr;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClassLoader getDefaultClassLoader() {
+ return getClass().getClassLoader();
+ }
+
+ /** {@inheritDoc} */
+ @Override public URI getDefaultURI() {
+ return DEFAULT_URI;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Properties getDefaultProperties() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheManager getCacheManager(URI uri, ClassLoader clsLdr) {
+ return getCacheManager(uri, clsLdr, getDefaultProperties());
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheManager getCacheManager() {
+ return getCacheManager(getDefaultURI(), getDefaultClassLoader());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ Collection<IgniteCacheManager> mgrs = new ArrayList<>();
+
+ synchronized (cacheManagers) {
+ for (Map<URI, IgniteCacheManager> uriMap : cacheManagers.values())
+ mgrs.addAll(uriMap.values());
+
+ cacheManagers.clear();
+ }
+
+ for (IgniteCacheManager mgr : mgrs)
+ mgr.close();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close(ClassLoader clsLdr) {
+ Collection<IgniteCacheManager> mgrs;
+
+ synchronized (cacheManagers) {
+ Map<URI, IgniteCacheManager> uriMap = cacheManagers.remove(clsLdr);
+
+ if (uriMap == null)
+ return;
+
+ mgrs = uriMap.values();
+ }
+
+ for (IgniteCacheManager mgr : mgrs)
+ mgr.close();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close(URI uri, ClassLoader clsLdr) {
+ IgniteCacheManager mgr;
+
+ synchronized (cacheManagers) {
+ Map<URI, IgniteCacheManager> uriMap = cacheManagers.get(clsLdr);
+
+ if (uriMap == null)
+ return;
+
+ mgr = uriMap.remove(uri);
+ }
+
+ if (mgr != null)
+ mgr.close();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isSupported(OptionalFeature optionalFeature) {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/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 a985fde..df9bc41 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
@@ -88,10 +88,12 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
/** {@inheritDoc} */
@Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
- if (!clazz.equals(GridCacheConfiguration.class))
+ GridCacheConfiguration cfg = ctx.config();
+
+ if (!clazz.isAssignableFrom(cfg.getClass()))
throw new IllegalArgumentException();
- return (C)ctx.config();
+ return clazz.cast(cfg);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
index 5a9a675..f92c10a 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
@@ -331,9 +331,16 @@ public class GridCacheConfiguration extends MutableConfiguration {
/**
* Copy constructor.
*
- * @param cc Configuration to copy.
+ * @param cfg Configuration to copy.
*/
- public GridCacheConfiguration(GridCacheConfiguration cc) {
+ public GridCacheConfiguration(CompleteConfiguration cfg) {
+ super(cfg);
+
+ if (!(cfg instanceof GridCacheConfiguration))
+ return;
+
+ GridCacheConfiguration cc = (GridCacheConfiguration)cfg;
+
/*
* NOTE: MAKE SURE TO PRESERVE ALPHABETIC ORDER!
* ==============================================
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
index 555ab55..24b92dd 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
@@ -103,7 +103,7 @@ import static org.apache.ignite.plugin.segmentation.GridSegmentationPolicy.*;
*/
public class GridGainEx {
/** Default configuration path relative to GridGain home. */
- private static final String DFLT_CFG = "config/default-config.xml";
+ public static final String DFLT_CFG = "config/default-config.xml";
/** Map of named grids. */
private static final ConcurrentMap<Object, GridNamedInstance> grids = new ConcurrentHashMap8<>();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef624c58/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java
new file mode 100644
index 0000000..c224ec2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java
@@ -0,0 +1,123 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import com.google.common.collect.*;
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.gridgain.grid.cache.*;
+
+import javax.cache.*;
+import javax.cache.spi.*;
+import java.util.*;
+
+/**
+ *
+ */
+public class IgniteCachingProviderSelfTest extends IgniteCacheAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridCacheMode cacheMode() {
+ return GridCacheMode.REPLICATED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridCacheAtomicityMode atomicityMode() {
+ return GridCacheAtomicityMode.TRANSACTIONAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridCacheDistributionMode distributionMode() {
+ return GridCacheDistributionMode.PARTITIONED_ONLY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getTestGridName(int idx) {
+ assert idx == 0;
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ assert gridName == null;
+
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ GridCacheConfiguration cache1 = cacheConfiguration(null);
+ cache1.setName("cache1");
+
+ GridCacheConfiguration cache2 = cacheConfiguration(null);
+ cache2.setName("cache2");
+
+ cfg.setCacheConfiguration(cacheConfiguration(null), cache1, cache2);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ // No-op. Disabling start of ignite.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ *
+ */
+ public void testStartIgnite() {
+ CachingProvider cachingProvider = Caching.getCachingProvider();
+
+ assert cachingProvider instanceof IgniteCachingProvider;
+
+ CacheManager cacheMgr = cachingProvider.getCacheManager();
+
+ assertEquals(Collections.<String>emptySet(), Sets.newHashSet(cacheMgr.getCacheNames()));
+
+ Cache<Integer, String> cacheA = cacheMgr.createCache("a", new GridCacheConfiguration());
+
+ cacheA.put(1, "1");
+
+ assertEquals("1", cacheA.get(1));
+
+ cacheMgr.createCache("b", new GridCacheConfiguration());
+
+ assertEquals(Sets.newHashSet("a", "b"), Sets.newHashSet(cacheMgr.getCacheNames()));
+
+ cacheMgr.destroyCache("a");
+ cacheMgr.destroyCache("b");
+
+ assertEquals(Collections.<String>emptySet(), Sets.newHashSet(cacheMgr.getCacheNames()));
+ }
+
+ /**
+ *
+ */
+ public void testCloseManager() throws Exception {
+ startGridsMultiThreaded(1);
+
+ CachingProvider cachingProvider = Caching.getCachingProvider();
+
+ assert cachingProvider instanceof IgniteCachingProvider;
+
+ CacheManager cacheMgr = cachingProvider.getCacheManager();
+
+ cachingProvider.close();
+
+ assertNotSame(cacheMgr, cachingProvider.getCacheManager());
+ }
+}
[07/12] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-45' into ignite-1
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-45' into ignite-1
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/22796ee9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/22796ee9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/22796ee9
Branch: refs/heads/ignite-53
Commit: 22796ee9cb21e4fa7cfb3f3886249e2c9e04f699
Parents: bb32d46 7b5d5f4
Author: sevdokimov <se...@gridgain.com>
Authored: Tue Jan 13 18:20:14 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Tue Jan 13 18:20:14 2015 +0300
----------------------------------------------------------------------
.../services/javax.cache.spi.CachingProvider | 1 +
.../org/apache/ignite/IgniteCacheMXBean.java | 72 ++++
.../org/apache/ignite/IgniteCacheManager.java | 372 +++++++++++++++++++
.../apache/ignite/IgniteCachingProvider.java | 189 ++++++++++
.../processors/cache/IgniteCacheProxy.java | 35 +-
.../grid/cache/GridCacheConfiguration.java | 11 +-
.../org/gridgain/grid/cache/GridCacheEntry.java | 3 +-
.../org/gridgain/grid/kernal/GridGainEx.java | 2 +-
.../processors/cache/GridCacheEntryImpl.java | 8 +
.../cache/GridCacheEvictionEntry.java | 8 +
.../cache/GridCacheFilterEvaluationEntry.java | 8 +
.../cache/query/GridCacheQueryManager.java | 8 +
.../GridCacheContinuousQueryEntry.java | 8 +
.../grid/kernal/tck/TCKMBeanServerBuilder.java | 118 ++++++
.../cache/IgniteCachingProviderSelfTest.java | 123 ++++++
.../cache/eviction/GridCacheMockEntry.java | 8 +
16 files changed, 960 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22796ee9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
[09/12] incubator-ignite git commit: # ignite-1 Do not allow null
value for MutableEntry.setValue
Posted by sb...@apache.org.
# ignite-1 Do not allow null value for MutableEntry.setValue
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/83fb7946
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/83fb7946
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/83fb7946
Branch: refs/heads/ignite-53
Commit: 83fb794691f1a51fa643ab8d4cfc72a9e30be0f0
Parents: 018a9b0
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 14 10:46:41 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 14 10:46:41 2015 +0300
----------------------------------------------------------------------
.../grid/kernal/processors/cache/CacheInvokeEntry.java | 3 +++
.../distributed/dht/GridCacheAtomicNearCacheSelfTest.java | 1 +
.../processors/hadoop/jobtracker/GridHadoopJobTracker.java | 7 ++++++-
3 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83fb7946/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
index 1f3900d..c9ca244 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
@@ -47,6 +47,9 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K, V> {
/** {@inheritDoc} */
@Override public void setValue(V val) {
+ if (val == null)
+ throw new NullPointerException();
+
this.val = val;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83fb7946/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java
index ab2024a..5f240fe 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java
@@ -802,6 +802,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
this.newVal = newVal;
}
+ /** {@inheritDoc} */
@Override public Void process(MutableEntry<Integer, Integer> e, Object... args) {
e.setValue(newVal);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83fb7946/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java b/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
index 6b3260f..4dcf5a6 100644
--- a/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
+++ b/modules/hadoop/src/main/java/org/gridgain/grid/kernal/processors/hadoop/jobtracker/GridHadoopJobTracker.java
@@ -1583,7 +1583,12 @@ public class GridHadoopJobTracker extends GridHadoopComponent {
/** {@inheritDoc} */
@Override public Void process(MutableEntry<GridHadoopJobId, GridHadoopJobMetadata> e, Object... args) {
- e.setValue(apply(e.getValue()));
+ GridHadoopJobMetadata val = apply(e.getValue());
+
+ if (val != null)
+ e.setValue(val);
+ else
+ e.remove();;
return null;
}
[03/12] incubator-ignite git commit: ignite-45: wip
Posted by sb...@apache.org.
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-53
Commit: 5190b12171bec52727fd40f6c69c8a3c5ac1112f
Parents: b03a483
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Fri Jan 9 17:47:52 2015 +0300
Committer: Yakov Zhdanov <yz...@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);
}
[06/12] incubator-ignite git commit: # IGNITE-45 fix notes found on
review.
Posted by sb...@apache.org.
# IGNITE-45 fix notes found on review.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7b5d5f44
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7b5d5f44
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7b5d5f44
Branch: refs/heads/ignite-53
Commit: 7b5d5f44186f2a076ae4130fc1d17cbc4a0ce936
Parents: 5800a75
Author: sevdokimov <se...@gridgain.com>
Authored: Tue Jan 13 18:17:38 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Tue Jan 13 18:17:38 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/IgniteCacheMXBean.java | 22 ++--
.../org/apache/ignite/IgniteCacheManager.java | 70 +++--------
.../apache/ignite/IgniteCachingProvider.java | 25 ++--
.../ignite/tck/TCKMBeanServerBuilder.java | 124 -------------------
.../grid/kernal/tck/TCKMBeanServerBuilder.java | 118 ++++++++++++++++++
5 files changed, 166 insertions(+), 193 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b5d5f44/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java b/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java
index 0200717..26cace6 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheMXBean.java
@@ -1,10 +1,18 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+/*
+ * 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;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b5d5f44/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 376c982..fa4530b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
@@ -1,10 +1,18 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+/*
+ * 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;
@@ -361,52 +369,4 @@ public class IgniteCacheManager implements CacheManager {
throw new IllegalArgumentException();
}
-
-// /**
-// *
-// */
-// private static class Future<T> {
-// /** */
-// private volatile T res;
-//
-// /** */
-// private volatile Throwable e;
-//
-// public T get() throws CacheException {
-// if (res == null && e == null) {
-// synchronized (this) {
-// try {
-// while (res == null && e == null)
-// wait();
-// }
-// catch (InterruptedException e) {
-// Thread.currentThread().interrupt();
-//
-// throw new RuntimeException(e);
-// }
-// }
-// }
-//
-// if (res != null)
-// return res;
-//
-// assert e != null;
-//
-// throw new CacheException(e);
-// }
-//
-// public synchronized void setException(Throwable e) {
-// this.e = e;
-//
-// notifyAll();
-// }
-//
-// public synchronized void setCacheManager(T res) {
-// assert res != null;
-//
-// this.res = res;
-//
-// notifyAll();
-// }
-// }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b5d5f44/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 ecc0560..ea97cb0 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCachingProvider.java
@@ -1,10 +1,18 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+/*
+ * 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;
@@ -26,6 +34,9 @@ public class IgniteCachingProvider implements CachingProvider {
/** */
private static final URI DEFAULT_URI;
+ /**
+ *
+ */
static {
URI uri = null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b5d5f44/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java b/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java
deleted file mode 100644
index 8123504..0000000
--- a/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
- */
-
-package org.apache.ignite.tck;
-
-import com.sun.jmx.mbeanserver.*;
-
-import javax.management.*;
-
-/**
- *
- */
-public class TCKMBeanServerBuilder extends MBeanServerBuilder {
- /** {@inheritDoc} */
- @Override public MBeanServer newMBeanServer(String dfltDomain, MBeanServer outer, MBeanServerDelegate delegate) {
- MBeanServerDelegate decoratingDelegate = new ServerDelegate(delegate);
- return JmxMBeanServer.newMBeanServer(dfltDomain, outer,
- decoratingDelegate, false);
- }
-
- /**
- *
- */
- private static class ServerDelegate extends MBeanServerDelegate {
- /** */
- private final MBeanServerDelegate delegate;
-
- /**
- * Constructor
- *
- * @param delegate the provided delegate
- */
- ServerDelegate(MBeanServerDelegate delegate) {
- this.delegate = delegate;
- }
-
- /** {@inheritDoc} */
- @Override public String getSpecificationName() {
- return delegate.getSpecificationName();
- }
-
- /** {@inheritDoc} */
- @Override
- public String getSpecificationVersion() {
- return delegate.getSpecificationVersion();
- }
-
- /** {@inheritDoc} */
- @Override
- public String getSpecificationVendor() {
- return delegate.getSpecificationVendor();
- }
-
- /** {@inheritDoc} */
- @Override
- public String getImplementationName() {
- return delegate.getImplementationName();
- }
-
- /** {@inheritDoc} */
- @Override
- public String getImplementationVersion() {
- return delegate.getImplementationVersion();
- }
-
- /** {@inheritDoc} */
- @Override
- public String getImplementationVendor() {
- return delegate.getImplementationVendor();
- }
-
- /** {@inheritDoc} */
- @Override
- public MBeanNotificationInfo[] getNotificationInfo() {
- return delegate.getNotificationInfo();
- }
-
- /** {@inheritDoc} */
- @Override
- public synchronized void addNotificationListener(NotificationListener listener,
- NotificationFilter filter,
- Object handback) throws
- IllegalArgumentException {
- delegate.addNotificationListener(listener, filter, handback);
- }
-
- /** {@inheritDoc} */
- @Override
- public synchronized void removeNotificationListener(NotificationListener
- listener,
- NotificationFilter
- filter,
- Object handback) throws
- ListenerNotFoundException {
- delegate.removeNotificationListener(listener, filter, handback);
- }
-
- /** {@inheritDoc} */
- @Override
- public synchronized void removeNotificationListener(NotificationListener
- listener) throws
- ListenerNotFoundException {
- delegate.removeNotificationListener(listener);
- }
-
- /** {@inheritDoc} */
- @Override
- public void sendNotification(Notification notification) {
- delegate.sendNotification(notification);
- }
-
- /** {@inheritDoc} */
- @Override
- public synchronized String getMBeanServerId() {
- return System.getProperty("org.jsr107.tck.management.agentId");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b5d5f44/modules/core/src/main/java/org/gridgain/grid/kernal/tck/TCKMBeanServerBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/tck/TCKMBeanServerBuilder.java b/modules/core/src/main/java/org/gridgain/grid/kernal/tck/TCKMBeanServerBuilder.java
new file mode 100644
index 0000000..fe5e495
--- /dev/null
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/tck/TCKMBeanServerBuilder.java
@@ -0,0 +1,118 @@
+/*
+ * 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.gridgain.grid.kernal.tck;
+
+import com.sun.jmx.mbeanserver.*;
+
+import javax.management.*;
+
+/**
+ * This class is needed for JCache TCK tests.
+ */
+public class TCKMBeanServerBuilder extends MBeanServerBuilder {
+ /** {@inheritDoc} */
+ @Override public MBeanServer newMBeanServer(String dfltDomain, MBeanServer outer, MBeanServerDelegate delegate) {
+ MBeanServerDelegate decoratingDelegate = new ServerDelegate(delegate);
+ return JmxMBeanServer.newMBeanServer(dfltDomain, outer,
+ decoratingDelegate, false);
+ }
+
+ /**
+ *
+ */
+ private static class ServerDelegate extends MBeanServerDelegate {
+ /** */
+ private final MBeanServerDelegate delegate;
+
+ /**
+ * Constructor
+ *
+ * @param delegate the provided delegate
+ */
+ ServerDelegate(MBeanServerDelegate delegate) {
+ this.delegate = delegate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSpecificationName() {
+ return delegate.getSpecificationName();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSpecificationVersion() {
+ return delegate.getSpecificationVersion();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSpecificationVendor() {
+ return delegate.getSpecificationVendor();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getImplementationName() {
+ return delegate.getImplementationName();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getImplementationVersion() {
+ return delegate.getImplementationVersion();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getImplementationVendor() {
+ return delegate.getImplementationVendor();
+ }
+
+ /** {@inheritDoc} */
+ @Override public MBeanNotificationInfo[] getNotificationInfo() {
+ return delegate.getNotificationInfo();
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void addNotificationListener(NotificationListener lsnr,
+ NotificationFilter filter,
+ Object handback) throws
+ IllegalArgumentException {
+ delegate.addNotificationListener(lsnr, filter, handback);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void removeNotificationListener(NotificationListener lsnr,
+ NotificationFilter filter,
+ Object handback) throws
+ ListenerNotFoundException {
+ delegate.removeNotificationListener(lsnr, filter, handback);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void removeNotificationListener(NotificationListener lsnr)
+ throws ListenerNotFoundException {
+ delegate.removeNotificationListener(lsnr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sendNotification(Notification notification) {
+ delegate.sendNotification(notification);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized String getMBeanServerId() {
+ return System.getProperty("org.jsr107.tck.management.agentId");
+ }
+ }
+}
[05/12] incubator-ignite git commit: # ignite-1 Implemented
loadCache/localLoadCache
Posted by sb...@apache.org.
# ignite-1 Implemented loadCache/localLoadCache
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bb32d468
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bb32d468
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bb32d468
Branch: refs/heads/ignite-53
Commit: bb32d468db01d1f6aab485e9f86c46a9184e6cc0
Parents: aceb586
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jan 13 16:03:46 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jan 13 16:03:46 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCache.java | 39 ++---
.../processors/cache/IgniteCacheProxy.java | 124 +++++++++++++-
.../GridCacheLoadOnlyStoreAdapterSelfTest.java | 5 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 2 +-
.../cache/GridCacheAbstractSelfTest.java | 4 +-
.../dht/GridCacheGlobalLoadTest.java | 163 +++++++++++++++++++
.../GridCachePartitionedLoadCacheSelfTest.java | 20 ++-
.../junits/common/GridCommonAbstractTest.java | 7 +
.../bamboo/GridDataGridTestSuite.java | 1 +
9 files changed, 328 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index f7b2c34..4644911 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -14,6 +14,7 @@ import org.apache.ignite.cache.query.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
+import org.gridgain.grid.cache.store.*;
import org.jetbrains.annotations.*;
import javax.cache.*;
@@ -86,20 +87,20 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* @param p Optional predicate (may be {@code null}). If provided, will be used to
* filter values to be put into cache.
* @param args Optional user arguments to be passed into
- * {@link org.gridgain.grid.cache.store.GridCacheStore#loadCache(IgniteBiInClosure, Object...)} method.
+ * {@link GridCacheStore#loadCache(IgniteBiInClosure, Object...)} method.
* @throws CacheException If loading failed.
*/
public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException;
/**
- * Delegates to {@link org.gridgain.grid.cache.store.GridCacheStore#loadCache(IgniteBiInClosure,Object...)} method
+ * Delegates to {@link GridCacheStore#loadCache(IgniteBiInClosure,Object...)} method
* to load state from the underlying persistent storage. The loaded values
* will then be given to the optionally passed in predicate, and, if the predicate returns
* {@code true}, will be stored in cache. If predicate is {@code null}, then
* all loaded values will be stored in cache.
* <p>
* Note that this method does not receive keys as a parameter, so it is up to
- * {@link org.gridgain.grid.cache.store.GridCacheStore} implementation to provide all the data to be loaded.
+ * {@link GridCacheStore} implementation to provide all the data to be loaded.
* <p>
* This method is not transactional and may end up loading a stale value into
* cache if another thread has updated the value immediately after it has been
@@ -109,7 +110,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* @param p Optional predicate (may be {@code null}). If provided, will be used to
* filter values to be put into cache.
* @param args Optional user arguments to be passed into
- * {@link org.gridgain.grid.cache.store.GridCacheStore#loadCache(IgniteBiInClosure, Object...)} method.
+ * {@link GridCacheStore#loadCache(IgniteBiInClosure, Object...)} method.
* @throws CacheException If loading failed.
*/
public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException;
@@ -121,14 +122,14 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link org.gridgain.grid.cache.store.GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putIfAbsent(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link org.gridgain.grid.cache.store.GridCacheStore}
- * via {@link org.gridgain.grid.cache.store.GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
+ * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -155,8 +156,8 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* are acquired in undefined order, so it may cause a deadlock when used with
* other concurrent transactional updates.
* <p>
- * If write-through is enabled, the values will be removed from {@link org.gridgain.grid.cache.store.GridCacheStore}
- * via {@link org.gridgain.grid.cache.store.GridCacheStore#removeAll(IgniteTx, java.util.Collection)} method.
+ * If write-through is enabled, the values will be removed from {@link GridCacheStore}
+ * via {@link GridCacheStore#removeAll(IgniteTx, java.util.Collection)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -310,13 +311,13 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link org.gridgain.grid.cache.store.GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putIf(Object, Object, IgnitePredicate)} should
* always be used instead of this one to avoid the overhead associated with returning of the previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link org.gridgain.grid.cache.store.GridCacheStore}
- * via {@link org.gridgain.grid.cache.store.GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
+ * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -347,8 +348,8 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* value and, therefore, does not have any overhead associated with returning a value. It
* should be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link org.gridgain.grid.cache.store.GridCacheStore}
- * via {@link org.gridgain.grid.cache.store.GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
+ * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -375,14 +376,14 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* caches, the value will be loaded from the primary node, which in its turn may load the value
* from the disk-based swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link org.gridgain.grid.cache.store.GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #removeIf(Object, IgnitePredicate)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the value will be removed from {@link org.gridgain.grid.cache.store.GridCacheStore}
- * via {@link org.gridgain.grid.cache.store.GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link GridCacheStore}
+ * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -407,8 +408,8 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* This method will return {@code true} if remove did occur, which means that all optionally
* provided filters have passed and there was something to remove, {@code false} otherwise.
* <p>
- * If write-through is enabled, the value will be removed from {@link org.gridgain.grid.cache.store.GridCacheStore}
- * via {@link org.gridgain.grid.cache.store.GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link GridCacheStore}
+ * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/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 a985fde..31940ec 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
@@ -12,7 +12,9 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
+import org.apache.ignite.cluster.*;
import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.*;
@@ -28,6 +30,7 @@ import javax.cache.integration.*;
import javax.cache.processor.*;
import java.io.*;
import java.util.*;
+import java.util.concurrent.*;
import java.util.concurrent.locks.*;
/**
@@ -115,16 +118,41 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
}
/** {@inheritDoc} */
- @Override public void loadCache(@Nullable IgniteBiPredicate p, @Nullable Object... args) throws CacheException {
- // TODO IGNITE-1.
- throw new UnsupportedOperationException();
+ @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
+ try {
+ GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+ try {
+ ClusterGroup nodes = ctx.kernalContext().grid().cluster().forCache(ctx.name());
+
+ IgniteCompute comp = ctx.kernalContext().grid().compute(nodes).withNoFailover();
+
+ comp.broadcast(new LoadCacheClosure<>(ctx.name(), p, args));
+ }
+ finally {
+ gate.leave(prev);
+ }
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
}
/** {@inheritDoc} */
- @Override public void localLoadCache(@Nullable IgniteBiPredicate p, @Nullable Object... args)
- throws CacheException {
- // TODO IGNITE-1.
- throw new UnsupportedOperationException();
+ @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
+ try {
+ GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+ try {
+ delegate.<K, V>cache().loadCache(p, 0, args);
+ }
+ finally {
+ gate.leave(prev);
+ }
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
}
/** {@inheritDoc} */
@@ -320,7 +348,17 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
/** {@inheritDoc} */
@Override public int size(CachePeekMode... peekModes) throws CacheException {
// TODO IGNITE-1.
- throw new UnsupportedOperationException();
+ if (peekModes.length != 0)
+ throw new UnsupportedOperationException();
+
+ GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+ try {
+ return delegate.size();
+ }
+ finally {
+ gate.leave(prev);
+ }
}
/** {@inheritDoc} */
@@ -922,4 +960,74 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
@Override public String toString() {
return S.toString(IgniteCacheProxy.class, this);
}
+
+ /**
+ *
+ */
+ private static class LoadCacheClosure<K, V> implements Callable<Void>, Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private String cacheName;
+
+ /** */
+ private IgniteBiPredicate<K, V> p;
+
+ /** */
+ private Object[] args;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /**
+ * Required by {@link Externalizable}.
+ */
+ public LoadCacheClosure() {
+ // No-op.
+ }
+
+ /**
+ * @param cacheName Cache name.
+ * @param p Predicate.
+ * @param args Arguments.
+ */
+ private LoadCacheClosure(String cacheName, IgniteBiPredicate<K, V> p, Object[] args) {
+ this.cacheName = cacheName;
+ this.p = p;
+ this.args = args;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() throws Exception {
+ IgniteCache<K, V> cache = ignite.jcache(cacheName);
+
+ assert cache != null : cacheName;
+
+ cache.localLoadCache(p, args);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(p);
+
+ out.writeObject(args);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ p = (IgniteBiPredicate<K, V>)in.readObject();
+
+ args = (Object[])in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(LoadCacheClosure.class, this);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
index 855fdeb..2e91b92 100644
--- a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
@@ -46,7 +46,7 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelf
* @throws Exception If failed.
*/
public void testStore() throws Exception {
- cache().loadCache(null, 0, 1, 2, 3);
+ jcache().localLoadCache(null, 1, 2, 3);
int cnt = 0;
@@ -56,6 +56,9 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelf
assertEquals(INPUT_SIZE - (INPUT_SIZE/10), cnt);
}
+ /**
+ *
+ */
private static class TestStore extends GridCacheLoadOnlyStoreAdapter<Integer, String, String> {
/** {@inheritDoc} */
@Override protected Iterator<String> inputIterator(@Nullable Object... args)
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 54397cc..8b6f777 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -2341,7 +2341,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
putToStore(key, Integer.parseInt(key));
for (int g = 0; g < gridCount(); g++)
- grid(g).cache(null).loadCache(null, 0);
+ grid(g).jcache(null).localLoadCache(null);
for (int g = 0; g < gridCount(); g++) {
for (int i = 0; i < cnt; i++) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
index b4cd689..c88736f 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
@@ -350,7 +350,8 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
/**
* @return Default cache instance.
*/
- protected IgniteCache<String, Integer> jcache() {
+ @SuppressWarnings({"unchecked"})
+ @Override protected IgniteCache<String, Integer> jcache() {
return jcache(0);
}
@@ -358,6 +359,7 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
* @param idx Index of grid.
* @return Default cache.
*/
+ @SuppressWarnings({"unchecked"})
protected IgniteCache<String, Integer> jcache(int idx) {
return ignite(idx).jcache(null);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
new file mode 100644
index 0000000..6027986
--- /dev/null
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
@@ -0,0 +1,163 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.gridgain.grid.kernal.processors.cache.distributed.dht;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.cache.*;
+import org.gridgain.grid.cache.store.*;
+import org.jdk8.backport.*;
+import org.jetbrains.annotations.*;
+import org.junit.*;
+
+import java.util.concurrent.*;
+
+import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
+import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
+import static org.gridgain.grid.cache.GridCacheMode.*;
+
+/**
+ * Load cache test.
+ */
+public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
+ /** */
+ private static ConcurrentMap<String, Object[]> map;
+
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 3;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridCacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridCacheAtomicityMode atomicityMode() {
+ return TRANSACTIONAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridCacheDistributionMode distributionMode() {
+ return NEAR_PARTITIONED;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLoadCache() throws Exception {
+ IgniteCache<Integer, Integer> cache = jcache();
+
+ map = new ConcurrentHashMap8<>();
+
+ cache.loadCache(null, 1, 2, 3);
+
+ assertEquals(3, map.size());
+
+ Object[] expArgs = {1, 2, 3};
+
+ for (int i = 0; i < gridCount(); i++) {
+ Object[] args = map.get(getTestGridName(i));
+
+ Assert.assertArrayEquals(expArgs, args);
+ }
+
+ assertEquals(cache.get(1), (Integer)1);
+ assertEquals(cache.get(2), (Integer)2);
+ assertEquals(cache.get(3), (Integer)3);
+
+ map = new ConcurrentHashMap8<>();
+
+ cache.loadCache(new IgniteBiPredicate<Integer, Integer>() {
+ @Override public boolean apply(Integer key, Integer val) {
+ assertNotNull(key);
+ assertNotNull(val);
+
+ return key % 2 == 0;
+ }
+ }, 1, 2, 3, 4, 5, 6);
+
+ assertEquals(3, map.size());
+
+ expArgs = new Object[]{1, 2, 3, 4, 5, 6};
+
+ for (int i = 0; i < gridCount(); i++) {
+ Object[] args = map.get(getTestGridName(i));
+
+ Assert.assertArrayEquals(expArgs, args);
+ }
+
+ assertEquals(cache.get(1), (Integer)1);
+ assertEquals(cache.get(2), (Integer)2);
+ assertEquals(cache.get(3), (Integer)3);
+ assertEquals(cache.get(4), (Integer)4);
+ assertEquals(cache.get(6), (Integer)6);
+ assertNull(cache.get(5));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ map = null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridCacheStore<?, ?> cacheStore() {
+ return new TestStore();
+ }
+
+ /**
+ * Test store.
+ */
+ private static class TestStore extends GridCacheStoreAdapter<Integer, Integer> {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo,
+ @Nullable Object... args) throws IgniteCheckedException {
+ assertNotNull(ignite);
+ assertNotNull(clo);
+ assertNotNull(map);
+ assertNotNull(args);
+
+ assertNull(map.put(ignite.name(), args));
+
+ for (Object arg : args) {
+ Integer key = (Integer)arg;
+
+ clo.apply(key, key);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer load(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ assertEquals((Integer)5, key);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void put(IgniteTx tx, Integer key, Integer val) throws IgniteCheckedException {
+ fail();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ fail();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
index e991574..a96515c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
@@ -17,6 +17,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
+import org.gridgain.grid.cache.affinity.*;
import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.junits.common.*;
@@ -63,27 +64,32 @@ public class GridCachePartitionedLoadCacheSelfTest extends GridCommonAbstractTes
/**
* @throws Exception If failed.
*/
- public void testLoadCache() throws Exception {
+ public void testLocalLoadCache() throws Exception {
try {
startGridsMultiThreaded(GRID_CNT);
- GridCache<Integer, String> cache = cache(0);
+ IgniteCache<Integer, String> cache = jcache(0);
- cache.loadCache(null, 0, PUT_CNT);
+ cache.localLoadCache(null, PUT_CNT);
- int[] parts = cache.affinity().allPartitions(grid(0).localNode());
+ GridCache<Integer, String> cache0 = cache(0);
+
+ GridCacheAffinity aff = cache0.affinity();
+
+ int[] parts = aff.allPartitions(grid(0).localNode());
int cnt1 = 0;
- for (int i = 0; i < PUT_CNT; i++)
- if (U.containsIntArray(parts, cache.affinity().partition(i)))
+ for (int i = 0; i < PUT_CNT; i++) {
+ if (U.containsIntArray(parts, aff.partition(i)))
cnt1++;
+ }
info("Number of keys to load: " + cnt1);
int cnt2 = 0;
- for (GridCacheEntry<Integer, String> e : cache.entrySet()) {
+ for (GridCacheEntry<Integer, String> e : cache0.entrySet()) {
assert e.primary() || e.backup();
cnt2++;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridCommonAbstractTest.java
index f40d941..33e88e6 100644
--- a/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/common/GridCommonAbstractTest.java
@@ -86,6 +86,13 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
/**
* @return Cache.
*/
+ protected <K, V> IgniteCache<K, V> jcache() {
+ return grid().jcache(null);
+ }
+
+ /**
+ * @return Cache.
+ */
protected <K, V> GridLocalCache<K, V> local() {
return (GridLocalCache<K, V>)((GridKernal)grid()).<K, V>internalCache();
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb32d468/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
index d9a5e22..8082d15 100644
--- a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
+++ b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
@@ -104,6 +104,7 @@ public class GridDataGridTestSuite extends TestSuite {
suite.addTestSuite(GridCacheOffHeapTieredEvictionSelfTest.class);
suite.addTestSuite(GridCacheOffHeapTieredAtomicSelfTest.class);
suite.addTestSuite(GridCacheOffHeapTieredSelfTest.class);
+ suite.addTestSuite(GridCacheGlobalLoadTest.class);
// Local cache.
suite.addTestSuite(GridCacheLocalProjectionSelfTest.class);
[10/12] incubator-ignite git commit: ignite-1 do not invoke expire
policy for dr if resolving is not needed (to pass TCK)
Posted by sb...@apache.org.
ignite-1 do not invoke expire policy for dr if resolving is not needed (to pass TCK)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0f8d9ea5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0f8d9ea5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0f8d9ea5
Branch: refs/heads/ignite-53
Commit: 0f8d9ea5986b9a2a66cda98f8066ab108ce557c4
Parents: 83fb794
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 14 14:27:54 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 14 14:27:54 2015 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheProxy.java | 24 ++++++++++++++++++--
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../processors/cache/dr/GridCacheDrManager.java | 2 +-
.../cache/dr/os/GridOsCacheDrManager.java | 2 +-
4 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0f8d9ea5/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 e746780..f432c39 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
@@ -693,13 +693,33 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
/** {@inheritDoc} */
@Override public void removeAll() {
// TODO IGNITE-1.
- throw new UnsupportedOperationException();
+ GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+ try {
+ delegate.removeAll();
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
+ finally {
+ gate.leave(prev);
+ }
}
/** {@inheritDoc} */
@Override public void clear() {
// TODO IGNITE-1.
- throw new UnsupportedOperationException();
+ GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+ try {
+ delegate.globalClearAll(0);
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
+ finally {
+ gate.leave(prev);
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0f8d9ea5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
index bb493cc..d380d9a 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
@@ -1655,7 +1655,7 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K, V>
op,
writeObj,
valBytes,
- expiryPlc != null ? (isNew() ? expiryPlc.forCreate() : expiryPlc.forUpdate()) : -1L,
+ expiryPlc,
drTtl,
drExpireTime,
drVer);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0f8d9ea5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java
index 8915fc1..8b34b33 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java
@@ -43,7 +43,7 @@ public interface GridCacheDrManager<K, V> extends GridCacheManager<K, V> {
GridCacheOperation op,
@Nullable Object writeObj,
@Nullable byte[] valBytes,
- long ttl,
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
long drTtl,
long drExpireTime,
@Nullable GridCacheVersion drVer) throws IgniteCheckedException, GridCacheEntryRemovedException;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0f8d9ea5/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java
index 702dd33..2d76e7d 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java
@@ -72,7 +72,7 @@ public class GridOsCacheDrManager<K, V> implements GridCacheDrManager<K, V> {
GridCacheOperation op,
@Nullable Object writeObj,
@Nullable byte[] valBytes,
- long ttl,
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
long drTtl,
long drExpireTime,
@Nullable GridCacheVersion drVer) throws IgniteCheckedException, GridCacheEntryRemovedException {
[12/12] incubator-ignite git commit: # ignite-53 review
Posted by sb...@apache.org.
# ignite-53 review
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/39946d07
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/39946d07
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/39946d07
Branch: refs/heads/ignite-53
Commit: 39946d07698c1493be92192527ed10e7aa16a5c5
Parents: f5039e3
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 14 14:43:20 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 14 14:43:20 2015 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheProxy.java | 29 ++++++++++--------
.../cache/GridCacheAbstractFullApiSelfTest.java | 31 ++++++++++----------
2 files changed, 33 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39946d07/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 307bb05..7e20204 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
@@ -16,8 +16,7 @@ import org.apache.ignite.cluster.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.query.GridCacheQuery;
-import org.gridgain.grid.cache.query.GridCacheQueryFuture;
+import org.gridgain.grid.cache.query.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.gridgain.grid.util.tostring.*;
@@ -852,9 +851,15 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
}
/** {@inheritDoc} */
- @Override
- public Iterator<Cache.Entry<K, V>> iterator() {
- return new IgniteCacheIterator();
+ @Override public Iterator<Cache.Entry<K, V>> iterator() {
+ GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+ try {
+ return new IgniteCacheIterator();
+ }
+ finally {
+ gate.leave(prev);
+ }
}
/** {@inheritDoc} */
@@ -1069,16 +1074,18 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
}
/**
- * Iterator over the IgniteCacheProxy
+ * Iterator over the cache.
*/
private class IgniteCacheIterator implements Iterator<Cache.Entry<K, V>> {
-
/** Cache query future for all entries in distributed ignite cache. */
private final GridCacheQueryFuture<Map.Entry<K, V>> fut;
- /** Current element from all entries in distributed ignite cache. */
+ /** Current element. */
private Map.Entry<K, V> curIter;
+ /**
+ *
+ */
public IgniteCacheIterator() {
fut = delegate.queries().createScanQuery(null).execute();
}
@@ -1087,6 +1094,7 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
@Override public boolean hasNext() {
try {
curIter = fut.next();
+
return curIter != null;
}
catch (IgniteCheckedException e) {
@@ -1097,17 +1105,14 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
/** {@inheritDoc} */
@Override public Entry<K, V> next() {
return new Cache.Entry<K, V>() {
- /** {@inheritDoc} */
@Override public K getKey() {
return curIter.getKey();
}
- /** {@inheritDoc} */
@Override public V getValue() {
return curIter.getValue();
}
- /** {@inheritDoc} */
@Override public <T> T unwrap(Class<T> clazz) {
throw new IllegalArgumentException();
}
@@ -1117,7 +1122,7 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
/** {@inheritDoc} */
@Override public void remove() {
try {
- delegate.remove(curIter.getKey(), curIter.getValue());
+ delegate.removex(curIter.getKey());
}
catch (IgniteCheckedException e) {
throw cacheException(e);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39946d07/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index a6e02dd..e2d7ba5 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -24,7 +24,7 @@ import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.*;
import org.jetbrains.annotations.*;
-import javax.cache.Cache;
+import javax.cache.*;
import javax.cache.expiry.*;
import javax.cache.processor.*;
import java.util.*;
@@ -5247,45 +5247,46 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
*/
public void testIgniteCacheIterator() throws Exception {
IgniteCache<String, Integer> cache = jcache(0);
- for (int i = 0; i < gridCount(); ++i) {
+
+ for (int i = 0; i < 100; ++i)
cache.put(Integer.toString(i), i);
- }
- checkIteratorCacheSize(cache, gridCount());
+ checkIteratorCacheSize(cache, 100);
removeCacheIterator(cache);
- checkIteratorCacheSize(cache, gridCount() - 1);
+ checkIteratorCacheSize(cache, 100 - 1);
}
/**
* Remove one element from the cache. Throws exception if cache is empty.
*
* @param cache Cache.
- * @throws Exception
*/
- private void removeCacheIterator(IgniteCache<String, Integer> cache) throws Exception {
+ private void removeCacheIterator(IgniteCache<String, Integer> cache) {
Iterator<Cache.Entry<String, Integer>> iter = cache.iterator();
- if (iter.hasNext()) {
+
+ if (iter.hasNext())
iter.remove();
- }
- else {
- assert false;
- }
+ else
+ fail();
}
/**
* @param cache Cache.
* @param size Expected value of cache's size.
- * @throws Exception if iteration size is not equal to expected value
*/
- private void checkIteratorCacheSize(IgniteCache<String, Integer> cache, int size) throws Exception {
+ private void checkIteratorCacheSize(IgniteCache<String, Integer> cache, int size) {
Iterator<Cache.Entry<String, Integer>> iter = cache.iterator();
+
int cnt = 0;
+
while (iter.hasNext()) {
iter.next();
+
cnt++;
}
- assert cnt == size;
+
+ assertEquals(size, cnt);
}
}
[02/12] incubator-ignite git commit: ignite-45: wip
Posted by sb...@apache.org.
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-53
Commit: b03a4835cd4f6329ecab3e68e0948e579e17c99f
Parents: ef624c5
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Fri Jan 9 12:52:02 2015 +0300
Committer: Yakov Zhdanov <yz...@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} */
[04/12] incubator-ignite git commit: ignite-45: wip
Posted by sb...@apache.org.
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/5800a756
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5800a756
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5800a756
Branch: refs/heads/ignite-53
Commit: 5800a75660a534711388367ef9046afb4603d041
Parents: 5190b12
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon Jan 12 09:35:30 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon Jan 12 09:35:30 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/IgniteCacheManager.java | 107 +++++++++++++---
.../processors/cache/IgniteCacheProxy.java | 9 +-
.../ignite/tck/TCKMBeanServerBuilder.java | 124 +++++++++++++++++++
3 files changed, 217 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5800a756/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 2f0073f..376c982 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheManager.java
@@ -10,11 +10,14 @@
package org.apache.ignite;
import org.apache.ignite.configuration.*;
+import org.apache.ignite.lang.*;
import org.gridgain.grid.cache.*;
+import org.gridgain.grid.util.typedef.*;
import javax.cache.*;
import javax.cache.configuration.*;
import javax.cache.spi.*;
+import javax.management.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.atomic.*;
@@ -24,7 +27,7 @@ import java.util.concurrent.atomic.*;
*/
public class IgniteCacheManager implements CacheManager {
/** */
- private final Map<String, Ignite> igniteMap = new HashMap<>();
+ private final Map<String, IgniteBiTuple<Ignite, IgniteCacheMXBean>> igniteMap = new HashMap<>();
/** */
private final URI uri;
@@ -45,7 +48,7 @@ public class IgniteCacheManager implements CacheManager {
* @param uri Uri.
* @param cachingProvider Caching provider.
* @param clsLdr Class loader.
- * @param props
+ * @param props Properties.
*/
public IgniteCacheManager(URI uri, CachingProvider cachingProvider, ClassLoader clsLdr, Properties props) {
this.uri = uri;
@@ -102,12 +105,14 @@ public class IgniteCacheManager implements CacheManager {
}
}
- Ignite ignite;
+ IgniteCache<K, V> res;
synchronized (igniteMap) {
if (igniteMap.containsKey(cacheName))
throw new CacheException("Cache already exists [cacheName=" + cacheName + ", manager=" + uri + ']');
+ Ignite ignite;
+
if (uri.equals(cachingProvider.getDefaultURI())) {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setGridName("grid-for-" + cacheName);
@@ -126,26 +131,31 @@ public class IgniteCacheManager implements CacheManager {
else
throw new UnsupportedOperationException();
- igniteMap.put(cacheName, ignite);
+ res = ignite.jcache(cacheName);
+
+ igniteMap.put(cacheName, new T2<>(ignite, new IgniteCacheMXBean(res)));
}
- return ignite.jcache(cacheName);
+ if (((CompleteConfiguration)cacheCfg).isManagementEnabled())
+ enableManagement(cacheName, true);
+
+ return res;
}
/**
* @param cacheName Cache name.
*/
private <K, V> IgniteCache<K, V> findCache(String cacheName) {
- Ignite ignite;
+ IgniteBiTuple<Ignite, IgniteCacheMXBean> tuple;
synchronized (igniteMap) {
- ignite = igniteMap.get(cacheName);
+ tuple = igniteMap.get(cacheName);
}
- if (ignite == null)
+ if (tuple == null)
return null;
- return ignite.jcache(cacheName);
+ return tuple.get1().jcache(cacheName);
}
/** {@inheritDoc} */
@@ -202,8 +212,13 @@ public class IgniteCacheManager implements CacheManager {
*/
public boolean isManagedIgnite(Ignite ignite) {
synchronized (igniteMap) {
- return igniteMap.values().contains(ignite);
+ for (IgniteBiTuple<Ignite, IgniteCacheMXBean> tuple : igniteMap.values()) {
+ if (ignite.equals(tuple.get1()))
+ return true;
+ }
}
+
+ return false;
}
/** {@inheritDoc} */
@@ -213,19 +228,48 @@ public class IgniteCacheManager implements CacheManager {
if (cacheName == null)
throw new NullPointerException();
- Ignite ignite;
+ IgniteBiTuple<Ignite, IgniteCacheMXBean> tuple;
synchronized (igniteMap) {
- ignite = igniteMap.remove(cacheName);
+ tuple = igniteMap.remove(cacheName);
}
- if (ignite != null) {
+ if (tuple != null) {
try {
- ignite.close();
+ tuple.get1().close();
}
catch (Exception ignored) {
}
+
+ ObjectName objName = getObjectName(cacheName);
+
+ MBeanServer mBeanSrv = tuple.get1().configuration().getMBeanServer();
+
+ for (ObjectName n : mBeanSrv.queryNames(objName, null)) {
+ try {
+ mBeanSrv.unregisterMBean(n);
+ }
+ catch (Exception ignored) {
+
+ }
+ }
+ }
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ private ObjectName getObjectName(String cacheName) {
+ String mBeanName = "javax.cache:type=CacheConfiguration,CacheManager="
+ + uri.toString().replaceAll(",|:|=|\n", ".")
+ + ",Cache=" + cacheName.replaceAll(",|:|=|\n", ".");
+
+ try {
+ return new ObjectName(mBeanName);
+ }
+ catch (MalformedObjectNameException e) {
+ throw new CacheException("Failed to create MBean name: " + mBeanName, e);
}
}
@@ -236,7 +280,32 @@ public class IgniteCacheManager implements CacheManager {
if (cacheName == null)
throw new NullPointerException();
- throw new UnsupportedOperationException();
+ IgniteBiTuple<Ignite, IgniteCacheMXBean> tuple;
+
+ synchronized (igniteMap) {
+ tuple = igniteMap.get(cacheName);
+ }
+
+ ObjectName objName = getObjectName(cacheName);
+ MBeanServer mBeanSrv = tuple.get1().configuration().getMBeanServer();
+
+ try {
+ if (enabled) {
+ if(mBeanSrv.queryNames(objName, null).isEmpty())
+ mBeanSrv.registerMBean(tuple.get2(), objName);
+ }
+ else {
+ for (ObjectName n : mBeanSrv.queryNames(objName, null))
+ mBeanSrv.unregisterMBean(n);
+
+ }
+ }
+ catch (InstanceAlreadyExistsException | InstanceNotFoundException ignored) {
+
+ }
+ catch (MBeanRegistrationException | NotCompliantMBeanException e) {
+ throw new CacheException(e);
+ }
}
/** {@inheritDoc} */
@@ -260,15 +329,15 @@ public class IgniteCacheManager implements CacheManager {
/** {@inheritDoc} */
@Override public void close() {
if (closed.compareAndSet(false, true)) {
- Ignite[] ignites;
+ IgniteBiTuple<Ignite, IgniteCacheMXBean>[] ignites;
synchronized (igniteMap) {
- ignites = igniteMap.values().toArray(new Ignite[igniteMap.values().size()]);
+ ignites = igniteMap.values().toArray(new IgniteBiTuple[igniteMap.values().size()]);
}
- for (Ignite ignite : ignites) {
+ for (IgniteBiTuple<Ignite, IgniteCacheMXBean> tuple : ignites) {
try {
- ignite.close();
+ tuple.get1().close();
}
catch (Exception ignored) {
// Ignore any exceptions according to javadoc of javax.cache.CacheManager#close()
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5800a756/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 7d0bf2d..2f47697 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
@@ -747,6 +747,7 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
/** {@inheritDoc} */
@Override public CacheManager getCacheManager() {
+ // TODO IGNITE-45 (Support start/close/destroy cache correctly)
IgniteCachingProvider provider = (IgniteCachingProvider)Caching.getCachingProvider(
IgniteCachingProvider.class.getName(),
IgniteCachingProvider.class.getClassLoader());
@@ -759,14 +760,14 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
/** {@inheritDoc} */
@Override public void close() {
- // TODO IGNITE-1.
- throw new UnsupportedOperationException();
+ // TODO IGNITE-45 (Support start/close/destroy cache correctly)
+ getCacheManager().destroyCache(getName());
}
/** {@inheritDoc} */
@Override public boolean isClosed() {
- // TODO IGNITE-1.
- throw new UnsupportedOperationException();
+ // TODO IGNITE-45 (Support start/close/destroy cache correctly)
+ return getCacheManager() == null;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5800a756/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java b/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java
new file mode 100644
index 0000000..8123504
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/tck/TCKMBeanServerBuilder.java
@@ -0,0 +1,124 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.tck;
+
+import com.sun.jmx.mbeanserver.*;
+
+import javax.management.*;
+
+/**
+ *
+ */
+public class TCKMBeanServerBuilder extends MBeanServerBuilder {
+ /** {@inheritDoc} */
+ @Override public MBeanServer newMBeanServer(String dfltDomain, MBeanServer outer, MBeanServerDelegate delegate) {
+ MBeanServerDelegate decoratingDelegate = new ServerDelegate(delegate);
+ return JmxMBeanServer.newMBeanServer(dfltDomain, outer,
+ decoratingDelegate, false);
+ }
+
+ /**
+ *
+ */
+ private static class ServerDelegate extends MBeanServerDelegate {
+ /** */
+ private final MBeanServerDelegate delegate;
+
+ /**
+ * Constructor
+ *
+ * @param delegate the provided delegate
+ */
+ ServerDelegate(MBeanServerDelegate delegate) {
+ this.delegate = delegate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSpecificationName() {
+ return delegate.getSpecificationName();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getSpecificationVersion() {
+ return delegate.getSpecificationVersion();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getSpecificationVendor() {
+ return delegate.getSpecificationVendor();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getImplementationName() {
+ return delegate.getImplementationName();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getImplementationVersion() {
+ return delegate.getImplementationVersion();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getImplementationVendor() {
+ return delegate.getImplementationVendor();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public MBeanNotificationInfo[] getNotificationInfo() {
+ return delegate.getNotificationInfo();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public synchronized void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object handback) throws
+ IllegalArgumentException {
+ delegate.addNotificationListener(listener, filter, handback);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public synchronized void removeNotificationListener(NotificationListener
+ listener,
+ NotificationFilter
+ filter,
+ Object handback) throws
+ ListenerNotFoundException {
+ delegate.removeNotificationListener(listener, filter, handback);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public synchronized void removeNotificationListener(NotificationListener
+ listener) throws
+ ListenerNotFoundException {
+ delegate.removeNotificationListener(listener);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void sendNotification(Notification notification) {
+ delegate.sendNotification(notification);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public synchronized String getMBeanServerId() {
+ return System.getProperty("org.jsr107.tck.management.agentId");
+ }
+ }
+}
[11/12] incubator-ignite git commit: # Merge remote-tracking branch
'remotes/origin/ignite-1' into ignite-53
Posted by sb...@apache.org.
# Merge remote-tracking branch 'remotes/origin/ignite-1' into ignite-53
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f5039e31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f5039e31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f5039e31
Branch: refs/heads/ignite-53
Commit: f5039e3166b60e89c745c05607e9f83beb123a95
Parents: 84597ce 0f8d9ea
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 14 14:30:39 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 14 14:30:39 2015 +0300
----------------------------------------------------------------------
.../services/javax.cache.spi.CachingProvider | 1 +
.../java/org/apache/ignite/IgniteCache.java | 39 +-
.../org/apache/ignite/IgniteCacheMXBean.java | 72 ++++
.../org/apache/ignite/IgniteCacheManager.java | 372 +++++++++++++++++++
.../apache/ignite/IgniteCachingProvider.java | 189 ++++++++++
.../processors/cache/IgniteCacheProxy.java | 183 ++++++++-
.../grid/cache/GridCacheConfiguration.java | 11 +-
.../org/gridgain/grid/cache/GridCacheEntry.java | 3 +-
.../org/gridgain/grid/kernal/GridGainEx.java | 2 +-
.../processors/cache/CacheInvokeEntry.java | 3 +
.../processors/cache/GridCacheEntryImpl.java | 8 +
.../cache/GridCacheEvictionEntry.java | 8 +
.../cache/GridCacheFilterEvaluationEntry.java | 8 +
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../processors/cache/dr/GridCacheDrManager.java | 2 +-
.../cache/dr/os/GridOsCacheDrManager.java | 2 +-
.../cache/query/GridCacheQueryManager.java | 8 +
.../GridCacheContinuousQueryEntry.java | 8 +
.../grid/kernal/tck/TCKMBeanServerBuilder.java | 118 ++++++
.../cache/IgniteCachingProviderSelfTest.java | 131 +++++++
.../GridCacheLoadOnlyStoreAdapterSelfTest.java | 5 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 2 +-
.../cache/GridCacheAbstractSelfTest.java | 4 +-
.../dht/GridCacheAtomicNearCacheSelfTest.java | 1 +
.../dht/GridCacheGlobalLoadTest.java | 163 ++++++++
.../GridCachePartitionedLoadCacheSelfTest.java | 20 +-
.../cache/eviction/GridCacheMockEntry.java | 8 +
.../junits/common/GridCommonAbstractTest.java | 7 +
.../bamboo/GridDataGridTestSuite.java | 1 +
.../hadoop/jobtracker/GridHadoopJobTracker.java | 7 +-
30 files changed, 1331 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f5039e31/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index c6b4aba,f432c39..307bb05
--- 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
@@@ -12,10 -12,10 +12,12 @@@ package org.apache.ignite.internal.proc
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
+ import org.apache.ignite.cluster.*;
import org.apache.ignite.lang.*;
+ import org.apache.ignite.resources.*;
import org.gridgain.grid.cache.*;
+import org.gridgain.grid.cache.query.GridCacheQuery;
+import org.gridgain.grid.cache.query.GridCacheQueryFuture;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.gridgain.grid.util.tostring.*;
@@@ -926,59 -997,72 +999,129 @@@ public class IgniteCacheProxy<K, V> ext
}
/**
+ *
+ */
+ private static class LoadCacheClosure<K, V> implements Callable<Void>, Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private String cacheName;
+
+ /** */
+ private IgniteBiPredicate<K, V> p;
+
+ /** */
+ private Object[] args;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /**
+ * Required by {@link Externalizable}.
+ */
+ public LoadCacheClosure() {
+ // No-op.
+ }
+
+ /**
+ * @param cacheName Cache name.
+ * @param p Predicate.
+ * @param args Arguments.
+ */
+ private LoadCacheClosure(String cacheName, IgniteBiPredicate<K, V> p, Object[] args) {
+ this.cacheName = cacheName;
+ this.p = p;
+ this.args = args;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() throws Exception {
+ IgniteCache<K, V> cache = ignite.jcache(cacheName);
+
+ assert cache != null : cacheName;
+
+ cache.localLoadCache(p, args);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(p);
+
+ out.writeObject(args);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ p = (IgniteBiPredicate<K, V>)in.readObject();
+
+ args = (Object[])in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(LoadCacheClosure.class, this);
+ }
+ }
++
++ /**
+ * Iterator over the IgniteCacheProxy
+ */
+ private class IgniteCacheIterator implements Iterator<Cache.Entry<K, V>> {
+
+ /** Cache query future for all entries in distributed ignite cache. */
+ private final GridCacheQueryFuture<Map.Entry<K, V>> fut;
+
+ /** Current element from all entries in distributed ignite cache. */
+ private Map.Entry<K, V> curIter;
+
+ public IgniteCacheIterator() {
+ fut = delegate.queries().createScanQuery(null).execute();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasNext() {
+ try {
+ curIter = fut.next();
+ return curIter != null;
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Entry<K, V> next() {
+ return new Cache.Entry<K, V>() {
+ /** {@inheritDoc} */
+ @Override public K getKey() {
+ return curIter.getKey();
+ }
+
+ /** {@inheritDoc} */
+ @Override public V getValue() {
+ return curIter.getValue();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T unwrap(Class<T> clazz) {
+ throw new IllegalArgumentException();
+ }
+ };
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove() {
+ try {
+ delegate.remove(curIter.getKey(), curIter.getValue());
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f5039e31/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
[08/12] incubator-ignite git commit: # IGNITE-45 fix header.
Posted by sb...@apache.org.
# IGNITE-45 fix header.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/018a9b0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/018a9b0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/018a9b0c
Branch: refs/heads/ignite-53
Commit: 018a9b0cd154ab5aefc220294b070b3079bb0270
Parents: 22796ee
Author: sevdokimov <se...@gridgain.com>
Authored: Tue Jan 13 18:21:34 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Tue Jan 13 18:21:34 2015 +0300
----------------------------------------------------------------------
.../cache/IgniteCachingProviderSelfTest.java | 22 +++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/018a9b0c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java
index c224ec2..8786c27 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java
@@ -1,10 +1,18 @@
-/* @java.file.header */
-
-/* _________ _____ __________________ _____
- * __ ____/___________(_)______ /__ ____/______ ____(_)_______
- * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
- * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
- * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+/*
+ * 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;