You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sh...@apache.org on 2016/11/01 02:38:03 UTC
[44/50] [abbrv] ignite git commit: IGNITE-2383 Non-string system
properties should be ignored in node attributes and update checker
IGNITE-2383 Non-string system properties should be ignored in node attributes and update checker
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3adc493b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3adc493b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3adc493b
Branch: refs/heads/ignite-2788
Commit: 3adc493b0616e4b5f56a253513b8ab684c394010
Parents: 1beea53
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 28 15:30:39 2016 +0300
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Fri May 13 16:11:16 2016 +0900
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 16 ++-
.../processors/cluster/GridUpdateNotifier.java | 3 +-
...GridServiceProxyClientReconnectSelfTest.java | 2 +-
.../properties/NotStringSystemPropertyTest.java | 124 +++++++++++++++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +
5 files changed, 144 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3adc493b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 858cb71..c8a2566 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -19,6 +19,8 @@ package org.apache.ignite;
import java.io.Serializable;
import java.lang.management.RuntimeMXBean;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
import javax.net.ssl.HostnameVerifier;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
@@ -542,10 +544,22 @@ public final class IgniteSystemProperties {
/**
* Gets snapshot of system properties.
* Snapshot could be used for thread safe iteration over system properties.
+ * Non-string properties are removed before return.
*
* @return Snapshot of system properties.
*/
public static Properties snapshot() {
- return (Properties)System.getProperties().clone();
+ Properties sysProps = (Properties)System.getProperties().clone();
+
+ Iterator<Map.Entry<Object, Object>> iter = sysProps.entrySet().iterator();
+
+ while (iter.hasNext()) {
+ Map.Entry entry = iter.next();
+
+ if (!(entry.getValue() instanceof String) || !(entry.getKey() instanceof String))
+ iter.remove();
+ }
+
+ return sysProps;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3adc493b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
index 2e2f9e4..b41bf28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
@@ -37,6 +37,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.internal.GridKernalGateway;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgniteProperties;
@@ -201,7 +202,7 @@ class GridUpdateNotifier {
StringWriter sw = new StringWriter();
try {
- System.getProperties().store(new PrintWriter(sw), "");
+ IgniteSystemProperties.snapshot().store(new PrintWriter(sw), "");
}
catch (IOException ignore) {
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/3adc493b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
index 2488e7a..1fa6b0f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
@@ -82,7 +82,7 @@ public class GridServiceProxyClientReconnectSelfTest extends GridCommonAbstractT
startGrid("server");
- assert latch.await(2000, TimeUnit.MILLISECONDS);
+ assert latch.await(10, TimeUnit.SECONDS);
client.services().deployClusterSingleton("my-service", new MyServiceImpl());
http://git-wip-us.apache.org/repos/asf/ignite/blob/3adc493b/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java b/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java
new file mode 100644
index 0000000..5e108a6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.startup.properties;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * The test checks start of Ignite with non-string properties.
+ */
+public class NotStringSystemPropertyTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration optimize(IgniteConfiguration cfg) throws IgniteCheckedException {
+ IgniteConfiguration oCfg = super.optimize(cfg);
+
+ oCfg.setIncludeProperties(null);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If fail.
+ */
+ public void testGridStart() throws Exception {
+ Some some = new Some(0, "prop");
+
+ String p = "NotStringSystemPropertyTest";
+
+ System.getProperties().put(p, p);
+ System.getProperties().put(some, "prop");
+ System.getProperties().put("prop", new Some(0, "prop"));
+
+ try {
+ Ignite ignite = startGridsMultiThreaded(2);
+
+ assertNull(ignite.configuration().getIncludeProperties());
+
+ assertEquals(p, ignite.cluster().localNode().attribute(p));
+
+ checkTopology(2);
+ }
+ finally {
+ System.getProperties().remove(some);
+ System.getProperties().remove("prop");
+ System.getProperties().remove(p);
+
+ stopAllGrids();
+ }
+ }
+
+ /**
+ * Some non-string class.
+ */
+ private static class Some {
+ /**
+ * Int field.
+ */
+ private int cnt = 0;
+
+ /**
+ * String field.
+ */
+ private String name;
+
+ /**
+ * @param cnt Int value.
+ * @param name String value.
+ */
+ public Some(int cnt, String name) {
+ this.cnt = cnt;
+ this.name = name;
+ }
+
+ /**
+ * @return Count.
+ */
+ public int getCount() {
+ return cnt;
+ }
+
+ /**
+ * @param cnt Count.
+ */
+ public void setCount(int cnt) {
+ this.cnt = cnt;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Some [cnt=" + cnt + ", name=" + name + ']';
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3adc493b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index c67a07d..6b4ef70 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -50,6 +50,7 @@ import org.apache.ignite.messaging.GridMessagingNoPeerClassLoadingSelfTest;
import org.apache.ignite.messaging.GridMessagingSelfTest;
import org.apache.ignite.messaging.IgniteMessagingWithClientTest;
import org.apache.ignite.spi.GridSpiLocalHostInjectionTest;
+import org.apache.ignite.startup.properties.NotStringSystemPropertyTest;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.test.ConfigVariationsTestSuiteBuilderTest;
import org.apache.ignite.testframework.test.ParametersTest;
@@ -130,6 +131,7 @@ public class IgniteBasicTestSuite extends TestSuite {
suite.addTestSuite(ParametersTest.class);
suite.addTestSuite(VariationsIteratorTest.class);
suite.addTestSuite(ConfigVariationsTestSuiteBuilderTest.class);
+ suite.addTestSuite(NotStringSystemPropertyTest.class);
return suite;
}