• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JvmInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.monitor.jvm.JvmInfo的典型用法代码示例。如果您正苦于以下问题:Java JvmInfo类的具体用法?Java JvmInfo怎么用?Java JvmInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JvmInfo类属于org.elasticsearch.monitor.jvm包,在下文中一共展示了JvmInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: NodeInfo

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
public NodeInfo(Version version, Build build, DiscoveryNode node, @Nullable Settings settings,
                @Nullable OsInfo os, @Nullable ProcessInfo process, @Nullable JvmInfo jvm, @Nullable ThreadPoolInfo threadPool,
                @Nullable TransportInfo transport, @Nullable HttpInfo http, @Nullable PluginsAndModules plugins,
                @Nullable IngestInfo ingest, @Nullable ByteSizeValue totalIndexingBuffer) {
    super(node);
    this.version = version;
    this.build = build;
    this.settings = settings;
    this.os = os;
    this.process = process;
    this.jvm = jvm;
    this.threadPool = threadPool;
    this.transport = transport;
    this.http = http;
    this.plugins = plugins;
    this.ingest = ingest;
    this.totalIndexingBuffer = totalIndexingBuffer;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:NodeInfo.java


示例2: readFrom

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    version = Version.readVersion(in);
    build = Build.readBuild(in);
    if (in.readBoolean()) {
        totalIndexingBuffer = new ByteSizeValue(in.readLong());
    } else {
        totalIndexingBuffer = null;
    }
    if (in.readBoolean()) {
        settings = Settings.readSettingsFromStream(in);
    }
    os = in.readOptionalWriteable(OsInfo::new);
    process = in.readOptionalWriteable(ProcessInfo::new);
    jvm = in.readOptionalWriteable(JvmInfo::new);
    threadPool = in.readOptionalWriteable(ThreadPoolInfo::new);
    transport = in.readOptionalWriteable(TransportInfo::new);
    http = in.readOptionalWriteable(HttpInfo::new);
    plugins = in.readOptionalWriteable(PluginsAndModules::new);
    ingest = in.readOptionalWriteable(IngestInfo::new);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:NodeInfo.java


示例3: execute

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
@Override
protected void execute(Terminal terminal, OptionSet options, Environment env) throws UserException {
    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, "Elasticsearch version option is mutually exclusive with any other option");
        }
        terminal.println("Version: " + org.elasticsearch.Version.CURRENT
                + ", Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date()
                + ", JVM: " + JvmInfo.jvmInfo().version());
        return;
    }

    final boolean daemonize = options.has(daemonizeOption);
    final Path pidFile = pidfileOption.value(options);
    final boolean quiet = options.has(quietOption);

    try {
        init(daemonize, pidFile, quiet, env);
    } catch (NodeValidationException e) {
        throw new UserException(ExitCodes.CONFIG, e.getMessage());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:Elasticsearch.java


示例4: testUseSerialGCCheck

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
public void testUseSerialGCCheck() throws NodeValidationException {
    final AtomicReference<String> useSerialGC = new AtomicReference<>("true");
    final BootstrapCheck check = new BootstrapChecks.UseSerialGCCheck() {
        @Override
        String getUseSerialGC() {
            return useSerialGC.get();
        }
    };

    final NodeValidationException e = expectThrows(
        NodeValidationException.class,
        () -> BootstrapChecks.check(true, Collections.singletonList(check), "testUseSerialGCCheck"));
    assertThat(
        e.getMessage(),
        containsString("JVM is using the serial collector but should not be for the best performance; " + "" +
            "either it's the default for the VM [" + JvmInfo.jvmInfo().getVmName() +"] or -XX:+UseSerialGC was explicitly specified"));

    useSerialGC.set("false");
    BootstrapChecks.check(true, Collections.singletonList(check), "testUseSerialGCCheck");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:BootstrapCheckTests.java


示例5: NodeInfo

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
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;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:NodeInfo.java


示例6: tryVirtualLock

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:JNANatives.java


示例7: errorMessage

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
@Override
public String errorMessage() {
    return 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());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:BootstrapChecks.java


示例8: testMemorySize

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
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);
    try {
        settingUpdater.apply(Settings.builder().put("a.byte.size", 12).build(), Settings.EMPTY);
        fail("no unit");
    } catch (IllegalArgumentException ex) {
        assertEquals("failed to parse setting [a.byte.size] with value [12] as a size in bytes: unit is missing or unrecognized",
                ex.getMessage());
    }

    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());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:SettingTests.java


示例9: testCircuitBreakerSettings

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
public void testCircuitBreakerSettings() {
    assertMemorySizeSetting(HierarchyCircuitBreakerService.TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, "indices.breaker.total.limit",
            new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.7)));
    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())));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:MemorySizeSettingsTests.java


示例10: assertMemorySizeSetting

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
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)));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:MemorySizeSettingsTests.java


示例11: runTestThatVersionIsReturned

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
private void runTestThatVersionIsReturned(String... args) throws Exception {
    runTestVersion(ExitCodes.OK, output -> {
        assertThat(output, containsString("Version: " + Version.CURRENT.toString()));
        assertThat(output, containsString("Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date()));
        assertThat(output, containsString("JVM: " + JvmInfo.jvmInfo().version()));
    }, args);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ElasticsearchCliTests.java


示例12: readFrom

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:40,代码来源:NodeInfo.java


示例13: tryVirtualLock

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:35,代码来源:JNANatives.java


示例14: main

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
@SuppressForbidden(reason = "System.out.*")
public static void main(String[] args) {
    System.out.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date() + ", JVM: "
            + JvmInfo.jvmInfo().version());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:Version.java


示例15: maybeLogHeapDetails

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:NodeEnvironment.java


示例16: JvmVersion

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
JvmVersion(JvmInfo jvmInfo) {
    version = jvmInfo.version();
    vmName = jvmInfo.getVmName();
    vmVersion = jvmInfo.getVmVersion();
    vmVendor = jvmInfo.getVmVendor();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:ClusterStatsNodes.java


示例17: getJvm

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
/**
 * JVM level information.
 */
@Nullable
public JvmInfo getJvm() {
    return jvm;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:NodeInfo.java


示例18: initializeProbes

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
static void initializeProbes() {
    // Force probes to be loaded
    ProcessProbe.getInstance();
    OsProbe.getInstance();
    JvmInfo.jvmInfo();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:Bootstrap.java


示例19: getInitialHeapSize

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
long getInitialHeapSize() {
    return JvmInfo.jvmInfo().getConfiguredInitialHeapSize();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:BootstrapChecks.java


示例20: getMaxHeapSize

import org.elasticsearch.monitor.jvm.JvmInfo; //导入依赖的package包/类
long getMaxHeapSize() {
    return JvmInfo.jvmInfo().getConfiguredMaxHeapSize();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:BootstrapChecks.java



注:本文中的org.elasticsearch.monitor.jvm.JvmInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CachedBlock类代码示例发布时间:2022-05-22
下一篇:
Java TexturePackLoader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap