Merge remote-tracking branch 'remotes/origin/sprint-1' into ignite-56

Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/186c621b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/186c621b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/186c621b

Branch: refs/heads/ignite-111
Commit: 186c621b1c3b25d41496863539cbd7a94750b369
Parents: d2382f4 1244764
Author: sevdokimov <sevdoki...@gridgain.com>
Authored: Fri Feb 6 12:48:17 2015 +0300
Committer: sevdokimov <sevdoki...@gridgain.com>
Committed: Fri Feb 6 12:48:17 2015 +0300

----------------------------------------------------------------------
 .../MessagingPingPongListenActorExample.java    |    4 +-
 .../java/org/apache/ignite/IgniteCache.java     |   22 -
 .../java/org/apache/ignite/IgniteQueue.java     |    4 +-
 .../main/java/org/apache/ignite/IgniteSet.java  |    2 +-
 .../ignite/cache/eviction/EvictableEntry.java   |    2 +-
 .../store/jdbc/CacheAbstractJdbcStore.java      | 1567 ++++++++++++++++++
 .../cache/store/jdbc/CacheJdbcPojoStore.java    |  205 +++
 .../ignite/cache/store/jdbc/JdbcCacheStore.java | 1560 -----------------
 .../cache/store/jdbc/JdbcPojoCacheStore.java    |  205 ---
 .../processors/cache/IgniteCacheProxy.java      |    6 -
 .../GridDistributedCacheAdapter.java            |   46 +-
 .../processors/rest/GridRestProcessor.java      |    2 +
 .../IgniteOptimizedObjectInputStream.java       |    2 +
 .../ignite/messaging/MessagingListenActor.java  |   18 +-
 .../core/src/test/config/store/jdbc/Ignite.xml  |   50 +
 ...ractJdbcCacheStoreMultithreadedSelfTest.java |  196 ---
 .../CacheJdbcPojoStoreMultitreadedSelfTest.java |   35 +
 .../store/jdbc/CacheJdbcPojoStoreTest.java      |  759 +++++++++
 ...eJdbcStoreAbstractMultithreadedSelfTest.java |  275 +++
 .../PojoJdbcCacheStoreMultitreadedSelfTest.java |   34 -
 .../store/jdbc/PojoJdbcCacheStoreTest.java      |  702 --------
 .../store/jdbc/model/PersonComplexKey.java      |  146 ++
 .../internal/GridListenActorSelfTest.java       |   11 +-
 .../ignite/testsuites/IgniteCacheTestSuite.java |    2 +
 .../schema/load/AbstractSchemaLoaderTest.java   |    4 +-
 .../commands/open/VisorOpenCommandSpec.scala    |    6 +-
 .../yardstick/config/benchmark-store.properties |   35 +-
 .../yardstick/config/ignite-store-config.xml    |   11 +-
 .../jdbc/IgniteJdbcStoreAbstractBenchmark.java  |   89 +-
 .../store/jdbc/IgniteJdbcStoreGetBenchmark.java |   10 +-
 .../jdbc/IgniteJdbcStoreGetTxBenchmark.java     |   47 +
 .../store/jdbc/IgniteJdbcStorePutBenchmark.java |    5 +
 .../jdbc/IgniteJdbcStorePutGetBenchmark.java    |    5 +
 .../jdbc/IgniteJdbcStorePutGetTxBenchmark.java  |   52 +
 .../jdbc/IgniteJdbcStorePutTxBenchmark.java     |   47 +
 35 files changed, 3354 insertions(+), 2812 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/186c621b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
index 0000000,d1424c4..6f58679
mode 000000,100644..100644
--- 
a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
@@@ -1,0 -1,275 +1,275 @@@
+ /*
+  * 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.cache.store.jdbc;
+ 
+ import org.apache.ignite.*;
+ import org.apache.ignite.cache.*;
+ import org.apache.ignite.cache.store.jdbc.model.*;
+ import org.apache.ignite.configuration.*;
+ import org.apache.ignite.internal.*;
+ import org.apache.ignite.internal.util.typedef.*;
+ import org.apache.ignite.internal.util.typedef.internal.*;
+ import org.apache.ignite.spi.discovery.tcp.*;
+ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+ import org.apache.ignite.testframework.junits.common.*;
+ import org.apache.ignite.transactions.*;
+ import org.jetbrains.annotations.*;
+ import org.springframework.beans.*;
+ import org.springframework.beans.factory.xml.*;
+ import org.springframework.context.support.*;
+ import org.springframework.core.io.*;
+ 
+ import javax.cache.configuration.*;
+ import java.io.*;
+ import java.net.*;
+ import java.sql.*;
+ import java.util.*;
+ import java.util.concurrent.*;
+ 
+ import static org.apache.ignite.cache.CacheAtomicityMode.*;
+ import static org.apache.ignite.cache.CacheMode.*;
+ import static org.apache.ignite.testframework.GridTestUtils.*;
+ 
+ /**
+  *
+  */
+ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends 
CacheAbstractJdbcStore>
+     extends GridCommonAbstractTest {
+     /** Database connection URL. */
+     protected static final String DFLT_CONN_URL = 
"jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1";
+ 
+     /** IP finder. */
+     protected static final TcpDiscoveryIpFinder IP_FINDER = new 
TcpDiscoveryVmIpFinder(true);
+ 
+     /** Number of transactions. */
+     private static final int TX_CNT = 200;
+ 
+     /** Number of transactions. */
+     private static final int BATCH_CNT = 2000;
+ 
+     /** Cache store. */
+     protected static CacheAbstractJdbcStore store;
+ 
+     /** {@inheritDoc} */
+     @Override protected void beforeTestsStarted() throws Exception {
+         store = store();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void beforeTest() throws Exception {
+         Connection conn = DriverManager.getConnection(DFLT_CONN_URL, "sa", 
"");
+ 
+         Statement stmt = conn.createStatement();
+ 
+         stmt.executeUpdate("DROP TABLE IF EXISTS Organization");
+         stmt.executeUpdate("DROP TABLE IF EXISTS Person");
+ 
+         stmt.executeUpdate("CREATE TABLE Organization (id integer PRIMARY 
KEY, name varchar(50), city varchar(50))");
+         stmt.executeUpdate("CREATE TABLE Person (id integer PRIMARY KEY, 
org_id integer, name varchar(50))");
+ 
+         conn.commit();
+ 
+         U.closeQuiet(stmt);
+ 
+         U.closeQuiet(conn);
+ 
+         startGrid();
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void afterTest() throws Exception {
+         stopAllGrids();
+     }
+ 
+     /**
+      * @return New store.
+      * @throws Exception In case of error.
+      */
+     protected abstract T store() throws Exception;
+ 
+     /** {@inheritDoc} */
+     @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+         IgniteConfiguration c = super.getConfiguration(gridName);
+ 
+         TcpDiscoverySpi disco = new TcpDiscoverySpi();
+ 
+         disco.setIpFinder(IP_FINDER);
+ 
+         c.setDiscoverySpi(disco);
+ 
+         CacheConfiguration cc = defaultCacheConfiguration();
+ 
+         cc.setCacheMode(PARTITIONED);
+         cc.setAtomicityMode(ATOMIC);
+         cc.setSwapEnabled(false);
+         cc.setWriteBehindEnabled(false);
+ 
+         UrlResource metaUrl;
+ 
+         try {
+             metaUrl = new UrlResource(new 
File("modules/core/src/test/config/store/jdbc/Ignite.xml").toURI().toURL());
+         }
+         catch (MalformedURLException e) {
+             throw new IgniteCheckedException("Failed to resolve metadata path 
[err=" + e.getMessage() + ']', e);
+         }
+ 
+         try {
+             GenericApplicationContext springCtx = new 
GenericApplicationContext();
+ 
+             new 
XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(metaUrl);
+ 
+             springCtx.refresh();
+ 
+             Collection<CacheTypeMetadata> tp = 
springCtx.getBeansOfType(CacheTypeMetadata.class).values();
+ 
+             cc.setTypeMetadata(tp);
+         }
+         catch (BeansException e) {
+             if (X.hasCause(e, ClassNotFoundException.class))
+                 throw new IgniteCheckedException("Failed to instantiate 
Spring XML application context " +
+                     "(make sure all classes used in Spring configuration are 
present at CLASSPATH) " +
+                     "[springUrl=" + metaUrl + ']', e);
+             else
+                 throw new IgniteCheckedException("Failed to instantiate 
Spring XML application context [springUrl=" +
+                     metaUrl + ", err=" + e.getMessage() + ']', e);
+         }
+ 
+         cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+         cc.setReadThrough(true);
+         cc.setWriteThrough(true);
+         cc.setLoadPreviousValue(true);
+ 
+         c.setCacheConfiguration(cc);
+ 
+         return c;
+     }
+ 
+     /**
+      * @throws Exception If failed.
+      */
+     public void testMultithreadedPut() throws Exception {
+         IgniteInternalFuture<?> fut1 = runMultiThreadedAsync(new 
Callable<Object>() {
+             private final Random rnd = new Random();
+ 
+             @Override public Object call() throws Exception {
+                 for (int i = 0; i < TX_CNT; i++) {
+                     GridCache<Object, Object> cache = cache();
+ 
+                     int id = rnd.nextInt(1000);
+ 
+                     if (rnd.nextBoolean())
+                         cache.put(new OrganizationKey(id), new 
Organization(id, "Name" + id, "City" + id));
+                     else
+                         cache.put(new PersonKey(id), new Person(id, 
rnd.nextInt(), "Name" + id));
+                 }
+ 
+                 return null;
+             }
+         }, 4, "put");
+ 
+         IgniteInternalFuture<?> fut2 = runMultiThreadedAsync(new 
Callable<Object>() {
+             private final Random rnd = new Random();
+ 
+             @Override public Object call() throws Exception {
+                 for (int i = 0; i < TX_CNT; i++) {
+                     GridCache<Object, Object> cache = cache();
+ 
+                     int id = rnd.nextInt(1000);
+ 
+                     if (rnd.nextBoolean())
+                         cache.putIfAbsent(new OrganizationKey(id), new 
Organization(id, "Name" + id, "City" + id));
+                     else
+                         cache.putIfAbsent(new PersonKey(id), new Person(id, 
rnd.nextInt(), "Name" + id));
+                 }
+ 
+                 return null;
+             }
+         }, 8, "putIfAbsent");
+ 
+         fut1.get();
+         fut2.get();
+     }
+ 
+     /**
+      * @throws Exception If failed.
+      */
+     public void testMultithreadedPutAll() throws Exception {
+         multithreaded(new Callable<Object>() {
+             private final Random rnd = new Random();
+ 
+             @Nullable @Override public Object call() throws Exception {
+                 for (int i = 0; i < TX_CNT; i++) {
+                     int cnt = rnd.nextInt(BATCH_CNT);
+ 
+                     Map<Object, Object> map = U.newHashMap(cnt);
+ 
+                     for (int j = 0; j < cnt; j++) {
+                         int id = rnd.nextInt();
+ 
+                         if (rnd.nextBoolean())
+                             map.put(new OrganizationKey(id), new 
Organization(id, "Name" + id, "City" + id));
+                         else
+                             map.put(new PersonKey(id), new Person(id, 
rnd.nextInt(), "Name" + id));
+                     }
+ 
 -                    GridCache<Object, Object> cache = cache();
++                    IgniteCache<Object, Object> cache = jcache();
+ 
+                     cache.putAll(map);
+                 }
+ 
+                 return null;
+             }
+         }, 8, "putAll");
+     }
+ 
+     /**
+      * @throws Exception If failed.
+      */
+     public void testMultithreadedExplicitTx() throws Exception {
+         runMultiThreaded(new Callable<Object>() {
+             private final Random rnd = new Random();
+ 
+             @Override public Object call() throws Exception {
+                 for (int i = 0; i < TX_CNT; i++) {
+                     GridCache<PersonKey, Person> cache = cache();
+ 
+                     try (IgniteTx tx = cache.txStart()) {
+                         cache.put(new PersonKey(1), new Person(1, 
rnd.nextInt(), "Name" + 1));
+                         cache.put(new PersonKey(2), new Person(2, 
rnd.nextInt(), "Name" + 2));
+                         cache.put(new PersonKey(3), new Person(3, 
rnd.nextInt(), "Name" + 3));
+ 
+                         cache.get(new PersonKey(1));
+                         cache.get(new PersonKey(4));
+ 
+                         Map<PersonKey, Person> map =  U.newHashMap(2);
+ 
+                         map.put(new PersonKey(5), new Person(5, 
rnd.nextInt(), "Name" + 5));
+                         map.put(new PersonKey(6), new Person(6, 
rnd.nextInt(), "Name" + 6));
+ 
+                         cache.putAll(map);
+ 
+                         tx.commit();
+                     }
+                 }
+ 
+                 return null;
+             }
+         }, 8, "tx");
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/186c621b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------

Reply via email to