You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/03/25 09:23:30 UTC
[01/11] ignite git commit: IGNITE-2870: .NET: Fixed incorrect
handling of attribute-based SQL configuration with nested indexed field. This
closes #568. [Forced Update!]
Repository: ignite
Updated Branches:
refs/heads/ignite-11048 4713e8722 -> b0aea3589 (forced update)
IGNITE-2870: .NET: Fixed incorrect handling of attribute-based SQL configuration with nested indexed field. This closes #568.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1332c80f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1332c80f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1332c80f
Branch: refs/heads/ignite-11048
Commit: 1332c80faefdbe0849afdbc4d92e59774556b578
Parents: cfc7d4e
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Mar 24 16:54:14 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Mar 24 16:54:14 2016 +0300
----------------------------------------------------------------------
.../Query/CacheQueriesCodeConfigurationTest.cs | 16 +++++++++++++++-
.../Cache/Configuration/QueryEntity.cs | 9 +++++----
2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1332c80f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
index 684dd62..d5f98ac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
@@ -140,7 +140,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
cache[1] = new AttributeQueryPerson("Arnold", 10)
{
- Address = new AttributeQueryAddress {Country = "USA", Street = "Pine Tree road"}
+ Address = new AttributeQueryAddress {Country = "USA", Street = "Pine Tree road", Zip = 1}
};
cache[2] = new AttributeQueryPerson("John", 20);
@@ -155,6 +155,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
Assert.AreEqual(1, cursor.GetAll().Single().Key);
}
+ using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson), "Zip = ?", 1)))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+
using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Ar*")))
{
Assert.AreEqual(1, cursor.GetAll().Single().Key);
@@ -226,6 +231,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
public string Country { get; set; }
/// <summary>
+ /// Gets or sets the zip.
+ /// </summary>
+ /// <value>
+ /// The zip.
+ /// </value>
+ [QuerySqlField(IsIndexed = true)]
+ public int Zip { get; set; }
+
+ /// <summary>
/// Gets or sets the street.
/// </summary>
/// <value>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1332c80f/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
index 4ce0211..f4c12f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
@@ -314,16 +314,17 @@ namespace Apache.Ignite.Core.Cache.Configuration
{
var columnName = attr.Name ?? memberInfo.Key.Name;
+ // No dot notation for indexes
+ if (attr.IsIndexed)
+ indexes.Add(new QueryIndexEx(columnName, attr.IsDescending, QueryIndexType.Sorted,
+ attr.IndexGroups));
+
// Dot notation is required for nested SQL fields
if (parentPropName != null)
columnName = parentPropName + "." + columnName;
fields.Add(new QueryField(columnName, memberInfo.Value));
- if (attr.IsIndexed)
- indexes.Add(new QueryIndexEx(columnName, attr.IsDescending, QueryIndexType.Sorted,
- attr.IndexGroups));
-
ScanAttributes(memberInfo.Value, fields, indexes, columnName, visitedTypes);
}
[07/11] ignite git commit: Added CacheLoadOnlyStoreExample's csv to
exclusions from RAT validation.
Posted by nt...@apache.org.
Added CacheLoadOnlyStoreExample's csv to exclusions from RAT validation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b81e38dc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b81e38dc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b81e38dc
Branch: refs/heads/ignite-11048
Commit: b81e38dc6c7b97bcc846744d62f9e4213cacbde2
Parents: 093623e
Author: shtykh_roman <rs...@yahoo.com>
Authored: Fri Mar 25 09:48:43 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Fri Mar 25 09:48:43 2016 +0900
----------------------------------------------------------------------
parent/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b81e38dc/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index a52ac12..8be235a 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -791,6 +791,7 @@
<exclude>src/test/java/org/apache/ignite/internal/processors/hadoop/books/*.txt</exclude><!--books examples-->
<exclude>src/main/java/org/apache/ignite/examples/streaming/wordcount/*.txt</exclude><!--books examples-->
<exclude>examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/*.txt</exclude><!--books examples-->
+ <exclude>src/main/resources/person.csv</exclude><!--CacheLoadOnlyStoreExample csv-->
<exclude>src/main/java/META-INF/services/javax.cache.spi.CachingProvider</exclude><!--cannot be changed-->
<exclude>src/main/java/org/jetbrains/annotations/*.java</exclude><!--copyright-->
<exclude>src/main/resources/META-INF/services/org.apache.hadoop.mapreduce.protocol.ClientProtocolProvider</exclude><!--cannot be changed-->
[11/11] ignite git commit: IGNITE-11048 Fix missed event notification
in remove-remove case.
Posted by nt...@apache.org.
IGNITE-11048 Fix missed event notification in remove-remove case.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b0aea358
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b0aea358
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b0aea358
Branch: refs/heads/ignite-11048
Commit: b0aea3589c465f8348a426465ef174299a728be9
Parents: 166bce8
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Fri Mar 25 11:20:39 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Fri Mar 25 11:20:39 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../dht/atomic/GridDhtAtomicCache.java | 4 +-
...acheContinuousQueryRandomOperationsTest.java | 197 ++++++++++++++++++-
...inuousQueryRandomOperationsTwoNodesTest.java | 28 +++
.../IgniteCacheQuerySelfTestSuite.java | 2 +
5 files changed, 224 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0aea358/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index fb6aeef..c5df29b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -2092,7 +2092,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
null,
null,
false,
- updateCntr0 == null ? 0 : updateCntr0);
+ 0);
}
}
else
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0aea358/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index e908c05..4938794 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -2115,7 +2115,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
"[entry=" + entry + ", filter=" + Arrays.toString(req.filter()) + ']');
}
}
- else if (lsnrs != null && updRes.success()) {
+ else if (lsnrs != null && updRes.updateCounter() != 0) {
ctx.continuousQueries().onEntryUpdated(
lsnrs,
entry.key(),
@@ -2868,7 +2868,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (updRes.removeVersion() != null)
ctx.onDeferredDelete(entry, updRes.removeVersion());
- if (lsnrs != null && updRes.success()) {
+ if (lsnrs != null && updRes.updateCounter() != 0) {
ctx.continuousQueries().onEntryUpdated(
lsnrs,
entry.key(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0aea358/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
index cdf4ffd..f6ad411 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
@@ -31,12 +31,14 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import javax.cache.Cache;
import javax.cache.configuration.Factory;
import javax.cache.event.CacheEntryEvent;
import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryListenerException;
import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.event.EventType;
import javax.cache.integration.CacheLoaderException;
import javax.cache.integration.CacheWriterException;
import javax.cache.processor.EntryProcessor;
@@ -56,6 +58,8 @@ import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.cache.store.CacheStoreAdapter;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.PA;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -121,11 +125,11 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
- startGridsMultiThreaded(NODES - 1);
+ startGridsMultiThreaded(getServerNodeCount());
client = true;
- startGrid(NODES - 1);
+ startGrid(getServerNodeCount());
}
/** {@inheritDoc} */
@@ -417,6 +421,171 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
/**
* @throws Exception If failed.
*/
+ public void testDoubleRemoveAtomicWithoutBackup() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ ATOMIC,
+ ONHEAP_TIERED,
+ false);
+
+ testDoubleRemove(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveAtomic() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ ATOMIC,
+ ONHEAP_TIERED,
+ false);
+
+ testDoubleRemove(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveAtomicOffheap() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ ATOMIC,
+ OFFHEAP_TIERED,
+ false);
+
+ testDoubleRemove(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL,
+ ONHEAP_TIERED,
+ false);
+
+ testDoubleRemove(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveReplicatedTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL,
+ ONHEAP_TIERED,
+ false);
+
+ testDoubleRemove(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveReplicatedAtomic() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ ATOMIC,
+ ONHEAP_TIERED,
+ false);
+
+ testDoubleRemove(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemove(CacheConfiguration ccfg) throws Exception {
+ IgniteCache<QueryTestKey, QueryTestValue> cache = grid(getClientIndex()).createCache(ccfg);
+
+ try {
+ ContinuousQuery<QueryTestKey, QueryTestValue> qry = new ContinuousQuery<>();
+
+ final List<CacheEntryEvent<? extends QueryTestKey, ? extends QueryTestValue>> evts =
+ new CopyOnWriteArrayList<>();
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<QueryTestKey, QueryTestValue>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> events) throws CacheEntryListenerException {
+ for (CacheEntryEvent<? extends QueryTestKey, ? extends QueryTestValue> e : events)
+ evts.add(e);
+ }
+ });
+
+ QueryTestKey key = new QueryTestKey(1);
+
+ try (QueryCursor qryCur = cache.query(qry)) {
+ for (int i = 0; i < ITERATION_CNT; i++) {
+ log.info("Start iteration: " + i);
+
+ cache.put(key, new QueryTestValue(1));
+
+ cache.remove(key);
+ cache.invoke(key, (EntryProcessor<QueryTestKey, QueryTestValue, ? extends Object>)
+ (Object)new EntrySetValueProcessor(null, false));
+ cache.invoke(key, (EntryProcessor<QueryTestKey, QueryTestValue, ? extends Object>)
+ (Object)new EntrySetValueProcessor(null, false));
+ cache.remove(key);
+
+ cache.put(key, new QueryTestValue(2));
+
+ cache.invoke(key, (EntryProcessor<QueryTestKey, QueryTestValue, ? extends Object>)
+ (Object)new EntrySetValueProcessor(null, false));
+ cache.remove(key);
+
+ cache.put(key, new QueryTestValue(3));
+ cache.put(key, new QueryTestValue(4));
+
+ assert GridTestUtils.waitForCondition(new PA() {
+ @Override public boolean apply() {
+ return evts.size() == 6;
+ }
+ }, 5_000);
+
+ checkSingleEvent(evts.get(0), EventType.CREATED, new QueryTestValue(1), null);
+ checkSingleEvent(evts.get(1), EventType.REMOVED, null, new QueryTestValue(1));
+ checkSingleEvent(evts.get(2), EventType.CREATED, new QueryTestValue(2), null);
+ checkSingleEvent(evts.get(3), EventType.REMOVED, null, new QueryTestValue(2));
+ checkSingleEvent(evts.get(4), EventType.CREATED, new QueryTestValue(3), null);
+ checkSingleEvent(evts.get(5), EventType.UPDATED, new QueryTestValue(4), new QueryTestValue(3));
+
+ cache.remove(key);
+ cache.remove(key);
+
+ evts.clear();
+
+ log.info("Finish iteration: " + i);
+ }
+ }
+ }
+ finally {
+ grid(getClientIndex()).destroyCache(ccfg.getName());
+ }
+ }
+
+ /**
+ * @param event Event.
+ * @param type Event type.
+ * @param val Value.
+ * @param oldVal Old value.
+ */
+ private void checkSingleEvent(
+ CacheEntryEvent<? extends QueryTestKey, ? extends QueryTestValue> event,
+ EventType type,
+ QueryTestValue val,
+ QueryTestValue oldVal) {
+ assertEquals(event.getEventType(), type);
+ assertEquals(event.getValue(), val);
+ assertEquals(event.getOldValue(), oldVal);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testTxClient() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
1,
@@ -656,7 +825,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
evtsQueues.add(evtsQueue);
- QueryCursor<?> cur = grid(NODES - 1).cache(ccfg.getName()).query(qry);
+ QueryCursor<?> cur = grid(getClientIndex()).cache(ccfg.getName()).query(qry);
curs.add(cur);
}
@@ -674,12 +843,12 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
evtsQueues.add(evtsQueue);
- QueryCursor<?> cur = grid(rnd.nextInt(NODES - 1)).cache(ccfg.getName()).query(qry);
+ QueryCursor<?> cur = grid(rnd.nextInt(getServerNodeCount())).cache(ccfg.getName()).query(qry);
curs.add(cur);
}
else {
- for (int i = 0; i < NODES - 1; i++) {
+ for (int i = 0; i <= getServerNodeCount(); i++) {
ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();
final BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue = new ArrayBlockingQueue<>(50_000);
@@ -708,7 +877,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
if (i % 20 == 0)
log.info("Iteration: " + i);
- for (int idx = 0; idx < NODES; idx++)
+ for (int idx = 0; idx < getServerNodeCount(); idx++)
randomUpdate(rnd, evtsQueues, expData, partCntr, grid(idx).cache(ccfg.getName()));
}
}
@@ -723,6 +892,20 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
}
/**
+ * @return Client node index.
+ */
+ private int getClientIndex() {
+ return getServerNodeCount() - 1;
+ }
+
+ /**
+ * @return Count nodes.
+ */
+ protected int getServerNodeCount() {
+ return NODES;
+ }
+
+ /**
* @param rnd Random generator.
* @param evtsQueues Events queue.
* @param expData Expected cache data.
@@ -1272,9 +1455,11 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
*/
public static class QueryTestValue implements Serializable {
/** */
+ @GridToStringInclude
protected final Integer val1;
/** */
+ @GridToStringInclude
protected final String val2;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0aea358/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTwoNodesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTwoNodesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTwoNodesTest.java
new file mode 100644
index 0000000..ebb7861
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTwoNodesTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.query.continuous;
+
+/**
+ *
+ */
+public class CacheContinuousQueryRandomOperationsTwoNodesTest extends CacheContinuousQueryRandomOperationsTest {
+ /** {@inheritDoc} */
+ @Override protected int getServerNodeCount() {
+ return 1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b0aea358/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 0aa3560..e9360ba 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
@@ -88,6 +88,7 @@ import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinu
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationP2PTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTwoNodesTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapTieredTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapValuesTest;
@@ -228,6 +229,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest.class);
suite.addTestSuite(CacheContinuousQueryFailoverTxOffheapTieredTest.class);
suite.addTestSuite(CacheContinuousQueryRandomOperationsTest.class);
+ suite.addTestSuite(CacheContinuousQueryRandomOperationsTwoNodesTest.class);
suite.addTestSuite(CacheContinuousQueryFactoryFilterTest.class);
suite.addTestSuite(GridCacheContinuousQueryConcurrentTest.class);
suite.addTestSuite(CacheContinuousQueryOperationP2PTest.class);
[08/11] ignite git commit: Added CacheLoadOnlyStoreExample's csv to
exclusions from RAT validation.
Posted by nt...@apache.org.
Added CacheLoadOnlyStoreExample's csv to exclusions from RAT validation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c63faf67
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c63faf67
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c63faf67
Branch: refs/heads/ignite-11048
Commit: c63faf677dc97c613d7ef95e061a354dc650763f
Parents: b81e38d
Author: shtykh_roman <rs...@yahoo.com>
Authored: Fri Mar 25 11:18:55 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Fri Mar 25 11:18:55 2016 +0900
----------------------------------------------------------------------
parent/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c63faf67/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 8be235a..8b613fa 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -792,6 +792,7 @@
<exclude>src/main/java/org/apache/ignite/examples/streaming/wordcount/*.txt</exclude><!--books examples-->
<exclude>examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/*.txt</exclude><!--books examples-->
<exclude>src/main/resources/person.csv</exclude><!--CacheLoadOnlyStoreExample csv-->
+ <exclude>examples/src/main/resources/person.csv</exclude><!--CacheLoadOnlyStoreExample csv-->
<exclude>src/main/java/META-INF/services/javax.cache.spi.CachingProvider</exclude><!--cannot be changed-->
<exclude>src/main/java/org/jetbrains/annotations/*.java</exclude><!--copyright-->
<exclude>src/main/resources/META-INF/services/org.apache.hadoop.mapreduce.protocol.ClientProtocolProvider</exclude><!--cannot be changed-->
[02/11] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by nt...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7b63eee3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7b63eee3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7b63eee3
Branch: refs/heads/ignite-11048
Commit: 7b63eee332801d770878699b59ef03ddd25d1709
Parents: 1332c80 34a9b66
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Mar 24 16:54:28 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Mar 24 16:54:28 2016 +0300
----------------------------------------------------------------------
.../CacheContinuousQueryFailoverAbstractSelfTest.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
[03/11] ignite git commit: IGNITE-2866 .NET: Added automatic
JAVA_HOME detection. This closes #577.
Posted by nt...@apache.org.
IGNITE-2866 .NET: Added automatic JAVA_HOME detection. This closes #577.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/afe453ff
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/afe453ff
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/afe453ff
Branch: refs/heads/ignite-11048
Commit: afe453ff6d219134685f5e5b8224156e8d6673b9
Parents: 7b63eee
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Mar 24 16:57:55 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Mar 24 16:57:55 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.csproj | 1 +
.../Apache.Ignite.Core.Tests/JavaHomeTest.cs | 69 ++++++++++++++++++++
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 34 ++++++++++
3 files changed, 104 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/afe453ff/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 0dcd1f0..fedbd63 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -130,6 +130,7 @@
<Compile Include="IgniteConfigurationSerializerTest.cs" />
<Compile Include="IgniteConfigurationTest.cs" />
<Compile Include="IgniteTestBase.cs" />
+ <Compile Include="JavaHomeTest.cs" />
<Compile Include="LifecycleTest.cs" />
<Compile Include="LoadDllTest.cs" />
<Compile Include="IgniteManagerTest.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/afe453ff/modules/platforms/dotnet/Apache.Ignite.Core.Tests/JavaHomeTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/JavaHomeTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/JavaHomeTest.cs
new file mode 100644
index 0000000..b229557
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/JavaHomeTest.cs
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests the JAVA_HOME detection.
+ /// </summary>
+ public class JavaHomeTest
+ {
+ /** Environment variable: JAVA_HOME. */
+ private const string EnvJavaHome = "JAVA_HOME";
+
+ /** Backed up value. */
+ private string _javaHomeBackup;
+
+ /// <summary>
+ /// Fixture set up.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ _javaHomeBackup = Environment.GetEnvironmentVariable(EnvJavaHome);
+
+ Environment.SetEnvironmentVariable(EnvJavaHome, null);
+ }
+
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ Environment.SetEnvironmentVariable(EnvJavaHome, _javaHomeBackup);
+ }
+
+ /// <summary>
+ /// Tests the detection.
+ /// </summary>
+ [Test]
+ public void TestDetection([Values(null, "c:\\invalid111")] string javaHome)
+ {
+ Environment.SetEnvironmentVariable(EnvJavaHome, javaHome);
+
+ using (var ignite = Ignition.Start(TestUtils.GetTestConfiguration()))
+ {
+ Assert.IsNotNull(ignite);
+ Console.WriteLine("Detected JVM dll path: " + ignite.GetConfiguration().JvmDllPath);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/afe453ff/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 3206fc8..7f6fab8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -33,6 +33,7 @@ namespace Apache.Ignite.Core.Impl
using Apache.Ignite.Core.Impl.Cluster;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Unmanaged;
+ using Microsoft.Win32;
using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
/// <summary>
@@ -46,6 +47,13 @@ namespace Apache.Ignite.Core.Impl
/** Lookup paths. */
private static readonly string[] JvmDllLookupPaths = {@"jre\bin\server", @"jre\bin\default"};
+ /** Registry lookup paths. */
+ private static readonly string[] JreRegistryKeys =
+ {
+ @"Software\JavaSoft\Java Runtime Environment",
+ @"Software\Wow6432Node\JavaSoft\Java Runtime Environment"
+ };
+
/** File: jvm.dll. */
internal const string FileJvmDll = "jvm.dll";
@@ -256,6 +264,32 @@ namespace Apache.Ignite.Core.Impl
foreach (var path in JvmDllLookupPaths)
yield return
new KeyValuePair<string, string>(EnvJavaHome, Path.Combine(javaHomeDir, path, FileJvmDll));
+
+ // Get paths from the Windows Registry
+ foreach (var regPath in JreRegistryKeys)
+ {
+ using (var jSubKey = Registry.LocalMachine.OpenSubKey(regPath))
+ {
+ if (jSubKey == null)
+ continue;
+
+ var curVer = jSubKey.GetValue("CurrentVersion") as string;
+
+ // Current version comes first
+ var versions = new[] {curVer}.Concat(jSubKey.GetSubKeyNames().Where(x => x != curVer));
+
+ foreach (var ver in versions)
+ {
+ using (var verKey = jSubKey.OpenSubKey(ver))
+ {
+ var dllPath = verKey == null ? null : verKey.GetValue("RuntimeLib") as string;
+
+ if (dllPath != null)
+ yield return new KeyValuePair<string, string>(verKey.Name, dllPath);
+ }
+ }
+ }
+ }
}
/// <summary>
[09/11] ignite git commit: IGNITE-2882: .NET: Decreased amount of
memory consumed by examples to allow the to run smoothly on 32-bit
environment. Improved error messages when JVM fails to start. This closes
#573.
Posted by nt...@apache.org.
IGNITE-2882: .NET: Decreased amount of memory consumed by examples to allow the to run smoothly on 32-bit environment. Improved error messages when JVM fails to start. This closes #573.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/090144c4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/090144c4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/090144c4
Branch: refs/heads/ignite-11048
Commit: 090144c4578952335ea30ba9ce266ac0569af8c0
Parents: c63faf6
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Mar 25 09:21:51 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Mar 25 09:21:51 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/common/src/java.cpp | 74 ++++++++++++++++----
.../Examples/ExamplesTest.cs | 3 +-
.../Compute/ClosureExample.cs | 2 +-
.../Compute/TaskExample.cs | 2 +-
.../Datagrid/ContinuousQueryExample.cs | 2 +-
.../Datagrid/DataStreamerExample.cs | 2 +-
.../Datagrid/PutGetExample.cs | 2 +-
.../Datagrid/QueryExample.cs | 2 +-
.../Datagrid/StoreExample.cs | 2 +-
.../Datagrid/TransactionExample.cs | 2 +-
.../Events/EventsExample.cs | 2 +-
.../Messaging/MessagingExample.cs | 2 +-
.../Misc/LifecycleExample.cs | 2 +-
.../Services/ServicesExample.cs | 2 +-
14 files changed, 72 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index 89f4713..ae06c30 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -788,7 +788,7 @@ namespace ignite
/**
* Create JVM.
*/
- void CreateJvm(char** opts, int optsLen, JavaVM** jvm, JNIEnv** env) {
+ jint CreateJvm(char** opts, int optsLen, JavaVM** jvm, JNIEnv** env) {
JavaVMOption* opts0 = new JavaVMOption[optsLen];
for (int i = 0; i < optsLen; i++)
@@ -805,8 +805,7 @@ namespace ignite
delete[] opts0;
- if (res != JNI_OK)
- throw JvmException();
+ return res;
}
void RegisterNatives(JNIEnv* env) {
@@ -903,6 +902,40 @@ namespace ignite
return Create(opts, optsLen, hnds, NULL);
}
+ void GetJniErrorMessage(std::string& errMsg, jint res)
+ {
+ switch (res)
+ {
+ case JNI_ERR:
+ errMsg = "Unknown error (JNI_ERR).";
+ break;
+
+ case JNI_EDETACHED:
+ errMsg = "Thread detached from the JVM.";
+ break;
+
+ case JNI_EVERSION:
+ errMsg = "JNI version error.";
+ break;
+
+ case JNI_ENOMEM:
+ errMsg = "Could not reserve enough space for object heap. Check Xmx option.";
+ break;
+
+ case JNI_EEXIST:
+ errMsg = "JVM already created.";
+ break;
+
+ case JNI_EINVAL:
+ errMsg = "Invalid JVM arguments.";
+ break;
+
+ default:
+ errMsg = "Unexpected JNI_CreateJavaVM result.";
+ break;
+ }
+ }
+
JniContext* JniContext::Create(char** opts, int optsLen, JniHandlers hnds, JniErrorInfo* errInfo)
{
// Acquire global lock to instantiate the JVM.
@@ -926,25 +959,36 @@ namespace ignite
int errMsgLen = 0;
try {
- if (!JVM.GetJvm()) {
+ if (!JVM.GetJvm())
+ {
// 1. Create JVM itself.
- CreateJvm(opts, optsLen, &jvm, &env);
+ jint res = CreateJvm(opts, optsLen, &jvm, &env);
- // 2. Populate members;
- javaMembers.Initialize(env);
- members.Initialize(env);
+ if (res == JNI_OK)
+ {
+ // 2. Populate members;
+ javaMembers.Initialize(env);
+ members.Initialize(env);
- // 3. Register native functions.
- RegisterNatives(env);
+ // 3. Register native functions.
+ RegisterNatives(env);
- // 4. Create JNI JVM.
- JVM = JniJvm(jvm, javaMembers, members);
+ // 4. Create JNI JVM.
+ JVM = JniJvm(jvm, javaMembers, members);
- char* printStack = getenv("IGNITE_CPP_PRINT_STACK");
- PRINT_EXCEPTION = printStack && strcmp("true", printStack) == 0;
+ char* printStack = getenv("IGNITE_CPP_PRINT_STACK");
+ PRINT_EXCEPTION = printStack && strcmp("true", printStack) == 0;
+ }
+ else
+ {
+ GetJniErrorMessage(errMsg, res);
+
+ errMsgLen = errMsg.length();
+ }
}
- ctx = new JniContext(&JVM, hnds);
+ if (JVM.GetJvm())
+ ctx = new JniContext(&JVM, hnds);
}
catch (JvmException)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
index 4e8a036..7cf0d57 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -20,7 +20,6 @@ namespace Apache.Ignite.Core.Tests.Examples
using System;
using System.Collections.Generic;
using System.IO;
- using System.Linq;
using Apache.Ignite.Core.Tests.Process;
using Apache.Ignite.ExamplesDll.Compute;
using NUnit.Framework;
@@ -104,7 +103,7 @@ namespace Apache.Ignite.Core.Tests.Examples
var proc = new IgniteProcess(args.ToArray());
- Assert.IsTrue(ignite.WaitTopology(i + 2, 30000));
+ Assert.IsTrue(ignite.WaitTopology(i + 2));
Assert.IsTrue(proc.Alive);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
index aeb352f..e1194f8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Examples.Compute
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
index 38faf59..f0bcf13 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Compute
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
index ca7f852..8dad1f4 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Examples.Datagrid
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
index 1db89fe..08a670f 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Examples.Datagrid
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
index 4d38ad9..e2502e8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -55,7 +55,7 @@ namespace Apache.Ignite.Examples.Datagrid
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
index d961f11..809eb65 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Datagrid
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-query.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
index 421d3bc..1654b41 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Datagrid
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-store.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
index c2b6e98..e814f8c 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Datagrid
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
index 42b1777..3b068e8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -52,7 +52,7 @@ namespace Apache.Ignite.Examples.Events
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
index 3fafd8f..6438b95 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
@@ -45,7 +45,7 @@ namespace Apache.Ignite.Examples.Messaging
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
};
using (var ignite = Ignition.Start(cfg))
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
index 4a1162b..bba6719 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Examples.Misc
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" },
LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
index d513305..e57774c 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
@@ -47,7 +47,7 @@ namespace Apache.Ignite.Examples.Services
var cfg = new IgniteConfiguration
{
SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
- JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx512m"}
};
using (var ignite = Ignition.Start(cfg))
[05/11] ignite git commit: IGNITE-2873: .NET: Added support for app
configuration from executable. This closes #576.
Posted by nt...@apache.org.
IGNITE-2873: .NET: Added support for app configuration from executable. This closes #576.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e3ba037a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e3ba037a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e3ba037a
Branch: refs/heads/ignite-11048
Commit: e3ba037a6a912c54ec378facc9a66d9a6b320752
Parents: 7864826
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Mar 24 17:18:16 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Mar 24 17:18:16 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.csproj | 9 +
.../Config/Apache.Ignite.exe.config.test2 | 58 +++++++
.../Config/Apache.Ignite.exe.config.test3 | 34 ++++
.../Config/ignite-dotnet-cfg.xml | 52 ++++++
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 89 +++++++---
.../IgniteConfigurationSerializerTest.cs | 3 +-
.../IgniteConfigurationSection.xsd | 8 +
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 2 +-
.../Config/AppSettingsConfigurator.cs | 97 +++--------
.../Apache.Ignite/Config/ArgsConfigurator.cs | 145 ++--------------
.../dotnet/Apache.Ignite/Config/Configurator.cs | 168 +++++++++++++++++++
.../Apache.Ignite/Config/IConfigurator.cs | 34 ----
.../dotnet/Apache.Ignite/IgniteRunner.cs | 24 +--
.../Apache.Ignite/Service/IgniteService.cs | 21 +--
14 files changed, 448 insertions(+), 296 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index fedbd63..7cc9296 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -265,6 +265,15 @@
<None Include="Apache.Ignite.Core.Tests.nunit" />
<None Include="Apache.Ignite.Core.Tests.snk" />
<None Include="app.config" />
+ <Content Include="Config\ignite-dotnet-cfg.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <None Include="Config\Apache.Ignite.exe.config.test3">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Include="Config\Apache.Ignite.exe.config.test2">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2 b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2
new file mode 100644
index 0000000..ecfce18
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ 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.
+-->
+
+<configuration>
+ <configSections>
+ <section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
+ </configSections>
+
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
+ </startup>
+
+ <runtime>
+ <gcServer enabled="true" />
+ </runtime>
+
+ <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection">
+ <discoverySpi type="TcpDiscoverySpi">
+ <ipFinder type="TcpDiscoveryStaticIpFinder">
+ <endpoints>
+ <string>127.0.0.1:47500..47501</string>
+ </endpoints>
+ </ipFinder>
+ </discoverySpi>
+
+ <jvmOptions>
+ <string>-Xms1g</string>
+ <string>-Xmx702m</string>
+ </jvmOptions>
+ </igniteConfiguration>
+
+ <appSettings>
+ <add key="Ignite.SpringConfigUrl" value="config\compute\compute-standalone.xml" />
+ <add key="Ignite.Assembly.1" value="test-1.dll" />
+ <add key="Ignite.Assembly.2" value="test-2.dll" />
+ <add key="Ignite.JvmOption.1" value="-DOPT1" />
+ <add key="Ignite.JvmOption.2" value="-DOPT2" />
+ <add key="Ignite.JvmOption.3" value="-Xms601m" />
+ <add key="Ignite.ConfigSectionName" value="igniteConfiguration" />
+ </appSettings>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test3
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test3 b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test3
new file mode 100644
index 0000000..c09f3f4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test3
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ 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.
+-->
+
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
+ </startup>
+
+ <runtime>
+ <gcServer enabled="true" />
+ </runtime>
+
+ <appSettings>
+ <add key="Ignite.ConfigFileName" value="config\ignite-dotnet-cfg.xml" />
+ <add key="Ignite.ConfigSectionName" value="igniteConfiguration" />
+ </appSettings>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/ignite-dotnet-cfg.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/ignite-dotnet-cfg.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/ignite-dotnet-cfg.xml
new file mode 100644
index 0000000..53f2f0f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/ignite-dotnet-cfg.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ 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.
+-->
+
+<configuration>
+ <configSections>
+ <section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
+ </configSections>
+
+ <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection"
+ localhost="127.0.0.1">
+ <discoverySpi type="TcpDiscoverySpi">
+ <ipFinder type="TcpDiscoveryStaticIpFinder">
+ <endpoints>
+ <string>127.0.0.1:47500..47501</string>
+ </endpoints>
+ </ipFinder>
+ </discoverySpi>
+
+ <jvmOptions>
+ <string>-Xms512m</string>
+ <string>-Xmx702m</string>
+ <string>-DOPT25</string>
+ </jvmOptions>
+
+ <cacheConfiguration>
+ <cacheConfiguration name='testCache' cacheMode='Replicated' />
+ </cacheConfiguration>
+
+ <binaryConfiguration>
+ <types>
+ <string>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfiguration, Apache.Ignite.Core.Tests</string>
+ <string>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfigurationClosure, Apache.Ignite.Core.Tests</string>
+ </types>
+ </binaryConfiguration>
+ </igniteConfiguration>
+</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
index e34e0ba..9e6de05 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
@@ -17,6 +17,8 @@
// ReSharper disable UnusedVariable
// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable UnusedAutoPropertyAccessor.Local
+//#pragma warning disable 618
namespace Apache.Ignite.Core.Tests
{
using System;
@@ -27,7 +29,6 @@ namespace Apache.Ignite.Core.Tests
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Resource;
using Apache.Ignite.Core.Tests.Process;
- using Microsoft.CSharp;
using NUnit.Framework;
/// <summary>
@@ -77,7 +78,7 @@ namespace Apache.Ignite.Core.Tests
{
TestUtils.KillProcesses();
- Assert.IsTrue(_grid.WaitTopology(1, 30000));
+ Assert.IsTrue(_grid.WaitTopology(1));
IgniteProcess.SaveConfigurationBackup();
}
@@ -106,7 +107,7 @@ namespace Apache.Ignite.Core.Tests
"-jvmClasspath=" + TestUtils.CreateTestClasspath()
);
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
var cfg = RemoteConfig();
@@ -133,7 +134,7 @@ namespace Apache.Ignite.Core.Tests
"-assembly=test-2.dll"
);
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
var cfg = RemoteConfig();
@@ -153,7 +154,7 @@ namespace Apache.Ignite.Core.Tests
"-J-DOPT2"
);
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
var cfg = RemoteConfig();
@@ -173,7 +174,7 @@ namespace Apache.Ignite.Core.Tests
"-J-Xmx607m"
);
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
Assert.AreEqual((long) 506*1024*1024, minMem);
@@ -195,7 +196,7 @@ namespace Apache.Ignite.Core.Tests
"-JvmMaxMemoryMB=863"
);
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
Assert.AreEqual((long) 615*1024*1024, minMem);
@@ -208,16 +209,17 @@ namespace Apache.Ignite.Core.Tests
/// Test JVM memory options passing from application configuration.
/// </summary>
[Test]
- public void TestJvmMemoryOptsAppConfig()
+ public void TestJvmMemoryOptsAppConfig(
+ [Values("config\\Apache.Ignite.exe.config.test", "config\\Apache.Ignite.exe.config.test2")] string config)
{
- IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test");
+ IgniteProcess.ReplaceConfiguration(config);
GenerateDll("test-1.dll");
GenerateDll("test-2.dll");
var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath());
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
Assert.AreEqual((long) 601*1024*1024, minMem);
@@ -227,14 +229,14 @@ namespace Apache.Ignite.Core.Tests
proc.Kill();
- Assert.IsTrue(_grid.WaitTopology(1, 30000));
+ Assert.IsTrue(_grid.WaitTopology(1));
// Command line options overwrite config file options
// ReSharper disable once RedundantAssignment
proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(),
"-J-Xms605m", "-J-Xmx706m");
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
Assert.AreEqual((long) 605*1024*1024, minMem);
@@ -258,7 +260,7 @@ namespace Apache.Ignite.Core.Tests
"-JvmMaxMemoryMB=256"
);
- Assert.IsTrue(_grid.WaitTopology(2, 30000));
+ Assert.IsTrue(_grid.WaitTopology(2));
// Raw JVM options (Xms/Xmx) should override custom options
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
@@ -269,6 +271,45 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
+ /// Tests the .NET XML configuration specified in app.config.
+ /// </summary>
+ [Test]
+ public void TestXmlConfigurationAppConfig()
+ {
+ IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test3");
+
+ var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath());
+
+ Assert.IsTrue(_grid.WaitTopology(2));
+
+ var remoteCfg = RemoteConfig();
+ Assert.IsTrue(remoteCfg.JvmOptions.Contains("-DOPT25"));
+
+ proc.Kill();
+
+ Assert.IsTrue(_grid.WaitTopology(1));
+ }
+
+ /// <summary>
+ /// Tests the .NET XML configuration specified in command line.
+ /// </summary>
+ [Test]
+ public void TestXmlConfigurationCmd()
+ {
+ var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(),
+ "-configFileName=config\\ignite-dotnet-cfg.xml");
+
+ Assert.IsTrue(_grid.WaitTopology(2));
+
+ var remoteCfg = RemoteConfig();
+ Assert.IsTrue(remoteCfg.JvmOptions.Contains("-DOPT25"));
+
+ proc.Kill();
+
+ Assert.IsTrue(_grid.WaitTopology(1));
+ }
+
+ /// <summary>
/// Get remote node configuration.
/// </summary>
/// <returns>Configuration.</returns>
@@ -325,21 +366,15 @@ namespace Apache.Ignite.Core.Tests
/// <param name="outputPath"></param>
private static void GenerateDll(string outputPath)
{
- var codeProvider = new CSharpCodeProvider();
-
-#pragma warning disable 0618
-
- var icc = codeProvider.CreateCompiler();
-
-#pragma warning restore 0618
-
- var parameters = new CompilerParameters();
- parameters.GenerateExecutable = false;
- parameters.OutputAssembly = outputPath;
+ var parameters = new CompilerParameters
+ {
+ GenerateExecutable = false,
+ OutputAssembly = outputPath
+ };
var src = "namespace Apache.Ignite.Client.Test { public class Foo {}}";
- var results = icc.CompileAssemblyFromSource(parameters, src);
+ var results = CodeDomProvider.CreateProvider("CSharp").CompileAssemblyFromSource(parameters, src);
Assert.False(results.Errors.HasErrors);
}
@@ -357,7 +392,7 @@ namespace Apache.Ignite.Core.Tests
/// <summary>
/// Closure which extracts configuration and passes it back.
/// </summary>
- public class RemoteConfigurationClosure : IComputeFunc<RemoteConfiguration>
+ private class RemoteConfigurationClosure : IComputeFunc<RemoteConfiguration>
{
#pragma warning disable 0649
@@ -396,7 +431,7 @@ namespace Apache.Ignite.Core.Tests
/// <summary>
/// Configuration.
/// </summary>
- public class RemoteConfiguration
+ private class RemoteConfiguration
{
/// <summary>
/// GG home.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index e221a55..6e9effe 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -307,6 +307,7 @@ namespace Apache.Ignite.Core.Tests
Serializer = new TestSerializer()
}
},
+ Types = new [] {typeof(string).FullName },
DefaultIdMapper = new IdMapper(),
DefaultKeepDeserialized = true,
DefaultNameMapper = new NameMapper(),
@@ -319,7 +320,7 @@ namespace Apache.Ignite.Core.Tests
AtomicWriteOrderMode = CacheAtomicWriteOrderMode.Primary,
AtomicityMode = CacheAtomicityMode.Transactional,
Backups = 15,
- CacheMode = CacheMode.Partitioned,
+ CacheMode = CacheMode.Replicated,
CacheStoreFactory = new TestCacheStoreFactory(),
CopyOnRead = true,
EagerTtl = true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 8902d3a..c7b6cf2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -61,6 +61,13 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+ <xs:element name="types" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="string" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
<xs:element name="defaultNameMapper" minOccurs="0">
<xs:complexType>
<xs:attribute name="type" type="xs:string" use="required" />
@@ -161,6 +168,7 @@
</xs:element>
</xs:all>
<xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="cacheMode" type="xs:string" />
<xs:attribute name="writeSynchronizationMode" type="xs:string" />
<xs:attribute name="evictSynchronized" type="xs:boolean" />
<xs:attribute name="evictSynchronizedKeyBufferSize" type="xs:int" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
index e2dae25..ccebbfe 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
@@ -51,8 +51,8 @@
<ItemGroup>
<Compile Include="Config\AppSettingsConfigurator.cs" />
<Compile Include="Config\ArgsConfigurator.cs" />
+ <Compile Include="Config\Configurator.cs" />
<Compile Include="Config\ConfigValueParser.cs" />
- <Compile Include="Config\IConfigurator.cs" />
<Compile Include="IgniteRunner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service\IgniteService.cs">
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs b/modules/platforms/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs
index b2e827e..c15f29f 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs
@@ -17,97 +17,50 @@
namespace Apache.Ignite.Config
{
+ using System;
using System.Collections.Generic;
using System.Collections.Specialized;
- using Apache.Ignite.Core;
+ using System.Linq;
/// <summary>
/// Configurator which uses application configuration.
/// </summary>
- internal class AppSettingsConfigurator : IConfigurator<NameValueCollection>
+ internal static class AppSettingsConfigurator
{
/** Common configuration property prefix. */
- private static readonly string CfgPrefix = "Ignite.".ToLower();
+ private const string CfgPrefix = "Ignite.";
/** Configuration property: Ignite home. */
- private static readonly string CfgHome = "Home".ToLower();
-
- /** Configuration property: Spring config URL. */
- private static readonly string CfgSpringCfgUrl = "SpringConfigUrl".ToLower();
-
- /** Configuration property: Path to JVM dll. */
- private static readonly string CfgJvmDll = "JvmDll".ToLower();
-
- /** Configuration property: JVM classpath. */
- private static readonly string CfgJvmClasspath = "JvmClasspath".ToLower();
-
- /** Configuration property: suppress warnings flag. */
- private static readonly string CfgSuppressWarn = "SuppressWarnings".ToLower();
+ private const string CfgHome = "Home";
/** Configuration property: JVM option prefix. */
- private static readonly string CfgJvmOptPrefix = "JvmOption".ToLower();
+ private const string CfgJvmOptPrefix = "JvmOption";
/** Configuration property: assembly prefix. */
- private static readonly string CfgAssemblyPrefix = "Assembly".ToLower();
-
- /** Configuration property: JVM min memory. */
- private static readonly string CfgJvmMinMem = "JvmInitialMemoryMB".ToLower();
-
- /** Configuration property: JVM max memory. */
- private static readonly string CfgJvmMaxMem = "JvmMaxMemoryMB".ToLower();
+ private const string CfgAssemblyPrefix = "Assembly";
- /** <inheritDoc /> */
- public void Configure(IgniteConfiguration cfg, NameValueCollection src)
+ /// <summary>
+ /// Gets the arguments in split form.
+ /// </summary>
+ public static IEnumerable<Tuple<string, string>> GetArgs(NameValueCollection args)
{
- var jvmOpts = new List<string>();
- var assemblies = new List<string>();
-
- foreach (string key in src.Keys)
- {
- var key0 = key.ToLower();
-
- if (key0.StartsWith(CfgPrefix))
- {
- key0 = key0.Substring(CfgPrefix.Length);
-
- var val = src[key];
+ return args.AllKeys
+ .Where(x => x.StartsWith(CfgPrefix, StringComparison.OrdinalIgnoreCase))
+ .Select(k => Tuple.Create(Replace(k), args[k]));
+ }
- if (CfgHome.Equals(key0))
- cfg.IgniteHome = val;
- else if (CfgSpringCfgUrl.Equals(key0))
- cfg.SpringConfigUrl = val;
- else if (CfgJvmDll.Equals(key0))
- cfg.JvmDllPath = val;
- else if (CfgJvmClasspath.Equals(key0))
- cfg.JvmClasspath = val;
- else if (CfgSuppressWarn.Equals(key0))
- cfg.SuppressWarnings = val != null && bool.TrueString.ToLower().Equals(val.ToLower());
- else if (key0.StartsWith(CfgJvmOptPrefix))
- jvmOpts.Add(val);
- else if (key0.StartsWith(CfgAssemblyPrefix))
- assemblies.Add(val);
- else if (CfgJvmMinMem.Equals(key0))
- cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(val, key);
- else if (CfgJvmMaxMem.Equals(key0))
- cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(val, key);
- }
- }
+ /// <summary>
+ /// Replaces the appsettings-specific keys with common arg name.
+ /// </summary>
+ private static string Replace(string key)
+ {
+ key = key.Substring(CfgPrefix.Length);
- if (jvmOpts.Count > 0)
- {
- if (cfg.JvmOptions == null)
- cfg.JvmOptions = jvmOpts;
- else
- jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
- }
+ key = key.Equals(CfgHome, StringComparison.OrdinalIgnoreCase) ? Configurator.CmdIgniteHome : key;
+ key = key.StartsWith(CfgJvmOptPrefix, StringComparison.OrdinalIgnoreCase) ? Configurator.CmdJvmOpt : key;
+ key = key.StartsWith(CfgAssemblyPrefix, StringComparison.OrdinalIgnoreCase) ? Configurator.CmdAssembly : key;
- if (assemblies.Count > 0)
- {
- if (cfg.Assemblies == null)
- cfg.Assemblies = assemblies;
- else
- assemblies.ForEach(val => cfg.Assemblies.Add(val));
- }
+ return key;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs b/modules/platforms/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs
index b0651d7..c7dae66 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs
@@ -17,148 +17,27 @@
namespace Apache.Ignite.Config
{
+ using System;
using System.Collections.Generic;
- using Apache.Ignite.Core;
+ using System.Linq;
/// <summary>
/// Configurator which uses arguments array.
/// </summary>
- internal class ArgsConfigurator : IConfigurator<string[]>
+ internal static class ArgsConfigurator
{
- /** Command line argument: Ignite home. */
- private static readonly string CmdIgniteHome = "-IgniteHome=".ToLower();
-
- /** Command line argument: Spring config URL. */
- private static readonly string CmdSpringCfgUrl = "-SpringConfigUrl=".ToLower();
-
- /** Command line argument: Path to JVM dll. */
- private static readonly string CmdJvmDll = "-JvmDll=".ToLower();
-
- /** Command line argument: JVM classpath. */
- private static readonly string CmdJvmClasspath = "-JvmClasspath=".ToLower();
-
- /** Command line argument: suppress warnings flag. */
- private static readonly string CmdSuppressWarn = "-SuppressWarnings=".ToLower();
-
- /** Command line argument: JVM option prefix. */
- private static readonly string CmdJvmOpt = "-J".ToLower();
-
- /** Command line argument: assembly. */
- private static readonly string CmdAssembly = "-Assembly=".ToLower();
-
- /** Command line argument: JvmInitialMemoryMB. */
- private static readonly string CmdJvmMinMem = "-JvmInitialMemoryMB=".ToLower();
-
- /** Command line argument: JvmMaxMemoryMB. */
- private static readonly string CmdJvmMaxMem = "-JvmMaxMemoryMB=".ToLower();
-
- /// <summary>
- /// Convert configuration to arguments.
- /// </summary>
- /// <param name="cfg"></param>
- /// <returns></returns>
- internal static string[] ToArgs(IgniteConfiguration cfg)
- {
- var args = new List<string>();
-
- if (cfg.IgniteHome != null)
- args.Add(CmdIgniteHome + cfg.IgniteHome);
-
- if (cfg.SpringConfigUrl != null)
- args.Add(CmdSpringCfgUrl + cfg.SpringConfigUrl);
-
- if (cfg.JvmDllPath != null)
- args.Add(CmdJvmDll + cfg.JvmDllPath);
-
- if (cfg.JvmClasspath != null)
- args.Add(CmdJvmClasspath + cfg.JvmClasspath);
-
- if (cfg.SuppressWarnings)
- args.Add(CmdSuppressWarn + bool.TrueString);
-
- if (cfg.JvmOptions != null)
- {
- foreach (var jvmOpt in cfg.JvmOptions)
- args.Add(CmdJvmOpt + jvmOpt);
- }
-
- if (cfg.Assemblies != null)
- {
- foreach (var assembly in cfg.Assemblies)
- args.Add(CmdAssembly + assembly);
- }
-
- args.Add(CmdJvmMinMem + cfg.JvmInitialMemoryMb);
- args.Add(CmdJvmMaxMem + cfg.JvmMaxMemoryMb);
-
- return args.ToArray();
- }
-
/// <summary>
- /// Convert arguments to configuration.
+ /// Gets the arguments in split form.
/// </summary>
- /// <param name="args">Arguments.</param>
- /// <returns>Configuration.</returns>
- internal static IgniteConfiguration FromArgs(string[] args)
- {
- var cfg = new IgniteConfiguration();
-
- new ArgsConfigurator().Configure(cfg, args);
-
- return cfg;
- }
-
- /** <inheritDoc /> */
- public void Configure(IgniteConfiguration cfg, string[] src)
+ public static IEnumerable<Tuple<string, string>> GetArgs(IEnumerable<string> args)
{
- var jvmOpts = new List<string>();
- var assemblies = new List<string>();
-
- foreach (var arg in src)
- {
- var argLow = arg.ToLower();
-
- if (argLow.StartsWith(CmdIgniteHome))
- cfg.IgniteHome = arg.Substring(CmdIgniteHome.Length);
- else if (argLow.StartsWith(CmdSpringCfgUrl))
- cfg.SpringConfigUrl = arg.Substring(CmdSpringCfgUrl.Length);
- else if (argLow.StartsWith(CmdJvmDll))
- cfg.JvmDllPath = arg.Substring(CmdJvmDll.Length);
- else if (argLow.StartsWith(CmdJvmClasspath))
- cfg.JvmClasspath = arg.Substring(CmdJvmClasspath.Length);
- else if (argLow.StartsWith(CmdSuppressWarn))
- {
- var val = arg.Substring(CmdSuppressWarn.Length);
-
- cfg.SuppressWarnings = bool.TrueString.ToLower().Equals(val.ToLower());
- }
- else if (argLow.StartsWith(CmdJvmMinMem))
- cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(arg.Substring(CmdJvmMinMem.Length),
- CmdJvmMinMem);
- else if (argLow.StartsWith(CmdJvmMaxMem))
- cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(arg.Substring(CmdJvmMaxMem.Length),
- CmdJvmMaxMem);
- else if (argLow.StartsWith(CmdJvmOpt))
- jvmOpts.Add(arg.Substring(CmdJvmOpt.Length));
- else if (argLow.StartsWith(CmdAssembly))
- assemblies.Add(arg.Substring(CmdAssembly.Length));
- }
-
- if (jvmOpts.Count > 0)
- {
- if (cfg.JvmOptions == null)
- cfg.JvmOptions = jvmOpts;
- else
- jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
- }
-
- if (assemblies.Count > 0)
- {
- if (cfg.Assemblies == null)
- cfg.Assemblies = assemblies;
- else
- assemblies.ForEach(val => cfg.Assemblies.Add(val));
- }
+ return args
+ .Select(x => x.TrimStart('-'))
+ .Select(x => x.StartsWith(Configurator.CmdJvmOpt + "-")
+ ? new[] {Configurator.CmdJvmOpt, x.Substring(Configurator.CmdJvmOpt.Length)}
+ : x.Split('='))
+ .Where(x => x.Length == 2)
+ .Select(x => Tuple.Create(x[0], x[1]));
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite/Config/Configurator.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Config/Configurator.cs b/modules/platforms/dotnet/Apache.Ignite/Config/Configurator.cs
new file mode 100644
index 0000000..af009e8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite/Config/Configurator.cs
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Config
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Configuration;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.Core;
+
+ /// <summary>
+ /// Configurator which uses arguments array.
+ /// </summary>
+ internal static class Configurator
+ {
+ /** Command line argument: Ignite home. */
+ public const string CmdIgniteHome = "IgniteHome";
+
+ /** Command line argument: Spring config URL. */
+ private const string CmdSpringCfgUrl = "SpringConfigUrl";
+
+ /** Command line argument: Path to JVM dll. */
+ private const string CmdJvmDll = "JvmDll";
+
+ /** Command line argument: JVM classpath. */
+ private const string CmdJvmClasspath = "JvmClasspath";
+
+ /** Command line argument: suppress warnings flag. */
+ private const string CmdSuppressWarn = "SuppressWarnings";
+
+ /** Command line argument: JVM option prefix. */
+ public const string CmdJvmOpt = "J";
+
+ /** Command line argument: assembly. */
+ public const string CmdAssembly = "Assembly";
+
+ /** Command line argument: JvmInitialMemoryMB. */
+ private const string CmdJvmMinMem = "JvmInitialMemoryMB";
+
+ /** Command line argument: JvmMaxMemoryMB. */
+ private const string CmdJvmMaxMem = "JvmMaxMemoryMB";
+
+ /** Command line argument: Config section name to read config from. */
+ private const string CmdConfigSection = "ConfigSectionName";
+
+ /** Command line argument: Config file name to read config section from. */
+ private const string CmdConfigFile = "ConfigFileName";
+
+ /** <inheritDoc /> */
+ public static IgniteConfiguration GetConfiguration(Tuple<string, string>[] args)
+ {
+ var jvmOpts = new List<string>();
+ var assemblies = new List<string>();
+
+ var cfg = ReadConfigurationSection(args) ?? new IgniteConfiguration();
+
+ foreach (var arg in args)
+ {
+ Func<string, bool> argIs = x => arg.Item1.Equals(x, StringComparison.OrdinalIgnoreCase);
+
+ if (argIs(CmdIgniteHome))
+ cfg.IgniteHome = arg.Item2;
+ else if (argIs(CmdSpringCfgUrl))
+ cfg.SpringConfigUrl = arg.Item2;
+ else if (argIs(CmdJvmDll))
+ cfg.JvmDllPath = arg.Item2;
+ else if (argIs(CmdJvmClasspath))
+ cfg.JvmClasspath = arg.Item2;
+ else if (argIs(CmdSuppressWarn))
+ {
+ cfg.SuppressWarnings = bool.TrueString.Equals(arg.Item2, StringComparison.OrdinalIgnoreCase);
+ }
+ else if (argIs(CmdJvmMinMem))
+ cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(arg.Item2, CmdJvmMinMem);
+ else if (argIs(CmdJvmMaxMem))
+ cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(arg.Item2, CmdJvmMaxMem);
+ else if (argIs(CmdJvmOpt))
+ jvmOpts.Add(arg.Item2);
+ else if (argIs(CmdAssembly))
+ assemblies.Add(arg.Item2);
+ }
+
+ if (jvmOpts.Count > 0)
+ {
+ if (cfg.JvmOptions == null)
+ cfg.JvmOptions = jvmOpts;
+ else
+ jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
+ }
+
+ if (assemblies.Count > 0)
+ {
+ if (cfg.Assemblies == null)
+ cfg.Assemblies = assemblies;
+ else
+ assemblies.ForEach(val => cfg.Assemblies.Add(val));
+ }
+
+ return cfg;
+ }
+
+ /// <summary>
+ /// Reads the configuration section.
+ /// </summary>
+ private static IgniteConfiguration ReadConfigurationSection(Tuple<string, string>[] args)
+ {
+ var fileName = FindValue(args, CmdConfigFile);
+ var sectionName = FindValue(args, CmdConfigSection);
+
+ if (string.IsNullOrEmpty(fileName) && string.IsNullOrEmpty(sectionName))
+ return null;
+
+ var cfg = string.IsNullOrEmpty(fileName)
+ ? ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
+ : ConfigurationManager.OpenMappedExeConfiguration(GetConfigMap(fileName), ConfigurationUserLevel.None);
+
+ var section = string.IsNullOrEmpty(sectionName)
+ ? cfg.Sections.OfType<IgniteConfigurationSection>().FirstOrDefault()
+ : (IgniteConfigurationSection) cfg.GetSection(sectionName);
+
+ if (section == null)
+ throw new ConfigurationErrorsException(
+ string.Format("Could not find {0} in current application configuration",
+ typeof(IgniteConfigurationSection).Name));
+
+ return section.IgniteConfiguration;
+ }
+
+ /// <summary>
+ /// Gets the configuration file map.
+ /// </summary>
+ private static ExeConfigurationFileMap GetConfigMap(string fileName)
+ {
+ fileName = Path.GetFullPath(fileName);
+
+ if (!File.Exists(fileName))
+ throw new InvalidOperationException("Specified config file does not exist: " + fileName);
+
+ return new ExeConfigurationFileMap {ExeConfigFilename = fileName};
+ }
+
+ /// <summary>
+ /// Finds the config value.
+ /// </summary>
+ private static string FindValue(IEnumerable<Tuple<string, string>> args, string name)
+ {
+ return args.Where(x => name.Equals(x.Item1, StringComparison.OrdinalIgnoreCase))
+ .Select(x => x.Item2)
+ .FirstOrDefault();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite/Config/IConfigurator.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Config/IConfigurator.cs b/modules/platforms/dotnet/Apache.Ignite/Config/IConfigurator.cs
deleted file mode 100644
index f5c0acf..0000000
--- a/modules/platforms/dotnet/Apache.Ignite/Config/IConfigurator.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-namespace Apache.Ignite.Config
-{
- using Apache.Ignite.Core;
-
- /// <summary>
- /// Configurator which is capable of setting configuration properties taken from somewhere.
- /// </summary>
- internal interface IConfigurator<in T>
- {
- /// <summary>
- /// Set configuration.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- /// <param name="src">Source.</param>
- void Configure(IgniteConfiguration cfg, T src);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs b/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
index 122994f..68a8445 100644
--- a/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
@@ -49,8 +49,6 @@ namespace Apache.Ignite
/// </summary>
internal static void Main(string[] args)
{
- IgniteConfiguration cfg;
-
bool svc = false;
bool install = false;
@@ -59,7 +57,7 @@ namespace Apache.Ignite
// Check for special cases.
if (args.Length > 0)
{
- string first = args[0].ToLower();
+ string first = args[0].ToLowerInvariant();
if (Help.Contains(first))
{
@@ -91,19 +89,15 @@ namespace Apache.Ignite
if (!svc)
{
- // Pick application configuration.
- cfg = new IgniteConfiguration();
-
- new AppSettingsConfigurator().Configure(cfg, ConfigurationManager.AppSettings);
-
- // Pick command line arguments.
- new ArgsConfigurator().Configure(cfg, args);
+ // Pick application configuration first, command line arguments second.
+ var allArgs = AppSettingsConfigurator.GetArgs(ConfigurationManager.AppSettings)
+ .Concat(ArgsConfigurator.GetArgs(args)).ToArray();
if (install)
- IgniteService.DoInstall(cfg);
+ IgniteService.DoInstall(allArgs);
else
{
- Ignition.Start(cfg);
+ Ignition.Start(Configurator.GetConfiguration(allArgs));
IgniteManager.DestroyJvm();
}
@@ -113,16 +107,14 @@ namespace Apache.Ignite
}
catch (Exception e)
{
- Console.WriteLine("ERROR: " + e.Message);
+ Console.WriteLine("ERROR: " + e);
Environment.Exit(-1);
}
// If we are here, then this is a service call.
- cfg = new IgniteConfiguration();
-
// Use only arguments, not app.config.
- new ArgsConfigurator().Configure(cfg, args);
+ var cfg = Configurator.GetConfiguration(ArgsConfigurator.GetArgs(args).ToArray());
ServiceBase.Run(new IgniteService(cfg));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e3ba037a/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs b/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
index 49cce44..c64c7bf 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
@@ -25,7 +25,6 @@ namespace Apache.Ignite.Service
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Text;
- using Apache.Ignite.Config;
using Apache.Ignite.Core;
using Apache.Ignite.Core.Common;
@@ -35,21 +34,21 @@ namespace Apache.Ignite.Service
internal class IgniteService : ServiceBase
{
/** Service name. */
- internal static readonly string SvcName = "Apache Ignite.NET";
+ private static readonly string SvcName = "Apache Ignite.NET";
/** Service display name. */
- internal static readonly string SvcDisplayName = "Apache Ignite.NET " +
+ private static readonly string SvcDisplayName = "Apache Ignite.NET " +
Assembly.GetExecutingAssembly().GetName().Version.ToString(4);
/** Service description. */
- internal static readonly string SvcDesc = "Apache Ignite.NET Service.";
+ private static readonly string SvcDesc = "Apache Ignite.NET Service.";
/** Current executable name. */
- internal static readonly string ExeName =
+ private static readonly string ExeName =
new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).FullName;
/** Current executable fully qualified name. */
- internal static readonly string FullExeName = Path.GetFileName(FullExeName);
+ private static readonly string FullExeName = Path.GetFileName(FullExeName);
/** Ignite configuration to start with. */
private readonly IgniteConfiguration _cfg;
@@ -81,8 +80,8 @@ namespace Apache.Ignite.Service
/// <summary>
/// Install service programmatically.
/// </summary>
- /// <param name="cfg">Ignite configuration.</param>
- internal static void DoInstall(IgniteConfiguration cfg)
+ /// <param name="args">The arguments.</param>
+ internal static void DoInstall(Tuple<string, string>[] args)
{
// 1. Check if already defined.
if (ServiceController.GetServices().Any(svc => SvcName.Equals(svc.ServiceName)))
@@ -92,8 +91,6 @@ namespace Apache.Ignite.Service
}
// 2. Create startup arguments.
- var args = ArgsConfigurator.ToArgs(cfg);
-
if (args.Length > 0)
{
Console.WriteLine("Installing \"" + SvcName + "\" service with the following startup " +
@@ -140,13 +137,13 @@ namespace Apache.Ignite.Service
/// Native service installation.
/// </summary>
/// <param name="args">Arguments.</param>
- private static void Install0(string[] args)
+ private static void Install0(Tuple<string, string>[] args)
{
// 1. Prepare arguments.
var binPath = new StringBuilder(FullExeName).Append(" ").Append(IgniteRunner.Svc);
foreach (var arg in args)
- binPath.Append(" ").Append(arg);
+ binPath.Append(" ").AppendFormat("-{0}={1}", arg.Item1, arg.Item2);
// 2. Get SC manager.
var scMgr = OpenServiceControlManager();
[04/11] ignite git commit: IGNITE-2872 .NET: Removed deprecation from
IgniteConfiguration.SpringConfigUrl property. This closes #571.
Posted by nt...@apache.org.
IGNITE-2872 .NET: Removed deprecation from IgniteConfiguration.SpringConfigUrl property. This closes #571.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7864826c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7864826c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7864826c
Branch: refs/heads/ignite-11048
Commit: 7864826c2c99faf68276f7d963fe66b6e7ccb52e
Parents: afe453f
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Mar 24 17:15:15 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Mar 24 17:15:15 2016 +0300
----------------------------------------------------------------------
.../dotnet/Apache.Ignite.Core/IgniteConfiguration.cs | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7864826c/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index e8cc8ff..2aa6899 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -318,12 +318,14 @@
/// <summary>
/// URL to Spring configuration file.
+ /// <para />
+ /// Ignite.NET can be configured natively without Spring.
+ /// Setting this property will ignore all other properties except <see cref="IgniteHome"/>,
+ /// <see cref="Assemblies"/>, <see cref="SuppressWarnings"/>, <see cref="LifecycleBeans"/>,
+ /// <see cref="JvmOptions"/>, <see cref="JvmDllPath"/>, <see cref="IgniteHome"/>,
+ /// <see cref="JvmInitialMemoryMb"/>, <see cref="JvmMaxMemoryMb"/>.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
- [Obsolete("Ignite.NET can be configured natively without Spring. " +
- "Setting this property will ignore all other properties except " +
- "IgniteHome, Assemblies, SuppressWarnings, LifecycleBeans, JvmOptions, JvmdllPath, IgniteHome, " +
- "JvmInitialMemoryMb, JvmMaxMemoryMb.")]
public string SpringConfigUrl { get; set; }
/// <summary>
[10/11] ignite git commit: IGNITE-2889 .NET: Added tests for
IBinaryNameMapper. This closes #578.
Posted by nt...@apache.org.
IGNITE-2889 .NET: Added tests for IBinaryNameMapper. This closes #578.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/166bce84
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/166bce84
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/166bce84
Branch: refs/heads/ignite-11048
Commit: 166bce84516e6c1c10381eb6fa4fe356c9b83e1d
Parents: 090144c
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Mar 25 09:26:30 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Mar 25 09:26:30 2016 +0300
----------------------------------------------------------------------
.../Binary/BinaryBuilderSelfTest.cs | 60 +++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/166bce84/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
index e2f7d8a..1199790 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -17,6 +17,7 @@
// ReSharper disable UnassignedField.Global
// ReSharper disable CollectionNeverUpdated.Global
+// ReSharper disable UnusedAutoPropertyAccessor.Global
namespace Apache.Ignite.Core.Tests.Binary
{
using System;
@@ -83,9 +84,11 @@ namespace Apache.Ignite.Core.Tests.Binary
new BinaryTypeConfiguration(typeof (BuilderCollectionItem)),
new BinaryTypeConfiguration(typeof (DecimalHolder)),
new BinaryTypeConfiguration(TypeEmpty),
- new BinaryTypeConfiguration(typeof(TestEnumRegistered))
+ new BinaryTypeConfiguration(typeof(TestEnumRegistered)),
+ new BinaryTypeConfiguration(typeof(NameMapperTestType))
},
DefaultIdMapper = new IdMapper(),
+ DefaultNameMapper = new NameMapper(),
CompactFooter = GetCompactFooter()
},
JvmClasspath = TestUtils.CreateTestClasspath(),
@@ -1382,6 +1385,22 @@ namespace Apache.Ignite.Core.Tests.Binary
}
/// <summary>
+ /// Tests type name mapper.
+ /// </summary>
+ [Test]
+ public void TestTypeName()
+ {
+ var bytes = _marsh.Marshal(new NameMapperTestType {NameMapperTestField = 17});
+
+ var bin = _marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ var binType = bin.GetBinaryType();
+
+ Assert.AreEqual(BinaryUtils.GetStringHashCode(NameMapper.TestTypeName + "_"), binType.TypeId);
+ Assert.AreEqual(17, bin.GetField<int>(NameMapper.TestFieldName));
+ }
+
+ /// <summary>
/// Tests metadata methods.
/// </summary>
[Test]
@@ -1784,4 +1803,43 @@ namespace Apache.Ignite.Core.Tests.Binary
return 0;
}
}
+
+ /// <summary>
+ /// Test name mapper.
+ /// </summary>
+ public class NameMapper : IBinaryNameMapper
+ {
+ /** */
+ public const string TestTypeName = "NameMapperTestType";
+
+ /** */
+ public const string TestFieldName = "NameMapperTestField";
+
+ /** <inheritdoc /> */
+ public string GetTypeName(string name)
+ {
+ if (name == TestTypeName)
+ return name + "_";
+
+ return name;
+ }
+
+ /** <inheritdoc /> */
+ public string GetFieldName(string name)
+ {
+ if (name == TestFieldName)
+ return name + "_";
+
+ return name;
+ }
+ }
+
+ /// <summary>
+ /// Name mapper test type.
+ /// </summary>
+ public class NameMapperTestType
+ {
+ /** */
+ public int NameMapperTestField { get; set; }
+ }
}
[06/11] ignite git commit: IGNITE-2849: BinaryObjectBuilder doesn't
properly check metadata
Posted by nt...@apache.org.
IGNITE-2849: BinaryObjectBuilder doesn't properly check metadata
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/093623eb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/093623eb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/093623eb
Branch: refs/heads/ignite-11048
Commit: 093623eb4ca69fdb8ff705ebc50d4b867be8b2e9
Parents: e3ba037
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Mar 24 20:07:48 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Mar 24 20:07:48 2016 +0300
----------------------------------------------------------------------
.../cache/store/jdbc/CacheJdbcPojoStore.java | 2 +-
.../ignite/internal/binary/BinaryUtils.java | 16 ---
.../binary/builder/BinaryObjectBuilderImpl.java | 107 ++++++++------
.../BinaryObjectBuilderAdditionalSelfTest.java | 144 +++++++++++++++++--
...naryObjectBuilderDefaultMappersSelfTest.java | 2 +-
5 files changed, 197 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/093623eb/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
index 200aa0f..b9a3118 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
@@ -248,7 +248,7 @@ public class CacheJdbcPojoStore<K, V> extends CacheAbstractJdbcStore<K, V> {
Object colVal = getColumnValue(rs, colIdx, field.getJavaFieldType());
- builder.setField(field.getJavaFieldName(), colVal);
+ builder.setField(field.getJavaFieldName(), colVal, (Class<Object>)field.getJavaFieldType());
if (calcHash)
hashValues.add(colVal);
http://git-wip-us.apache.org/repos/asf/ignite/blob/093623eb/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 727501a..37f1d6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -320,22 +320,6 @@ public class BinaryUtils {
}
/**
- * @param typeName Field type name.
- * @return Field type ID;
- */
- @SuppressWarnings("StringEquality")
- public static int fieldTypeId(String typeName) {
- for (int i = 0; i < FIELD_TYPE_NAMES.length; i++) {
- String typeName0 = FIELD_TYPE_NAMES[i];
-
- if (typeName.equals(typeName0))
- return i;
- }
-
- throw new IllegalArgumentException("Invalid metadata type name: " + typeName);
- }
-
- /**
* @param typeId Field type ID.
* @return Field type name.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/093623eb/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index 9043a8b..16c51b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -195,6 +195,10 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
Set<Integer> remainsFlds = null;
+ BinaryType meta = ctx.metadata(typeId);
+
+ Map<String, Integer> fieldsMeta = null;
+
if (reader != null) {
BinarySchema schema = reader.schema();
@@ -204,9 +208,15 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
assignedFldsById = U.newHashMap(assignedVals.size());
for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
- int fieldId = ctx.fieldId(typeId, entry.getKey());
+ String name = entry.getKey();
+ Object val = entry.getValue();
+
+ int fieldId = ctx.fieldId(typeId, name);
- assignedFldsById.put(fieldId, entry.getValue());
+ assignedFldsById.put(fieldId, val);
+
+ if (val != REMOVED_FIELD_MARKER)
+ fieldsMeta = checkMetadata(meta, fieldsMeta, val, name);
}
remainsFlds = assignedFldsById.keySet();
@@ -280,10 +290,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
}
- BinaryType meta = ctx.metadata(typeId);
-
- Map<String, Integer> fieldsMeta = null;
-
if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
Object val = entry.getValue();
@@ -302,43 +308,9 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
serializer.writeValue(writer, val);
- String oldFldTypeName = meta == null ? null : meta.fieldTypeName(name);
-
- boolean nullObjField = false;
-
- int newFldTypeId;
-
- if (val instanceof BinaryValueWithType) {
- newFldTypeId = ((BinaryValueWithType)val).typeId();
-
- if (newFldTypeId == GridBinaryMarshaller.OBJ && ((BinaryValueWithType)val).value() == null)
- nullObjField = true;
- }
- else
- newFldTypeId = BinaryUtils.typeByClass(val.getClass());
-
- String newFldTypeName = BinaryUtils.fieldTypeName(newFldTypeId);
-
- if (oldFldTypeName == null) {
- // It's a new field, we have to add it to metadata.
- if (fieldsMeta == null)
- fieldsMeta = new HashMap<>();
-
- fieldsMeta.put(name, BinaryUtils.fieldTypeId(newFldTypeName));
- }
- else if (!nullObjField) {
- String objTypeName = BinaryUtils.fieldTypeName(GridBinaryMarshaller.OBJ);
-
- if (!objTypeName.equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
- throw new BinaryObjectException(
- "Wrong value has been set [" +
- "typeName=" + (typeName == null ? meta.typeName() : typeName) +
- ", fieldName=" + name +
- ", fieldType=" + oldFldTypeName +
- ", assignedValueType=" + newFldTypeName + ']'
- );
- }
- }
+ if (reader == null)
+ // Metadata has already been checked.
+ fieldsMeta = checkMetadata(meta, fieldsMeta, val, name);
}
}
@@ -386,6 +358,55 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
}
+ /**
+ * Checks metadata when a BinaryObject is being serialized.
+ *
+ * @param meta Current metadata.
+ * @param fieldsMeta Map holding metadata information that has to be updated.
+ * @param newVal Field value being serialized.
+ * @param name Field name.
+ */
+ private Map<String, Integer> checkMetadata(BinaryType meta, Map<String, Integer> fieldsMeta, Object newVal,
+ String name) {
+ String oldFldTypeName = meta == null ? null : meta.fieldTypeName(name);
+
+ boolean nullFieldVal = false;
+
+ int newFldTypeId;
+
+ if (newVal instanceof BinaryValueWithType) {
+ newFldTypeId = ((BinaryValueWithType)newVal).typeId();
+
+ if (((BinaryValueWithType)newVal).value() == null)
+ nullFieldVal = true;
+ }
+ else
+ newFldTypeId = BinaryUtils.typeByClass(newVal.getClass());
+
+ if (oldFldTypeName == null) {
+ // It's a new field, we have to add it to metadata.
+ if (fieldsMeta == null)
+ fieldsMeta = new HashMap<>();
+
+ fieldsMeta.put(name, newFldTypeId);
+ }
+ else if (!nullFieldVal) {
+ String newFldTypeName = BinaryUtils.fieldTypeName(newFldTypeId);
+
+ if (!F.eq(newFldTypeName, oldFldTypeName)) {
+ throw new BinaryObjectException(
+ "Wrong value has been set [" +
+ "typeName=" + (typeName == null ? meta.typeName() : typeName) +
+ ", fieldName=" + name +
+ ", fieldType=" + oldFldTypeName +
+ ", assignedValueType=" + newFldTypeName + ']'
+ );
+ }
+ }
+
+ return fieldsMeta;
+ }
+
/** {@inheritDoc} */
@Override public BinaryObjectBuilderImpl hashCode(int hashCode) {
this.hashCode = hashCode;
http://git-wip-us.apache.org/repos/asf/ignite/blob/093623eb/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
index 804c060..e3e538b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -234,7 +235,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
public void testDateArrayModification() {
GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
- obj.dateArr = new Date[] {new Date(11111), new Date(11111), new Date(11111)};
+ obj.dateArr = new Date[] {new Date(11111), new Date(11111), new Date(11111)};
BinaryObjectBuilderImpl mutObj = wrap(obj);
@@ -498,7 +499,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
- mutObj.setField("foo", createdArr.clone());
+ mutObj.setField("foo", createdArr.clone(), Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -555,7 +556,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
ArrayList<Object> list = Lists.newArrayList(mutObj, "a", Lists.newArrayList(1, 2));
- mutObj.setField("foo", list);
+ mutObj.setField("foo", list, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -653,7 +654,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
List<Object> list = Lists.newLinkedList(Arrays.asList(mutObj, "a", Lists.newLinkedList(Arrays.asList(1, 2))));
- mutObj.setField("foo", list);
+ mutObj.setField("foo", list, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -736,7 +737,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
Set<Object> c = Sets.newHashSet(mutObj, "a", Sets.newHashSet(1, 2));
- mutObj.setField("foo", c);
+ mutObj.setField("foo", c, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -815,7 +816,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
Map<Object, Object> map = Maps.newHashMap(ImmutableMap.of(mutObj, "a", "b", mutObj));
- mutObj.setField("foo", map);
+ mutObj.setField("foo", map, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -995,6 +996,123 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
/**
*
*/
+ public void testWrongMetadataNullField() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType");
+
+ builder.setField("dateField", null);
+
+ builder.setField("objectField", null, Integer.class);
+
+ builder.build();
+
+ try {
+ builder = binaries().builder("SomeType");
+
+ builder.setField("dateField", new Date());
+
+ builder.build();
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+
+ builder = binaries().builder("SomeType");
+
+ try {
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+
+ fail("BinaryObjectBuilder accepted wrong metadata");
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+ }
+
+ /**
+ *
+ */
+ public void testWrongMetadataNullField2() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType1");
+
+ builder.setField("dateField", null);
+
+ builder.setField("objectField", null, Integer.class);
+
+ BinaryObject obj = builder.build();
+
+ try {
+ builder = binaries().builder(obj);
+
+ builder.setField("dateField", new Date());
+
+ builder.build();
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+
+ builder = binaries().builder(obj);
+
+ try {
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+
+ fail("BinaryObjectBuilder accepted wrong metadata");
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+ }
+
+ /**
+ *
+ */
+ public void testCorrectMetadataNullField() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType2");
+
+ builder.setField("dateField", null, Date.class);
+
+ builder.setField("objectField", null, GridBinaryTestClasses.Company.class);
+
+ builder.build();
+
+ builder = binaries().builder("SomeType2");
+
+ builder.setField("dateField", new Date());
+
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+
+ }
+
+ /**
+ *
+ */
+ public void testCorrectMetadataNullField2() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType3");
+
+ builder.setField("dateField", null, Date.class);
+
+ builder.setField("objectField", null, GridBinaryTestClasses.Company.class);
+
+ BinaryObject obj = builder.build();
+
+ builder = binaries().builder(obj);
+
+ builder.setField("dateField", new Date());
+
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+ }
+
+ /**
+ *
+ */
public void testDateInObjectField() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
@@ -1053,9 +1171,9 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
BinaryObjectBuilderImpl mutableObj = wrap(obj);
- Date[] arr = { new Date() };
+ Date[] arr = {new Date()};
- mutableObj.setField("foo", arr);
+ mutableObj.setField("foo", arr, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
@@ -1072,9 +1190,9 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
BinaryObjectBuilderImpl mutableObj = wrap(obj);
- Timestamp[] arr = { new Timestamp(100020003) };
+ Timestamp[] arr = {new Timestamp(100020003)};
- mutableObj.setField("foo", arr);
+ mutableObj.setField("foo", arr, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
@@ -1264,7 +1382,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
CacheObjectBinaryProcessorImpl processor = (CacheObjectBinaryProcessorImpl)(
(IgniteBinaryImpl)binaries()).processor();
- return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
+ return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
processor.binaryContext().userTypeName(aCls.getName()));
}
@@ -1305,7 +1423,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
root.setField("linkedHashSet", linkedHashSet);
root.setField("singletonList", Collections.singletonList(Integer.MAX_VALUE), Collection.class);
- root.setField("singletonSet", Collections.singleton(Integer.MAX_VALUE), Collection.class);
+ root.setField("singletonSet", Collections.singleton(Integer.MAX_VALUE), Collection.class);
// maps
root.setField("hashMap", hashMap);
@@ -1319,7 +1437,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
root.setField("asMap", Collections.singletonMap("key", "val"));
root.setField("asListHint", Collections.singletonList(Integer.MAX_VALUE), List.class);
root.setField("asSetHint", Collections.singleton(Integer.MAX_VALUE), Set.class);
- root.setField("asMapHint", (AbstractMap) Collections.singletonMap("key", "val"), AbstractMap.class);
+ root.setField("asMapHint", (AbstractMap)Collections.singletonMap("key", "val"), AbstractMap.class);
BinaryObject binaryObj = root.build();
http://git-wip-us.apache.org/repos/asf/ignite/blob/093623eb/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
index 9659c39..4fc5c6c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -146,7 +146,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
builder = builder(obj);
- builder.setField("objField", "value");
+ builder.setField("objField", "value", Object.class);
builder.setField("otherField", (Object)null);
obj = builder.build();