/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.ignite.internal.processors.cache.mvcc; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.transactions.Transaction; import org.junit.Test; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; /** * */ public class CacheMvccSqlTxModesTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return PARTITIONED; } /** * @throws Exception If failed */ @Test public void testConsequentMvccNonMvccOperations() throws Exception { IgniteEx node = startGrid(0); IgniteCache dummy = node.createCache(new CacheConfiguration<>("dummy")); dummy.query(new SqlFieldsQuery("create table person (id int primary key, firstName varchar) " + "with \"atomicity=transactional_snapshot,cache_name=Person\"")).getAll(); dummy.query(new SqlFieldsQuery("create table person_nonMvcc (id int primary key, firstName varchar) " + "with \"atomicity=transactional,cache_name=Person_nonMvcc\"")).getAll(); IgniteCache nonMvccCache = node.cache("Person_nonMvcc").withKeepBinary(); IgniteCache mvccCache = node.cache("Person").withKeepBinary(); nonMvccCache.query(new SqlFieldsQuery("INSERT INTO person_nonMvcc (id, firstName) VALUES (1, 'a')")).getAll(); mvccCache.query(new SqlFieldsQuery("INSERT INTO Person (id, firstName) VALUES (1, 'a')")).getAll(); try (Transaction tx = node.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) { mvccCache.query(new SqlFieldsQuery("SELECT * FROM Person_nonMvcc")/*.setLocal(true)*/).getAll(); tx.commit(); } } }