Example usage for com.google.common.base StandardSystemProperty OS_NAME

List of usage examples for com.google.common.base StandardSystemProperty OS_NAME

Introduction

In this page you can find the example usage for com.google.common.base StandardSystemProperty OS_NAME.

Prototype

StandardSystemProperty OS_NAME

To view the source code for com.google.common.base StandardSystemProperty OS_NAME.

Click Source Link

Document

Operating system name.

Usage

From source file:com.facebook.presto.server.PrestoJvmRequirements.java

public static void verifyJvmRequirements() {
    String specVersion = StandardSystemProperty.JAVA_SPECIFICATION_VERSION.value();
    if ((specVersion == null) || (specVersion.compareTo("1.8") < 0)) {
        failRequirement("Presto requires Java 1.8+ (found %s)", specVersion);
    }// ww w  .  j a va  2 s  .  c  o  m

    String vendor = StandardSystemProperty.JAVA_VENDOR.value();
    if (!"Oracle Corporation".equals(vendor)) {
        failRequirement("Presto requires an Oracle or OpenJDK JVM (found %s)", vendor);
    }

    String dataModel = System.getProperty("sun.arch.data.model");
    if (!"64".equals(dataModel)) {
        failRequirement("Presto requires a 64-bit JVM (found %s)", dataModel);
    }

    String osName = StandardSystemProperty.OS_NAME.value();
    String osArch = StandardSystemProperty.OS_ARCH.value();
    if ("Linux".equals(osName)) {
        if (!"amd64".equals(osArch)) {
            failRequirement("Presto requires x86-64 or amd64 on Linux (found %s)", osArch);
        }
    } else if ("Mac OS X".equals(osName)) {
        if (!"x86_64".equals(osArch)) {
            failRequirement("Presto requires x86_64 on Mac OS X (found %s)", osArch);
        }
    } else {
        failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
    }

    if (!ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
        failRequirement("Presto requires a little endian platform (found %s)", ByteOrder.nativeOrder());
    }

    verifySlice();
}

From source file:io.prestosql.server.PrestoSystemRequirements.java

private static void verifyOsArchitecture() {
    String osName = StandardSystemProperty.OS_NAME.value();
    String osArch = StandardSystemProperty.OS_ARCH.value();
    if ("Linux".equals(osName)) {
        if (!"amd64".equals(osArch) && !"ppc64le".equals(osArch)) {
            failRequirement("Presto requires amd64 or ppc64le on Linux (found %s)", osArch);
        }//from  w  w w  . j av a  2s.  c o m
        if ("ppc64le".equals(osArch)) {
            warnRequirement("Support for the POWER architecture is experimental");
        }
    } else if ("Mac OS X".equals(osName)) {
        if (!"x86_64".equals(osArch)) {
            failRequirement("Presto requires x86_64 on Mac OS X (found %s)", osArch);
        }
    } else {
        failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
    }
}

From source file:de.ks.flatadocdb.session.SessionAction.java

protected void applyWindowsHiddenAttribute(Path flushComplete) {
    if (StandardSystemProperty.OS_NAME.value().toLowerCase(Locale.ROOT).contains("win")) {
        try {/*from  w  ww .  j  a v  a2s .c o m*/
            Files.setAttribute(flushComplete, "dos:hidden", true);
            log.trace("Hiding flush file {}", flushComplete);
        } catch (IOException e) {
            log.warn("Cannot set hidden attribute on {}", flushComplete, e);
        }
    }
}

From source file:io.nebo.container.NettyEmbeddedServletContainer.java

private void groups(ServerBootstrap b) {
    if (StandardSystemProperty.OS_NAME.value().equals("Linux")) {
        bossGroup = new EpollEventLoopGroup(1);
        workerGroup = new EpollEventLoopGroup();
        b.channel(EpollServerSocketChannel.class).group(bossGroup, workerGroup)
                .option(EpollChannelOption.TCP_CORK, true);
    } else {/*from   w w w .  ja v  a 2s.c  om*/
        bossGroup = new NioEventLoopGroup(1);
        workerGroup = new NioEventLoopGroup();
        b.channel(NioServerSocketChannel.class).group(bossGroup, workerGroup);
    }
    b.option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_REUSEADDR, true)
            .option(ChannelOption.SO_BACKLOG, 100);
    logger.info("Bootstrap configuration: " + b.toString());
}

From source file:org.killbill.billing.server.updatechecker.ClientInfo.java

public String getOSName() {
    return getProperty(StandardSystemProperty.OS_NAME);
}

From source file:com.google.copybara.Main.java

/**
 * Returns the base directory to be used by Copybara to write execution related files (Like
 * logs).//  w w  w .  jav  a  2  s. c  o  m
 */
private String getBaseExecDir() {
    // In this case we are not using GeneralOptions.getEnvironment() because we still haven't built
    // the options, but it's fine. This is the tool's Main and is also injecting System.getEnv()
    // to the options, so the value is the same.
    String userHome = StandardSystemProperty.USER_HOME.value();

    switch (StandardSystemProperty.OS_NAME.value()) {
    case "Linux":
        String xdgCacheHome = System.getenv("XDG_CACHE_HOME");
        return Strings.isNullOrEmpty(xdgCacheHome) ? userHome + "/.cache/" + COPYBARA_NAMESPACE
                : xdgCacheHome + COPYBARA_NAMESPACE;
    case "Mac OS X":
        return userHome + "/Library/Logs/" + COPYBARA_NAMESPACE;
    default:
        return "/var/tmp/" + COPYBARA_NAMESPACE;
    }
}

From source file:org.ow2.proactive.resourcemanager.updater.RMNodeUpdater.java

/**
 * Build the java subprocess which will be spawned from this JVM.
 * @param args current JVM arguments/* ww w  .  ja v a  2s  .  c  o m*/
 * @param jarFile up-to-date node jar file
 * @return
 */
private ProcessBuilder generateSubProcess(String[] args, String jarFile) {
    ProcessBuilder pb;
    List<String> command = new ArrayList<>();
    if (StandardSystemProperty.OS_NAME.value().toLowerCase().contains("windows")) {
        command.add((new File(StandardSystemProperty.JAVA_HOME.value(), "bin/java.exe")).getAbsolutePath());
    } else {
        command.add((new File(StandardSystemProperty.JAVA_HOME.value(), "bin/java")).getAbsolutePath());
    }
    command.addAll(buildJVMOptions());
    command.add("-jar");
    command.add(jarFile);
    command.addAll(removeOptionsUnrecognizedByRMNodeStarter(args));
    logger.info("Starting Java command: " + command);
    pb = new ProcessBuilder(command);
    pb.inheritIO();
    if (pb.environment().containsKey("CLASSPATH")) {
        pb.environment().remove("CLASSPATH");
    }
    return pb;
}