Repository: incubator-ignite Updated Branches: refs/heads/ignite-648 3b72253d8 -> d5fe1f75d
ignite-648: log, implementation Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/36d9487f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/36d9487f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/36d9487f Branch: refs/heads/ignite-648 Commit: 36d9487f51301b137d880a09ddbbeed8dc824836 Parents: 3b72253 Author: Artem Shutak <ashu...@gridgain.com> Authored: Mon Apr 27 18:21:05 2015 +0300 Committer: Artem Shutak <ashu...@gridgain.com> Committed: Mon Apr 27 18:21:05 2015 +0300 ---------------------------------------------------------------------- .../cache/GridCacheAbstractFullApiSelfTest.java | 6 +- .../cache/GridCacheAbstractSelfTest.java | 1 + .../processors/cache/multijvm/CacheProxy.java | 375 ----------------- ...CachePartitionedMultiJvmFullApiSelfTest.java | 84 +++- .../cache/multijvm/IgniteCacheProcessProxy.java | 382 +++++++++++++++++ .../cache/multijvm/IgniteExProcessProxy.java | 413 +++++++++++++++++++ .../cache/multijvm/IgniteExProxy.java | 412 ------------------ .../cache/multijvm/IgniteNodeRunner.java | 23 +- .../testframework/junits/GridAbstractTest.java | 2 +- 9 files changed, 876 insertions(+), 822 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 455fcdb..7587951 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -160,10 +160,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (Map.Entry<String, CacheConfiguration[]> entry : cacheCfgMap.entrySet()) { Ignite ignite; - + if (isMultiJvm()) - ignite = IgniteExProxy.grid(entry.getKey()); - else + ignite = IgniteExProcessProxy.grid(entry.getKey()); + else ignite = IgnitionEx.grid(entry.getKey()); for (CacheConfiguration cfg : entry.getValue()) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java index 342eb5a..d491be5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java @@ -535,6 +535,7 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { * Serializable factory. */ private static class TestStoreFactory implements Factory<CacheStore> { + /** {@inheritDoc} */ @Override public CacheStore create() { return cacheStore(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/CacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/CacheProxy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/CacheProxy.java deleted file mode 100644 index 6ff1c83..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/CacheProxy.java +++ /dev/null @@ -1,375 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.internal.processors.cache.multijvm; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.cache.query.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.internal.util.lang.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.mxbean.*; -import org.jetbrains.annotations.*; - -import javax.cache.*; -import javax.cache.CacheManager; -import javax.cache.configuration.*; -import javax.cache.expiry.*; -import javax.cache.integration.*; -import javax.cache.processor.*; -import java.util.*; -import java.util.concurrent.locks.*; - -/** - * TODO: Add class description. - * - * @author @java.author - * @version @java.version - */ -public class CacheProxy<K, V> implements IgniteCache<K, V> { - /** Proxy. */ - private final transient IgniteExProxy proxy; - - /** Compute. */ - private final transient IgniteCompute compute; - - /** Cache name. */ - private final String cacheName; - - /** Grid id. */ - private final UUID gridId; - - /** - * @param name Name. - * @param proxy Ignite Process Proxy. - */ - public CacheProxy(String name, IgniteExProxy proxy) { - this.proxy = proxy; - cacheName = name; - gridId = proxy.getId(); - - ClusterGroup grp = proxy.localJvmGrid().cluster().forNodeId(proxy.getId()); - - compute = proxy.localJvmGrid().compute(grp); - } - - /** {@inheritDoc} */ - @Override public IgniteCache<K, V> withAsync() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean isAsync() { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <R> IgniteFuture<R> future() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Entry<K, V> randomEntry() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteCache<K, V> withSkipStore() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public V getAndPutIfAbsent(K key, V val) throws CacheException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Lock lock(K key) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Lock lockAll(Collection<? extends K> keys) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean isLocalLocked(K key, boolean byCurrThread) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <R> QueryCursor<R> query(Query<R> qry) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public QueryMetrics queryMetrics() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void localEvict(Collection<? extends K> keys) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public V localPeek(K key, CachePeekMode... peekModes) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void localPromote(Set<? extends K> keys) throws CacheException { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public int size(CachePeekMode... peekModes) throws CacheException { - return 0; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public int localSize(CachePeekMode... peekModes) { - return 0; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map, - Object... args) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public V get(K key) { - return compute.broadcast(new IgniteClosureX<K, V>() { - @Override public V applyx(K k) { - return (V)Ignition.ignite(gridId).cache(cacheName).get(k); - } - }, key).iterator().next(); - } - - /** {@inheritDoc} */ - @Override public Map<K, V> getAll(Set<? extends K> keys) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean containsKey(K key) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionListener) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean containsKeys(Set<? extends K> keys) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void put(K key, V val) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public V getAndPut(K key, V val) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void putAll(Map<? extends K, ? extends V> map) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean putIfAbsent(K key, V val) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean remove(K key) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean remove(K key, V oldVal) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public V getAndRemove(K key) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean replace(K key, V oldVal, V newVal) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean replace(K key, V val) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public V getAndReplace(K key, V val) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void removeAll(final Set<? extends K> keys) { - compute.broadcast(new IgniteClosureX<Set<?>, Void>() { - @Override public Void applyx(Set<?> ks) { - Ignition.ignite(gridId).cache(cacheName).removeAll(ks); - - return null; - } - }, keys); - } - - /** {@inheritDoc} */ - @Override public void removeAll() { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void clear() { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void clear(K key) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void clearAll(Set<? extends K> keys) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void localClear(K key) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void localClearAll(Set<? extends K> keys) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... arguments) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, EntryProcessor<K, V, T> entryProcessor, - Object... args) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public String getName() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public CacheManager getCacheManager() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void close() { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean isClosed() { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> T unwrap(Class<T> clazz) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Iterator<Entry<K, V>> iterator() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, - CacheEntryProcessor<K, V, T> entryProcessor, Object... args) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteFuture<?> rebalance() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public CacheMetrics metrics() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public CacheMetrics metrics(ClusterGroup grp) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public CacheMetricsMXBean mxBean() { - return null; // TODO: CODE: implement. - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java index c5e7c11..7cb4c08 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCachePartitionedMultiJvmFullApiSelfTest.java @@ -23,6 +23,7 @@ import org.apache.ignite.events.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; import org.apache.ignite.internal.processors.resource.*; +import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -38,7 +39,7 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit /** */ private CountDownLatch allNodesJoinLatch; - + /** */ private final IgnitePredicate<Event> nodeJoinLsnr = new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { @@ -47,14 +48,14 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit return true; } }; - + /** Proces name to process map. */ - private final Map<String, IgniteExProxy> ignites = new HashMap<>(); + private final Map<String, IgniteExProcessProxy> ignites = new HashMap<>(); /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { allNodesJoinLatch = new CountDownLatch(gridCount() - 1); - + super.beforeTestsStarted(); assert allNodesJoinLatch.await(5, TimeUnit.SECONDS); @@ -62,24 +63,27 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { - for (IgniteExProxy ignite : ignites.values()) + for (IgniteExProcessProxy ignite : ignites.values()) ignite.getProcess().kill(); ignites.clear(); - + locIgnite = null; super.afterTestsStopped(); } + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); // TODO: CODE: implement. } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { - for (IgniteExProxy ignite : ignites.values()) + // TODO: remove processes killing from here. + for (IgniteExProcessProxy ignite : ignites.values()) ignite.getProcess().kill(); - + super.afterTest(); // TODO: CODE: implement. } @@ -90,9 +94,9 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IgniteNodeRunner.ipFinder); Map<IgnitePredicate<? extends Event>, int[]> lsnrs = new HashMap<>(); - + lsnrs.put(nodeJoinLsnr, new int[] {EventType.EVT_NODE_JOINED}); - + cfg.setLocalEventListeners(lsnrs); return cfg; @@ -126,7 +130,7 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit try { IgniteConfiguration cfg = optimize(getConfiguration(gridName)); - IgniteExProxy proxy = new IgniteExProxy(cfg, log, grid(0)); + IgniteExProcessProxy proxy = new IgniteExProcessProxy(cfg, log, grid(0)); ignites.put(gridName, proxy); @@ -164,25 +168,65 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit for (int i = 0; i < size; i++) putMap.put(i, i * i); - IgniteEx grid0 = grid(0); - - IgniteCache<Object, Object> c0 = grid0.cache(null); - - IgniteEx grid1 = grid(1); - - IgniteCache<Object, Object> c1 = grid1.cache(null); + IgniteCache<Object, Object> c0 = grid(0).cache(null); + IgniteCache<Object, Object> c1 = grid(1).cache(null); c0.putAll(putMap); atomicClockModeDelay(c0); c1.removeAll(putMap.keySet()); - - Thread.sleep(5_000); for (int i = 0; i < size; i++) { assertNull(c0.get(i)); assertNull(c1.get(i)); } } + + /** + * @throws Exception If failed. + */ + public void testPutRemove() throws Exception { + IgniteCache<Object, Object> c0 = grid(0).cache(null); + IgniteCache<Object, Object> c1 = grid(1).cache(null); + + final int key = 1; + final int val = 3; + + c0.put(key, val); + + assertEquals(val, c0.get(key)); + assertEquals(val, c1.get(key)); + + assertTrue(c1.remove(key)); + + U.sleep(1_000); + + assertTrue(c0.get(key) == null || c1.get(key) == null); + assertNull(c1.get(key)); + assertNull(c0.get(key)); + } + + /** + * @throws Exception If failed. + */ + public void testPutRemove2() throws Exception { + IgniteCache<Object, Object> c0 = grid(0).cache(null); + IgniteCache<Object, Object> c1 = grid(1).cache(null); + + final int key = 1; + final int val = 3; + + c1.put(key, val); + + assertEquals(val, c1.get(key)); + assertEquals(val, c0.get(key)); + + assertTrue(c1.remove(key)); + + U.sleep(1_000); + + assertNull(c1.get(key)); + assertNull(c0.get(key)); + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteCacheProcessProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteCacheProcessProxy.java new file mode 100644 index 0000000..ea03f5d --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteCacheProcessProxy.java @@ -0,0 +1,382 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.internal.processors.cache.multijvm; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cache.query.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.lang.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.mxbean.*; +import org.jetbrains.annotations.*; + +import javax.cache.*; +import javax.cache.CacheManager; +import javax.cache.configuration.*; +import javax.cache.expiry.*; +import javax.cache.integration.*; +import javax.cache.processor.*; +import java.util.*; +import java.util.concurrent.locks.*; + +/** + * TODO: Add class description. + * + * @author @java.author + * @version @java.version + */ +public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> { + /** Compute. */ + private final transient IgniteCompute compute; + + /** Cache name. */ + private final String cacheName; + + /** Grid id. */ + private final UUID gridId; + + /** + * @param name Name. + * @param proxy Ignite Process Proxy. + */ + public IgniteCacheProcessProxy(String name, IgniteExProcessProxy proxy) { + cacheName = name; + gridId = proxy.getId(); + + ClusterGroup grp = proxy.localJvmGrid().cluster().forNodeId(proxy.getId()); + + compute = proxy.localJvmGrid().compute(grp); + } + + /** {@inheritDoc} */ + @Override public IgniteCache<K, V> withAsync() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean isAsync() { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <R> IgniteFuture<R> future() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Entry<K, V> randomEntry() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteCache<K, V> withSkipStore() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public V getAndPutIfAbsent(K key, V val) throws CacheException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Lock lock(K key) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Lock lockAll(Collection<? extends K> keys) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean isLocalLocked(K key, boolean byCurrThread) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <R> QueryCursor<R> query(Query<R> qry) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public QueryMetrics queryMetrics() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void localEvict(Collection<? extends K> keys) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public V localPeek(K key, CachePeekMode... peekModes) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void localPromote(Set<? extends K> keys) throws CacheException { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public int size(CachePeekMode... peekModes) throws CacheException { + return 0; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public int localSize(CachePeekMode... peekModes) { + return 0; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map, + Object... args) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public V get(K key) { + return F.first(compute.broadcast(new IgniteClosureX<K, V>() { + @Override public V applyx(K k) { + return (V)Ignition.ignite(gridId).cache(cacheName).get(k); + } + }, key)); + } + + /** {@inheritDoc} */ + @Override public Map<K, V> getAll(Set<? extends K> keys) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean containsKey(K key) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionListener) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean containsKeys(Set<? extends K> keys) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void put(K key, V val) { + compute.broadcast(new IgniteClosureX<List<?>, Object>() { + @Override public Object applyx(List<?> l) { + Ignition.ignite(gridId).cache(cacheName).put(l.get(0), l.get(1)); + + return null; + } + }, Arrays.asList(key, val)); + } + + /** {@inheritDoc} */ + @Override public V getAndPut(K key, V val) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void putAll(Map<? extends K, ? extends V> map) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean putIfAbsent(K key, V val) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean remove(K key) { + return F.first(compute.broadcast(new IgniteClosureX<K, Boolean>() { + @Override public Boolean applyx(K k) { + return Ignition.ignite(gridId).cache(cacheName).remove(k); + } + }, key)); + } + + /** {@inheritDoc} */ + @Override public boolean remove(K key, V oldVal) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public V getAndRemove(K key) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean replace(K key, V oldVal, V newVal) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean replace(K key, V val) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public V getAndReplace(K key, V val) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void removeAll(final Set<? extends K> keys) { + compute.broadcast(new IgniteClosureX<Set<?>, Void>() { + @Override public Void applyx(Set<?> ks) { + Ignition.ignite(gridId).cache(cacheName).removeAll(ks); + + return null; + } + }, keys); + } + + /** {@inheritDoc} */ + @Override public void removeAll() { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void clear() { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void clear(K key) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void clearAll(Set<? extends K> keys) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void localClear(K key) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void localClearAll(Set<? extends K> keys) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... arguments) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, EntryProcessor<K, V, T> entryProcessor, + Object... args) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public String getName() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public CacheManager getCacheManager() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void close() { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean isClosed() { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> T unwrap(Class<T> clazz) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Iterator<Entry<K, V>> iterator() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, + CacheEntryProcessor<K, V, T> entryProcessor, Object... args) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteFuture<?> rebalance() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public CacheMetrics metrics() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public CacheMetrics metrics(ClusterGroup grp) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public CacheMetricsMXBean mxBean() { + return null; // TODO: CODE: implement. + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProcessProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProcessProxy.java new file mode 100644 index 0000000..f7c8a4c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProcessProxy.java @@ -0,0 +1,413 @@ +/* + * 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.multijvm; + +import org.apache.ignite.*; +import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.cluster.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.hadoop.*; +import org.apache.ignite.internal.util.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.*; +import org.jetbrains.annotations.*; + +import java.util.*; +import java.util.concurrent.*; + +/** + * Ignite proxy for ignite instance at another JVM. + */ +public class IgniteExProcessProxy implements IgniteEx { + /** Grid proxies. */ + private static final Map<String, IgniteExProcessProxy> gridProxies = new HashMap<>(); + + /** Jvm process with ignite instance. */ + private final GridJavaProcess proc; + + /** Configuration. */ + private final IgniteConfiguration cfg; + + /** Local jvm grid. */ + private final Ignite locJvmGrid; + + /** Logger. */ + private final IgniteLogger log; + + /** Grid id. */ + private final UUID id = UUID.randomUUID(); + + /** + * @param cfg Configuration. + * @param log Logger. + * @param locJvmGrid Local jvm grid. + */ + public IgniteExProcessProxy(final IgniteConfiguration cfg, final IgniteLogger log, final Ignite locJvmGrid) throws Exception { + this.cfg = cfg; + this.locJvmGrid = locJvmGrid; + this.log = log.getLogger("jvm-" + id); + + IgniteNodeRunner.storeToFile(cfg.getCacheConfiguration()[0]); + + List<String> jvmArgs = U.jvmArgs(); + + List<String> filteredJvmArgs = new ArrayList<>(); + + for (String arg : jvmArgs) { + if(!arg.toLowerCase().startsWith("-agentlib")) + filteredJvmArgs.add(arg); + } + + proc = GridJavaProcess.exec( + IgniteNodeRunner.class, + IgniteNodeRunner.asParams(id, cfg), // Params. + this.log, + // Optional closure to be called each time wrapped process prints line to system.out or system.err. + new IgniteInClosure<String>() { + @Override public void apply(String s) { + IgniteExProcessProxy.this.log.info(s); + } + }, + null, + filteredJvmArgs, // JVM Args. + System.getProperty("surefire.test.class.path") + ); + + // TODO: delete sleep. + U.sleep(3_000); + + gridProxies.put(cfg.getGridName(), this); + } + + /** + * @return Local JVM grid instance. + */ + public Ignite localJvmGrid() { + return locJvmGrid; + } + + /** + * @return Grid id. + */ + public UUID getId() { + return id; + } + + /** {@inheritDoc} */ + @Override public String name() { + return cfg.getGridName(); + } + + /** {@inheritDoc} */ + @Override public IgniteLogger log() { + return log; + } + + /** {@inheritDoc} */ + @Override public IgniteConfiguration configuration() { + return cfg; + } + + /** {@inheritDoc} */ + @Override public <K extends GridCacheUtilityKey, V> IgniteInternalCache<K, V> utilityCache() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex(@Nullable String name) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Collection<IgniteInternalCache<?, ?>> cachesx( + @Nullable IgnitePredicate<? super IgniteInternalCache<?, ?>>... p) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean eventUserRecordable(int type) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean allEventsUserRecordable(int[] types) { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean isJmxRemoteEnabled() { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public boolean isRestartEnabled() { + return false; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Nullable @Override public IgniteFileSystem igfsx(@Nullable String name) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Hadoop hadoop() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteClusterEx cluster() { + return (IgniteClusterEx)locJvmGrid.cluster(); + } + + /** {@inheritDoc} */ + @Nullable @Override public String latestVersion() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public ClusterNode localNode() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public GridKernalContext context() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteCompute compute() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteCompute compute(ClusterGroup grp) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteMessaging message() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteMessaging message(ClusterGroup grp) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteEvents events() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteEvents events(ClusterGroup grp) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteServices services() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteServices services(ClusterGroup grp) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public ExecutorService executorService() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public ExecutorService executorService(ClusterGroup grp) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteProductVersion version() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteScheduler scheduler() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> createCache(String cacheName) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String cacheName) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> void addCacheConfiguration(CacheConfiguration<K, V> cacheCfg) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg, + NearCacheConfiguration<K, V> nearCfg) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg, + NearCacheConfiguration<K, V> nearCfg) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName, NearCacheConfiguration<K, V> nearCfg) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable String cacheName, + NearCacheConfiguration<K, V> nearCfg) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void destroyCache(String cacheName) { + // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteCache<K, V> cache(@Nullable final String name) { + return new IgniteCacheProcessProxy(name, this); + } + + /** {@inheritDoc} */ + @Override public IgniteTransactions transactions() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <K, V> IgniteDataStreamer<K, V> dataStreamer(@Nullable String cacheName) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteFileSystem fileSystem(String name) { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public Collection<IgniteFileSystem> fileSystems() { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) throws IgniteException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteAtomicLong atomicLong(String name, long initVal, boolean create) throws IgniteException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, + boolean create) throws IgniteException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp, + boolean create) throws IgniteException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, + boolean create) throws IgniteException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> IgniteQueue<T> queue(String name, int cap, + @Nullable CollectionConfiguration cfg) throws IgniteException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T> IgniteSet<T> set(String name, @Nullable CollectionConfiguration cfg) throws IgniteException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException { + return null; // TODO: CODE: implement. + } + + /** {@inheritDoc} */ + @Override public void close() throws IgniteException { + try { + getProcess().kill(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** {@inheritDoc} */ + @Override public <K> Affinity<K> affinity(String cacheName) { + return null; // TODO: CODE: implement. + } + + public GridJavaProcess getProcess() { + return proc; + } + + public static Ignite grid(@Nullable String name) { +// IgniteNamedInstance grid = name != null ? grids.get(name) : dfltGrid; + + Ignite res = gridProxies.get(name); + + if (res == null) + throw new IgniteIllegalStateException("Grid instance was not properly started " + + "or was already stopped: " + name); + + return res; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java deleted file mode 100644 index 4f95708..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteExProxy.java +++ /dev/null @@ -1,412 +0,0 @@ -/* - * 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.multijvm; - -import org.apache.ignite.*; -import org.apache.ignite.cache.affinity.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.cluster.*; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.hadoop.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.plugin.*; -import org.jetbrains.annotations.*; - -import java.util.*; -import java.util.concurrent.*; - -/** - * Ignite proxy for ignite instance at another JVM. - */ -public class IgniteExProxy implements IgniteEx { - /** Grid proxies. */ - private static final Map<String, IgniteExProxy> gridProxies = new HashMap<>(); - - /** Jvm process with ignite instance. */ - private final GridJavaProcess proc; - - /** Configuration. */ - private final IgniteConfiguration cfg; - - /** Local jvm grid. */ - private final Ignite locJvmGrid; - - /** Logger. */ - private final IgniteLogger log; - - /** Grid id. */ - private final UUID id = UUID.randomUUID(); - - /** - * @param cfg Configuration. - * @param log Logger. - * @param locJvmGrid Local jvm grid. - */ - public IgniteExProxy(final IgniteConfiguration cfg, final IgniteLogger log, final Ignite locJvmGrid) throws Exception { - this.cfg = cfg; - this.locJvmGrid = locJvmGrid; - this.log = log; - - IgniteNodeRunner.storeToFile(cfg.getCacheConfiguration()[0]); - - List<String> jvmArgs = U.jvmArgs(); - - List<String> filteredJvmArgs = new ArrayList<>(); - - for (String arg : jvmArgs) { - if(!arg.toLowerCase().startsWith("-agentlib")) - filteredJvmArgs.add(arg); - } - - proc = GridJavaProcess.exec( - IgniteNodeRunner.class, - IgniteNodeRunner.asParams(id, cfg), // Params. - log, - // Optional closure to be called each time wrapped process prints line to system.out or system.err. - new IgniteInClosure<String>() { - @Override public void apply(String s) { - log.info("[" + cfg.getGridName() + "] " + s); - } - }, - null, - filteredJvmArgs, // JVM Args. - System.getProperty("surefire.test.class.path") - ); - - Thread.sleep(3_000); - - gridProxies.put(cfg.getGridName(), this); - } - - /** - * @return Local JVM grid instance. - */ - public Ignite localJvmGrid() { - return locJvmGrid; - } - - /** - * @return Grid id. - */ - public UUID getId() { - return id; - } - - /** {@inheritDoc} */ - @Override public String name() { - return cfg.getGridName(); - } - - /** {@inheritDoc} */ - @Override public IgniteLogger log() { - return log; - } - - /** {@inheritDoc} */ - @Override public IgniteConfiguration configuration() { - return cfg; - } - - /** {@inheritDoc} */ - @Override public <K extends GridCacheUtilityKey, V> IgniteInternalCache<K, V> utilityCache() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex(@Nullable String name) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Collection<IgniteInternalCache<?, ?>> cachesx( - @Nullable IgnitePredicate<? super IgniteInternalCache<?, ?>>... p) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean eventUserRecordable(int type) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean allEventsUserRecordable(int[] types) { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean isJmxRemoteEnabled() { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public boolean isRestartEnabled() { - return false; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Nullable @Override public IgniteFileSystem igfsx(@Nullable String name) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Hadoop hadoop() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteClusterEx cluster() { - return (IgniteClusterEx)locJvmGrid.cluster(); - } - - /** {@inheritDoc} */ - @Nullable @Override public String latestVersion() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public ClusterNode localNode() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public GridKernalContext context() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteCompute compute() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteCompute compute(ClusterGroup grp) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteMessaging message() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteMessaging message(ClusterGroup grp) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteEvents events() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteEvents events(ClusterGroup grp) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteServices services() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteServices services(ClusterGroup grp) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public ExecutorService executorService() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public ExecutorService executorService(ClusterGroup grp) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteProductVersion version() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteScheduler scheduler() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> createCache(String cacheName) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String cacheName) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> void addCacheConfiguration(CacheConfiguration<K, V> cacheCfg) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg, - NearCacheConfiguration<K, V> nearCfg) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg, - NearCacheConfiguration<K, V> nearCfg) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName, NearCacheConfiguration<K, V> nearCfg) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable String cacheName, - NearCacheConfiguration<K, V> nearCfg) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void destroyCache(String cacheName) { - // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteCache<K, V> cache(@Nullable final String name) { - return new CacheProxy(name, this); - } - - /** {@inheritDoc} */ - @Override public IgniteTransactions transactions() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <K, V> IgniteDataStreamer<K, V> dataStreamer(@Nullable String cacheName) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteFileSystem fileSystem(String name) { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public Collection<IgniteFileSystem> fileSystems() { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) throws IgniteException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteAtomicLong atomicLong(String name, long initVal, boolean create) throws IgniteException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, - boolean create) throws IgniteException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp, - boolean create) throws IgniteException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, - boolean create) throws IgniteException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> IgniteQueue<T> queue(String name, int cap, - @Nullable CollectionConfiguration cfg) throws IgniteException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T> IgniteSet<T> set(String name, @Nullable CollectionConfiguration cfg) throws IgniteException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException { - return null; // TODO: CODE: implement. - } - - /** {@inheritDoc} */ - @Override public void close() throws IgniteException { - try { - getProcess().kill(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - /** {@inheritDoc} */ - @Override public <K> Affinity<K> affinity(String cacheName) { - return null; // TODO: CODE: implement. - } - - public GridJavaProcess getProcess() { - return proc; - } - - public static Ignite grid(@Nullable String name) { -// IgniteNamedInstance grid = name != null ? grids.get(name) : dfltGrid; - - Ignite res = gridProxies.get(name); - - if (res == null) - throw new IgniteIllegalStateException("Grid instance was not properly started " + - "or was already stopped: " + name); - - return res; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java index 16af81d..32f33dc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/IgniteNodeRunner.java @@ -32,19 +32,19 @@ import java.io.*; import java.util.*; /** - * Run ignite node. + * Run ignite node. */ public class IgniteNodeRunner { /** VM ip finder for TCP discovery. */ public static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder(); - + /** */ - private static final String CACHE_CONFIGURATION_TMP_FILE = System.getProperty("java.io.tmpdir") + + private static final String CACHE_CONFIGURATION_TMP_FILE = System.getProperty("java.io.tmpdir") + File.separator + "cacheConfiguration.tmp"; /** * Starts {@link Ignite} instance accorging to given arguments. - * + * * @param args Arguments. * @throws Exception If failed. */ @@ -60,12 +60,12 @@ public class IgniteNodeRunner { } catch (Throwable e) { e.printStackTrace(); - + System.exit(1); } } - /** + /** * @param id Grid id. * @param cfg Configuration. * @return Given paramethers as command line string arguments. @@ -74,7 +74,7 @@ public class IgniteNodeRunner { return id.toString() + ' ' + cfg.getGridName(); } - /** + /** * @param args Command line args. * @return Ignite configuration. * @throws Exception If failed. @@ -85,11 +85,11 @@ public class IgniteNodeRunner { final UUID nodeId = UUID.fromString(args[0]); final String gridName = args[1]; - + // Configuration. IgniteConfiguration cfg = GridAbstractTest.getConfiguration0(gridName, new IgniteTestResources(), GridCachePartitionedMultiJvmFullApiSelfTest.class, false); - + TcpDiscoverySpi disco = new TcpDiscoverySpi(); // disco.setMaxMissedHeartbeats(Integer.MAX_VALUE); @@ -101,7 +101,7 @@ public class IgniteNodeRunner { cfg.setDiscoverySpi(disco); -// cfg.setCacheConfiguration(cacheConfiguration()); + cfg.setCacheConfiguration(cacheConfiguration()); cfg.setMarshaller(new OptimizedMarshaller(false)); //// ---------------- @@ -130,6 +130,7 @@ public class IgniteNodeRunner { public static void storeToFile(CacheConfiguration cc) throws IOException { File ccfgTmpFile = new File(CACHE_CONFIGURATION_TMP_FILE); + // TODO: add file created check (and delete the file after tests). boolean created = ccfgTmpFile.createNewFile(); try(ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(ccfgTmpFile))) { @@ -139,7 +140,7 @@ public class IgniteNodeRunner { /** * Reads cache configuration from the file. - * + * * @return Cache configuration. * @throws Exception If exception. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36d9487f/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index ed8ddac..ca24226 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -1091,7 +1091,7 @@ public abstract class GridAbstractTest extends TestCase { protected IgniteConfiguration getConfiguration(String gridName, IgniteTestResources rsrcs) throws Exception { return getConfiguration0(gridName, rsrcs, getClass(), isDebug()); } - + public static IgniteConfiguration getConfiguration0(String gridName, IgniteTestResources rsrcs, Class<? extends GridAbstractTest> cls, boolean isDebug) throws Exception { IgniteConfiguration cfg = new IgniteConfiguration();