Search in sources :

Example 1 with CacheAtomicityMode

use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.

the class JmhCacheAbstractBenchmark method cacheConfiguration.

/**
     * Create cache configuration.
     *
     * @return Cache configuration.
     */
protected CacheConfiguration cacheConfiguration() {
    CacheConfiguration cacheCfg = new CacheConfiguration();
    cacheCfg.setName(DEFAULT_CACHE_NAME);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    // Set atomicity mode.
    CacheAtomicityMode atomicityMode = enumProperty(PROP_ATOMICITY_MODE, CacheAtomicityMode.class);
    if (atomicityMode != null)
        cacheCfg.setAtomicityMode(atomicityMode);
    // Set write synchronization mode.
    CacheWriteSynchronizationMode writeSyncMode = enumProperty(PROP_WRITE_SYNC_MODE, CacheWriteSynchronizationMode.class);
    if (writeSyncMode != null)
        cacheCfg.setWriteSynchronizationMode(writeSyncMode);
    // Set backups.
    cacheCfg.setBackups(intProperty(PROP_BACKUPS));
    return cacheCfg;
}
Also used : CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 2 with CacheAtomicityMode

use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.

the class IgniteCacheTxIteratorSelfTest method checkModes.

/**
     * @throws Exception if failed.
     */
public void checkModes(int gridCnt) throws Exception {
    startGrids(gridCnt);
    try {
        for (CacheMode mode : CacheMode.values()) {
            for (CacheAtomicityMode atomMode : CacheAtomicityMode.values()) {
                if (mode == CacheMode.PARTITIONED) {
                    // Near cache makes sense only for partitioned cache.
                    checkTxCache(CacheMode.PARTITIONED, atomMode, true, false);
                }
                checkTxCache(CacheMode.PARTITIONED, atomMode, false, true);
                checkTxCache(CacheMode.PARTITIONED, atomMode, false, false);
            }
        }
    } finally {
        stopAllGrids();
    }
}
Also used : CacheMode(org.apache.ignite.cache.CacheMode) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode)

Example 3 with CacheAtomicityMode

use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.

the class GridSqlQueryParser method processExtraParam.

/**
     * @param name Param name.
     * @param val Param value.
     * @param res Table params to update.
     */
private static void processExtraParam(String name, String val, GridSqlCreateTable res) {
    assert !F.isEmpty(name);
    switch(name) {
        case PARAM_TEMPLATE:
            ensureNotEmpty(name, val);
            res.templateName(val);
            break;
        case PARAM_BACKUPS:
            ensureNotEmpty(name, val);
            int backups = parseIntParam(PARAM_BACKUPS, val);
            if (backups < 0)
                throw new IgniteSQLException("\"" + PARAM_BACKUPS + "\" cannot be negative: " + backups, IgniteQueryErrorCode.PARSING);
            res.backups(backups);
            break;
        case PARAM_ATOMICITY:
            ensureNotEmpty(name, val);
            CacheAtomicityMode mode;
            if (CacheAtomicityMode.TRANSACTIONAL.name().equalsIgnoreCase(val))
                mode = CacheAtomicityMode.TRANSACTIONAL;
            else if (CacheAtomicityMode.ATOMIC.name().equalsIgnoreCase(val))
                mode = CacheAtomicityMode.ATOMIC;
            else
                throw new IgniteSQLException("Invalid value of \"" + PARAM_ATOMICITY + "\" parameter " + "(should be either TRANSACTIONAL or ATOMIC): " + val, IgniteQueryErrorCode.PARSING);
            res.atomicityMode(mode);
            break;
        default:
            throw new IgniteSQLException("Unsupported parameter: " + name, IgniteQueryErrorCode.PARSING);
    }
}
Also used : IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) AlterTableAddConstraint(org.h2.command.ddl.AlterTableAddConstraint)

Example 4 with CacheAtomicityMode

use of org.apache.ignite.cache.CacheAtomicityMode in project ignite by apache.

the class IgniteClientReconnectCacheTest method testReconnectOperationInProgress.

/**
     * @throws Exception If failed.
     */
public void testReconnectOperationInProgress() throws Exception {
    clientMode = true;
    IgniteEx client = startGrid(SRV_CNT);
    client.events().localListen(new IgnitePredicate<Event>() {

        @Override
        public boolean apply(Event evt) {
            if (evt.type() == EVT_CLIENT_NODE_DISCONNECTED)
                info("Client disconnected: " + evt);
            else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED)
                info("Client reconnected: " + evt);
            return true;
        }
    }, EVT_CLIENT_NODE_DISCONNECTED, EVT_CLIENT_NODE_RECONNECTED);
    IgniteInClosure<IgniteCache<Object, Object>> putOp = new CI1<IgniteCache<Object, Object>>() {

        @Override
        public void apply(IgniteCache<Object, Object> cache) {
            cache.put(1, 1);
        }
    };
    IgniteInClosure<IgniteCache<Object, Object>> getOp = new CI1<IgniteCache<Object, Object>>() {

        @Override
        public void apply(IgniteCache<Object, Object> cache) {
            cache.get(1);
        }
    };
    IgniteInClosure<IgniteCache<Object, Object>> getAllOp = new CI1<IgniteCache<Object, Object>>() {

        @Override
        public void apply(IgniteCache<Object, Object> cache) {
            cache.getAll(F.asSet(1, 2));
        }
    };
    int cnt = 0;
    for (CacheAtomicityMode atomicityMode : CacheAtomicityMode.values()) {
        for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
            CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
            ccfg.setAtomicityMode(atomicityMode);
            ccfg.setName("cache-" + cnt++);
            ccfg.setWriteSynchronizationMode(syncMode);
            if (syncMode != FULL_ASYNC) {
                Class<?> cls = (ccfg.getAtomicityMode() == ATOMIC) ? GridNearAtomicUpdateResponse.class : GridNearTxPrepareResponse.class;
                log.info("Test cache put [atomicity=" + atomicityMode + ", syncMode=" + syncMode + ']');
                checkOperationInProgressFails(client, ccfg, cls, putOp);
                client.destroyCache(ccfg.getName());
            }
            log.info("Test cache get [atomicity=" + atomicityMode + ", syncMode=" + syncMode + ']');
            checkOperationInProgressFails(client, ccfg, GridNearSingleGetResponse.class, getOp);
            checkOperationInProgressFails(client, ccfg, GridNearGetResponse.class, getAllOp);
            client.destroyCache(ccfg.getName());
        }
    }
}
Also used : CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) IgniteCache(org.apache.ignite.IgniteCache) CI1(org.apache.ignite.internal.util.typedef.CI1) Event(org.apache.ignite.events.Event) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)4 CacheWriteSynchronizationMode (org.apache.ignite.cache.CacheWriteSynchronizationMode)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteCache (org.apache.ignite.IgniteCache)1 CacheMode (org.apache.ignite.cache.CacheMode)1 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)1 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)1 Event (org.apache.ignite.events.Event)1 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)1 CI1 (org.apache.ignite.internal.util.typedef.CI1)1 AlterTableAddConstraint (org.h2.command.ddl.AlterTableAddConstraint)1