You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/12/07 18:13:09 UTC

[1/2] ignite git commit: IGNITE-2050 - Remove duplicates from the configuration.

Repository: ignite
Updated Branches:
  refs/heads/ignite-2050 [created] c0caf7749


IGNITE-2050 - Remove duplicates from the configuration.


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

Branch: refs/heads/ignite-2050
Commit: 2bc901bc3dcf54c88cfdbf8bc1131ef9b4bafe85
Parents: ad9e4db
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Dec 3 15:13:38 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Dec 3 15:13:38 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |  34 ++++-
 ...cheDuplicateEntityConfigurationSelfTest.java | 126 +++++++++++++++++++
 .../IgniteCacheQuerySelfTestSuite.java          |   4 +
 3 files changed, 159 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2bc901bc/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 034d20d..af3530a 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -1872,7 +1872,20 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
 
             TypeDescriptor desc = processKeyAndValueClasses(keyCls, valCls);
 
-            qryEntities.add(convert(desc));
+            QueryEntity converted = convert(desc);
+
+            boolean dup = false;
+
+            for (QueryEntity entity : qryEntities) {
+                if (F.eq(entity.getValueType(), converted.getValueType())) {
+                    dup = true;
+
+                    break;
+                }
+            }
+
+            if (!dup)
+                qryEntities.add(converted);
         }
 
         return this;
@@ -1968,10 +1981,21 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     public CacheConfiguration<K, V> setQueryEntities(Collection<QueryEntity> qryEntities) {
         if (this.qryEntities == null)
             this.qryEntities = new ArrayList<>(qryEntities);
-        else if (indexedTypes != null)
-            this.qryEntities.addAll(qryEntities);
-        else
-            throw new CacheException("Query entities can be set only once.");
+
+        for (QueryEntity entity : qryEntities) {
+            boolean found = false;
+
+            for (QueryEntity existing : this.qryEntities) {
+                if (F.eq(entity.getValueType(), existing.getValueType())) {
+                    found = true;
+
+                    break;
+                }
+            }
+
+            if (!found)
+                this.qryEntities.add(entity);
+        }
 
         return this;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/2bc901bc/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java
new file mode 100644
index 0000000..8311213
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class IgniteCacheDuplicateEntityConfigurationSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration c = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(ipFinder);
+
+        c.setDiscoverySpi(disco);
+
+        return c;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrid(0);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClassDuplicatesQueryEntity() throws Exception {
+        String cacheName = "duplicate";
+
+        CacheConfiguration ccfg = new CacheConfiguration(cacheName);
+
+        ccfg.setIndexedTypes(Integer.class, Person.class);
+
+        QueryEntity entity = new QueryEntity();
+
+        entity.setKeyType(Integer.class.getName());
+        entity.setValueType(Person.class.getName());
+
+        LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+        fields.put("name", String.class.getName());
+
+        entity.setFields(fields);
+
+        ccfg.setQueryEntities(Arrays.asList(entity));
+
+        try {
+            ignite(0).getOrCreateCache(ccfg);
+        }
+        finally {
+            ignite(0).destroyCache(cacheName);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClassDuplicatesQueryReverse() throws Exception {
+        String cacheName = "duplicate";
+
+        CacheConfiguration ccfg = new CacheConfiguration(cacheName);
+
+        QueryEntity entity = new QueryEntity();
+
+        entity.setKeyType(Integer.class.getName());
+        entity.setValueType(Person.class.getName());
+
+        LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+        fields.put("name", String.class.getName());
+
+        entity.setFields(fields);
+
+        ccfg.setQueryEntities(Arrays.asList(entity));
+
+        ccfg.setIndexedTypes(Integer.class, Person.class);
+
+        try {
+            ignite(0).getOrCreateCache(ccfg);
+        }
+        finally {
+            ignite(0).destroyCache(cacheName);
+        }
+    }
+
+    private static class Person {
+        @QuerySqlField
+        private String name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2bc901bc/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 8311414..fc88c75 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSel
 import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheReduceQueryMultithreadedSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityConfigurationSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheLargeResultSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheNoClassQuerySelfTest;
@@ -111,6 +112,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         // Parsing
         suite.addTestSuite(GridQueryParsingTest.class);
 
+        // Config.
+        suite.addTestSuite(IgniteCacheDuplicateEntityConfigurationSelfTest.class);
+
         // Queries tests.
         suite.addTestSuite(IgniteSqlSplitterSelfTest.class);
         suite.addTestSuite(GridCacheQueryIndexDisabledSelfTest.class);


[2/2] ignite git commit: Merge branch 'ignite-1.5' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-2050

Posted by ag...@apache.org.
Merge branch 'ignite-1.5' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-2050


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

Branch: refs/heads/ignite-2050
Commit: c0caf77492fcb4edc2f167a750866b3f798f57da
Parents: 2bc901b 9a14d64
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Dec 7 18:43:56 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Dec 7 18:43:56 2015 +0300

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |   1 +
 examples/config/example-default.xml             |   7 +
 examples/pom.xml                                |   2 +-
 examples/schema-import/pom.xml                  |   2 +-
 .../store/auto/CacheBinaryAutoStoreExample.java | 158 ++++++
 .../datagrid/store/auto/package-info.java       |  22 +
 .../store/auto/CacheAutoStoreExample.java       |  93 +++-
 .../auto/CacheAutoStoreLoadDataExample.java     |  85 ----
 .../datagrid/store/auto/CacheConfig.java        |  81 ---
 .../datagrid/store/auto/DbH2ServerStartup.java  |  79 ---
 .../ignite/examples/util/DbH2ServerStartup.java |  79 +++
 .../ignite/examples/util/package-info.java      |  22 +
 modules/aop/pom.xml                             |  12 +-
 modules/aws/pom.xml                             |  18 +-
 modules/camel/pom.xml                           |  11 +-
 modules/core/pom.xml                            |  28 +-
 .../store/jdbc/CacheAbstractJdbcStore.java      |  12 +-
 .../cache/store/jdbc/CacheJdbcPojoStore.java    |   9 +
 .../ignite/internal/MarshallerContextImpl.java  |   7 +-
 .../internal/portable/BinaryReaderExImpl.java   |   2 +-
 .../internal/portable/PortableContext.java      |  34 +-
 .../processors/cache/GridCacheContext.java      |  30 ++
 .../processors/cache/GridCacheIoManager.java    |   2 +-
 .../CacheDataStructuresManager.java             |  31 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |  51 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  20 +-
 .../dht/preloader/GridDhtPartitionDemander.java |   2 +-
 .../GridDhtPartitionsExchangeFuture.java        |   9 +-
 .../CacheObjectBinaryProcessorImpl.java         |   8 +
 .../cache/query/GridCacheQueryManager.java      |  12 +-
 .../cache/transactions/IgniteTxAdapter.java     |   5 +
 .../cache/transactions/IgniteTxEntry.java       |   8 +-
 .../transactions/IgniteTxLocalAdapter.java      |  11 +-
 .../datastructures/CollocatedQueueItemKey.java  |  75 +++
 .../datastructures/CollocatedSetItemKey.java    |  87 ++++
 .../datastructures/DataStructuresProcessor.java |   7 +-
 .../GridAtomicCacheQueueImpl.java               |   8 +-
 .../datastructures/GridCacheQueueAdapter.java   |  30 +-
 .../datastructures/GridCacheQueueItemKey.java   |   9 +-
 .../datastructures/GridCacheSetImpl.java        |  37 +-
 .../datastructures/GridCacheSetItemKey.java     |  21 +-
 .../GridTransactionalCacheQueueImpl.java        |   2 +-
 .../processors/datastructures/QueueItemKey.java |  27 +
 .../processors/datastructures/SetItemKey.java   |  36 ++
 .../handlers/query/QueryCommandHandler.java     |   6 +-
 ...eAtomicEntryProcessorDeploymentSelfTest.java |   6 +-
 .../IgniteCacheEntryProcessorCallTest.java      | 497 +++++++++++++++++++
 .../cache/IgniteCacheInvokeAbstractTest.java    | 369 ++++++++++----
 ...eAbstractDataStructuresFailoverSelfTest.java |   7 +-
 .../GridCacheQueueApiSelfAbstractTest.java      |  18 +-
 .../GridCacheSetFailoverAbstractSelfTest.java   |   6 +-
 .../GridCachePartitionedQueueApiSelfTest.java   |   5 +
 ...dCachePartitionedQueueEntryMoveSelfTest.java |   2 +-
 .../IgnitePartitionedQueueNoBackupsTest.java    |  92 ++++
 .../GridCacheReplicatedQueueApiSelfTest.java    |   5 +
 .../dht/GridCacheTxNodeFailureSelfTest.java     |   2 +
 .../dht/GridNearCacheTxNodeFailureSelfTest.java |   4 -
 ...idCachePartitionedHitsAndMissesSelfTest.java |   4 +-
 .../GridCacheWriteBehindStoreAbstractTest.java  |   2 +-
 .../config/GridTestProperties.java              |   3 +
 .../testframework/junits/GridAbstractTest.java  |   7 +
 .../IgniteBinaryObjectsCacheTestSuite3.java     |   2 +
 .../IgniteCacheDataStructuresSelfTestSuite.java |   3 +
 .../ignite/testsuites/IgniteCacheTestSuite.java |   2 +
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +
 modules/flume/pom.xml                           |  16 +-
 modules/geospatial/pom.xml                      |  20 +
 modules/hadoop/pom.xml                          |   2 +-
 modules/hibernate/pom.xml                       |  10 +-
 modules/indexing/pom.xml                        |  22 +-
 modules/jcl/pom.xml                             |  11 +
 modules/jms11/pom.xml                           |  20 +-
 modules/jta/pom.xml                             |  17 +
 modules/kafka/pom.xml                           |  16 +-
 modules/log4j/pom.xml                           |  10 +
 modules/log4j2/pom.xml                          |  11 +
 modules/mqtt/pom.xml                            |  24 +-
 modules/osgi-karaf/README.txt                   |  18 +
 modules/osgi-karaf/licenses/apache-2.0.txt      | 202 ++++++++
 modules/osgi-karaf/pom.xml                      |  84 ++++
 .../osgi-karaf/src/main/resources/features.xml  | 327 ++++++++++++
 modules/osgi-paxlogging/README.txt              |  12 +
 modules/osgi-paxlogging/licenses/apache-2.0.txt | 202 ++++++++
 modules/osgi-paxlogging/pom.xml                 |  69 +++
 modules/osgi/README.txt                         |  65 +++
 modules/osgi/licenses/apache-2.0.txt            | 202 ++++++++
 modules/osgi/pom.xml                            | 171 +++++++
 .../IgniteAbstractOsgiContextActivator.java     | 238 +++++++++
 .../org/apache/ignite/osgi/IgniteOsgiUtils.java |  69 +++
 .../BundleDelegatingClassLoader.java            | 147 ++++++
 .../classloaders/ContainerSweepClassLoader.java | 134 +++++
 .../OsgiClassLoadingStrategyType.java           |  29 ++
 .../ignite/osgi/AbstractIgniteKarafTest.java    | 109 ++++
 .../IgniteKarafFeaturesInstallationTest.java    | 100 ++++
 .../ignite/osgi/IgniteOsgiServiceTest.java      | 131 +++++
 .../apache/ignite/osgi/IgniteOsgiTestSuite.java |  32 ++
 .../activators/BasicIgniteTestActivator.java    |  76 +++
 .../ignite/osgi/activators/TestOsgiFlags.java   |  53 ++
 .../osgi/activators/TestOsgiFlagsImpl.java      |  83 ++++
 .../Apache.Ignite.Core.Tests/EventsTest.cs      |   3 +-
 modules/rest-http/pom.xml                       |  34 +-
 modules/scalar-2.10/pom.xml                     |   9 +-
 modules/scalar/pom.xml                          |   9 +-
 modules/schedule/pom.xml                        |  25 +-
 modules/schema-import/pom.xml                   |   2 +-
 .../ignite/schema/ui/SchemaImportApp.java       |  14 +
 modules/slf4j/pom.xml                           |  12 +-
 modules/spark-2.10/pom.xml                      |   2 +-
 modules/spring/pom.xml                          |  30 +-
 modules/ssh/pom.xml                             |  19 +-
 modules/twitter/pom.xml                         |  12 +-
 modules/urideploy/pom.xml                       |  17 +-
 modules/visor-console-2.10/pom.xml              |   4 +-
 modules/visor-console/pom.xml                   |   2 +-
 modules/visor-plugins/pom.xml                   |   4 +-
 modules/web/pom.xml                             |  13 +-
 .../yardstick/cache/IgnitePutTxBenchmark.java   |  26 +-
 ...IgniteTransactionalInvokeRetryBenchmark.java |   4 +-
 ...IgniteTransactionalWriteInvokeBenchmark.java |  22 +-
 .../apache/ignite/yarn/utils/package-info.java  |  22 +
 modules/zookeeper/pom.xml                       |  14 +-
 parent/pom.xml                                  | 140 +++++-
 pom.xml                                         |  44 +-
 123 files changed, 4936 insertions(+), 615 deletions(-)
----------------------------------------------------------------------