/** @throws Exception If failed. */ public void testStartMultipleInstanceSpi() throws Exception { IgniteConfiguration cfg1 = getConfiguration(); IgniteConfiguration cfg2 = getConfiguration(); IgniteConfiguration cfg3 = getConfiguration(); cfg1.setCollisionSpi(new TestMultipleInstancesCollisionSpi()); cfg2.setCollisionSpi(new TestMultipleInstancesCollisionSpi()); cfg3.setCollisionSpi(new TestMultipleInstancesCollisionSpi()); cfg2.setGridName(getTestGridName() + '1'); G.start(cfg2); G.start(cfg1); cfg3.setGridName(getTestGridName() + '2'); G.start(cfg3); assert G.state(cfg1.getGridName()) == STARTED; assert G.state(getTestGridName() + '1') == STARTED; assert G.state(getTestGridName() + '2') == STARTED; G.stop(getTestGridName() + '2', false); G.stop(cfg1.getGridName(), false); G.stop(getTestGridName() + '1', false); assert G.state(cfg1.getGridName()) == STOPPED; assert G.state(getTestGridName() + '1') == STOPPED; assert G.state(getTestGridName() + '2') == STOPPED; }
/** @throws Exception If failed. */ public void testStopCancel() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setConnectorConfiguration(null); Ignite ignite = G.start(cfg); ignite.compute().execute(TestTask.class, null); G.stop(true); }
/** * Start grid with IGFS. * * @param gridName Grid name. * @param igfsName IGFS name * @param mode IGFS mode. * @param secondaryFs Secondary file system (optional). * @param restCfg Rest configuration string (optional). * @return Started grid instance. * @throws Exception If failed. */ protected Ignite startGridWithIgfs( String gridName, String igfsName, IgfsMode mode, @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg) throws Exception { FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setDataCacheName("dataCache"); igfsCfg.setMetaCacheName("metaCache"); igfsCfg.setName(igfsName); igfsCfg.setBlockSize(IGFS_BLOCK_SIZE); igfsCfg.setDefaultMode(mode); igfsCfg.setIpcEndpointConfiguration(restCfg); igfsCfg.setSecondaryFileSystem(secondaryFs); igfsCfg.setPrefetchBlocks(PREFETCH_BLOCKS); igfsCfg.setSequentialReadsBeforePrefetch(SEQ_READS_BEFORE_PREFETCH); CacheConfiguration dataCacheCfg = defaultCacheConfiguration(); dataCacheCfg.setName("dataCache"); dataCacheCfg.setCacheMode(PARTITIONED); dataCacheCfg.setNearConfiguration(null); dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2)); dataCacheCfg.setBackups(0); dataCacheCfg.setAtomicityMode(TRANSACTIONAL); dataCacheCfg.setOffHeapMaxMemory(0); CacheConfiguration metaCacheCfg = defaultCacheConfiguration(); metaCacheCfg.setName("metaCache"); metaCacheCfg.setCacheMode(REPLICATED); metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); metaCacheCfg.setAtomicityMode(TRANSACTIONAL); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setGridName(gridName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg); cfg.setFileSystemConfiguration(igfsCfg); cfg.setLocalHost("127.0.0.1"); cfg.setConnectorConfiguration(null); return G.start(cfg); }
/** @throws Exception If failed. */ @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"}) public void testStartMultipleGridsFromSpring() throws Exception { File cfgFile = GridTestUtils.resolveIgnitePath( GridTestProperties.getProperty("loader.self.multipletest.config")); assert cfgFile != null; String path = cfgFile.getAbsolutePath(); info("Loading Grid from configuration file: " + path); final GridTuple<IgniteState> gridState1 = F.t(null); final GridTuple<IgniteState> gridState2 = F.t(null); final Object mux = new Object(); IgnitionListener factoryLsnr = new IgnitionListener() { @Override public void onStateChange(String name, IgniteState state) { synchronized (mux) { if ("grid-factory-test-1".equals(name)) gridState1.set(state); else if ("grid-factory-test-2".equals(name)) gridState2.set(state); } } }; G.addListener(factoryLsnr); G.start(path); assert G.ignite("grid-factory-test-1") != null; assert G.ignite("grid-factory-test-2") != null; synchronized (mux) { assert gridState1.get() == STARTED : "Invalid grid state [expected=" + STARTED + ", returned=" + gridState1 + ']'; assert gridState2.get() == STARTED : "Invalid grid state [expected=" + STARTED + ", returned=" + gridState2 + ']'; } G.stop("grid-factory-test-1", true); G.stop("grid-factory-test-2", true); synchronized (mux) { assert gridState1.get() == STOPPED : "Invalid grid state [expected=" + STOPPED + ", returned=" + gridState1 + ']'; assert gridState2.get() == STOPPED : "Invalid grid state [expected=" + STOPPED + ", returned=" + gridState2 + ']'; } }
/** @throws Exception If failed. */ public void testStartGridWithConfigUrl() throws Exception { GridEmbeddedHttpServer srv = null; String gridName = "grid_with_url_config"; try { srv = GridEmbeddedHttpServer.startHttpServer() .withFileDownloadingHandler( null, GridTestUtils.resolveIgnitePath( "modules/core/src/test/config/default-spring-url-testing.xml")); Ignite ignite = G.start(new URL(srv.getBaseUrl())); assert gridName.equals(ignite.name()) : "Unexpected grid name: " + ignite.name(); } finally { if (srv != null) srv.stop(1); G.stop(gridName, false); } }
/** {@inheritDoc} */ @Override protected Object executeJob(int gridSize, String type) { log.info(">>> Starting new grid node [currGridSize=" + gridSize + ", arg=" + type + "]"); if (type == null) throw new IllegalArgumentException("Node type to start should be specified."); IgniteConfiguration cfg = getConfig(type); // Generate unique for this VM grid name. String gridName = cfg.getGridName() + " (" + UUID.randomUUID() + ")"; // Update grid name (required to be unique). cfg.setGridName(gridName); // Start new node in current VM. Ignite g = G.start(cfg); log.info( ">>> Grid started [nodeId=" + g.cluster().localNode().id() + ", name='" + g.name() + "']"); return true; }
/** * Example for start/stop node tasks. * * @param args Not used. */ public static void main(String[] args) { String nodeType = "tcp+ssl"; // Start initial node = 1 try (Ignite g = G.start(NODE_CFG.get(nodeType))) { // Change topology. changeTopology(g, 4, 1, nodeType); changeTopology(g, 1, 4, nodeType); // Stop node by id = 0 g.compute().execute(ClientStopNodeTask.class, g.cluster().localNode().id().toString()); // Wait for node stops. // U.sleep(1000); assert G.allGrids().isEmpty(); } catch (Exception e) { System.err.println("Uncaught exception: " + e.getMessage()); e.printStackTrace(System.err); } }
/** * @param args Arguments. * @throws Exception If failed. */ public static void main(String[] args) throws Exception { // resetLog4j("org.apache.ignite.internal.processors.cache.distributed.dht.preloader", // Level.DEBUG, false, 0); // G.start("modules/tests/config/spring-multicache.xml"); // G.start("examples/config/example-cache.xml"); G.start(); // Wait until Ok is pressed. JOptionPane.showMessageDialog( null, new JComponent[] { new JLabel("Ignite started."), new JLabel( "<html>" + "You can use JMX console at <u>http://localhost:1234</u>" + "</html>"), new JLabel("Press OK to stop Ignite.") }, "Ignite Startup JUnit", JOptionPane.INFORMATION_MESSAGE); G.stop(true); }
/** * @param args Args. * @throws Exception If failed. */ public static void main(String[] args) throws Exception { G.start("modules/core/src/test/config/jobs-load-server.xml"); }