# ignite-648: start with common test configuration
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/005637c4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/005637c4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/005637c4 Branch: refs/heads/ignite-648 Commit: 005637c4753b9361821593b24c8f5e34a0c56523 Parents: 4f8ac15 Author: Artem Shutak <ashu...@gridgain.com> Authored: Mon Apr 20 19:57:23 2015 +0300 Committer: Artem Shutak <ashu...@gridgain.com> Committed: Mon Apr 20 19:57:23 2015 +0300 ---------------------------------------------------------------------- ...CachePartitionedMultiJvmFullApiSelfTest.java | 23 +++--- .../cache/multijvm/IgniteExProxy.java | 9 +- .../cache/multijvm/IgniteNodeRunner.java | 86 +++++++++++++------- .../testframework/junits/GridAbstractTest.java | 15 ++-- 4 files changed, 83 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/005637c4/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 c94eccb..b9cad74 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 @@ -58,14 +58,7 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = IgniteNodeRunner.configuration(null); - - cfg.setGridName(gridName); - -// cfg.setCacheConfiguration(super.getConfiguration(gridName).getCacheConfiguration()); - cfg.setCacheConfiguration(new CacheConfiguration()); - - return cfg; // TODO: change. + return super.getConfiguration(gridName); } /** {@inheritDoc} */ @@ -85,9 +78,13 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit /** {@inheritDoc} */ protected Ignite startGrid(String gridName, GridSpringResourceContext ctx) throws Exception { - if (gridName.endsWith("0")) { + if ( + gridName.endsWith("0") +// || +// gridName.endsWith("1") + ) { locIgnite = super.startGrid(gridName, ctx); - + return locIgnite; } @@ -109,7 +106,11 @@ public class GridCachePartitionedMultiJvmFullApiSelfTest extends GridCachePartit /** {@inheritDoc} */ @Override protected IgniteEx grid(int idx) { - if (idx == 0) + if ( + idx == 0 +// || +// idx == 1 + ) return super.grid(idx); String name = getTestGridName(idx); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/005637c4/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 index d6e2478..65e17d9 100644 --- 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 @@ -98,19 +98,20 @@ public class IgniteExProxy implements IgniteEx { return cfg; } - @Override public <K extends GridCacheUtilityKey, V> GridCacheProjectionEx<K, V> utilityCache() { + @Override public <K extends GridCacheUtilityKey, V> IgniteInternalCache<K, V> utilityCache() { return null; // TODO: CODE: implement. } - @Nullable @Override public <K, V> GridCache<K, V> cachex(@Nullable String name) { + @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex(@Nullable String name) { return null; // TODO: CODE: implement. } - @Nullable @Override public <K, V> GridCache<K, V> cachex() { + @Nullable @Override public <K, V> IgniteInternalCache<K, V> cachex() { return null; // TODO: CODE: implement. } - @Override public Collection<GridCache<?, ?>> cachesx(@Nullable IgnitePredicate<? super GridCache<?, ?>>... p) { + @Override public Collection<IgniteInternalCache<?, ?>> cachesx( + @Nullable IgnitePredicate<? super IgniteInternalCache<?, ?>>... p) { return null; // TODO: CODE: implement. } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/005637c4/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 0914d70..7f40a00 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 @@ -22,10 +22,9 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.marshaller.optimized.*; -import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*; +import org.apache.ignite.testframework.junits.*; import java.io.*; import java.util.*; @@ -39,9 +38,11 @@ public class IgniteNodeRunner { setAddresses(Collections.singleton("127.0.0.1:47500..47509")); }}; +// private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + public static final char DELIM = ' '; - public static final String CACHE_CONFIGURATION_TMP_FILE = "/tmp/cacheConfiguration.tmp"; +// public static final String CACHE_CONFIGURATION_TMP_FILE = "/tmp/cacheConfiguration.tmp"; public static void main(String[] args) throws Exception { try { @@ -51,8 +52,6 @@ public class IgniteNodeRunner { IgniteConfiguration cfg = configuration(args); - cfg.setCacheConfiguration(cacheConfiguration()); - Ignite ignite = Ignition.start(cfg); } catch (Throwable e) { @@ -66,44 +65,71 @@ public class IgniteNodeRunner { return id.toString() + DELIM + cfg.getGridName(); } - public static IgniteConfiguration configuration(String[] args) throws Exception { - IgniteConfiguration cfg = new IgniteConfiguration(); - - cfg.setLocalHost("127.0.0.1"); - - cfg.setNodeId((args != null && args.length >= 1) ? UUID.fromString(args[0]) : null); - //------- - TcpDiscoverySpi disco = new TcpDiscoverySpi(); + private static IgniteConfiguration configuration(String[] args) throws Exception { + // Pars args. + assert args != null && args.length >= 1; - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - - cfg.setMarshaller(new OptimizedMarshaller(false)); + final UUID nodeId = UUID.fromString(args[0]); + final String gridName = "Node " + nodeId; + + IgniteConfiguration cfg = GridAbstractTest.getConfiguration0(gridName, new IgniteTestResources(), + GridCachePartitionedMultiJvmFullApiSelfTest.class, isDebug()); +//// --------------- +// TcpDiscoverySpi disco = new TcpDiscoverySpi(); +// +// disco.setMaxMissedHeartbeats(Integer.MAX_VALUE); +// +// disco.setIpFinder(ipFinder); +// +//// if (isDebug()) +//// disco.setAckTimeout(Integer.MAX_VALUE); +// +// cfg.setDiscoverySpi(disco); +// +// // TODO +//// cfg.setCacheConfiguration(cacheConfiguration()); +// +// cfg.setMarshaller(new OptimizedMarshaller(false)); +//// ---------------- +//// if (offHeapValues()) +//// cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi()); +//// ---------------- +// cfg.getTransactionConfiguration().setTxSerializableEnabled(true); +// +//// --------------- +//// Special. +// cfg.setLocalHost("127.0.0.1"); +// +// cfg.setNodeId(nodeId); return cfg; } + private static boolean isDebug() { + return false; + } + public static void storeToFile(CacheConfiguration cc) throws IOException { // TODO use actual config. cc = new CacheConfiguration(); - File ccfgTmpFile = new File(CACHE_CONFIGURATION_TMP_FILE); - - ccfgTmpFile.createNewFile(); +// File ccfgTmpFile = new File(CACHE_CONFIGURATION_TMP_FILE); +// +// ccfgTmpFile.createNewFile(); // if (!ccfgTmpFile.createNewFile()) // throw new IgniteSpiException("File was not created."); - try(ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(ccfgTmpFile))) { - out.writeObject(cc); - } +// try(ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(ccfgTmpFile))) { +// out.writeObject(cc); +// } } - public static CacheConfiguration cacheConfiguration() throws Exception { - File ccfgTmpFile = new File(CACHE_CONFIGURATION_TMP_FILE); - - try(ObjectInputStream in = new ObjectInputStream(new FileInputStream(ccfgTmpFile))) { - return (CacheConfiguration)in.readObject(); - } + private static CacheConfiguration cacheConfiguration() throws Exception { +// File ccfgTmpFile = new File(CACHE_CONFIGURATION_TMP_FILE); +// +// try(ObjectInputStream in = new ObjectInputStream(new FileInputStream(ccfgTmpFile))) { +// return (CacheConfiguration)in.readObject(); +// } + return new CacheConfiguration(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/005637c4/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 6be9953..7af45bf 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 @@ -1042,7 +1042,7 @@ public abstract class GridAbstractTest extends TestCase { * @return Path for specific marshaller. */ @SuppressWarnings({"IfMayBeConditional", "deprecation"}) - protected String getDefaultCheckpointPath(Marshaller marshaller) { + private static String getDefaultCheckpointPath(Marshaller marshaller) { if (marshaller instanceof JdkMarshaller) return SharedFsCheckpointSpi.DFLT_DIR_PATH + "/jdk/"; else @@ -1074,6 +1074,11 @@ public abstract class GridAbstractTest extends TestCase { */ @SuppressWarnings("deprecation") 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(); cfg.setGridName(gridName); @@ -1089,14 +1094,14 @@ public abstract class GridAbstractTest extends TestCase { TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); - commSpi.setLocalPort(GridTestUtils.getNextCommPort(getClass())); + commSpi.setLocalPort(GridTestUtils.getNextCommPort(cls)); commSpi.setTcpNoDelay(true); cfg.setCommunicationSpi(commSpi); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - if (isDebug()) { + if (isDebug) { discoSpi.setMaxMissedHeartbeats(Integer.MAX_VALUE); cfg.setNetworkTimeout(Long.MAX_VALUE); } @@ -1111,13 +1116,13 @@ public abstract class GridAbstractTest extends TestCase { // Set heartbeat interval to 1 second to speed up tests. discoSpi.setHeartbeatFrequency(1000); - String mcastAddr = GridTestUtils.getNextMulticastGroup(getClass()); + String mcastAddr = GridTestUtils.getNextMulticastGroup(cls); if (!F.isEmpty(mcastAddr)) { TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder(); ipFinder.setMulticastGroup(mcastAddr); - ipFinder.setMulticastPort(GridTestUtils.getNextMulticastPort(getClass())); + ipFinder.setMulticastPort(GridTestUtils.getNextMulticastPort(cls)); discoSpi.setIpFinder(ipFinder); }