当前位置: 首页>>代码示例>>Java>>正文


Java RuntimeMXBean.getInputArguments方法代码示例

本文整理汇总了Java中java.lang.management.RuntimeMXBean.getInputArguments方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeMXBean.getInputArguments方法的具体用法?Java RuntimeMXBean.getInputArguments怎么用?Java RuntimeMXBean.getInputArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.RuntimeMXBean的用法示例。


在下文中一共展示了RuntimeMXBean.getInputArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeapDumpPathOption

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
/**
 * Retrieves the value of the <code>HeapDumpPath</code> JVM option.
 * @return the value of the <code>HeapDumpPath</code> JVM option or <code>null</code> if the value has not been
 * specified.
 */
private static String getHeapDumpPathOption()
{
    RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
    List<String> inputArguments = runtimeMxBean.getInputArguments();
    String heapDumpPathOption = null;
    for (String argument : inputArguments)
    {
        if (argument.startsWith("-XX:HeapDumpPath="))
        {
            heapDumpPathOption = argument;
            // We do not break in case the option has been specified several times.
            // In general it seems that JVMs use the right-most argument as the winner.
        }
    }

    if (heapDumpPathOption == null)
        return null;

    return heapDumpPathOption.substring(17, heapDumpPathOption.length());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:26,代码来源:HeapUtils.java

示例2: handleStartupInfo

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private boolean handleStartupInfo(@NotNull List<String> args) {
  if (args.size() > 0 && "startup-info".equals(args.get(0))) {
    String jvmLocation = API.getJvmLocation();
    infoln("%s", jvmLocation);
    RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
    List<String> jvmArgs = bean.getInputArguments();

    for (String jvmArg : jvmArgs) {
      infoln(jvmArg);
    }
    infoln("-classpath " + System.getProperty("java.class.path"));
    // print the non-JVM command line arguments
    // print name of the main class with its arguments, like org.ClassName param1 param2
    infoln(System.getProperty("sun.java.command"));
    return true;
  }
  return false;
}
 
开发者ID:jomof,项目名称:cdep,代码行数:19,代码来源:CDep.java

示例3: isDebugged

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private static synchronized boolean isDebugged() {
    if (debugMode == null) {
        debugMode = Boolean.FALSE;

        // check if we are debugged
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        List<String> args = runtime.getInputArguments();
        if (args.contains(X_DEBUG_ARG)) {
            debugMode = Boolean.TRUE;
        } else if (args.contains(JDWP_DEBUG_ARG)) {
            debugMode = Boolean.TRUE;
        } else {
            for (String arg : args) {
                if (arg.startsWith(JDWP_DEBUG_ARG_PREFIX)) {
                    debugMode = Boolean.TRUE;
                    break;
                }
            }
        }
    }
    return debugMode.booleanValue();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:InternalSampler.java

示例4: checkIfDebugged

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private static boolean checkIfDebugged() {
    try {
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        List<String> args = runtime.getInputArguments();
        for (String arg : args) {
            if ("-Xdebug".equals(arg)) { // NOI18N
                return true;                        
            } else if ("-agentlib:jdwp".equals(arg)) { // NOI18N
                // The idea of checking -agentlib:jdwp 
                // is taken from org.netbeans.modules.sampler.InternalSampler
                return true;
            } else if (arg.startsWith("-agentlib:jdwp=")) { // NOI18N
                return true;
            }
        }
    } catch (SecurityException ex) {                
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MiscUtils.java

示例5: getJvmStartupOptions

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
/**
 * 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 getJvmStartupOptions() {
	try {
		final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
		final StringBuilder bld = new StringBuilder();
		
		for (String s : bean.getInputArguments()) {
			bld.append(s).append(' ');
		}

		return bld.toString();
	}
	catch (Throwable t) {
		return UNKNOWN;
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:21,代码来源:EnvironmentInformation.java

示例6: addJvmArgsToSnooper

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private void addJvmArgsToSnooper()
{
    RuntimeMXBean runtimemxbean = ManagementFactory.getRuntimeMXBean();
    List<String> list = runtimemxbean.getInputArguments();
    int i = 0;

    for (String s : list)
    {
        if (s.startsWith("-X"))
        {
            this.addClientStat("jvm_arg[" + i++ + "]", s);
        }
    }

    this.addClientStat("jvm_args", Integer.valueOf(i));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:Snooper.java

示例7: initialize

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
public LocatorStatusResponse initialize(final int locatorPort, final String locatorHost,
    final String locatorLogFile, final String locatorName) {
  final RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
  this.pid = identifyPid();
  this.jvmArgs = runtimeBean.getInputArguments();
  this.uptime = runtimeBean.getUptime();
  this.classpath = runtimeBean.getClassPath();
  this.gemfireVersion = GemFireVersion.getGemFireVersion();
  this.javaVersion = System.getProperty("java.version");
  this.workingDirectory = System.getProperty("user.dir");
  this.logFile = locatorLogFile;
  this.host = locatorHost;
  this.port = locatorPort;
  this.name = locatorName;
  return this;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:LocatorStatusResponse.java

示例8: getHeapDump

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
static File getHeapDump() {
    String heapDumpPath = null;
    RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
    List<String> lst = RuntimemxBean.getInputArguments();
    for (String arg : lst) {
        if (arg.contains("XX:HeapDumpPath")){
            int index = arg.indexOf('=');
            heapDumpPath = arg.substring(index+1);
        }
    }

    if (heapDumpPath == null){
        LOG.info("XX:HeapDumpPath parametter not specified");
        return null;
    }
    File heapDumpFile = new File(heapDumpPath);
    if (heapDumpFile.exists() && heapDumpFile.canRead() && heapDumpFile.length() > 0) {
        return heapDumpFile;
    }
    LOG.log(Level.INFO, "heap dump was not created at {0}", heapDumpPath);
    LOG.log(Level.INFO, "heapdump file: exists():{0}, canRead():{1}, length:{2}",new Object[] 
            {heapDumpFile.exists(), heapDumpFile.canRead(), heapDumpFile.length()});
    // no heap dump file found - this can happen in case of OOME: unable to create new native thread
    // try to create heap dump 
    dumpHeap(heapDumpFile.getAbsolutePath());
    if (heapDumpFile.exists() && heapDumpFile.canRead() && heapDumpFile.length() > 0) {
        return heapDumpFile;
    }        
    LOG.log(Level.INFO, "heap dump failed for {0}", heapDumpPath);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:Installer.java

示例9: logEnvironment

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private static void logEnvironment() {
    logger.out("Temp dir is " + TEMP_DIR);

    // Get the VM arguments and log
    RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
    List<String> arguments = RuntimemxBean.getInputArguments();
    logger.separateLine();
    logger.out(OS_version + "\n");

    if (isDebug()) {
        Map<String, String> env = System.getenv();
        for (String envName : env.keySet()) {
            if (envName.contains("PROCESSOR")) {
                logger.out(envName + " : " + env.get(envName));
            }
        }
    }
    logger.separateLine();
    String JAVA_version = System.getProperty("java.version");
    String JVM_version = ManagementFactory.getRuntimeMXBean().getVmVersion();
    logger.addToList("Java version : " + JAVA_version);
    logger.addToList("JVM version : " + JVM_version);
    for (String arg : arguments) {
        logger.addToList(arg);
        if (arg.startsWith("-Xloggc:")) {
            GCLog = new File(arg.substring(arg.indexOf(':') + 1));
        }
    }
    logger.separateLine();
}
 
开发者ID:phweda,项目名称:MFM,代码行数:31,代码来源:MFM.java

示例10: telnet

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
@Override
   public String telnet(Channel channel, String message) {
	StringBuilder sb = new StringBuilder();
	//内存使用情况
       MemoryMXBean mmxb = ManagementFactory.getMemoryMXBean();
       long max = mmxb.getHeapMemoryUsage().getMax();
       long used = mmxb.getHeapMemoryUsage().getUsed();
       long init = mmxb.getHeapMemoryUsage().getInit();
       long commit = mmxb.getHeapMemoryUsage().getCommitted();
       sb.append("********Memory status******************").append(line);
       sb.append("Max JVM Heap Memory:").append(max / 1024 / 1024).append("M").append(line)
               .append("Used Heap Memory:").append(used / 1024 / 1024).append("M").append(line)
               .append("Init Heap Memory:").append(init / 1024 / 1024).append("M").append(line)
               .append("Commited Heap Memory:").append(commit/1024/1024).append("M").append(line);
       
       sb.append("********Thread status********************").append(line);
       //线程数
       ThreadMXBean txmb = ManagementFactory.getThreadMXBean();
       sb.append("Peak thread count:").append(txmb.getPeakThreadCount()).append("").append(line)
               .append("Thread count:").append(txmb.getThreadCount()).append("").append(line);

       sb.append("********Runtime status******************").append(line);
       //启动入口参数
       RuntimeMXBean rmxb = ManagementFactory.getRuntimeMXBean();
       sb.append("InputArguments:[");
       for(String ia : rmxb.getInputArguments()){
       	sb.append(ia).append(",");
       }
       sb.deleteCharAt(sb.length()-1).append("]").append(line);
       sb.append("JVM start time:").append(DateUtils.dateToStr(new Date(rmxb.getStartTime()))).append(line);
       
       return sb.toString();
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:34,代码来源:JVMStatusTelnetHandler.java

示例11: systemInfo

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
/**
 *
 */
private static List<String> systemInfo() {
    String java = System.getProperty("java.home") + "/bin/java";
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
    List<String> jvmArgs = runtime.getInputArguments();

    REG_LOGGER.debug("JAVA_HOME     - " + java);
    REG_LOGGER.debug("ClassLoader   - " + runtime.getBootClassPath());
    REG_LOGGER.debug("ClassPath     - " + runtime.getClassPath());
    REG_LOGGER.debug("LibraryPath   - " + runtime.getLibraryPath());

    REG_LOGGER.debug("SYSTEM ARCH   - " + os.getArch());
    REG_LOGGER.debug("SYSTEM NAME   - " + os.getName());
    REG_LOGGER.debug("SYSTEM VERSION- " + os.getVersion());
    REG_LOGGER.debug("PROCESSORS    - " + os.getAvailableProcessors());

    for (int i = 0; i < jvmArgs.size(); i++) {
        REG_LOGGER.debug("JVM ARGS  - " + jvmArgs.get(i));
    }

    return Arrays.asList(
            "GPS server auto-restart has initiated",
            "JAVA_HOME     - " + java,
            "ClassLoader   - " + runtime.getBootClassPath(),
            "ClassPath     - " + runtime.getClassPath(),
            "LibraryPath   - " + runtime.getLibraryPath(),
            "SYSTEM ARCH   - " + os.getArch(),
            "SYSTEM NAME   - " + os.getName(),
            "SYSTEM VERSION- " + os.getVersion(),
            "PROCESSORS    - " + os.getAvailableProcessors()
    );
}
 
开发者ID:benj-c,项目名称:java-gps-tracking-server,代码行数:36,代码来源:MessageSenderConsumer.java

示例12: getDirectMemorySize

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
/**
 * @return the setting of -XX:MaxDirectMemorySize as a long. Returns 0 if
 *         -XX:MaxDirectMemorySize is not set.
 */
public static long getDirectMemorySize() {
  RuntimeMXBean runtimemxBean = ManagementFactory.getRuntimeMXBean();
  List<String> arguments = runtimemxBean.getInputArguments();
  long multiplier = 1; //for the byte case.
  for (String s : arguments) {
    if (s.contains("-XX:MaxDirectMemorySize=")) {
      String memSize = s.toLowerCase()
          .replace("-xx:maxdirectmemorysize=", "").trim();

      if (memSize.contains("k")) {
        multiplier = 1024;
      }

      else if (memSize.contains("m")) {
        multiplier = 1048576;
      }

      else if (memSize.contains("g")) {
        multiplier = 1073741824;
      }
      memSize = memSize.replaceAll("[^\\d]", "");

      long retValue = Long.parseLong(memSize);
      return retValue * multiplier;
    }
  }
  return 0;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:DirectMemoryUtils.java

示例13: logParams

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private String logParams() {
        StringBuilder sb = new StringBuilder(500);
        sb.append("Diagnostic information\n");
        try {
            RuntimeMXBean         rmBean     = ManagementFactory.getRuntimeMXBean();
            CompilationMXBean     cmpMBean   = ManagementFactory.getCompilationMXBean();
//            ThreadMXBean          tmBean     = ManagementFactory.getThreadMXBean();
            MemoryMXBean          memoryBean = ManagementFactory.getMemoryMXBean();
            ClassLoadingMXBean    clMBean    = ManagementFactory.getClassLoadingMXBean();

//            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
//            ObjectName hsDiag = new ObjectName("com.sun.management:name=HotSpotDiagnostic");
//            com.sun.management.OperatingSystemMXBean sunOSMBean  =
//               ManagementFactory.getSunOperatingSystemMXBean();

//            Map<String, String> props = new TreeMap<String, String>(rmBean.getSystemProperties());
//            System.out.println("System properties");
//            for (Map.Entry<String, String> entry: props.entrySet()) {
//                System.out.println("Property: "+entry.getKey()+" Value: "+entry.getValue());
//            }
            sb.append("Input arguments:");
            for (String s: rmBean.getInputArguments()) {
                sb.append("\n\t").append(s);
            }
            
            if (cmpMBean != null) {
                sb.append("\nCompiler: "+cmpMBean.getName()).append('\n');
            }
            
            // Memory
            MemoryUsage usage = memoryBean.getHeapMemoryUsage();
            logMemoryUsage(sb, usage, "Heap memory");
            usage = memoryBean.getNonHeapMemoryUsage();
            logMemoryUsage(sb, usage, "Non heap memory");
            for (GarbageCollectorMXBean gcMBean: ManagementFactory.getGarbageCollectorMXBeans()) {
                sb.append("Garbage collector: ").append(gcMBean.getName())
                        .append(" (Collections=").append(gcMBean.getCollectionCount())
                        .append(" Total time spent=").append(formatTime(gcMBean.getCollectionTime()))
                        .append(")\n");
            }
            
            // classes
            int clsLoaded;
            long clsTotal, clsUnloaded;
            clsLoaded = clMBean.getLoadedClassCount();
            clsTotal = clMBean.getTotalLoadedClassCount();
            clsUnloaded = clMBean.getUnloadedClassCount();
            sb.append("Classes: loaded=").append(clsLoaded)
                    .append(" total loaded=").append(clsTotal)
                    .append(" unloaded ").append(clsUnloaded).append('\n');

//        } catch (MalformedObjectNameException ex) {
//            Logger.getLogger("global").log(Level.WARNING, null, ex);
        } catch (NullPointerException ex) {
            LOG.log(Level.WARNING, null, ex);
        }
        return sb.toString();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:59,代码来源:DiagnosticTask.java

示例14: getVMArgs

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private static List<String> getVMArgs() {
	RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
	return new ArrayList<String>(runtimeMxBean.getInputArguments());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:5,代码来源:AllureUtils.java

示例15: testCallAnalyzerConcurrencyAndLeaks

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
public void testCallAnalyzerConcurrencyAndLeaks() throws Exception {
	ExecutorService ex = Executors.newFixedThreadPool(400);
	final CallAnalyzer tp = new CallAnalyzer();
	final MetricReference sec = new MetricReference("sec");
	MetricReference se1c = new MetricReference("se111c");
	tp.configure(sec, new MetricAnalysisConfiguration(10,500,500));
	tp.startAnalysis(sec);
	tp.startAnalysis(se1c);
	Runnable r = new Runnable() {
		
		public void run() {
			tp.enter(sec);
			try {
				if(++count % 10000==0) {
					System.out.println("Avg " + tp.getMetricStats(sec).averageTime);
					Thread.sleep(1000);
				}
				
				Thread.sleep(stuck);
				
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			tp.leave(sec);
		}
	};
	for(int q=0; q<200000; q++) {
		ex.execute(r);
	}
	
	System.out.println("size:" + tp.getNumberOfThreads());
	Thread.sleep(5000);
	ex.shutdown();
	ex.awaitTermination(60, TimeUnit.SECONDS);
	ex.shutdownNow();
	ex = null;
	System.gc();
	System.gc();Thread.sleep(1000);
	System.out.println("size:" + tp.getNumberOfThreads());
	RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
	
	List<String> arguments = RuntimemxBean.getInputArguments();
	for(String arg : arguments) {
		System.out.println(arg);
	}
	
	assertTrue(Math.abs(tp.getMetricStats(sec).averageTime - stuck)<10); // wrong avg time
	//assertEquals(0, tp.getNumberOfThreads()); // Memory leaking
	System.out.println("Active threads " + tp.getNumberOfThreads());
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:52,代码来源:SIPEventInterceptorTest.java


注:本文中的java.lang.management.RuntimeMXBean.getInputArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。