Package java.lang.management

Examples of java.lang.management.RuntimeMXBean


      ObjectName osname = new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
      PlatformMBeanIDC osidc = new PlatformMBeanIDC(server, osname, osbean);
      mbeans.put(osname.getCanonicalName(), osidc);

      // RuntimeMXBean
      RuntimeMXBean rtbean = ManagementFactory.getRuntimeMXBean();
      ObjectName rtname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
      PlatformMBeanIDC rtidc = new PlatformMBeanIDC(server, rtname, rtbean);
      mbeans.put(rtname.getCanonicalName(), rtidc);

      // ThreadMXBean
View Full Code Here


  public void test(TestHarness h)
  {
    try
      {
  Exception caught = null;
  RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();

  bg.install();

  // Check getVmName
        caught = null;
        try
          {
            bean.getVmName();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "vmName");

  // Check getVmVendor
        caught = null;
        try
          {
            bean.getVmVendor();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "vmVendor");

  // Check getVmVersion
        caught = null;
        try
          {
            bean.getVmVersion();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "vmVersion");

  // Check getSpecName
        caught = null;
        try
          {
            bean.getSpecName();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "specName");

  // Check getSpecVendor
        caught = null;
        try
          {
            bean.getSpecVendor();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "specVendor");

  // Check getSpecVersion
        caught = null;
        try
          {
            bean.getSpecVersion();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "specVersion");

  // Check getClassPath
        caught = null;
        try
          {
            bean.getClassPath();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "classPath");

  // Check getLibraryPath
        caught = null;
        try
          {
            bean.getLibraryPath();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "libraryPath");

  // Check getBootClassPath
        caught = null;
        try
          {
            bean.getBootClassPath();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
  if (bean.isBootClassPathSupported())
    h.check(caught instanceof SecurityException, "bootClassPath");
  else
    h.check(caught instanceof UnsupportedOperationException, "bootClassPath");

  // Check getInputArguments
        caught = null;
        try
          {
            bean.getInputArguments();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
        h.check(caught instanceof SecurityException, "inputArguments");

  // Check getSystemProperties
        caught = null;
        try
          {
            bean.getSystemProperties();
          }
        catch (Exception ex)
          {
            caught = ex;
          }
View Full Code Here

        return futureContainer;
    }

    private String getVMArguments() {
      final StringBuilder result = new StringBuilder(1024);
      final RuntimeMXBean rmBean = ManagementFactory.getRuntimeMXBean();
      final List<String> inputArguments = rmBean.getInputArguments();
      for (String arg : inputArguments) {
          result.append(arg).append(" ");
      }
      return result.toString();
   }
View Full Code Here

    private List<InfoProvider> infoProviders = new LinkedList<InfoProvider>();

    protected Object doExecute() throws Exception {
        int maxNameLen;

        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
        ThreadMXBean threads = ManagementFactory.getThreadMXBean();
        MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
        ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();

        //
        // print Karaf informations
        //
        maxNameLen = 25;
        System.out.println("Karaf");
        printValue("Karaf version", maxNameLen, System.getProperty("karaf.version"));
        printValue("Karaf home", maxNameLen, System.getProperty("karaf.home"));
        printValue("Karaf base", maxNameLen, System.getProperty("karaf.base"));
        printValue("OSGi Framework", maxNameLen, bundleContext.getBundle(0).getSymbolicName() + " - " +
                bundleContext.getBundle(0).getVersion());
        System.out.println();

        System.out.println("JVM");
        printValue("Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
        printValue("Version", maxNameLen, System.getProperty("java.version"));
        printValue("Vendor", maxNameLen, runtime.getVmVendor());
        printValue("Uptime", maxNameLen, printDuration(runtime.getUptime()));
        try {
            printValue("Process CPU time", maxNameLen, printDuration(getSunOsValueAsLong(os, "getProcessCpuTime") / 1000000));
        } catch (Throwable t) {
        }
        printValue("Total compile time", maxNameLen, printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
View Full Code Here

    private void writePid(Properties props) {
        try {
            String pidFile = props.getProperty(KARAF_SHUTDOWN_PID_FILE);
            if (pidFile != null) {
                RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
                String processName = rtb.getName();
                Pattern pattern = Pattern.compile("^([0-9]+)@.+$", Pattern.CASE_INSENSITIVE);
                Matcher matcher = pattern.matcher(processName);
                if (matcher.matches()) {
                    int pid = Integer.parseInt(matcher.group(1));
                    Writer w = new OutputStreamWriter(new FileOutputStream(pidFile));
View Full Code Here

          // LocalHBaseCluster.  It manages 'local' clusters.
          if (LocalHBaseCluster.isLocal(conf)) {
            LOG.warn("Not starting a distinct region server because " +
              HConstants.CLUSTER_DISTRIBUTED + " is false");
          } else {
            RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
            if (runtime != null) {
              LOG.info("vmInputArguments=" + runtime.getInputArguments());
            }
            Constructor<? extends HRegionServer> c =
              regionServerClass.getConstructor(HBaseConfiguration.class);
            HRegionServer hrs = c.newInstance(conf);
            Thread t = new Thread(hrs);
View Full Code Here

   * dump and bring up resultant hprof in something like jprofiler which
   * allows you get 'deep size' on objects.
   * @param args
   */
  public static void main(String [] args) {
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" +
      runtime.getVmVendor() + ", vmVersion=" + runtime.getVmVersion());
    LOG.info("vmInputArguments=" + runtime.getInputArguments());
    MemStore memstore1 = new MemStore();
    // TODO: x32 vs x64
    long size = 0;
    final int count = 10000;
    byte [] column = Bytes.toBytes("col:umn");
View Full Code Here

    // (but hopefully something not as painful as cli options).
    for (String cmd: args) {

      if (cmd.equals("start")) {
        try {
          RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
          if (runtime != null) {
            LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" +
              runtime.getVmVendor() + ", vmVersion=" + runtime.getVmVersion());
            LOG.info("vmInputArguments=" + runtime.getInputArguments());
          }
          // If 'local', defer to LocalHBaseCluster instance.
          if (LocalHBaseCluster.isLocal(conf)) {
            (new LocalHBaseCluster(conf)).startup();
          } else {
View Full Code Here

                serverSocket = new ServerSocket(0);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
            MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();

            // Deploy an MBean of our own to run additional tests with a custom-jmx-plugin
            try {
                ObjectName mBeanName = new ObjectName("rhq.test:name=TestTarget");
                mBeanServer.createMBean(TestTarget.class.getName(), mBeanName);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            String jvmName = runtimeMXBean.getName();
            int atIndex = jvmName.indexOf('@');
            String pid = (atIndex != -1) ? jvmName.substring(0, atIndex) : "?";

            System.out.println("Test server JVM with pid [" + pid + "] listening on port ["
                + serverSocket.getLocalPort() + "]...");
View Full Code Here

            JMXConnector jmxConnector = null;
            Long pid;
            try {
                jmxConnector = connect(jmxServiceURL);
                MBeanServerConnection mbeanServerConnection = jmxConnector.getMBeanServerConnection();
                RuntimeMXBean runtimeMXBean = ManagementFactory.newPlatformMXBeanProxy(mbeanServerConnection,
                    ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
                pid = getJvmPid(runtimeMXBean);
                if (pid == null) {
                    throw new RuntimeException("Failed to determine JVM pid by parsing JVM name.");
                }
View Full Code Here

TOP

Related Classes of java.lang.management.RuntimeMXBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.