Repository: ignite Updated Branches: refs/heads/master e7a530791 -> 3459bdd3a
Reviewed and merged IGNITE-4374 contributed by daradurvs daradurvs at gmail.com Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3459bdd3 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3459bdd3 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3459bdd3 Branch: refs/heads/master Commit: 3459bdd3a35869df13c9b35f616325c0c3e3481e Parents: e7a5307 Author: daradurvs <[email protected]> Authored: Thu Feb 9 20:29:02 2017 +0700 Committer: Yakov Zhdanov <[email protected]> Committed: Thu Feb 9 20:29:02 2017 +0700 ---------------------------------------------------------------------- .../ignite/internal/GridKernalContext.java | 1 + .../ignite/internal/GridKernalContextImpl.java | 1 + .../internal/GridPerformanceSuggestions.java | 92 -------------- .../apache/ignite/internal/IgniteKernal.java | 9 ++ .../processors/cache/GridCacheProcessor.java | 2 +- .../suggestions/GridPerformanceSuggestions.java | 104 +++++++++++++++ .../JvmConfigurationSuggestions.java | 104 +++++++++++++++ .../suggestions/OsConfigurationSuggestions.java | 127 +++++++++++++++++++ .../internal/suggestions/package-info.java | 21 +++ .../ignite/internal/util/IgniteUtils.java | 14 ++ 10 files changed, 382 insertions(+), 93 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java index 927944f..00696c7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java @@ -65,6 +65,7 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessor; import org.apache.ignite.internal.processors.session.GridTaskSessionProcessor; import org.apache.ignite.internal.processors.task.GridTaskProcessor; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.suggestions.GridPerformanceSuggestions; import org.apache.ignite.internal.util.IgniteExceptionRegistry; import org.apache.ignite.internal.util.StripedExecutor; import org.apache.ignite.internal.util.tostring.GridToStringExclude; http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java index a2ad1b2..e80ec6b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java @@ -82,6 +82,7 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessor; import org.apache.ignite.internal.processors.session.GridTaskSessionProcessor; import org.apache.ignite.internal.processors.task.GridTaskProcessor; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.suggestions.GridPerformanceSuggestions; import org.apache.ignite.internal.util.IgniteExceptionRegistry; import org.apache.ignite.internal.util.StripedExecutor; import org.apache.ignite.internal.util.spring.IgniteSpringHelper; http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/GridPerformanceSuggestions.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridPerformanceSuggestions.java b/modules/core/src/main/java/org/apache/ignite/internal/GridPerformanceSuggestions.java deleted file mode 100644 index 5e8e520..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridPerformanceSuggestions.java +++ /dev/null @@ -1,92 +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. - */ - -package org.apache.ignite.internal; - -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashSet; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.IgniteSystemProperties.IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED; - -/** - * Grid performance suggestions. - */ -public class GridPerformanceSuggestions { - /** */ - private static final boolean disabled = Boolean.getBoolean(IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED); - - /** */ - private final Collection<String> perfs = !disabled ? new LinkedHashSet<String>() : null; - - /** */ - private final Collection<String> suppressed = !disabled ? new HashSet<String>() : null; - - /** - * @param sug Suggestion to add. - */ - public synchronized void add(String sug) { - add(sug, false); - } - - /** - * @param sug Suggestion to add. - * @param suppress {@code True} to suppress this suggestion. - */ - public synchronized void add(String sug, boolean suppress) { - if (disabled) - return; - - if (!suppress) - perfs.add(sug); - else - suppressed.add(sug); - } - - /** - * @param log Log. - * @param gridName Grid name. - */ - public synchronized void logSuggestions(IgniteLogger log, @Nullable String gridName) { - if (disabled) - return; - - if (!F.isEmpty(perfs) && !suppressed.containsAll(perfs)) { - U.quietAndInfo(log, "Performance suggestions for grid " + - (gridName == null ? "" : '\'' + gridName + '\'') + " (fix if possible)"); - U.quietAndInfo(log, "To disable, set -D" + IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED + "=true"); - - for (String s : perfs) - if (!suppressed.contains(s)) - U.quietAndInfo(log, " ^-- " + s); - - U.quietAndInfo(log, ""); - - perfs.clear(); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridPerformanceSuggestions.class, this); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 9f1c746..a3d8c7b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -138,6 +138,9 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessor; import org.apache.ignite.internal.processors.session.GridTaskSessionProcessor; import org.apache.ignite.internal.processors.task.GridTaskProcessor; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.suggestions.GridPerformanceSuggestions; +import org.apache.ignite.internal.suggestions.JvmConfigurationSuggestions; +import org.apache.ignite.internal.suggestions.OsConfigurationSuggestions; import org.apache.ignite.internal.util.StripedExecutor; import org.apache.ignite.internal.util.future.GridCompoundFuture; import org.apache.ignite.internal.util.future.GridFinishedFuture; @@ -930,6 +933,12 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { // Suggest configuration optimizations. suggestOptimizations(cfg); + // Suggest JVM optimizations. + ctx.performance().addAll(JvmConfigurationSuggestions.getSuggestions()); + + // Suggest Operation System optimizations. + ctx.performance().addAll(OsConfigurationSuggestions.getSuggestions()); + // Notify discovery manager the first to make sure that topology is discovered. ctx.discovery().onKernalStart(); http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index 87f5236..b0a78f4 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -63,7 +63,7 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.events.EventType; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.GridPerformanceSuggestions; +import org.apache.ignite.internal.suggestions.GridPerformanceSuggestions; import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; import org.apache.ignite.internal.IgniteComponentType; import org.apache.ignite.internal.IgniteInternalFuture; http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/suggestions/GridPerformanceSuggestions.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/suggestions/GridPerformanceSuggestions.java b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/GridPerformanceSuggestions.java new file mode 100644 index 0000000..c51a136 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/GridPerformanceSuggestions.java @@ -0,0 +1,104 @@ +/* + * 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.suggestions; + +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED; + +/** + * Grid performance suggestions. + */ +public class GridPerformanceSuggestions { + /** Link to article about Ignite performance tuning */ + private static final String SUGGESTIONS_LINK = "https://apacheignite.readme.io/docs/jvm-and-system-tuning"; + + /** */ + private static final boolean disabled = Boolean.getBoolean(IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED); + + /** */ + private final Collection<String> perfs = !disabled ? new LinkedHashSet<String>() : null; + + /** */ + private final Collection<String> suppressed = !disabled ? new HashSet<String>() : null; + + /** + * @param suggestions Suggestions to add. + */ + public synchronized void addAll(List<String> suggestions) { + for (String suggestion : suggestions) + add(suggestion); + } + + /** + * @param sug Suggestion to add. + */ + public synchronized void add(String sug) { + add(sug, false); + } + + /** + * @param sug Suggestion to add. + * @param suppress {@code True} to suppress this suggestion. + */ + public synchronized void add(String sug, boolean suppress) { + if (disabled) + return; + + if (!suppress) + perfs.add(sug); + else + suppressed.add(sug); + } + + /** + * @param log Log. + * @param gridName Grid name. + */ + public synchronized void logSuggestions(IgniteLogger log, @Nullable String gridName) { + if (disabled) + return; + + if (!F.isEmpty(perfs) && !suppressed.containsAll(perfs)) { + U.quietAndInfo(log, "Performance suggestions for grid " + + (gridName == null ? "" : '\'' + gridName + '\'') + " (fix if possible)"); + U.quietAndInfo(log, "To disable, set -D" + IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED + "=true"); + + for (String s : perfs) + if (!suppressed.contains(s)) + U.quietAndInfo(log, " ^-- " + s); + + perfs.clear(); + } + U.quietAndInfo(log, "Refer to this page for more performance suggestions: " + SUGGESTIONS_LINK); + U.quietAndInfo(log, ""); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridPerformanceSuggestions.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/suggestions/JvmConfigurationSuggestions.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/suggestions/JvmConfigurationSuggestions.java b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/JvmConfigurationSuggestions.java new file mode 100644 index 0000000..4319229 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/JvmConfigurationSuggestions.java @@ -0,0 +1,104 @@ +/* + * 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.suggestions; + +import java.util.ArrayList; +import java.util.List; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.NotNull; + +/** + * Java Virtual Machine configuration suggestions. + */ +public class JvmConfigurationSuggestions { + /** */ + private static final String XMX = "-Xmx"; + + /** */ + private static final String MX = "-mx"; + + /** */ + private static final String MAX_DIRECT_MEMORY_SIZE = "-XX:MaxDirectMemorySize"; + + /** */ + private static final String DISABLE_EXPLICIT_GC = "-XX:+DisableExplicitGC"; + + /** */ + private static final String NOT_USE_TLAB = "-XX:-UseTLAB"; + + /** */ + private static final String SERVER = "-server"; + + /** */ + private static final String USE_G1_GC = "-XX:+UseG1GC"; + + /** + * Checks JVM configurations and produces tuning suggestions. + * + * @return List of suggestions of Java Virtual Machine configuration tuning to increase Ignite performance. + */ + public static synchronized List<String> getSuggestions() { + List<String> suggestions = new ArrayList<>(); + + List<String> args = U.jvmArgs(); + + if (!U.jvmName().toLowerCase().contains("server")) + suggestions.add("Enable server mode for JVM (add '" + SERVER + "' to JVM options)"); + + if (!U.jdkVersion().equals("1.8")) + suggestions.add("Switch to the most recent 1.8 JVM version"); + + if (U.jdkVersion().equals("1.8") && !args.contains(USE_G1_GC)) + suggestions.add("Enable G1 Garbage Collector (add '" + USE_G1_GC + "' to JVM options)"); + + if (!anyStartWith(args, XMX) && !anyStartWith(args, MX)) + suggestions.add("Specify JVM heap max size (add '" + XMX + "<size>[g|G|m|M|k|K]' to JVM options)"); + + if (!anyStartWith(args, MAX_DIRECT_MEMORY_SIZE)) + suggestions.add("Set max direct memory size if getting 'OOME: Direct buffer memory' " + + "(add '" + MAX_DIRECT_MEMORY_SIZE + "=<size>[g|G|m|M|k|K]' to JVM options)"); + + if (args.contains(NOT_USE_TLAB)) + suggestions.add("Enable thread-local allocation buffer (add '-XX:+UseTLAB' to JVM options)"); + + if (!args.contains(DISABLE_EXPLICIT_GC)) + suggestions.add("Disable processing of calls to System.gc() (add '" + DISABLE_EXPLICIT_GC + "' to JVM options)"); + + return suggestions; + } + + /** + * @param lines Lines to check. + * @param prefix Prefix. + * @return {@code True} if found. + */ + private static boolean anyStartWith(@NotNull List<String> lines, @NotNull String prefix) { + for (String line : lines) { + if (line.startsWith(prefix)) + return true; + } + + return false; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(JvmConfigurationSuggestions.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/suggestions/OsConfigurationSuggestions.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/suggestions/OsConfigurationSuggestions.java b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/OsConfigurationSuggestions.java new file mode 100644 index 0000000..e5b4c12 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/OsConfigurationSuggestions.java @@ -0,0 +1,127 @@ +/* + * 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.suggestions; + +import java.io.BufferedReader; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Operation System configuration suggestions. + */ +public class OsConfigurationSuggestions { + /** */ + private static final String VM_PARAMS_BASE_PATH = "/proc/sys/vm/"; + + /** */ + private static final String DIRTY_WRITEBACK_CENTISECS = "dirty_writeback_centisecs"; + + /** */ + private static final String DIRTY_EXPIRE_CENTISECS = "dirty_expire_centisecs"; + + /** */ + private static final String SWAPPINESS = "swappiness"; + + /** */ + private static final String ZONE_RECLAIM_MODE = "zone_reclaim_mode"; + + /** */ + private static final String EXTRA_FREE_KBYTES = "extra_free_kbytes"; + + /** + * Checks OS configurations and produces tuning suggestions. + * + * @return List of suggestions of Operation system configuration tuning to increase Ignite performance. + */ + public static synchronized List<String> getSuggestions() { + List<String> suggestions = new ArrayList<>(); + + if (U.isRedHat()) { + String value; + String expected = "500"; + + boolean dwcParamFlag = (value = readVmParam(DIRTY_WRITEBACK_CENTISECS)) != null && !value.equals(expected); + boolean decParamFlag = (value = readVmParam(DIRTY_EXPIRE_CENTISECS)) != null && !value.equals(expected); + + if (dwcParamFlag || decParamFlag) + suggestions.add(String.format("Speed up flushing of dirty pages by OS " + + "(alter %s%s%s parameter%s by setting to %s)", + (dwcParamFlag ? "vm." + DIRTY_WRITEBACK_CENTISECS : ""), + (dwcParamFlag && decParamFlag ? " and " : ""), + (decParamFlag ? "vm." + DIRTY_EXPIRE_CENTISECS : ""), + (dwcParamFlag && decParamFlag ? "s" : ""), + expected)); + + if ((value = readVmParam(SWAPPINESS)) != null && !value.equals(expected = "10")) + suggestions.add(String.format("Reduce pages swapping ratio (set vm.%s=%s)", SWAPPINESS, expected)); + + if ((value = readVmParam(ZONE_RECLAIM_MODE)) != null && !value.equals(expected = "0")) + suggestions.add(String.format("Disable NUMA memory reclaim (set vm.%s=%s)", ZONE_RECLAIM_MODE, + expected)); + + if ((value = readVmParam(EXTRA_FREE_KBYTES)) != null && !value.equals(expected = "1240000")) + suggestions.add(String.format("Avoid direct reclaim and page allocation failures (set vm.%s=%s)", + EXTRA_FREE_KBYTES, expected)); + } + + return suggestions; + } + + /** + * @param name Parameter name. + * @return Value (possibly null). + */ + @Nullable private static String readVmParam(@NotNull String name) { + try { + Path path = Paths.get(VM_PARAMS_BASE_PATH + name); + + if (!Files.exists(path)) + return null; + + return readLine(path); + } + catch (Exception ignored) { + return null; + } + } + + /** + * @param path Path. + * @return Read line. + * @throws IOException If failed. + */ + @Nullable private static String readLine(@NotNull Path path) throws IOException { + try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { + return reader.readLine(); + } + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(OsConfigurationSuggestions.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/suggestions/package-info.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/suggestions/package-info.java b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/package-info.java new file mode 100644 index 0000000..baced67 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/suggestions/package-info.java @@ -0,0 +1,21 @@ +/* + * 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. + */ + +/** + * Contains classes for configurations suggestions. + */ +package org.apache.ignite.internal.suggestions; http://git-wip-us.apache.org/repos/asf/ignite/blob/3459bdd3/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index 653302c..f6c8163 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -73,6 +73,8 @@ import java.nio.channels.FileLock; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; import java.security.AccessController; import java.security.KeyManagementException; import java.security.MessageDigest; @@ -366,6 +368,9 @@ public abstract class IgniteUtils { /** Indicates whether current OS is Mac OS. */ private static boolean mac; + /** Indicates whether current OS is of RedHat family. */ + private static boolean redHat; + /** Indicates whether current OS architecture is Sun Sparc. */ private static boolean sparc; @@ -525,6 +530,8 @@ public abstract class IgniteUtils { assertionsEnabled = assertionsEnabled0; } + redHat = Files.exists(Paths.get("/etc/redhat-release")); // RedHat family OS (Fedora, CentOS, RedHat) + String osName = System.getProperty("os.name"); String osLow = osName.toLowerCase(); @@ -6282,6 +6289,13 @@ public abstract class IgniteUtils { } /** + * @return {@code True} if current OS is RedHat. + */ + public static boolean isRedHat() { + return redHat; + } + + /** * Indicates whether current OS is Netware. * * @return {@code true} if current OS is Netware - {@code false} otherwise.
