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

Java JavaSysMon类代码示例

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

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



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

示例1: findEditorProcess

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@Nullable
public static UnityProcess findEditorProcess()
{
	JavaSysMon javaSysMon = new JavaSysMon();
	ProcessInfo[] processInfos = javaSysMon.processTable();

	UnityProcess unityProcess = null;
	for(ProcessInfo processInfo : processInfos)
	{
		String name = processInfo.getName();
		if(name.equalsIgnoreCase("unity.exe") || name.equalsIgnoreCase("unity") || name.equalsIgnoreCase("unity.app"))
		{
			unityProcess = new UnityProcess(processInfo.getPid(), processInfo.getName(), "localhost", UnityProcessDialog.buildDebuggerPort(processInfo.getPid()));
			break;
		}
	}

	return unityProcess;
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:20,代码来源:UnityEditorCommunication.java


示例2: cancelTaskShouldBeProcessedBeforeKillChildProcess

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@Test
@RunIf(value = EnhancedOSChecker.class, arguments = {DO_NOT_RUN_ON, WINDOWS})
public void cancelTaskShouldBeProcessedBeforeKillChildProcess() throws InterruptedException {
    final BuildSession buildSession = newBuildSession();
    final BuildCommand printSubProcessCount = exec("/bin/bash", "-c", "pgrep -P " + new JavaSysMon().currentPid() + " | wc -l");
    Thread buildingThread = new Thread(new Runnable() {
        @Override
        public void run() {
            buildSession.build(compose(
                    compose(execSleepScript(50),
                            echo("after sleep"))
                            .setOnCancel(printSubProcessCount)));
        }
    });

    buildingThread.start();
    waitUntilSubProcessExists(execSleepScriptProcessCommand(), true);
    assertTrue(buildInfo(), buildSession.cancel(30, TimeUnit.SECONDS));
    waitUntilSubProcessExists(execSleepScriptProcessCommand(), false);
    assertThat(Integer.parseInt(console.lastLine().trim()), greaterThan(0));
    buildingThread.join();
}
 
开发者ID:gocd,项目名称:gocd,代码行数:23,代码来源:BuildSessionCancelingTest.java


示例3: stubSysMon

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
private JavaSysMon stubSysMon() {
    final OsProcess process1 = mock(OsProcess.class);
    when(process1.processInfo()).thenReturn(new ProcessInfo(101, 100, "command-1", "name-1", "owner-1", 100, 200, 400, 800));
    final OsProcess process1a = mock(OsProcess.class);
    when(process1a.processInfo()).thenReturn(new ProcessInfo(103, 100, "command-1a", "name-1a", "owner-1", 160, 260, 460, 860));
    final OsProcess process2 = mock(OsProcess.class);
    when(process2.processInfo()).thenReturn(new ProcessInfo(102, 101, "command-2", "name-2", "owner-1", 150, 250, 450, 850));
    JavaSysMon sysMon = new JavaSysMon() {
        @Override
        public void visitProcessTree(int pid, ProcessVisitor processVisitor) {
            processVisitor.visit(process2, 2);
            processVisitor.visit(process1, 1);
            processVisitor.visit(process1a, 1);
        }

        @Override
        public int currentPid() {
            return 100;
        }
    };
    return sysMon;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:23,代码来源:SubprocessLoggerTest.java


示例4: collectItems

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@NotNull
public static List<UnityProcess> collectItems()
{
	Collection<UnityPlayer> players = UnityPlayerService.getInstance().getPlayers();
	List<UnityProcess> items = new ArrayList<>(players.size() + 1);
	try
	{
		for(UnityPlayer player : players)
		{
			if(player.isSupportDebugging())
			{
				items.add(new UnityProcess((int) player.getGuid(), player.getId(), player.getIp(), player.getDebuggerPort()));
			}
		}
		JavaSysMon javaSysMon = new JavaSysMon();
		ProcessInfo[] processInfos = javaSysMon.processTable();
		for(ProcessInfo processInfo : processInfos)
		{
			String name = processInfo.getName();
			if((StringUtil.startsWithIgnoreCase(name, "unity") || StringUtil.containsIgnoreCase(name, "Unity.app")) && !(StringUtil.containsIgnoreCase(name, "Unity") && StringUtil
					.containsIgnoreCase(name, "Helper")) //ignore 'UnityHelper' and 'Unity Helper'
					&& !StringUtil.containsIgnoreCase(name, "UnityShader"))
			{
				items.add(new UnityProcess(processInfo.getPid(), name, "localhost", buildDebuggerPort(processInfo.getPid())));
			}
		}
	}
	catch(Exception e)
	{
		LOGGER.error(e);
	}
	return items;
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:34,代码来源:UnityProcessDialog.java


示例5: cancel

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
/**
 * Cancel build and wait for build session done
 *
 * @return {@code true} if the build session is done and {@code false}
 * if time out happens
 */
public boolean cancel(int timeout, TimeUnit timeoutUnit) throws InterruptedException {
    if (isCanceled()) {
        return true;
    }

    cancelLatch.countDown();

    try {
        return doneLatch.await(timeout, timeoutUnit);
    } finally {
        new JavaSysMon().infanticide();
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:BuildSession.java


示例6: cancelShouldProcessOnCancelCommandOfCommandThatIsRunning

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@Test
public void cancelShouldProcessOnCancelCommandOfCommandThatIsRunning() throws InterruptedException {
    final BuildSession buildSession = newBuildSession();
    Thread buildingThread = new Thread(new Runnable() {
        @Override
        public void run() {
            buildSession.build(compose(
                    compose(
                            execSleepScript(50).setOnCancel(echo("exec canceled")),
                            echo("after sleep"))
                            .setOnCancel(echo("inner oncancel"))
            ).setOnCancel(echo("outter oncancel")));
        }
    });

    buildingThread.start();
    waitUntilSubProcessExists(execSleepScriptProcessCommand(), true);
    assertTrue(buildInfo(), buildSession.cancel(30, TimeUnit.SECONDS));
    waitUntilSubProcessExists(execSleepScriptProcessCommand(), false);
    JavaSysMon javaSysMon = new JavaSysMon();
    final boolean[] exists = {false};
    javaSysMon.visitProcessTree(javaSysMon.currentPid(), new ProcessVisitor() {
        @Override
        public boolean visit(OsProcess osProcess, int i) {
            String command = osProcess.processInfo().getName();
            if (execSleepScriptProcessCommand().equals(command)) {
                exists[0] = true;
            }
            return false;
        }
    });
    assertThat(exists[0], is(false));

    assertThat(buildInfo(), getLast(statusReporter.results()), is(Cancelled));
    assertThat(buildInfo(), console.output(), not(containsString("after sleep")));
    assertThat(buildInfo(), console.output(), containsString("exec canceled"));
    assertThat(buildInfo(), console.output(), containsString("inner oncancel"));
    assertThat(buildInfo(), console.output(), containsString("outter oncancel"));
    buildingThread.join();
}
 
开发者ID:gocd,项目名称:gocd,代码行数:41,代码来源:BuildSessionCancelingTest.java


示例7: subProcessNames

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
private List<String> subProcessNames() {
    JavaSysMon javaSysMon = new JavaSysMon();
    final List<String> names = new ArrayList<>();
    final int currentPid = javaSysMon.currentPid();
    javaSysMon.visitProcessTree(currentPid, new ProcessVisitor() {
        @Override
        public boolean visit(OsProcess osProcess, int i) {
            if(osProcess.processInfo().getPid() != currentPid) {
                names.add(osProcess.processInfo().getName());
            }
            return false;
        }
    });
    return names;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:16,代码来源:BuildSessionCancelingTest.java


示例8: shouldNotLogAnythingWhenNoChildProcessesFound

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@Test
public void shouldNotLogAnythingWhenNoChildProcessesFound() {
    JavaSysMon sysMon = mock(JavaSysMon.class);
    logger = new SubprocessLogger(sysMon);
    try (LogFixture log = logFixtureFor(SubprocessLogger.class, Level.ALL)) {
        logger.run();
        String result;
        synchronized (log) {
            result = log.getLog();
        }
        assertThat(result, is(""));
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:14,代码来源:SubprocessLoggerTest.java


示例9: shouldRegisterItselfAsExitHook

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@Test
public void shouldRegisterItselfAsExitHook() {
    logger = new SubprocessLogger(new JavaSysMon());
    logger.registerAsExitHook("foo");
    try {
        Runtime.getRuntime().addShutdownHook(logger.exitHook());
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), is("Hook previously registered"));
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:SubprocessLoggerTest.java


示例10: getProcessList

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@Nonnull
public static ProcessInfo[] getProcessList() {
  JavaSysMon javaSysMon = new JavaSysMon();
  com.jezhumble.javasysmon.ProcessInfo[] processInfos = javaSysMon.processTable();
  ProcessInfo[] infos = new ProcessInfo[processInfos.length];
  for (int i = 0; i < processInfos.length; i++) {
    com.jezhumble.javasysmon.ProcessInfo info = processInfos[i];

    String executable;
    String args;
    List<String> commandLineList = StringUtil.splitHonorQuotes(info.getCommand(), ' ');
    if (commandLineList.isEmpty()) {
      executable = info.getName();
      args = "";
    }
    else {
      executable = commandLineList.get(0);
      if (commandLineList.size() > 1) {
        args = StringUtil.join(commandLineList.subList(1, commandLineList.size()), " ");
      }
      else {
        args = "";
      }
    }

    infos[i] = new ProcessInfo(info.getPid(), info.getCommand(), StringUtil.unquoteString(executable, '\"'), args);
  }
  return infos;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:30,代码来源:OSProcessUtil.java


示例11: getFreeMemory

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
private long getFreeMemory(){
    JavaSysMon monitor =   new JavaSysMon();
    return monitor.physical().getFreeBytes() / 1000000;
}
 
开发者ID:matheusmessora,项目名称:nursery,代码行数:5,代码来源:ServerMemoryMonitor.java


示例12: getTotalMemory

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
private long getTotalMemory(){
    JavaSysMon monitor =   new JavaSysMon();
    return monitor.physical().getTotalBytes() / 1000000;
}
 
开发者ID:matheusmessora,项目名称:nursery,代码行数:5,代码来源:ServerMemoryMonitor.java


示例13: afterPropertiesSet

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    LOG.info("[Startup] Go Version: {}", version());
    LOG.info("[Startup] PID: {}", new JavaSysMon().currentPid());
    LOG.info("[Startup] JVM properties: {}", System.getProperties());
    LOG.info("[Startup] Environment Variables: {}", System.getenv());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:ServerVersion.java


示例14: SubprocessLogger

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
public SubprocessLogger() {
    this(new JavaSysMon());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:4,代码来源:SubprocessLogger.java


示例15: build

import com.jezhumble.javasysmon.JavaSysMon; //导入依赖的package包/类
@Override
public void build(DefaultGoPublisher publisher, EnvironmentVariableContext environmentVariableContext, TaskExtension taskExtension, ArtifactExtension artifactExtension, PluginRequestProcessorRegistry pluginRequestProcessorRegistry, String consoleLogCharset) throws CruiseControlException {
    new JavaSysMon().infanticide();
}
 
开发者ID:gocd,项目名称:gocd,代码行数:5,代码来源:BuilderForKillAllChildTask.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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