Java Code Examples for org.apache.ignite.cache.CacheMode#REPLICATED

The following examples show how to use org.apache.ignite.cache.CacheMode#REPLICATED . 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: CacheGroupsPreloadTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testCachePreloadMvcc4() throws Exception {
    cacheMode = CacheMode.REPLICATED;
    atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;

    cachePreloadTest();
}
 
Example 2
Source File: CacheGroupsPreloadTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testCachePreload3() throws Exception {
    cacheMode = CacheMode.REPLICATED;

    cachePreloadTest();
}
 
Example 3
Source File: GridCacheAbstractMetricsSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testMisses() throws Exception {
    IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME);

    int keyCnt = keyCount();

    int expReads = 0;

    // Get a few keys missed keys.
    for (int i = 0; i < keyCnt; i++) {
        assertNull("Value is not null for key: " + i, cache.get(i));

        if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() == CacheMode.REPLICATED ||
            affinity(cache).isPrimary(grid(0).localNode(), i))
            expReads++;
        else
            expReads += 2;
    }

    // Check metrics for the whole cache.
    long puts = 0;
    long reads = 0;
    long hits = 0;
    long misses = 0;

    for (int i = 0; i < gridCount(); i++) {
        CacheMetrics m = grid(i).cache(DEFAULT_CACHE_NAME).localMetrics();

        puts += m.getCachePuts();
        reads += m.getCacheGets();
        hits += m.getCacheHits();
        misses += m.getCacheMisses();
    }

    assertEquals(0, puts);
    assertEquals(expReads, reads);
    assertEquals(0, hits);
    assertEquals(expReads, misses);
}
 
Example 4
Source File: CacheGroupsPreloadTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testCachePreload8() throws Exception {
    sameGrp = false;
    cacheMode = CacheMode.REPLICATED;
    atomicityMode = CacheAtomicityMode.TRANSACTIONAL;

    cachePreloadTest();
}
 
Example 5
Source File: GridCacheReferenceCleanupSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** @throws Exception If failed. */
@Test
public void testOneAsyncOpReplicated() throws Exception {
    mode = CacheMode.REPLICATED;

    startGrids(2);

    try {
        checkReferenceCleanup(oneAsyncOpCallable());
    }
    finally {
        stopAllGrids();
    }
}
 
Example 6
Source File: GridCacheReferenceCleanupSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** @throws Exception If failed. */
@Test
public void testAsyncOpsAsyncCommitReplicated() throws Exception {
    mode = CacheMode.REPLICATED;

    startGrids(2);

    try {
        checkReferenceCleanup(asyncOpsAsyncCommitCallable());
    }
    finally {
        stopAllGrids();
    }
}
 
Example 7
Source File: IgniteTopologyValidatorReplicatedTxCacheGroupsTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 8
Source File: GridCacheReplicatedUsersAffinityMapperSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode getCacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 9
Source File: ReplicatedExplicitTransactionalReadRepairTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 10
Source File: H2DynamicIndexAtomicReplicatedSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 11
Source File: H2DynamicTableSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Test that {@code CREATE TABLE} with given template cache name actually creates new cache,
 * H2 table and type descriptor on all nodes, optionally with cache type check.
 * @param tplCacheName Template cache name.
 * @param cacheGrp Cache group name, or {@code null} if no group is set.
 * @param cacheMode Expected cache mode, or {@code null} if no check is needed.
 * @param writeSyncMode Expected write sync mode, or {@code null} if no check is needed.
 * @param useLegacyCacheGrpParamName Whether legacy (harder-to-read) cache group param name should be used.
 * @param additionalParams Supplemental parameters to append to {@code CREATE TABLE} SQL.
 */
private void doTestCreateTable(String tplCacheName, String cacheGrp, CacheMode cacheMode,
    CacheWriteSynchronizationMode writeSyncMode, boolean useLegacyCacheGrpParamName, String... additionalParams)
    throws SQLException {
    String cacheGrpParamName = useLegacyCacheGrpParamName ? "cacheGroup" : "cache_group";

    String sql = "CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," +
        " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " +
        (F.isEmpty(tplCacheName) ? "" : "\"template=" + tplCacheName + "\",") + "\"backups=10,atomicity=atomic\"" +
        (F.isEmpty(cacheGrp) ? "" : ",\"" + cacheGrpParamName + '=' + cacheGrp + '"');

    for (String p : additionalParams)
        sql += ",\"" + p + "\"";

    execute(sql);

    String cacheName = cacheName("Person");

    for (int i = 0; i < 4; i++) {
        IgniteEx node = grid(i);

        assertNotNull(node.cache(cacheName));

        DynamicCacheDescriptor cacheDesc = node.context().cache().cacheDescriptor(cacheName);

        assertNotNull(cacheDesc);

        if (cacheMode == CacheMode.REPLICATED)
            assertEquals(Integer.MAX_VALUE, cacheDesc.cacheConfiguration().getBackups());
        else
            assertEquals(10, cacheDesc.cacheConfiguration().getBackups());

        assertEquals(CacheAtomicityMode.ATOMIC, cacheDesc.cacheConfiguration().getAtomicityMode());

        assertTrue(cacheDesc.sql());

        assertEquals(cacheGrp, cacheDesc.groupDescriptor().groupName());

        if (cacheMode != null)
            assertEquals(cacheMode, cacheDesc.cacheConfiguration().getCacheMode());

        if (writeSyncMode != null)
            assertEquals(writeSyncMode, cacheDesc.cacheConfiguration().getWriteSynchronizationMode());

        List<String> colNames = new ArrayList<>(5);

        List<Class<?>> colTypes = new ArrayList<>(5);

        List<String> pkColNames = new ArrayList<>(2);

        try (Connection c = connect(node)) {
            try (ResultSet rs = c.getMetaData().getColumns(null, QueryUtils.DFLT_SCHEMA, "Person", null)) {
                for (int j = 0; j < 5; j++) {
                    assertTrue(rs.next());

                    colNames.add(rs.getString("COLUMN_NAME"));

                    try {
                        colTypes.add(Class.forName(DataType.getTypeClassName(DataType
                            .convertSQLTypeToValueType(rs.getInt("DATA_TYPE")))));
                    }
                    catch (ClassNotFoundException e) {
                        throw new AssertionError(e);
                    }
                }

                assertFalse(rs.next());
            }

            try (ResultSet rs = c.getMetaData().getPrimaryKeys(null, QueryUtils.DFLT_SCHEMA, "Person")) {
                for (int j = 0; j < 2; j++) {
                    assertTrue(rs.next());

                    pkColNames.add(rs.getString("COLUMN_NAME"));
                }

                assertFalse(rs.next());
            }
        }

        assertEqualsCollections(F.asList("id", "city", "name", "surname", "age"), colNames);

        assertEqualsCollections(F.<Class<?>>asList(Integer.class, String.class, String.class, String.class,
            Integer.class), colTypes);

        assertEqualsCollections(F.asList("id", "city"), pkColNames);
    }
}
 
Example 12
Source File: CacheContinuousQueryCounterReplicatedAtomicTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 13
Source File: DynamicEnableIndexingAbstractTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** */
protected void checkQueryParallelism(IgniteEx ig, CacheMode cacheMode) {
    int expectedParallelism = cacheMode != CacheMode.REPLICATED ? QUERY_PARALLELISM :
            CacheConfiguration.DFLT_QUERY_PARALLELISM;

    IgniteH2Indexing indexing = (IgniteH2Indexing)ig.context().query().getIndexing();

    SchemaManager schemaMgr = indexing.schemaManager();

    H2TableDescriptor descr = schemaMgr.tableForType(POI_SCHEMA_NAME, POI_CACHE_NAME, POI_CLASS_NAME);

    assertNotNull(descr);

    if (descr.table().getIndex(KEY_PK_IDX_NAME) instanceof H2TreeIndex) {
        H2TreeIndex pkIdx = (H2TreeIndex)descr.table().getIndex(KEY_PK_IDX_NAME);

        assertNotNull(pkIdx);

        assertEquals(expectedParallelism, pkIdx.segmentsCount());
    }

    CacheConfiguration<?, ?> cfg = ig.context().cache().cacheConfiguration(POI_CACHE_NAME);

    assertEquals(expectedParallelism, cfg.getQueryParallelism());
}
 
Example 14
Source File: DynamicIndexReplicatedTransactionalConcurrentSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor.
 */
public DynamicIndexReplicatedTransactionalConcurrentSelfTest() {
    super(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL);
}
 
Example 15
Source File: DynamicColumnsConcurrentTransactionalReplicatedSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor.
 */
public DynamicColumnsConcurrentTransactionalReplicatedSelfTest() {
    super(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL);
}
 
Example 16
Source File: GridCacheContext.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @return {@code True} if cache is replicated cache.
 */
public boolean isReplicated() {
    return config().getCacheMode() == CacheMode.REPLICATED;
}
 
Example 17
Source File: GridCacheReplicatedEvictionEventSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 18
Source File: JdbcThinDynamicIndexTransactionalReplicatedSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 19
Source File: CacheMvccSqlContinuousQueryReplicatedSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}
 
Example 20
Source File: CacheVersionedEntryReplicatedAtomicSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
    return CacheMode.REPLICATED;
}