Java Code Examples for org.apache.ignite.Ignite#active()

The following examples show how to use org.apache.ignite.Ignite#active() . 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: IgniteChangeGlobalStateTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception if fail.
 */
@Test
public void testDeActivateFromClientNode() throws Exception {
    Ignite ig1 = primary(0);
    Ignite ig2 = primary(1);
    Ignite ig3 = primary(2);

    Ignite ig1C = primaryClient(0);
    Ignite ig2C = primaryClient(1);
    Ignite ig3C = primaryClient(2);

    assertTrue(ig1.active());
    assertTrue(ig2.active());
    assertTrue(ig3.active());

    ig1C.active(false);

    assertTrue(!ig1.active());
    assertTrue(!ig2.active());
    assertTrue(!ig3.active());

    assertTrue(!ig1C.active());
    assertTrue(!ig2C.active());
    assertTrue(!ig3C.active());
}
 
Example 2
Source File: IgniteUidAsConsistentIdMigrationTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * test two nodes started at the same db root folder, second node should get index 1
 *
 * @throws Exception if failed
 */
@Test
public void testNodeIndexIncremented() throws Exception {
    final Ignite ignite0 = startGrid(0);
    final Ignite ignite1 = startGrid(1);

    ignite0.active(true);

    ignite0.getOrCreateCache(CACHE_NAME).put("hi", "there!");
    ignite1.getOrCreateCache(CACHE_NAME).put("hi1", "there!");

    assertPdsDirsDefaultExist(genNewStyleSubfolderName(0, ignite0));
    assertPdsDirsDefaultExist(genNewStyleSubfolderName(1, ignite1));

    stopGrid(0);
    stopGrid(1);
    assertNodeIndexesInFolder(0, 1);
}
 
Example 3
Source File: MigratingToWalV2SerializerWithCompactionTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void apply(Ignite ignite) {
    ignite.active(true);

    CacheConfiguration<Object, Object> cacheCfg = new CacheConfiguration<>();
    cacheCfg.setName(TEST_CACHE_NAME);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cacheCfg.setBackups(0);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

    IgniteCache<Object, Object> cache = ignite.getOrCreateCache(cacheCfg);

    for (int i = 0; i < ENTRIES; i++) { // At least 20MB of raw data in total.
        final byte[] val = new byte[20000];

        ThreadLocalRandom.current().nextBytes(val);

        val[i] = 1;

        cache.put(i, val);
    }
}
 
Example 4
Source File: IgnitePersistentStoreCacheGroupsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testCreateDropCache() throws Exception {
    ccfgs = new CacheConfiguration[]{cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1)
        .setIndexedTypes(Integer.class, Person.class)};

    Ignite ignite = startGrid();

    ignite.active(true);

    ignite.cache("c1").destroy();

    stopGrid();
}
 
Example 5
Source File: IgniteChangeGlobalStateTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if fail.
 */
@Test
public void testDeActivateCheckCacheDestroy() throws Exception {
    String chName = "myCache";

    Ignite ig1 = primary(0);
    Ignite ig2 = primary(1);
    Ignite ig3 = primary(2);

    ig1.getOrCreateCache(chName);

    assertTrue(ig1.active());
    assertTrue(ig2.active());
    assertTrue(ig3.active());

    ig1.active(false);

    assertTrue(!ig1.active());
    assertTrue(!ig2.active());
    assertTrue(!ig3.active());

    IgniteEx ex = (IgniteEx)ig1;

    GridCacheProcessor cache = ex.context().cache();

    assertTrue(F.isEmpty(cache.jcaches()));
}
 
Example 6
Source File: GridCommonAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cnt Count.
 * @param awaitPartMapExchange If we need to await partition map exchange.
 * @return Ignite.
 * @throws Exception If failed.
 */
protected final Ignite startGridsMultiThreaded(int cnt, boolean awaitPartMapExchange) throws Exception {
    Ignite g = super.startGridsMultiThreaded(cnt);

    if (awaitPartMapExchange) {
        if (!g.active())
            g.active(true);

        awaitPartitionMapExchange();
    }

    return g;
}
 
Example 7
Source File: JdbcThinMissingLongArrayResultsTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
    super.beforeTestsStarted();

    startGridsMultiThreaded(GRID_CNT);

    Ignite ignite = ignite(0);

    try (IgniteDataStreamer<Key, Value> streamer = ignite.dataStreamer(CACHE_NAME)) {
        streamer.allowOverwrite(true);
        streamer.perNodeBufferSize(50);
        streamer.autoFlushFrequency(TimeUnit.SECONDS.toMillis(45));
        streamer.skipStore(false);
        streamer.keepBinary(true);

        int secId = 0;

        final int maxBlocks = SAMPLE_SIZE / BLOCK_SIZE;

        Key key = new Key();
        Value value = new Value();
        long date = System.nanoTime();

        for (int blockId = 0; blockId < maxBlocks; blockId++) {

            final long[] time = new long[BLOCK_SIZE];
            final double[] open = new double[BLOCK_SIZE];
            final double[] close = new double[BLOCK_SIZE];
            final double[] high = new double[BLOCK_SIZE];
            final double[] low = new double[BLOCK_SIZE];
            final double[] marketVWAP = new double[BLOCK_SIZE];

            for (int i = 0; i < BLOCK_SIZE; i++) {
                // Fake data
                time[i] = System.nanoTime();
                open[i] = Math.abs(RAND.nextGaussian());
                close[i] = Math.abs(RAND.nextGaussian());
                high[i] = Math.max(open[i], Math.abs(RAND.nextGaussian()));
                low[i] = Math.min(open[i], Math.abs(RAND.nextGaussian()));
                marketVWAP[i] = Math.abs(RAND.nextGaussian());
            }

            // Add to the cache
            key.setDate(date);
            key.setSecurityId(secId);

            value.setTime(time); // BUG  in providing it via JDBC

            value.setOpen(open);
            value.setHigh(high);
            value.setLow(low);
            value.setClose(close);
            value.setMarketVWAP(marketVWAP);

            streamer.addData(key, value);

            secId++; // for unique values
            //secId = RAND.nextInt(1000);

            if (blockId % 100 == 0)
                System.out.println("+++ Processed " + (blockId * BLOCK_SIZE) + " events so far " + new Date());
        }
        streamer.flush();
    }
    ignite.active(true);
}
 
Example 8
Source File: IgniteChangeGlobalStateTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testActivateOnAlreadyActivatedCluster() throws Exception {
    Ignite ig1P = primary(0);
    Ignite ig2P = primary(1);
    Ignite ig3P = primary(2);

    Ignite ig1B = backUp(0);
    Ignite ig2B = backUp(1);
    Ignite ig3B = backUp(2);

    Ignite ig1C = backUpClient(0);
    Ignite ig2C = backUpClient(1);
    Ignite ig3C = backUpClient(2);

    assertTrue(ig1P.active());
    assertTrue(ig2P.active());
    assertTrue(ig3P.active());

    assertTrue(!ig1B.active());
    assertTrue(!ig2B.active());
    assertTrue(!ig3B.active());

    assertTrue(!ig1C.active());
    assertTrue(!ig2C.active());
    assertTrue(!ig3C.active());

    stopAllPrimary();

    ig2B.active(true);

    assertTrue(ig1B.active());
    assertTrue(ig2B.active());
    assertTrue(ig3B.active());

    assertTrue(ig1C.active());
    assertTrue(ig2C.active());
    assertTrue(ig3C.active());

    ig1B.active(true);
    ig2B.active(true);
    ig3B.active(true);

    ig1C.active(true);
    ig2C.active(true);
    ig3C.active(true);

    assertTrue(ig1B.active());
    assertTrue(ig2B.active());
    assertTrue(ig3B.active());

    assertTrue(ig1C.active());
    assertTrue(ig2C.active());
    assertTrue(ig3C.active());
}
 
Example 9
Source File: IgniteChangeGlobalStateDataStreamerTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testDeActivateAndActivateDataStreamer() throws Exception {
    Ignite ig1 = primary(0);
    Ignite ig2 = primary(1);
    Ignite ig3 = primary(2);

    Ignite ig1C = primaryClient(0);
    Ignite ig2C = primaryClient(1);
    Ignite ig3C = primaryClient(2);

    assertTrue(ig1.active());
    assertTrue(ig2.active());
    assertTrue(ig3.active());

    assertTrue(ig1C.active());
    assertTrue(ig2C.active());
    assertTrue(ig3C.active());

    String cacheName = "myStreamCache";

    ig2C.getOrCreateCache(cacheName);

    try (IgniteDataStreamer<Integer, String> stmr = ig1.dataStreamer(cacheName)) {
        for (int i = 0; i < 100; i++)
            stmr.addData(i, Integer.toString(i));
    }

    ig2C.active(false);

    assertTrue(!ig1.active());
    assertTrue(!ig2.active());
    assertTrue(!ig3.active());

    assertTrue(!ig1C.active());
    assertTrue(!ig2C.active());
    assertTrue(!ig3C.active());

    boolean fail = false;

    try {
        IgniteDataStreamer<String, String> strm2 = ig2.dataStreamer(cacheName);
    }
    catch (Exception e) {
        fail = true;

        assertTrue(e.getMessage().contains("Can not perform the operation because the cluster is inactive."));
    }

    if (!fail)
        fail("exception was not throw");

    ig3C.active(true);

    assertTrue(ig1.active());
    assertTrue(ig2.active());
    assertTrue(ig3.active());

    assertTrue(ig1C.active());
    assertTrue(ig2C.active());
    assertTrue(ig3C.active());

    try (IgniteDataStreamer<Integer, String> stmr2 = ig2.dataStreamer(cacheName)) {
        for (int i = 100; i < 200; i++)
            stmr2.addData(i, Integer.toString(i));
    }

    IgniteCache<Integer, String> cache = ig3.cache(cacheName);

    for (int i = 0; i < 200; i++)
        assertEquals(String.valueOf(i), cache.get(i));
}
 
Example 10
Source File: IgniteBaselineAffinityTopologyActivationTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 *
 */
@Test
public void testNodeFailsToJoinWithIncompatiblePreviousBaselineTopology() throws Exception {
    startGridWithConsistentId("A");
    startGridWithConsistentId("B");
    Ignite nodeC = startGridWithConsistentId("C");

    nodeC.cluster().baselineAutoAdjustEnabled(false);
    nodeC.active(true);

    stopAllGrids(false);

    Ignite nodeA = startGridWithConsistentId("A");
    startGridWithConsistentId("B").active(true);

    nodeA.cluster().setBaselineTopology(baselineNodes(nodeA.cluster().forServers().nodes()));

    stopAllGrids(false);

    startGridWithConsistentId("C").active(true);

    stopGrid("C", false);

    startGridWithConsistentId("A");
    startGridWithConsistentId("B");

    boolean expectedExceptionThrown = false;

    try {
        startGridWithConsistentId("C");
    }
    catch (IgniteCheckedException e) {
        expectedExceptionThrown = true;

        if (e.getCause() != null && e.getCause().getCause() != null) {
            Throwable rootCause = e.getCause().getCause();

            if (!(rootCause instanceof IgniteSpiException) || !rootCause.getMessage().contains("not compatible"))
                Assert.fail("Unexpected ignite exception was thrown: " + e);
        }
        else
            throw e;
    }

    assertTrue("Expected exception wasn't thrown.", expectedExceptionThrown);
}
 
Example 11
Source File: IgnitePdsBinaryMetadataOnClusterRestartTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * If joining node has incompatible BinaryMetadata (e.g. when user manually copies binary_meta file),
 * coordinator detects it and fails the node providing information about conflict.
 *
 * @see <a href="https://issues.apache.org/jira/browse/IGNITE-7258">IGNITE-7258</a> refer to the following JIRA for more context about the problem verified by the test.
 */
@Test
public void testNodeWithIncompatibleMetadataIsProhibitedToJoinTheCluster() throws Exception {
    final String decimalFieldName = "decField";

    Ignite igniteA = startGridInASeparateWorkDir("A");
    Ignite igniteB = startGridInASeparateWorkDir("B");

    String bConsId = igniteB.cluster().localNode().consistentId().toString();

    igniteA.active(true);

    IgniteCache<Object, Object> cache = igniteA.cache(CACHE_NAME);

    BinaryObject bObj = igniteA.binary()
        .builder(DYNAMIC_TYPE_NAME).setField(decimalFieldName, 10).build();

    cache.put(0, bObj);

    int createdTypeId = igniteA.binary().type(DYNAMIC_TYPE_NAME).typeId();

    stopAllGrids();

    Ignite igniteC = startGridInASeparateWorkDir("C");
    String cConsId = igniteC.cluster().localNode().consistentId().toString();
    igniteC.active(true);

    cache = igniteC.cache(CACHE_NAME);
    bObj = igniteC.binary().builder(DYNAMIC_TYPE_NAME).setField(decimalFieldName, 10L).build();

    cache.put(0, bObj);

    stopAllGrids();

    copyIncompatibleBinaryMetadata(
        String.format(CUSTOM_WORK_DIR_NAME_PATTERN, "C"),
        cConsId,
        String.format(CUSTOM_WORK_DIR_NAME_PATTERN, "B"),
        bConsId,
        DYNAMIC_TYPE_NAME.toLowerCase().hashCode() + ".bin");

    startGridInASeparateWorkDir("A");

    String expectedMsg = String.format(
        "Type '%s' with typeId %d has a different/incorrect type for field '%s'. Expected 'int' but 'long' was " +
            "provided. The type of an existing field can not be changed. Use a different field name or follow " +
            "this procedure to reuse the current name:\n" +
            "- Delete data records that use the old field type;\n" +
            "- Remove metadata by the command: 'control.sh --meta remove --typeId %d'.",
        DYNAMIC_TYPE_NAME,
        createdTypeId,
        decimalFieldName,
        createdTypeId);

    Throwable thrown = GridTestUtils.assertThrows(
        log,
        () -> startGridInASeparateWorkDir("B"),
        Exception.class,
        null);

    assertNotNull(thrown.getCause());
    assertNotNull(thrown.getCause().getCause());

    String actualMsg = thrown.getCause().getCause().getMessage();

    assertTrue("Cause is not correct [expected='" + expectedMsg + "', actual='" + actualMsg + "'].",
        actualMsg.contains(expectedMsg));
}
 
Example 12
Source File: IgnitePersistentStoreDataStructuresTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testAtomic() throws Exception {
    Ignite ignite = startGrids(4);

    ignite.active(true);

    IgniteAtomicLong atomicLong = ignite.atomicLong("testLong", 0, true);

    for (int i = 0; i < 100; i++)
        atomicLong.incrementAndGet();

    stopAllGrids();

    ignite = startGrids(4);

    ignite.active(true);

    atomicLong = ignite.atomicLong("testLong", 0, false);

    for (int i = 100; i != 0; )
        assertEquals(i--, atomicLong.getAndDecrement());
}
 
Example 13
Source File: IgniteChangeGlobalStateTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testFailGetLock() throws Exception {
    Ignite ig1P = primary(0);
    Ignite ig2P = primary(1);
    Ignite ig3P = primary(2);

    Ignite ig1B = backUp(0);
    Ignite ig2B = backUp(1);
    Ignite ig3B = backUp(2);

    Ignite ig1C = backUpClient(0);
    Ignite ig2C = backUpClient(1);

    final Ignite ig3C = backUpClient(2);

    assertTrue(ig1P.active());
    assertTrue(ig2P.active());
    assertTrue(ig3P.active());

    assertTrue(!ig1B.active());
    assertTrue(!ig2B.active());
    assertTrue(!ig3B.active());

    assertTrue(!ig1C.active());
    assertTrue(!ig2C.active());
    assertTrue(!ig3C.active());

    stopPrimary(0);

    boolean exc = false;

    try {
        ig3C.active(true);
    }
    catch (IgniteException e) {
        exc = true;

        log.error("stack trace from remote node", e);

        for (Throwable t : e.getSuppressed())
            assertTrue(t.getMessage().contains("can't get lock during"));
    }

    if (!exc)
        fail();

    assertTrue(!ig1B.active());
    assertTrue(!ig2B.active());
    assertTrue(!ig3B.active());

    assertTrue(!ig1C.active());
    assertTrue(!ig2C.active());
    assertTrue(!ig3C.active());
}
 
Example 14
Source File: IgniteChangeGlobalStateDataStructureTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testDeActivateAndActivateAtomicLong() throws Exception {
    String lName = "myLong";

    Ignite ig1 = primary(0);
    Ignite ig2 = primary(1);
    Ignite ig3 = primary(2);

    IgniteAtomicLong lexp = ig1.atomicLong(lName, 100, true);

    lexp.incrementAndGet();
    lexp.incrementAndGet();
    lexp.incrementAndGet();

    assertTrue(ig1.active());
    assertTrue(ig2.active());
    assertTrue(ig3.active());

    ig2.active(false);

    IgniteEx ex1 = (IgniteEx)ig1;
    IgniteEx ex2 = (IgniteEx)ig2;
    IgniteEx ex3 = (IgniteEx)ig3;

    GridCacheProcessor cache1 = ex1.context().cache();
    GridCacheProcessor cache2 = ex2.context().cache();
    GridCacheProcessor cache3 = ex3.context().cache();

    assertTrue(F.isEmpty(cache1.jcaches()));
    assertTrue(F.isEmpty(cache2.jcaches()));
    assertTrue(F.isEmpty(cache3.jcaches()));

    assertTrue(!ig1.active());
    assertTrue(!ig2.active());
    assertTrue(!ig3.active());

    ig3.active(true);

    assertTrue(ig1.active());
    assertTrue(ig2.active());
    assertTrue(ig3.active());

    IgniteAtomicLong lact1 = ig1.atomicLong(lName, 0, false);
    IgniteAtomicLong lact2 = ig2.atomicLong(lName, 0, false);
    IgniteAtomicLong lact3 = ig3.atomicLong(lName, 0, false);

    assertEquals(103, lact1.get());
    assertEquals(103, lact2.get());
    assertEquals(103, lact3.get());

    lact1.incrementAndGet();

    assertEquals(104, lact1.get());
    assertEquals(104, lact2.get());
    assertEquals(104, lact3.get());

    lact2.incrementAndGet();

    assertEquals(105, lact1.get());
    assertEquals(105, lact2.get());
    assertEquals(105, lact3.get());

    lact3.incrementAndGet();

    assertEquals(106, lact3.get());
    assertEquals(106, lact3.get());
    assertEquals(106, lact3.get());
}
 
Example 15
Source File: IgniteUidAsConsistentIdMigrationTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * Tests compatible mode enabled by this test to start.
 * Expected to be 2 folders and no new style folders in this case.
 *
 * @throws Exception if failed.
 */
@Test
public void testStartOldStyleNodesByCompatibleProperty() throws Exception {
    clearPropsAfterTest = true;
    System.setProperty(IGNITE_DATA_STORAGE_FOLDER_BY_CONSISTENT_ID, "true");

    final Ignite ignite1 = startGrid(0);
    final Ignite ignite2 = startGrid(1);

    ignite1.active(true);

    final String expVal = "there is compatible mode with old style folders!";

    ignite2.getOrCreateCache(CACHE_NAME).put("hi", expVal);

    assertNodeIndexesInFolder(); // expected to have no new style folders

    final Object consistentId1 = ignite1.cluster().localNode().consistentId();

    assertPdsDirsDefaultExist(U.maskForFileName(consistentId1.toString()));
    final Object consistentId2 = ignite2.cluster().localNode().consistentId();

    assertPdsDirsDefaultExist(U.maskForFileName(consistentId2.toString()));
    stopAllGrids();

    System.clearProperty(IGNITE_DATA_STORAGE_FOLDER_BY_CONSISTENT_ID);
    final Ignite igniteRestart = startGrid(0);
    final Ignite igniteRestart2 = startGrid(1);

    igniteRestart2.active(true);

    assertEquals(consistentId1, igniteRestart.cluster().localNode().consistentId());
    assertEquals(consistentId2, igniteRestart2.cluster().localNode().consistentId());

    assertNodeIndexesInFolder(); //new style nodes should not be found
    stopGrid(0);
}
 
Example 16
Source File: IgnitePdsDynamicCacheTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testDynamicCacheSavingOnNewNode() throws Exception {
    Ignite ignite = startGrid(0);

    ignite.active(true);

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));

    IgniteCache cache = ignite.getOrCreateCache(ccfg);

    for (int i = 0; i < 160; i++)
        cache.put(i, i);

    ignite = startGrid(1);

    awaitPartitionMapExchange();

    cache = ignite.cache(DEFAULT_CACHE_NAME);

    for (int i = 0; i < 160; i++)
        assertEquals(i, cache.get(i));

    stopAllGrids(true);

    startGrid(0);
    ignite = startGrid(1);

    ignite.active(true);

    cache = ignite.cache(DEFAULT_CACHE_NAME);

    for (int i = 0; i < 160; i++)
        assertEquals(i, cache.get(i));
}
 
Example 17
Source File: IgnitePdsBinaryMetadataOnClusterRestartTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * Test verifies that binary metadata from regular java classes is saved and restored correctly
 * on cluster restart.
 */
@Test
public void testStaticMetadataIsRestoredOnRestart() throws Exception {
    startGrids(2);

    Ignite ignite0 = grid(0);

    ignite0.active(true);

    IgniteCache<Object, Object> cache0 = ignite0.cache(CACHE_NAME);

    cache0.put(0, new TestValue1(0));
    cache0.put(1, new TestValue2("value"));

    stopAllGrids();

    startGrids(2);

    ignite0 = grid(0);

    ignite0.active(true);

    examineStaticMetadata(2);

    startGrid(2);

    startGrid(3);

    awaitPartitionMapExchange();

    examineStaticMetadata(4);
}
 
Example 18
Source File: IgnitePdsBinaryMetadataOnClusterRestartTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 *
 */
@Test
public void testBinaryEnumMetadataIsRestoredOnRestart() throws Exception {
    Ignite ignite0 = startGrids(2);

    ignite0.active(true);

    BinaryObject enumBo0 = ignite0.binary().buildEnum(EnumType.class.getName(), 0);

    ignite0.cache(CACHE_NAME).put(4, enumBo0);

    stopAllGrids();

    ignite0 = startGrids(2);

    ignite0.active(true);

    startGrid(2);

    awaitPartitionMapExchange();

    examineDynamicMetadata(3, enumExaminer0);

    stopAllGrids();

    ignite0 = startGrids(3);

    ignite0.active(true);

    startClientGrid(3);

    awaitPartitionMapExchange();

    examineDynamicMetadata(4, enumExaminer0);
}
 
Example 19
Source File: IgnitePersistentStoreDataStructuresTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testSet() throws Exception {
    Ignite ignite = startGrids(4);

    ignite.active(true);

    IgniteSet<Object> set = ignite.set("testSet", new CollectionConfiguration());

    for (int i = 0; i < 100; i++)
        set.add(i);

    assertEquals(100, set.size());

    stopAllGrids();

    ignite = startGrids(4);

    ignite.active(true);

    set = ignite.set("testSet", null);

    assertFalse(set.add(99));

    for (int i = 0; i < 100; i++)
        assertTrue(set.contains(i));

    assertEquals(100, set.size());
}
 
Example 20
Source File: IgnitePdsBinaryMetadataOnClusterRestartTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * @see <a href="https://issues.apache.org/jira/browse/IGNITE-7258">IGNITE-7258</a> refer to the following JIRA for more context about the problem verified by the test.
 */
@Test
public void testUpdatedBinaryMetadataIsPreservedOnJoinToOldCoordinator() throws Exception {
    Ignite ignite0 = startGridInASeparateWorkDir("A");
    Ignite ignite1 = startGridInASeparateWorkDir("B");

    ignite0.active(true);

    IgniteCache<Object, Object> cache0 = ignite0.cache(CACHE_NAME);

    BinaryObject bo = ignite0
        .binary()
        .builder(DYNAMIC_TYPE_NAME)
        .setField(DYNAMIC_INT_FIELD_NAME, 10)
        .build();

    cache0.put(0, bo);

    stopGrid("A");

    IgniteCache<Object, Object> cache1 = ignite1.cache(CACHE_NAME);

    bo = ignite1
        .binary()
        .builder(DYNAMIC_TYPE_NAME)
        .setField(DYNAMIC_INT_FIELD_NAME, 20)
        .setField(DYNAMIC_STR_FIELD_NAME, "str")
        .build();

    cache1.put(1, bo);

    stopAllGrids();

    ignite0 = startGridInASeparateWorkDir("A");
    ignite1 = startGridInASeparateWorkDir("B");

    awaitPartitionMapExchange();

    cache0 = ignite0.cache(CACHE_NAME).withKeepBinary();

    BinaryObject bObj0 = (BinaryObject) cache0.get(0);

    assertEquals(10, (int) bObj0.field("intField"));

    cache1 = ignite1.cache(CACHE_NAME).withKeepBinary();

    BinaryObject bObj1 = (BinaryObject) cache1.get(1);

    assertEquals(20, (int) bObj1.field("intField"));
    assertEquals("str", bObj1.field("strField"));
}