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


Java OperatingSystem.ProcessSort方法代码示例

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


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

示例1: getRoot

import oshi.software.os.OperatingSystem; //导入方法依赖的package包/类
@GET
@RolesAllowed(BasicAuthorizer.AUTHENTICATED_ROLE)
public ProcessInfo getRoot(@Auth UserConfiguration user, @QueryParam("sortBy") Optional<String> processSort, @QueryParam("limit") Optional<Integer> limit) {
    OperatingSystem.ProcessSort sortBy = OperatingSystem.ProcessSort.NAME;
    if (processSort.isPresent()) {
        String method = processSort.get().toUpperCase();
        try {
            sortBy = OperatingSystem.ProcessSort.valueOf(method);
        } catch (IllegalArgumentException e) {
            String validOptions = Arrays.stream(OperatingSystem.ProcessSort.values()).map(Enum::name).collect(Collectors.joining(", ", "Valid options are: ", "."));
            LOGGER.error("No process sort method of type {} was found. {}", method, validOptions);
            throw new WebApplicationException(String.format("No process sort method of type %s was found. %s", method, validOptions),
                    Response.Status.BAD_REQUEST);
        }
    }
    Integer theLimit = limit.orElse(0);
    if(theLimit < 0){
        String message = String.format("limit cannot be negative (%d)", theLimit);
        LOGGER.error(message);
        throw new WebApplicationException(message, Response.Status.BAD_REQUEST);
    }

    ProcessesInfo value = provider.processesInfo(sortBy, theLimit);
    return ProcessInfoMapper.INSTANCE.map(value);
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:26,代码来源:ProcessesResource.java

示例2: getProcessesCorrectSortingMethod

import oshi.software.os.OperatingSystem; //导入方法依赖的package包/类
@Test
public void getProcessesCorrectSortingMethod() throws Exception {
    ArgumentCaptor<OperatingSystem.ProcessSort> captor = ArgumentCaptor.forClass(OperatingSystem.ProcessSort.class);
    when(provider.processesInfo(captor.capture(), anyInt()))
            .thenReturn(new ProcessesInfo(mock(GlobalMemory.class), 0, 0, 0,
                    new Process[]{process}));

    ProcessInfo processInfo = RESOURCES.getJerseyTest().target("/processes")
            .queryParam("sortBy", "MEMORY")
            .request(MediaType.APPLICATION_JSON_TYPE)
            .get(ProcessInfo.class);

    assertEquals(captor.getValue(), OperatingSystem.ProcessSort.MEMORY);
    assertThat(processInfo.getProcesses()[0].getName(), is(equalToIgnoringCase("name")));
    assertThat(processInfo.getProcesses()[0].getState(), is(equalToIgnoringCase(process.getState().name())));
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:17,代码来源:ProcessesResourceTest.java

示例3: setupDataUnix

import oshi.software.os.OperatingSystem; //导入方法依赖的package包/类
private void setupDataUnix(OperatingSystem.ProcessSort sort) {
    OSProcess[] processes = services.processorService.getProcessesList(sort);
    data = new String[processes.length][5];

    for(int i = 0; i < processes.length; i++) {
        // path, uptime, pid, name
        data[i][0] = processes[i].getName();
        data[i][1] = Integer.toString(processes[i].getProcessID());
        data[i][2] = Long.toString(processes[i].getResidentSetSize() / (1024 * 1024)) + " MB";
    }
}
 
开发者ID:ozankaraali,项目名称:SystemMonitor,代码行数:12,代码来源:ProcessesPanel.java

示例4: processesInfo

import oshi.software.os.OperatingSystem; //导入方法依赖的package包/类
@Override
public ProcessesInfo processesInfo(OperatingSystem.ProcessSort sortBy, int limit) {
    GlobalMemory memory = hal.getMemory();
    Process[] processes = Arrays
            .stream(operatingSystem.getProcesses(limit, sortBy))
            .map(p -> Process.create(p, memory))
            .collect(Collectors.toList())
            .toArray(new Process[0]);

    return new ProcessesInfo(memory, operatingSystem.getProcessId(), operatingSystem.getThreadCount(), operatingSystem.getProcessCount(), processes);
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:12,代码来源:DefaultInfoProvider.java

示例5: processesInfo

import oshi.software.os.OperatingSystem; //导入方法依赖的package包/类
ProcessesInfo processesInfo(OperatingSystem.ProcessSort sortBy, int limit); 
开发者ID:Krillsson,项目名称:sys-api,代码行数:2,代码来源:InfoProvider.java


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