org.apache.ignite.configuration.CacheConfiguration Java Examples

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration. 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: GridCacheGetAndTransformStoreAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setAtomicityMode(atomicityMode());
    cc.setRebalanceMode(SYNC);

    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example #2
Source File: AbstractContinuousQueryRemoteSecurityContextCheckTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Opens query cursor.
 *
 * @param q {@link Query}.
 * @param init True if needing put data to a cache before openning a cursor.
 */
protected void executeQuery(Query<Cache.Entry<Integer, Integer>> q, boolean init) {
    Ignite ignite = localIgnite();

    IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(
        new CacheConfiguration<Integer, Integer>()
            .setName(CACHE_NAME + CACHE_INDEX.incrementAndGet())
            .setCacheMode(CacheMode.PARTITIONED)
    );

    if (init)
        cache.put(primaryKey(grid(SRV_CHECK), cache.getName()), 100);

    try (QueryCursor<Cache.Entry<Integer, Integer>> cur = cache.query(q)) {
        if (!init)
            cache.put(primaryKey(grid(SRV_CHECK), cache.getName()), 100);

        cur.getAll();
    }
}
 
Example #3
Source File: MLPluginProvider.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Starts model descriptor storage.
 */
private void startModelDescriptorStorage(MLPluginConfiguration cfg) {
    CacheConfiguration<String, byte[]> storageCfg = new CacheConfiguration<>();

    storageCfg.setName(ModelDescriptorStorageFactory.MODEL_DESCRIPTOR_STORAGE_CACHE_NAME);
    storageCfg.setCacheMode(CacheMode.PARTITIONED);
    storageCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

    if (cfg.getMdlDescStorageBackups() == null)
        storageCfg.setBackups(MODEL_DESCRIPTOR_STORAGE_DEFAULT_BACKUPS);

    ignite.getOrCreateCache(storageCfg);

    if (log.isInfoEnabled())
        log.info("ML model descriptor storage is ready");
}
 
Example #4
Source File: RunningQueriesTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Check cleanup running queries on node stop.
 *
 * @throws Exception Exception in case of failure.
 */
@Test
public void testCloseRunningQueriesOnNodeStop() throws Exception {
    IgniteEx ign = startGrid(super.getConfiguration("TST"));

    IgniteCache<Integer, Integer> cache = ign.getOrCreateCache(new CacheConfiguration<Integer, Integer>()
        .setName("TST")
        .setQueryEntities(Collections.singletonList(new QueryEntity(Integer.class, Integer.class)))
    );

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

    cache.query(new SqlFieldsQuery("SELECT * FROM Integer order by _key"));

    Assert.assertEquals("Should be one running query",
        1,
        ign.context().query().runningQueries(-1).size());

    ign.close();

    Assert.assertEquals(0, ign.context().query().runningQueries(-1).size());
}
 
Example #5
Source File: GridCachePartitionedNodeFailureSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    c.getTransactionConfiguration().setTxSerializableEnabled(true);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(PARTITIONED);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setBackups(1);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example #6
Source File: CacheGetEntryAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param e Entry.
 * @param cache Cache.
 * @throws Exception If failed.
 */
private void compareVersionWithPrimaryNode(CacheEntry<Integer, ?> e, IgniteCache<Integer, TestValue> cache)
    throws Exception {
    CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);

    if (cfg.getCacheMode() != LOCAL) {
        Ignite prim = primaryNode(e.getKey(), cache.getName());

        GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal)prim).internalCache(cache.getName());

        if (cfg.getNearConfiguration() != null)
            cacheAdapter = ((GridNearCacheAdapter)cacheAdapter).dht();

        IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();

        CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();

        GridCacheEntryEx mapEntry = cacheAdapter.entryEx(cacheObjects.toCacheKeyObject(
            cacheObjCtx, cacheAdapter.context(), e.getKey(), true));

        mapEntry.unswap();

        assertNotNull("No entry for key: " + e.getKey(), mapEntry);
        assertEquals(mapEntry.version(), e.version());
    }
}
 
Example #7
Source File: CacheMvccClientTopologyTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Configure nodes in client mode (filtered by AttributeNodeFilter, no CacheConfiguration is set)
 * or in ordinary server mode.
 */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    if (getTestIgniteInstanceIndex(igniteInstanceName) != clientModeIdx) {
        String attrName = "has_cache";
        Object attrVal = Boolean.TRUE;

        CacheConfiguration ccfg = defaultCacheConfiguration()
            .setNearConfiguration(null)
            .setNodeFilter(new AttributeNodeFilter(attrName, attrVal))
            .setAtomicityMode(TRANSACTIONAL_SNAPSHOT);

        return cfg
            .setCacheConfiguration(ccfg)
            .setUserAttributes(F.asMap(attrName, attrVal));
    }

    return cfg;
}
 
Example #8
Source File: CacheMvccAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cacheMode Cache mode.
 * @param syncMode Write synchronization mode.
 * @param backups Number of backups.
 * @param parts Number of partitions.
 * @return Cache configuration.
 */
final CacheConfiguration<Object, Object> cacheConfiguration(
    CacheMode cacheMode,
    CacheWriteSynchronizationMode syncMode,
    int backups,
    int parts) {
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(cacheMode);
    ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
    ccfg.setWriteSynchronizationMode(syncMode);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, parts));

    if (cacheMode == PARTITIONED)
        ccfg.setBackups(backups);

    return ccfg;
}
 
Example #9
Source File: IgniteCacheContinuousQueryBackupQueueTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME);

    ccfg.setCacheMode(PARTITIONED);
    ccfg.setAtomicityMode(ATOMIC);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setBackups(1);

    cfg.setCacheConfiguration(ccfg);

    DataStorageConfiguration memCfg = new DataStorageConfiguration();
    memCfg.setPageSize(16 * 1024);

    cfg.setDataStorageConfiguration(memCfg);

    return cfg;
}
 
Example #10
Source File: IgniteBinaryObjectQueryArgumentsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Cache configurations.
 */
private CacheConfiguration[] getCacheConfigurations() {
    final ArrayList<CacheConfiguration> ccfgs = new ArrayList<>();

    ccfgs.add(getCacheConfiguration(OBJECT_CACHE));
    ccfgs.addAll(getCacheConfigurations(STR_CACHE, String.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(PRIM_CACHE, Integer.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(ENUM_CACHE, EnumKey.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(UUID_CACHE, UUID.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(DATE_CACHE, Date.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(TIMESTAMP_CACHE, Timestamp.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(BIG_DECIMAL_CACHE, BigDecimal.class, Person.class));
    ccfgs.add(getCacheConfiguration(FIELD_CACHE, Integer.class, SearchValue.class));

    return ccfgs.toArray(new CacheConfiguration[ccfgs.size()]);
}
 
Example #11
Source File: GridCacheUtils.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Create system cache used by Hadoop component.
 *
 * @return Hadoop cache configuration.
 */
public static CacheConfiguration hadoopSystemCache() {
    CacheConfiguration cache = new CacheConfiguration();

    cache.setName(CU.SYS_CACHE_HADOOP_MR);
    cache.setCacheMode(REPLICATED);
    cache.setAtomicityMode(TRANSACTIONAL);
    cache.setWriteSynchronizationMode(FULL_SYNC);

    cache.setEvictionPolicyFactory(null);
    cache.setEvictionPolicy(null);
    cache.setCacheStoreFactory(null);
    cache.setNodeFilter(CacheConfiguration.ALL_NODES);
    cache.setEagerTtl(true);
    cache.setRebalanceMode(SYNC);

    return cache;
}
 
Example #12
Source File: CacheSerializableTransactionsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cache Cache.
 * @return Test keys.
 * @throws Exception If failed.
 */
private List<Integer> testKeys(IgniteCache<Integer, Integer> cache) throws Exception {
    CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);

    List<Integer> keys = new ArrayList<>();

    if (!cache.unwrap(Ignite.class).configuration().isClientMode()) {
        if (ccfg.getCacheMode() == PARTITIONED)
            keys.add(nearKey(cache));

        keys.add(primaryKey(cache));

        if (ccfg.getBackups() != 0)
            keys.add(backupKey(cache));
    }
    else
        keys.add(nearKey(cache));

    return keys;
}
 
Example #13
Source File: IgniteCacheLargeResultSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setBackups(1);
    cacheCfg.setIndexedTypes(
        Integer.class, Integer.class
    );

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example #14
Source File: FilePageStoreManager.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param grpDesc Cache group descriptor.
 * @param ccfg Cache configuration.
 * @return Cache store holder.
 * @throws IgniteCheckedException If failed.
 */
private CacheStoreHolder initForCache(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) throws IgniteCheckedException {
    assert !grpDesc.sharedGroup() || ccfg.getGroupName() != null : ccfg.getName();

    File cacheWorkDir = cacheWorkDir(ccfg);

    String dataRegionName = grpDesc.config().getDataRegionName();

    DataRegionMetricsImpl regionMetrics = cctx.database().dataRegion(dataRegionName).memoryMetrics();

    LongAdderMetric allocatedTracker =
        regionMetrics.getOrAllocateGroupPageAllocationTracker(grpDesc.cacheOrGroupName());

    return initDir(
        cacheWorkDir,
        grpDesc.groupId(),
        grpDesc.config().getAffinity().partitions(),
        allocatedTracker,
        ccfg.isEncryptionEnabled()
    );
}
 
Example #15
Source File: IgniteCacheSizeFailoverTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(PARTITIONED);
    ccfg.setAtomicityMode(ATOMIC);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setBackups(1);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example #16
Source File: IgniteDbPutGetWithCacheStoreTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    DataStorageConfiguration dbCfg = new DataStorageConfiguration();

    dbCfg
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(512L * 1024 * 1024)
                .setPersistenceEnabled(true))
        .setWalMode(WALMode.LOG_ONLY);

    cfg.setDataStorageConfiguration(dbCfg);

    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(CACHE_NAME)
        .setCacheStoreFactory(new IgniteReflectionFactory<>(TestStore.class))
        .setAtomicityMode(atomicityMode)
        .setBackups(1)
        .setWriteThrough(true)
        .setReadThrough(true);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example #17
Source File: DhtAndNearEvictionTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Checking rebalancing which used to be affected by IGNITE-9315.
 */
@Test
public void testRebalancing() throws Exception {
    Ignite grid0 = startGrid(0);

    CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<Integer, Integer>("mycache")
        .setOnheapCacheEnabled(true)
        .setEvictionPolicyFactory(new LruEvictionPolicyFactory<>(500))
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
        .setNearConfiguration(
            new NearCacheConfiguration<Integer, Integer>()
                .setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(100))
        );

    IgniteCache<Integer, Integer> cache = grid0.createCache(ccfg);

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

    startGrid(1);

    awaitPartitionMapExchange(true, true, null);

    assertFalse(strLog.toString().contains("AssertionError"));
}
 
Example #18
Source File: IgniteSqlSchemaIndexingTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Tests collision for case insensitive sqlScheme.
 *
 * @throws Exception If failed.
 */
@Ignore("https://issues.apache.org/jira/browse/IGNITE-10723")
@Test
public void testCaseSensitive() throws Exception {
    //TODO rewrite with dynamic cache creation, and GRID start in #beforeTest after resolve of
    //TODO IGNITE-1094
    GridTestUtils.assertThrows(log, new Callable<Object>() {
        @Override public Object call() throws Exception {
            final CacheConfiguration cfg = cacheConfig("InSensitiveCache", true, Integer.class, Integer.class)
                .setSqlSchema("InsensitiveCache");

            final CacheConfiguration collisionCfg = cacheConfig("InsensitiveCache", true, Integer.class, Integer.class)
                .setSqlSchema("Insensitivecache");

            IgniteConfiguration icfg = new IgniteConfiguration()
                .setLocalHost("127.0.0.1")
                .setCacheConfiguration(cfg, collisionCfg);

            Ignition.start(icfg);

            return null;
        }
    }, IgniteException.class, "Duplicate index name");
}
 
Example #19
Source File: SqlStatisticsAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Start the cache with a test table and test data.
 */
protected IgniteCache createCacheFrom(Ignite node) {
    CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<Integer, String>(DEFAULT_CACHE_NAME)
        .setSqlFunctionClasses(SuspendQuerySqlFunctions.class)
        .setQueryEntities(Collections.singleton(
            new QueryEntity(Integer.class.getName(), String.class.getName())
                .setTableName("TAB")
                .addQueryField("id", Integer.class.getName(), null)
                .addQueryField("name", String.class.getName(), null)
                .setKeyFieldName("id")
                .setValueFieldName("name")
        ));

    IgniteCache<Integer, String> cache = node.createCache(ccfg);

    try (IgniteDataStreamer<Object, Object> ds = node.dataStreamer(DEFAULT_CACHE_NAME)) {
        for (int i = 0; i < TABLE_SIZE; i++)
            ds.addData(i, UUID.randomUUID().toString());
    }

    return cache;
}
 
Example #20
Source File: AlertMonitoring.java    From ignite-book-code-samples with GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Mark this cluster member as client.
    Ignition.setClientMode(true);

    try (Ignite ignite = Ignition.start("example-ignite.xml")) {
        if (!ExamplesUtils.hasServerNodes(ignite))
            return;

        CacheConfiguration<String, Alert> alert_Cfg = new CacheConfiguration<>("alerts");
        IgniteCache<String, Alert> instCache = ignite.getOrCreateCache(alert_Cfg);

        SqlFieldsQuery top3qry = new SqlFieldsQuery(QUERY_RED);
        while(true){
            // Execute queries.
            List<List<?>> top3 = instCache.query(top3qry).getAll();

            System.out.println("Service Health Monitoring");

            ExamplesUtils.printQueryResults(top3);

            Thread.sleep(1000);
        }

    }
}
 
Example #21
Source File: SqlQueriesTopologyMappingTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
private void checkQueryWithNodeFilter(CacheMode cacheMode) throws Exception {
    IgniteEx ign0 = startGrid(0);
    String name0 = ign0.name();

    IgniteCache<Object, Object> cache = ign0.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
        .setCacheMode(cacheMode)
        .setNodeFilter(node -> name0.equals(node.attribute(ATTR_IGNITE_INSTANCE_NAME)))
        .setIndexedTypes(Integer.class, Integer.class));

    cache.put(1, 2);

    startGrid(1);
    startClientGrid(10);

    for (Ignite ign : G.allGrids()) {
        List<List<?>> res = ign.cache(DEFAULT_CACHE_NAME)
            .query(new SqlFieldsQuery("select * from Integer")).getAll();

        assertEquals(1, res.size());
        assertEqualsCollections(Arrays.asList(1, 2), res.get(0));
    }
}
 
Example #22
Source File: GridLocalConfigManager.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Validates cache configuration against stored cache configuration when persistence is enabled.
 *
 * @param cfg Configured cache configuration.
 * @param cfgFromStore Stored cache configuration
 * @throws IgniteCheckedException If validation failed.
 */
private void validateCacheConfigurationOnRestore(CacheConfiguration cfg, CacheConfiguration cfgFromStore)
    throws IgniteCheckedException {
    assert cfg != null && cfgFromStore != null;

    if ((cfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT ||
        cfgFromStore.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT)
        && cfg.getAtomicityMode() != cfgFromStore.getAtomicityMode()) {
        throw new IgniteCheckedException("Cannot start cache. Statically configured atomicity mode differs from " +
            "previously stored configuration. Please check your configuration: [cacheName=" + cfg.getName() +
            ", configuredAtomicityMode=" + cfg.getAtomicityMode() +
            ", storedAtomicityMode=" + cfgFromStore.getAtomicityMode() + "]");
    }

    boolean staticCfgVal = cfg.isEncryptionEnabled();

    boolean storedVal = cfgFromStore.isEncryptionEnabled();

    if (storedVal != staticCfgVal) {
        throw new IgniteCheckedException("Encrypted flag value differs. Static config value is '" + staticCfgVal +
            "' and value stored on the disk is '" + storedVal + "'");
    }
}
 
Example #23
Source File: CompressionConfigurationTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String instanceName) throws Exception {
    CacheConfiguration<Object,Object> ccfg1 = new CacheConfiguration<>("cache1");

    ccfg1.setDiskPageCompression(compression1);
    ccfg1.setDiskPageCompressionLevel(level1);
    ccfg1.setGroupName("myGroup");

    CacheConfiguration<Object,Object> ccfg2 = new CacheConfiguration<>("cache2");

    ccfg2.setDiskPageCompression(compression2);
    ccfg2.setDiskPageCompressionLevel(level2);
    ccfg2.setGroupName("myGroup");

    return super.getConfiguration(instanceName).setCacheConfiguration(ccfg1, ccfg2);
}
 
Example #24
Source File: NormalizationExample.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
    CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();

    cacheConfiguration.setName("PERSONS");
    cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));

    IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);

    persons.put(1, new DenseVector(new Serializable[] {"Mike", 10, 20}));
    persons.put(2, new DenseVector(new Serializable[] {"John", 20, 10}));
    persons.put(3, new DenseVector(new Serializable[] {"George", 30, 0}));
    persons.put(4, new DenseVector(new Serializable[] {"Karl", 25, 15}));

    return persons;
}
 
Example #25
Source File: JdbcThinPartitionAwarenessSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Check that client side partition awareness optimizations are skipped by default.
 *
 * @throws Exception If failed.
 */
@Test
public void testPartitionAwarenessIsSkippedByDefault() throws Exception {
    try (Connection conn = DriverManager.getConnection(
        "jdbc:ignite:thin://127.0.0.1:10800..10802");
         Statement stmt = conn.createStatement()) {

        final String cacheName = "yacccc";

        CacheConfiguration<Object, Object> cache = prepareCacheConfig(cacheName);

        ignite(0).createCache(cache);

        stmt.executeQuery("select * from \"" + cacheName + "\".Person where _key = 1");

        AffinityCache affinityCache = GridTestUtils.getFieldValue(conn, "affinityCache");

        assertNull("Affinity cache is not null.", affinityCache);
    }
}
 
Example #26
Source File: GridCachePartitionedMultiNodeWithGroupFullApiSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setGroupName("group1");

    return ccfg;
}
 
Example #27
Source File: NearCacheMultithreadedUpdateTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param atomicityMode Cache atomicity mode.
 * @return Cache configuration.
 */
private CacheConfiguration<Integer, Integer> cacheConfiguration(CacheAtomicityMode atomicityMode) {
    CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setBackups(1);

    return ccfg;
}
 
Example #28
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 #29
Source File: CacheContinuousQueryOrderingEventTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testTxOnheapAsyncFullSync() throws Exception {
    CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL, FULL_SYNC);

    doOrderingTest(ccfg, true);
}
 
Example #30
Source File: PageMemoryLazyAllocationTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
private void createCacheAndPut(IgniteEx g, CacheMode cacheMode, IgnitePredicate<ClusterNode> fltr) {
    IgniteCache<Integer, String> cache =
        g.createCache(new CacheConfiguration<Integer, String>("my-cache-2")
            .setCacheMode(cacheMode)
            .setDataRegionName(LAZY_REGION)
            .setNodeFilter(fltr));

    cache.put(1, "test");

    assertEquals(cache.get(1), "test");
}