Java Code Examples for org.apache.ignite.Ignition#stop()

The following examples show how to use org.apache.ignite.Ignition#stop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaIgniteDataFrameJoinExample.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
public static void main(String args[]) {

    setupServerAndData();

    // Creating spark session.
    SparkSession spark = SparkSession
            .builder()
            .appName("JavaIgniteDataFrameJoinExample")
            .master("local")
            .config("spark.executor.instances", "2")
            .getOrCreate();

    // Adjust the logger to exclude the logs of no interest.
    Logger.getRootLogger().setLevel(Level.ERROR);
    Logger.getLogger("org.apache.ignite").setLevel(Level.INFO);

    // Executing examples.
    sparkDSLJoinExample(spark);
    nativeSparkSqlJoinExample(spark);

    Ignition.stop(false);
}
 
Example 2
Source File: JavaIgniteDataFrameExample.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
public static void main(String args[]) {

    setupServerAndData();

    //Creating spark session.
    SparkSession spark = SparkSession
            .builder()
            .appName("JavaIgniteDataFrameExample")
            .master("local")
            .config("spark.executor.instances", "2")
            .getOrCreate();

    // Adjust the logger to exclude the logs of no interest.
    Logger.getRootLogger().setLevel(Level.ERROR);
    Logger.getLogger("org.apache.ignite").setLevel(Level.INFO);

    // Executing examples.

    sparkDSLExample(spark);

    nativeSparkSqlExample(spark);

    Ignition.stop(false);
}
 
Example 3
Source File: PlatformIgnition.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Stop all instances.
 *
 * @param cancel Cancel flag.
 */
public static synchronized void stopAll(boolean cancel) {
    for (PlatformProcessor proc : instances.values())
        Ignition.stop(proc.ignite().name(), cancel);

    instances.clear();
}
 
Example 4
Source File: JavaIgniteDataFrameWriteExample.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
public static void main(String args[]) {
    //Starting Ignite.
    Ignite ignite = Ignition.start(CONFIG);

    //Starting Ignite server node.
    setupServerAndData(ignite);

    //Creating spark session.
    SparkSession spark = SparkSession
            .builder()
            .appName("Spark Ignite data sources write example")
            .master("local")
            .config("spark.executor.instances", "2")
            .getOrCreate();

    // Adjust the logger to exclude the logs of no interest.
    Logger.getRootLogger().setLevel(Level.ERROR);
    Logger.getLogger("org.apache.ignite").setLevel(Level.INFO);

    // Executing examples.
    System.out.println("Example of writing json file to Ignite:");

    writeJSonToIgnite(ignite, spark);

    System.out.println("Example of modifying existing Ignite table data through Data Fram API:");

    editDataAndSaveToNewTable(ignite, spark);

    Ignition.stop(false);
}
 
Example 5
Source File: TestGetIgniteCache.java    From nifi with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void tearDownClass() {
    if (preJava11) {
        ignite.close();
        Ignition.stop(true);
    }
}
 
Example 6
Source File: TestPutIgniteCache.java    From nifi with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void tearDownClass() {
    if (preJava11) {
        if ( ignite != null )
            ignite.close();
        Ignition.stop(true);
    }
}
 
Example 7
Source File: DynamicEnableIndexingConcurrentSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Test pending operation when coordinator change.
 */
@Test
public void testCoordinatorChange() throws Exception {
    // Start servers.
    IgniteEx srv1 = ignitionStart(serverConfiguration(1));
    ignitionStart(serverConfiguration(2));
    ignitionStart(serverConfiguration(3));
    ignitionStart(serverConfiguration(4));

    // Start client.
    IgniteEx cli = ignitionStart(clientConfiguration(5));
    cli.cluster().state(ClusterState.ACTIVE);

    createCache(cli);
    loadData(cli, 0, NUM_ENTRIES);

    // Test migration between normal servers.
    UUID id1 = srv1.cluster().localNode().id();

    CountDownLatch idxLatch = blockIndexing(id1);

    IgniteInternalFuture<?> tblFut = enableIndexing(cli);

    idxLatch.await();

    Ignition.stop(srv1.name(), true);

    unblockIndexing(id1);

    tblFut.get();

    for (Ignite g: G.allGrids()) {
        assertTrue(query(g, SELECT_ALL_QUERY).size() >= 3 * NUM_ENTRIES / 4 );

        performQueryingIntegrityCheck(g);

        checkQueryParallelism((IgniteEx)g, cacheMode);
    }
}
 
Example 8
Source File: BasicWarmupClosure.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void apply(IgniteConfiguration gridCfg) {
    // Remove cache duplicates, clean up the rest, etc.
    IgniteConfiguration cfg = prepareConfiguration(gridCfg);

    // Do nothing if no caches found.
    if (cfg == null)
        return;

    out("Starting grids to warmup caches [gridCnt=" + gridCnt +
        ", caches=" + cfg.getCacheConfiguration().length + ']');

    Collection<Ignite> ignites = new LinkedList<>();

    String old = System.getProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER);

    try {
        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");

        TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);

        for (int i = 0; i < gridCnt; i++) {
            IgniteConfiguration cfg0 = new IgniteConfiguration(cfg);

            TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

            discoSpi.setIpFinder(ipFinder);

            discoSpi.setLocalPort(discoveryPort);

            cfg0.setDiscoverySpi(discoSpi);

            cfg0.setGridLogger(new NullLogger());

            cfg0.setIgniteInstanceName("ignite-warmup-grid-" + i);

            ignites.add(Ignition.start(cfg0));
        }

        doWarmup(ignites);
    }
    catch (Exception e) {
        throw new IgniteException(e);
    }
    finally {
        for (Ignite ignite : ignites)
            Ignition.stop(ignite.name(), false);

        out("Stopped warmup grids.");

        if (old == null)
            old = "false";

        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, old);
    }
}
 
Example 9
Source File: TestPutIgniteCache.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void tearDownClass() {
    if ( ignite != null )
        ignite.close();
    Ignition.stop(true);
}
 
Example 10
Source File: IgniteKernal.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void close() throws IgniteException {
    Ignition.stop(igniteInstanceName, true);
}
 
Example 11
Source File: PlatformStopIgniteTask.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Object execute() throws IgniteException {
    return Ignition.stop(igniteInstanceName, true);
}
 
Example 12
Source File: Bucket4jIgniteRateLimiterTest.java    From spring-cloud-zuul-ratelimit with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void tearDownClass() {
    Ignition.stop(true);
}
 
Example 13
Source File: WalRecoveryTxLogicalRecordsTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Test checks that the number of pages per each page store are not changing before and after node restart.
 *
 * @throws Exception If failed.
 */
@Test
public void testRecoveryNoPageLost3() throws Exception {
    try {
        pageSize = 1024;
        checkpointFreq = 100L;
        extraCcfg = new CacheConfiguration(CACHE2_NAME);
        extraCcfg.setAffinity(new RendezvousAffinityFunction(false, 32));

        List<Integer> pages = null;

        for (int iter = 0; iter < 5; iter++) {
            log.info("Start node: " + iter);

            Ignite ignite = startGrid(0);

            ignite.cluster().active(true);

            if (pages != null) {
                List<Integer> curPags = allocatedPages(ignite, CACHE2_NAME);

                assertEquals("Iter = " + iter, pages, curPags);
            }

            final IgniteCache<Integer, Object> cache = ignite.cache(CACHE2_NAME);

            final int ops = ThreadLocalRandom.current().nextInt(10) + 10;

            GridTestUtils.runMultiThreaded(new Callable<Void>() {
                @Override public Void call() throws Exception {
                    ThreadLocalRandom rnd = ThreadLocalRandom.current();

                    for (int i = 0; i < ops; i++) {
                        Integer key = rnd.nextInt(1000);

                        cache.put(key, new byte[rnd.nextInt(512)]);

                        if (rnd.nextBoolean())
                            cache.remove(key);
                    }

                    return null;
                }
            }, 10, "update");

            pages = allocatedPages(ignite, CACHE2_NAME);

            Ignition.stop(ignite.name(), false); //will make checkpoint
        }
    }
    finally {
        stopAllGrids();
    }
}
 
Example 14
Source File: JavaStandaloneIgniteRDDSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
    Ignition.stop("client", false);
}
 
Example 15
Source File: IgfsExample.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Executes example.
 *
 * @param args Command line arguments, none required.
 * @throws Exception If example execution failed.
 */
public static void main(String[] args) throws Exception {
    Ignite ignite = Ignition.start("examples/config/filesystem/example-igfs.xml");

    System.out.println();
    System.out.println(">>> IGFS example started.");

    try {
        // Get an instance of Ignite File System.
        IgniteFileSystem fs = ignite.fileSystem("igfs");

        // Working directory path.
        IgfsPath workDir = new IgfsPath("/examples/fs");

        // Cleanup working directory.
        delete(fs, workDir);

        // Create empty working directory.
        mkdirs(fs, workDir);

        // Print information for working directory.
        printInfo(fs, workDir);

        // File path.
        IgfsPath filePath = new IgfsPath(workDir, "file.txt");

        // Create file.
        create(fs, filePath, new byte[] {1, 2, 3});

        // Print information for file.
        printInfo(fs, filePath);

        // Append more data to previously created file.
        append(fs, filePath, new byte[] {4, 5});

        // Print information for file.
        printInfo(fs, filePath);

        // Read data from file.
        read(fs, filePath);

        // Delete file.
        delete(fs, filePath);

        // Print information for file.
        printInfo(fs, filePath);

        // Create several files.
        for (int i = 0; i < 5; i++)
            create(fs, new IgfsPath(workDir, "file-" + i + ".txt"), null);

        list(fs, workDir);
    }
    finally {
        Ignition.stop(false);
    }
}
 
Example 16
Source File: Bucket4jJCacheRateLimiterTest.java    From spring-cloud-zuul-ratelimit with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void tearDownClass() {
    Ignition.stop(true);
}
 
Example 17
Source File: IgniteDatastoreProvider.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void stop() {
	if ( cacheManager != null && stopOnExit ) {
		Ignition.stop( cacheManager.name(), true );
	}
}
 
Example 18
Source File: TestGetIgniteCache.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void tearDownClass() {
    ignite.close();
    Ignition.stop(true);
}
 
Example 19
Source File: DynamicIndexAbstractConcurrentSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Make sure that coordinator migrates correctly between nodes.
 *
 * @throws Exception If failed.
 */
@Test
public void testCoordinatorChange() throws Exception {
    // Start servers.
    Ignite srv1 = ignitionStart(serverConfiguration(1));
    Ignite srv2 = ignitionStart(serverConfiguration(2));
    ignitionStart(serverConfiguration(3, true));
    ignitionStart(serverConfiguration(4));

    UUID srv1Id = srv1.cluster().localNode().id();
    UUID srv2Id = srv2.cluster().localNode().id();

    // Start client which will execute operations.
    Ignite cli = ignitionStart(clientConfiguration(5));

    createSqlCache(cli);

    put(srv1, 0, KEY_AFTER);

    // Test migration between normal servers.
    CountDownLatch idxLatch = blockIndexing(srv1Id);

    QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1));

    IgniteInternalFuture<?> idxFut1 = queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME,
        idx1, false, 0);

    idxLatch.await();

    //srv1.close();
    Ignition.stop(srv1.name(), true);

    unblockIndexing(srv1Id);

    idxFut1.get();

    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1));
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
    assertSqlSimpleData(SQL_SIMPLE_FIELD_1, KEY_AFTER - SQL_ARG_1);

    // Test migration from normal server to non-affinity server.
    idxLatch = blockIndexing(srv2Id);

    QueryIndex idx2 = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));

    IgniteInternalFuture<?> idxFut2 =
        queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx2, false, 0);

    idxLatch.await();

    //srv2.close();
    Ignition.stop(srv2.name(), true);

    unblockIndexing(srv2Id);

    idxFut2.get();

    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(aliasUnescaped(FIELD_NAME_2)));
    assertIndexUsed(IDX_NAME_2, SQL_SIMPLE_FIELD_2, SQL_ARG_1);
    assertSqlSimpleData(SQL_SIMPLE_FIELD_2, KEY_AFTER - SQL_ARG_1);
}
 
Example 20
Source File: JavaIgniteCatalogExample.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** */
public static void main(String args[]) throws AnalysisException {

    setupServerAndData();

    //Creating Ignite-specific implementation of Spark session.
    IgniteSparkSession igniteSession = IgniteSparkSession.builder()
            .appName("Spark Ignite catalog example")
            .master("local")
            .config("spark.executor.instances", "2")
            .igniteConfig(CONFIG)
            .getOrCreate();

    //Adjust the logger to exclude the logs of no interest.
    Logger.getRootLogger().setLevel(Level.ERROR);
    Logger.getLogger("org.apache.ignite").setLevel(Level.INFO);

    System.out.println("List of available tables:");

    //Showing existing tables.
    igniteSession.catalog().listTables().show();

    System.out.println("PERSON table description:");

    //Showing `person` schema.
    igniteSession.catalog().listColumns("person").show();

    System.out.println("CITY table description:");

    //Showing `city` schema.
    igniteSession.catalog().listColumns("city").show();

    println("Querying all persons from city with ID=2.");

    //Selecting data through Spark SQL engine.
    Dataset<Row> df = igniteSession.sql("SELECT * FROM person WHERE CITY_ID = 2");

    System.out.println("Result schema:");

    df.printSchema();

    System.out.println("Result content:");

    df.show();

    System.out.println("Querying all persons living in Denver.");

    //Selecting data through Spark SQL engine.
    Dataset<Row> df2 = igniteSession.sql("SELECT * FROM person p JOIN city c ON c.ID = p.CITY_ID WHERE c.NAME = 'Denver'");

    System.out.println("Result schema:");

    df2.printSchema();

    System.out.println("Result content:");

    df2.show();

    Ignition.stop(false);
}