Search in sources :

Example 76 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project jdk8u_jdk by JetBrains.

the class JdpController method getProcessId.

// Get the process id of the current running Java process
private static Integer getProcessId() {
    try {
        // Get the current process id using a reflection hack
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        Field jvm = runtime.getClass().getDeclaredField("jvm");
        jvm.setAccessible(true);
        VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
        Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
        pid_method.setAccessible(true);
        Integer pid = (Integer) pid_method.invoke(mgmt);
        return pid;
    } catch (Exception ex) {
        return null;
    }
}
Also used : Field(java.lang.reflect.Field) VMManagement(sun.management.VMManagement) RuntimeMXBean(java.lang.management.RuntimeMXBean) Method(java.lang.reflect.Method) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 77 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project flink by apache.

the class EnvironmentInformation method getJvmStartupOptionsArray.

/**
	 * Gets the system parameters and environment parameters that were passed to the JVM on startup.
	 *
	 * @return The options passed to the JVM on startup.
	 */
public static String[] getJvmStartupOptionsArray() {
    try {
        RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
        List<String> options = bean.getInputArguments();
        return options.toArray(new String[options.size()]);
    } catch (Throwable t) {
        return new String[0];
    }
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean)

Example 78 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project tdi-studio-se by Talend.

the class MBeanServer method getJvmArguments.

/**
     * Gets the JVM arguments.
     * 
     * @return The JVM arguments
     */
public String getJvmArguments() {
    if (!checkReachability()) {
        //$NON-NLS-1$
        return "";
    }
    List<String> arguments;
    try {
        RuntimeMXBean runtimeMXBean = (RuntimeMXBean) getMXBean(RuntimeMXBean.class, ManagementFactory.RUNTIME_MXBEAN_NAME);
        arguments = runtimeMXBean.getInputArguments();
    } catch (IOException e) {
        //$NON-NLS-1$
        Activator.log(IStatus.ERROR, NLS.bind(Messages.getAttributeFailedMsg, "InputArguments"), e);
        //$NON-NLS-1$
        return "";
    }
    StringBuffer buffer = new StringBuffer();
    for (String argument : arguments) {
        if (buffer.length() > 0) {
            //$NON-NLS-1$
            buffer.append(" ");
        }
        buffer.append(argument);
    }
    return buffer.toString();
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean) IOException(java.io.IOException)

Example 79 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project tdi-studio-se by Talend.

the class RuntimeModel method getJvmArguments.

/**
     * Gets the JVM arguments.
     * 
     * @return The JVM arguments
     */
private static String getJvmArguments() {
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    List<String> arguments = runtimeMXBean.getInputArguments();
    StringBuffer buffer = new StringBuffer();
    for (String argument : arguments) {
        if (buffer.length() > 0) {
            buffer.append(" ");
        }
        buffer.append(argument);
    }
    return buffer.toString();
}
Also used : RuntimeMXBean(java.lang.management.RuntimeMXBean)

Example 80 with RuntimeMXBean

use of java.lang.management.RuntimeMXBean in project tdi-studio-se by Talend.

the class HeapHistogramPage method isSupported.

/**
     * Gets the state indicating if heap histogram is supported.
     * <p>
     * WORKAROUND: Heap histogram is disabled on 64bit OS when monitoring eclipse itself, due to the issue that the
     * method heapHisto() of the class HotSpotVirtualMachine causes continuously increasing the committed heap memory.
     * 
     * @return <tt>true</tt> if heap histogram is supported
     */
boolean isSupported() {
    IActiveJvm jvm = section.getJvm();
    if (jvm == null) {
        return false;
    }
    OperatingSystemMXBean osMBean = ManagementFactory.getOperatingSystemMXBean();
    RuntimeMXBean runtimeMBean = ManagementFactory.getRuntimeMXBean();
    if (osMBean.getArch().contains(ARCH_64BIT) && runtimeMBean.getName().contains(String.valueOf(jvm.getPid()))) {
        return false;
    }
    return true;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) RuntimeMXBean(java.lang.management.RuntimeMXBean) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean)

Aggregations

RuntimeMXBean (java.lang.management.RuntimeMXBean)92 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)16 MemoryMXBean (java.lang.management.MemoryMXBean)11 IOException (java.io.IOException)9 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)9 ThreadMXBean (java.lang.management.ThreadMXBean)8 MemoryUsage (java.lang.management.MemoryUsage)6 Method (java.lang.reflect.Method)6 ArrayList (java.util.ArrayList)6 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Properties (java.util.Properties)5 InputStream (java.io.InputStream)4 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)4 Field (java.lang.reflect.Field)4 Date (java.util.Date)4 BufferedReader (java.io.BufferedReader)3 File (java.io.File)3 InputStreamReader (java.io.InputStreamReader)3