|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.tools.launchers; |
| 21 | + |
| 22 | +import java.util.Arrays; |
| 23 | +import java.util.Collections; |
| 24 | +import java.util.List; |
| 25 | + |
| 26 | +final class SystemJvmOptions { |
| 27 | + |
| 28 | + static List<String> systemJvmOptions() { |
| 29 | + return Collections.unmodifiableList(Arrays.asList( |
| 30 | + /* |
| 31 | + * Cache ttl in seconds for positive DNS lookups noting that this overrides the JDK security property networkaddress.cache.ttl; |
| 32 | + * can be set to -1 to cache forever. |
| 33 | + */ |
| 34 | + "-Des.networkaddress.cache.ttl=60", |
| 35 | + /* |
| 36 | + * Cache ttl in seconds for negative DNS lookups noting that this overrides the JDK security property |
| 37 | + * networkaddress.cache.negative ttl; set to -1 to cache forever. |
| 38 | + */ |
| 39 | + "-Des.networkaddress.cache.negative.ttl=10", |
| 40 | + // pre-touch JVM emory pages during initialization |
| 41 | + "-XX:+AlwaysPreTouch", |
| 42 | + // explicitly set the stack size |
| 43 | + "-Xss1m", |
| 44 | + // set to headless, just in case, |
| 45 | + "-Djava.awt.headless=true", |
| 46 | + // ensure UTF-8 encoding by default (e.g., filenames) |
| 47 | + "-Dfile.encoding=UTF-8", |
| 48 | + // use our provided JNA always versus the system one |
| 49 | + "-Djna.nosys=true", |
| 50 | + /* |
| 51 | + * Turn off a JDK optimization that throws away stack traces for common exceptions because stack traces are important for |
| 52 | + * debugging. |
| 53 | + */ |
| 54 | + "-XX:-OmitStackTraceInFastThrow", |
| 55 | + // flags to configure Netty |
| 56 | + "-Dio.netty.noUnsafe=true", |
| 57 | + "-Dio.netty.noKeySetOptimization=true", |
| 58 | + "-Dio.netty.recycler.maxCapacityPerThread=0", |
| 59 | + "-Dio.netty.allocator.numDirectArenas=0", |
| 60 | + // log4j 2 |
| 61 | + "-Dlog4j.shutdownHookEnabled=false", |
| 62 | + "-Dlog4j2.disable.jmx=true", |
| 63 | + /* |
| 64 | + * Due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise time/date |
| 65 | + * parsing will break in an incompatible way for some date patterns and locales. |
| 66 | + */ |
| 67 | + "-Djava.locale.providers=SPI,COMPAT")); |
| 68 | + } |
| 69 | + |
| 70 | +} |
0 commit comments