You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2018/03/13 14:41:12 UTC
ignite git commit: IGNITE-7765 Ensure that walSegmentSize doesn't
overflow.
Repository: ignite
Updated Branches:
refs/heads/master 1f8ec79d2 -> 8da7c9e1b
IGNITE-7765 Ensure that walSegmentSize doesn't overflow.
Signed-off-by: Andrey Gura <ag...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8da7c9e1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8da7c9e1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8da7c9e1
Branch: refs/heads/master
Commit: 8da7c9e1b90d14fbce971a6566ce369b795ed30b
Parents: 1f8ec79
Author: Ivan Daschinskiy <iv...@gmail.com>
Authored: Tue Mar 13 17:32:02 2018 +0300
Committer: Andrey Gura <ag...@apache.org>
Committed: Tue Mar 13 17:32:30 2018 +0300
----------------------------------------------------------------------
.../configuration/DataStorageConfiguration.java | 8 ++--
.../DataStorageConfigurationValidationTest.java | 46 ++++++++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
3 files changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8da7c9e1/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
index 4a3dbbf..a433760 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
@@ -528,16 +528,18 @@ public class DataStorageConfiguration implements Serializable {
* @return WAL segment size.
*/
public int getWalSegmentSize() {
- return walSegmentSize <= 0 ? DFLT_WAL_SEGMENT_SIZE : walSegmentSize;
+ return walSegmentSize == 0 ? DFLT_WAL_SEGMENT_SIZE : walSegmentSize;
}
/**
* Sets size of a WAL segment.
*
- * @param walSegmentSize WAL segment size. 64 MB is used by default. Maximum value is 2Gb
- * @return {@code this} for chaining.
+ * @param walSegmentSize WAL segment size. 64 MB is used by default. Maximum value is 2Gb.
+ * @return {@code This} for chaining.
*/
public DataStorageConfiguration setWalSegmentSize(int walSegmentSize) {
+ A.ensure(walSegmentSize >= 0, "WAL segment size must be non-negative and less than 2 Gb.");
+
this.walSegmentSize = walSegmentSize;
return this;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8da7c9e1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java
new file mode 100644
index 0000000..7f667ee
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.Callable;
+import junit.framework.TestCase;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Tests assertions in DataStorageConfiguration.
+ */
+public class DataStorageConfigurationValidationTest extends TestCase {
+ /**
+ * Tests {@link DataStorageConfiguration#walSegmentSize} property assertion.
+ *
+ * @throws Exception If failed.
+ */
+ public void testWalSegmentSizeOveflow() throws Exception {
+ final DataStorageConfiguration cfg = new DataStorageConfiguration();
+
+ GridTestUtils.assertThrows(null, new Callable<Void>() {
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cfg.setWalSegmentSize(1 << 31);
+
+ return null;
+ }
+ }, IllegalArgumentException.class, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8da7c9e1/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index b309b0a..bb397f7 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -82,6 +82,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSwapPreloadSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheTxPartitionedLocalStoreSelfTest;
import org.apache.ignite.internal.processors.cache.GridDataStorageConfigurationConsistencySelfTest;
+import org.apache.ignite.internal.processors.cache.DataStorageConfigurationValidationTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicInvokeTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalInvokeTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalWithStoreInvokeTest;
@@ -229,6 +230,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheConfigurationValidationSelfTest.class);
suite.addTestSuite(GridCacheConfigurationConsistencySelfTest.class);
suite.addTestSuite(GridDataStorageConfigurationConsistencySelfTest.class);
+ suite.addTestSuite(DataStorageConfigurationValidationTest.class);
suite.addTestSuite(GridCacheJdbcBlobStoreSelfTest.class);
suite.addTestSuite(GridCacheJdbcBlobStoreMultithreadedSelfTest.class);
suite.addTestSuite(JdbcTypesDefaultTransformerTest.class);