org.elasticsearch.monitor.jvm.JvmInfo Java Examples
The following examples show how to use
org.elasticsearch.monitor.jvm.JvmInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Node.java From crate with Apache License 2.0 | 6 votes |
private void logVersion(Logger logger, JvmInfo jvmInfo) { logger.info( "version[{}], pid[{}], build[{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", Version.displayVersion(Version.CURRENT, Version.CURRENT.isSnapshot()), jvmInfo.pid(), Build.CURRENT.hashShort(), Build.CURRENT.timestamp(), Constants.OS_NAME, Constants.OS_VERSION, Constants.OS_ARCH, Constants.JVM_VENDOR, Constants.JVM_NAME, Constants.JAVA_VERSION, Constants.JVM_VERSION); warnIfPreRelease(Version.CURRENT, Version.CURRENT.isSnapshot(), logger); }
Example #2
Source File: NodeInfo.java From Elasticsearch with Apache License 2.0 | 6 votes |
public NodeInfo(Version version, Build build, DiscoveryNode node, @Nullable ImmutableMap<String, String> serviceAttributes, @Nullable Settings settings, @Nullable OsInfo os, @Nullable ProcessInfo process, @Nullable JvmInfo jvm, @Nullable ThreadPoolInfo threadPool, @Nullable TransportInfo transport, @Nullable HttpInfo http, @Nullable PluginsAndModules plugins) { super(node); this.version = version; this.build = build; this.serviceAttributes = serviceAttributes; this.settings = settings; this.os = os; this.process = process; this.jvm = jvm; this.threadPool = threadPool; this.transport = transport; this.http = http; this.plugins = plugins; }
Example #3
Source File: Version.java From crate with Apache License 2.0 | 5 votes |
@SuppressForbidden(reason = "System.out.*") public static void main(String[] args) { final String versionOutput = String.format( Locale.ROOT, "Version: %s, Build: %s/%s, JVM: %s", Version.displayVersion(Version.CURRENT, Version.CURRENT.isSnapshot()), Build.CURRENT.hashShort(), Build.CURRENT.timestamp(), JvmInfo.jvmInfo().version()); System.out.println(versionOutput); }
Example #4
Source File: MemorySizeSettingsTests.java From crate with Apache License 2.0 | 5 votes |
private void assertMemorySizeSetting(Setting<ByteSizeValue> setting, String settingKey, ByteSizeValue defaultValue) { assertThat(setting, notNullValue()); assertThat(setting.getKey(), equalTo(settingKey)); assertThat(setting.getProperties(), hasItem(Property.NodeScope)); assertThat(setting.getDefault(Settings.EMPTY), equalTo(defaultValue)); Settings settingWithPercentage = Settings.builder().put(settingKey, "25%").build(); assertThat(setting.get(settingWithPercentage), equalTo(new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.25)))); Settings settingWithBytesValue = Settings.builder().put(settingKey, "1024b").build(); assertThat(setting.get(settingWithBytesValue), equalTo(new ByteSizeValue(1024))); }
Example #5
Source File: MemorySizeSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testCircuitBreakerSettings() { double defaultTotalPercentage = 0.95d; assertMemorySizeSetting(HierarchyCircuitBreakerService.TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, "indices.breaker.total.limit", new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * defaultTotalPercentage))); assertMemorySizeSetting(HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, "indices.breaker.fielddata.limit", new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.6))); assertMemorySizeSetting(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, "indices.breaker.request.limit", new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.6))); assertMemorySizeSetting(HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING, "network.breaker.inflight_requests.limit", new ByteSizeValue((JvmInfo.jvmInfo().getMem().getHeapMax().getBytes()))); }
Example #6
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
public void testMemorySize() { Setting<ByteSizeValue> memorySizeValueSetting = Setting.memorySizeSetting("a.byte.size", new ByteSizeValue(1024), Property.Dynamic, Property.NodeScope); assertFalse(memorySizeValueSetting.isGroupSetting()); ByteSizeValue memorySizeValue = memorySizeValueSetting.get(Settings.EMPTY); assertEquals(memorySizeValue.getBytes(), 1024); memorySizeValueSetting = Setting.memorySizeSetting("a.byte.size", s -> "2048b", Property.Dynamic, Property.NodeScope); memorySizeValue = memorySizeValueSetting.get(Settings.EMPTY); assertEquals(memorySizeValue.getBytes(), 2048); memorySizeValueSetting = Setting.memorySizeSetting("a.byte.size", "50%", Property.Dynamic, Property.NodeScope); assertFalse(memorySizeValueSetting.isGroupSetting()); memorySizeValue = memorySizeValueSetting.get(Settings.EMPTY); assertEquals(memorySizeValue.getBytes(), JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.5, 1.0); memorySizeValueSetting = Setting.memorySizeSetting("a.byte.size", s -> "25%", Property.Dynamic, Property.NodeScope); memorySizeValue = memorySizeValueSetting.get(Settings.EMPTY); assertEquals(memorySizeValue.getBytes(), JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.25, 1.0); AtomicReference<ByteSizeValue> value = new AtomicReference<>(null); ClusterSettings.SettingUpdater<ByteSizeValue> settingUpdater = memorySizeValueSetting.newUpdater(value::set, logger); assertTrue(settingUpdater.apply(Settings.builder().put("a.byte.size", "12").build(), Settings.EMPTY)); assertEquals(new ByteSizeValue(12), value.get()); assertTrue(settingUpdater.apply(Settings.builder().put("a.byte.size", "12b").build(), Settings.EMPTY)); assertEquals(new ByteSizeValue(12), value.get()); assertTrue(settingUpdater.apply(Settings.builder().put("a.byte.size", "20%").build(), Settings.EMPTY)); assertEquals(new ByteSizeValue((int) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.2)), value.get()); }
Example #7
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 5 votes |
@Override public BootstrapCheckResult check(Settings settings) { if (getUseSerialGC().equals("true")) { final String message = String.format( Locale.ROOT, "JVM is using the serial collector but should not be for the best performance; " + "either it's the default for the VM [%s] or -XX:+UseSerialGC was explicitly specified", JvmInfo.jvmInfo().getVmName()); return BootstrapCheckResult.failure(message); } else { return BootstrapCheckResult.success(); } }
Example #8
Source File: JNANatives.java From crate with Apache License 2.0 | 5 votes |
static void tryVirtualLock() { JNAKernel32Library kernel = JNAKernel32Library.getInstance(); Pointer process = null; try { process = kernel.GetCurrentProcess(); // By default, Windows limits the number of pages that can be locked. // Thus, we need to first increase the working set size of the JVM by // the amount of memory we wish to lock, plus a small overhead (1MB). SizeT size = new SizeT(JvmInfo.jvmInfo().getMem().getHeapInit().getBytes() + (1024 * 1024)); if (!kernel.SetProcessWorkingSetSize(process, size, size)) { LOGGER.warn("Unable to lock JVM memory. Failed to set working set size. Error code {}", Native.getLastError()); } else { JNAKernel32Library.MemoryBasicInformation memInfo = new JNAKernel32Library.MemoryBasicInformation(); long address = 0; while (kernel.VirtualQueryEx(process, new Pointer(address), memInfo, memInfo.size()) != 0) { boolean lockable = memInfo.State.longValue() == JNAKernel32Library.MEM_COMMIT && (memInfo.Protect.longValue() & JNAKernel32Library.PAGE_NOACCESS) != JNAKernel32Library.PAGE_NOACCESS && (memInfo.Protect.longValue() & JNAKernel32Library.PAGE_GUARD) != JNAKernel32Library.PAGE_GUARD; if (lockable) { kernel.VirtualLock(memInfo.BaseAddress, new SizeT(memInfo.RegionSize.longValue())); } // Move to the next region address += memInfo.RegionSize.longValue(); } LOCAL_MLOCKALL = true; } } catch (UnsatisfiedLinkError e) { // this will have already been logged by Kernel32Library, no need to repeat it } finally { if (process != null) { kernel.CloseHandle(process); } } }
Example #9
Source File: CrateDB.java From crate with Apache License 2.0 | 5 votes |
@Override protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { if (options.nonOptionArguments().isEmpty() == false) { throw new UserException(ExitCodes.USAGE, "Positional arguments not allowed, found " + options.nonOptionArguments()); } if (options.has(versionOption)) { if (options.has(daemonizeOption) || options.has(pidfileOption)) { throw new UserException(ExitCodes.USAGE, "CrateDB version option is mutually exclusive with any other option"); } terminal.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.hashShort() + "/" + Build.CURRENT.timestamp() + ", JVM: " + JvmInfo.jvmInfo().version()); return; } final boolean daemonize = options.has(daemonizeOption); final Path pidFile = pidfileOption.value(options); env = addPidFileSetting(pidFile, env); final boolean quiet = options.has(quietOption); try { init(daemonize, quiet, env); } catch (NodeValidationException e) { throw new UserException(ExitCodes.CONFIG, e.getMessage()); } }
Example #10
Source File: JNANatives.java From Elasticsearch with Apache License 2.0 | 5 votes |
static void tryVirtualLock() { JNAKernel32Library kernel = JNAKernel32Library.getInstance(); Pointer process = null; try { process = kernel.GetCurrentProcess(); // By default, Windows limits the number of pages that can be locked. // Thus, we need to first increase the working set size of the JVM by // the amount of memory we wish to lock, plus a small overhead (1MB). SizeT size = new SizeT(JvmInfo.jvmInfo().getMem().getHeapInit().getBytes() + (1024 * 1024)); if (!kernel.SetProcessWorkingSetSize(process, size, size)) { logger.warn("Unable to lock JVM memory. Failed to set working set size. Error code " + Native.getLastError()); } else { JNAKernel32Library.MemoryBasicInformation memInfo = new JNAKernel32Library.MemoryBasicInformation(); long address = 0; while (kernel.VirtualQueryEx(process, new Pointer(address), memInfo, memInfo.size()) != 0) { boolean lockable = memInfo.State.longValue() == JNAKernel32Library.MEM_COMMIT && (memInfo.Protect.longValue() & JNAKernel32Library.PAGE_NOACCESS) != JNAKernel32Library.PAGE_NOACCESS && (memInfo.Protect.longValue() & JNAKernel32Library.PAGE_GUARD) != JNAKernel32Library.PAGE_GUARD; if (lockable) { kernel.VirtualLock(memInfo.BaseAddress, new SizeT(memInfo.RegionSize.longValue())); } // Move to the next region address += memInfo.RegionSize.longValue(); } LOCAL_MLOCKALL = true; } } catch (UnsatisfiedLinkError e) { // this will have already been logged by Kernel32Library, no need to repeat it } finally { if (process != null) { kernel.CloseHandle(process); } } }
Example #11
Source File: NodeInfo.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); version = Version.readVersion(in); build = Build.readBuild(in); if (in.readBoolean()) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); int size = in.readVInt(); for (int i = 0; i < size; i++) { builder.put(in.readString(), in.readString()); } serviceAttributes = builder.build(); } if (in.readBoolean()) { settings = Settings.readSettingsFromStream(in); } if (in.readBoolean()) { os = OsInfo.readOsInfo(in); } if (in.readBoolean()) { process = ProcessInfo.readProcessInfo(in); } if (in.readBoolean()) { jvm = JvmInfo.readJvmInfo(in); } if (in.readBoolean()) { threadPool = ThreadPoolInfo.readThreadPoolInfo(in); } if (in.readBoolean()) { transport = TransportInfo.readTransportInfo(in); } if (in.readBoolean()) { http = HttpInfo.readHttpInfo(in); } if (in.readBoolean()) { plugins = new PluginsAndModules(); plugins.readFrom(in); } }
Example #12
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 4 votes |
long getInitialHeapSize() { return JvmInfo.jvmInfo().getConfiguredInitialHeapSize(); }
Example #13
Source File: IndexingMemoryController.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Inject public IndexingMemoryController(Settings settings, ThreadPool threadPool, IndicesService indicesService) { this(settings, threadPool, indicesService, JvmInfo.jvmInfo().getMem().getHeapMax().bytes()); }
Example #14
Source File: Version.java From Elasticsearch with Apache License 2.0 | 4 votes |
@SuppressForbidden(reason = "System.out.*") public static void main(String[] args) { System.out.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.hashShort() + "/" + Build.CURRENT.timestamp() + ", JVM: " + JvmInfo.jvmInfo().version()); }
Example #15
Source File: MemorySizeSettingsTests.java From crate with Apache License 2.0 | 4 votes |
@Test public void testQueryCacheSizeSetting() { assertMemorySizeSetting(IndicesQueryCache.INDICES_CACHE_QUERY_SIZE_SETTING, "indices.queries.cache.size", new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.1))); }
Example #16
Source File: MemorySizeSettingsTests.java From crate with Apache License 2.0 | 4 votes |
@Test public void testIndexBufferSizeSetting() { assertMemorySizeSetting(IndexingMemoryController.INDEX_BUFFER_SIZE_SETTING, "indices.memory.index_buffer_size", new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.1))); }
Example #17
Source File: MemorySizeSettingsTests.java From crate with Apache License 2.0 | 4 votes |
@Test public void testPageCacheLimitHeapSetting() { assertMemorySizeSetting(PageCacheRecycler.LIMIT_HEAP_SETTING, "cache.recycler.page.limit.heap", new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.1))); }
Example #18
Source File: NodeEnvironment.java From Elasticsearch with Apache License 2.0 | 4 votes |
private void maybeLogHeapDetails() { JvmInfo jvmInfo = JvmInfo.jvmInfo(); ByteSizeValue maxHeapSize = jvmInfo.getMem().getHeapMax(); String useCompressedOops = jvmInfo.useCompressedOops(); logger.info("heap size [{}], compressed ordinary object pointers [{}]", maxHeapSize, useCompressedOops); }
Example #19
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 4 votes |
String onOutOfMemoryError() { return JvmInfo.jvmInfo().onOutOfMemoryError(); }
Example #20
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 4 votes |
String onError() { return JvmInfo.jvmInfo().onError(); }
Example #21
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 4 votes |
String getUseSerialGC() { return JvmInfo.jvmInfo().useSerialGC(); }
Example #22
Source File: NettyTransport.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Inject public NettyTransport(Settings settings, ThreadPool threadPool, NetworkService networkService, BigArrays bigArrays, Version version, NamedWriteableRegistry namedWriteableRegistry) { super(settings); this.threadPool = threadPool; this.networkService = networkService; this.bigArrays = bigArrays; this.version = version; if (settings.getAsBoolean("netty.epollBugWorkaround", false)) { System.setProperty("org.jboss.netty.epollBugWorkaround", "true"); } this.workerCount = settings.getAsInt(WORKER_COUNT, EsExecutors.boundedNumberOfProcessors(settings) * 2); this.blockingClient = settings.getAsBoolean("transport.netty.transport.tcp.blocking_client", settings.getAsBoolean(TCP_BLOCKING_CLIENT, settings.getAsBoolean(TCP_BLOCKING, false))); this.connectTimeout = this.settings.getAsTime("transport.netty.connect_timeout", settings.getAsTime("transport.tcp.connect_timeout", settings.getAsTime(TCP_CONNECT_TIMEOUT, TCP_DEFAULT_CONNECT_TIMEOUT))); this.maxCumulationBufferCapacity = this.settings.getAsBytesSize("transport.netty.max_cumulation_buffer_capacity", null); this.maxCompositeBufferComponents = this.settings.getAsInt("transport.netty.max_composite_buffer_components", -1); this.compress = settings.getAsBoolean(TransportSettings.TRANSPORT_TCP_COMPRESS, false); this.connectionsPerNodeRecovery = this.settings.getAsInt("transport.netty.connections_per_node.recovery", settings.getAsInt(CONNECTIONS_PER_NODE_RECOVERY, 2)); this.connectionsPerNodeBulk = this.settings.getAsInt("transport.netty.connections_per_node.bulk", settings.getAsInt(CONNECTIONS_PER_NODE_BULK, 3)); this.connectionsPerNodeReg = this.settings.getAsInt("transport.netty.connections_per_node.reg", settings.getAsInt(CONNECTIONS_PER_NODE_REG, 6)); this.connectionsPerNodeState = this.settings.getAsInt("transport.netty.connections_per_node.high", settings.getAsInt(CONNECTIONS_PER_NODE_STATE, 1)); this.connectionsPerNodePing = this.settings.getAsInt("transport.netty.connections_per_node.ping", settings.getAsInt(CONNECTIONS_PER_NODE_PING, 1)); // we want to have at least 1 for reg/state/ping if (this.connectionsPerNodeReg == 0) { throw new IllegalArgumentException("can't set [connection_per_node.reg] to 0"); } if (this.connectionsPerNodePing == 0) { throw new IllegalArgumentException("can't set [connection_per_node.ping] to 0"); } if (this.connectionsPerNodeState == 0) { throw new IllegalArgumentException("can't set [connection_per_node.state] to 0"); } long defaultReceiverPredictor = 512 * 1024; if (JvmInfo.jvmInfo().getMem().getDirectMemoryMax().bytes() > 0) { // we can guess a better default... long l = (long) ((0.3 * JvmInfo.jvmInfo().getMem().getDirectMemoryMax().bytes()) / workerCount); defaultReceiverPredictor = Math.min(defaultReceiverPredictor, Math.max(l, 64 * 1024)); } // See AdaptiveReceiveBufferSizePredictor#DEFAULT_XXX for default values in netty..., we can use higher ones for us, even fixed one this.receivePredictorMin = this.settings.getAsBytesSize("transport.netty.receive_predictor_min", this.settings.getAsBytesSize("transport.netty.receive_predictor_size", new ByteSizeValue(defaultReceiverPredictor))); this.receivePredictorMax = this.settings.getAsBytesSize("transport.netty.receive_predictor_max", this.settings.getAsBytesSize("transport.netty.receive_predictor_size", new ByteSizeValue(defaultReceiverPredictor))); if (receivePredictorMax.bytes() == receivePredictorMin.bytes()) { receiveBufferSizePredictorFactory = new FixedReceiveBufferSizePredictorFactory((int) receivePredictorMax.bytes()); } else { receiveBufferSizePredictorFactory = new AdaptiveReceiveBufferSizePredictorFactory((int) receivePredictorMin.bytes(), (int) receivePredictorMin.bytes(), (int) receivePredictorMax.bytes()); } this.scheduledPing = new ScheduledPing(); this.pingSchedule = settings.getAsTime(PING_SCHEDULE, DEFAULT_PING_SCHEDULE); if (pingSchedule.millis() > 0) { threadPool.schedule(pingSchedule, ThreadPool.Names.GENERIC, scheduledPing); } this.namedWriteableRegistry = namedWriteableRegistry; }
Example #23
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 4 votes |
String getVmName() { return JvmInfo.jvmInfo().getVmName(); }
Example #24
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 4 votes |
long getMaxHeapSize() { return JvmInfo.jvmInfo().getConfiguredMaxHeapSize(); }
Example #25
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 4 votes |
JvmVersion(JvmInfo jvmInfo) { version = jvmInfo.version(); vmName = jvmInfo.getVmName(); vmVersion = jvmInfo.getVmVersion(); vmVendor = jvmInfo.getVmVendor(); }
Example #26
Source File: NodeEnvironment.java From crate with Apache License 2.0 | 4 votes |
private void maybeLogHeapDetails() { JvmInfo jvmInfo = JvmInfo.jvmInfo(); ByteSizeValue maxHeapSize = jvmInfo.getMem().getHeapMax(); String useCompressedOops = jvmInfo.useCompressedOops(); logger.info("heap size [{}], compressed ordinary object pointers [{}]", maxHeapSize, useCompressedOops); }
Example #27
Source File: Version.java From Elasticsearch with Apache License 2.0 | 4 votes |
public static void main(String[] args) { System.out.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.hashShort() + "/" + Build.CURRENT.timestamp() + ", ES: " + org.elasticsearch.Version.CURRENT + ", JVM: " + JvmInfo.jvmInfo().version() ); }
Example #28
Source File: NodeInfo.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * JVM level information. */ @Nullable public JvmInfo getJvm() { return jvm; }
Example #29
Source File: BootstrapProxy.java From crate with Apache License 2.0 | 4 votes |
static void initializeProbes() { // Force probes to be loaded ProcessProbe.getInstance(); OsProbe.getInstance(); JvmInfo.jvmInfo(); }
Example #30
Source File: VersionCommand.java From elasticshell with Apache License 2.0 | 4 votes |
@SuppressWarnings("unused") public void execute() { console.println("elasticsearch version: " + Version.CURRENT + ", JVM: " + JvmInfo.jvmInfo().vmVersion()); }