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


Java U.isMacOs方法代码示例

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


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

示例1: testLoopbackProblemSecondNodeOnLoopback

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @throws Exception If any error occurs.
 */
public void testLoopbackProblemSecondNodeOnLoopback() throws Exception {
    if (U.isWindows() || U.isMacOs())
        return;

    try {
        startGridNoOptimize("LoopbackProblemTest");

        GridTestUtils.assertThrows(
            log,
            new Callable<Object>() {
                @Nullable @Override public Object call() throws Exception {
                    // Exception will be thrown because we start node which uses loopback address,
                    // but the first node does not.
                    startGridNoOptimize(1);

                    return null;
                }
            },
            IgniteException.class,
            null);
    }
    finally {
        stopAllGrids();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:29,代码来源:TcpDiscoverySelfTest.java

示例2: handleNetworkError

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param e Network error to handle.
 * @return {@code True} if this error is recoverable and the operation can be retried.
 */
private boolean handleNetworkError(IOException e) {
    if ("Network is unreachable".equals(e.getMessage()) && U.isMacOs()) {
        U.warn(log, "Multicast does not work on Mac OS JVM loopback address (configure external IP address " +
            "for 'localHost' configuration property)");

        return false;
    }

    return true;
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:TcpDiscoveryMulticastIpFinder.java

示例3: mapLibraryName

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @return Maps library name to file name.
 */
private static String mapLibraryName(String name) {
    String libName = System.mapLibraryName(name);

    if (U.isMacOs() && libName.endsWith(".jnilib"))
        return libName.substring(0, libName.length() - "jnilib".length()) + "dylib";

    return libName;
}
 
开发者ID:apache,项目名称:ignite,代码行数:12,代码来源:IpcSharedMemoryNativeLoader.java

示例4: getPlatformDependentLineStartFlag

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** @return Flag for {@code ipcs} utility. */
private static String getPlatformDependentLineStartFlag() {
    if (U.isMacOs())
        return "m ";
    else if (U.isLinux())
        return "0x";
    else
        throw new IllegalStateException("This OS is not supported.");
}
 
开发者ID:apache,项目名称:ignite,代码行数:10,代码来源:IpcSharedMemoryUtils.java

示例5: testLoopbackProblemFirstNodeOnLoopback

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @throws Exception If any error occurs.
 */
public void testLoopbackProblemFirstNodeOnLoopback() throws Exception {
    // On Windows and Mac machines two nodes can reside on the same port
    // (if one node has localHost="127.0.0.1" and another has localHost="0.0.0.0").
    // So two nodes do not even discover each other.
    if (U.isWindows() || U.isMacOs() || U.isSolaris())
        return;

    try {
        startGridNoOptimize(1);

        GridTestUtils.assertThrows(
            log,
            new Callable<Object>() {
                @Nullable @Override public Object call() throws Exception {
                    // Exception will be thrown because we start node which does not use loopback address,
                    // but the first node does.
                    startGridNoOptimize("LoopbackProblemTest");

                    return null;
                }
            },
            IgniteException.class,
            null);
    }
    finally {
        stopAllGrids();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:32,代码来源:TcpDiscoverySelfTest.java

示例6: startLocalNode

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Start local node in terminal.
 *
 * @param log Logger.
 * @param cfgPath Path to node configuration to start with.
 * @param nodesToStart Number of nodes to start.
 * @param quite If {@code true} then start node in quiet mode.
 * @param envVars Optional map with environment variables.
 * @return List of started processes.
 * @throws IOException If failed to start.
 */
public static List<Process> startLocalNode(@Nullable IgniteLogger log, String cfgPath, int nodesToStart,
    boolean quite, Map<String, String> envVars) throws IOException {
    String quitePar = quite ? "" : "-v";

    String cmdFile = new File("bin", U.isWindows() ? "ignite.bat" : "ignite.sh").getPath();

    File cmdFilePath = U.resolveIgnitePath(cmdFile);

    if (cmdFilePath == null || !cmdFilePath.exists())
        throw new FileNotFoundException(String.format("File not found: %s", cmdFile));

    File nodesCfgPath = U.resolveIgnitePath(cfgPath);

    if (nodesCfgPath == null || !nodesCfgPath.exists())
        throw new FileNotFoundException(String.format("File not found: %s", cfgPath));

    String nodeCfg = nodesCfgPath.getCanonicalPath();

    log(log, String.format("Starting %s local %s with '%s' config", nodesToStart, nodesToStart > 1 ? "nodes" : "node", nodeCfg));

    List<Process> run = new ArrayList<>();

    try {
        String igniteCmd = cmdFilePath.getCanonicalPath();

        for (int i = 0; i < nodesToStart; i++) {
            if (U.isMacOs()) {
                Map<String, String> macEnv = new HashMap<>(System.getenv());

                if (envVars != null) {
                    for (Map.Entry<String, String> ent : envVars.entrySet())
                        if (macEnv.containsKey(ent.getKey())) {
                            String old = macEnv.get(ent.getKey());

                            if (old == null || old.isEmpty())
                                macEnv.put(ent.getKey(), ent.getValue());
                            else
                                macEnv.put(ent.getKey(), old + ':' + ent.getValue());
                        }
                        else
                            macEnv.put(ent.getKey(), ent.getValue());
                }

                StringBuilder envs = new StringBuilder();

                for (Map.Entry<String, String> entry : macEnv.entrySet()) {
                    String val = entry.getValue();

                    if (val.indexOf(';') < 0 && val.indexOf('\'') < 0)
                        envs.append(String.format("export %s='%s'; ",
                                entry.getKey(), val.replace('\n', ' ').replace("'", "\'")));
                }

                run.add(openInConsole(envs.toString(), igniteCmd, quitePar, nodeCfg));
            } else
                run.add(openInConsole(null, envVars, igniteCmd, quitePar, nodeCfg));
        }

        return run;
    }
    catch (Exception e) {
        for (Process proc: run)
            proc.destroy();

        throw e;
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:79,代码来源:VisorTaskUtils.java

示例7: openInConsole

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Run command in separated console.
 *
 * @param workFolder Work folder for command.
 * @param envVars Optional map with environment variables.
 * @param args A string array containing the program and its arguments.
 * @return Started process.
 * @throws IOException If failed to start process.
 */
public static Process openInConsole(@Nullable File workFolder, Map<String, String> envVars, String... args)
    throws IOException {
    String[] commands = args;

    String cmd = F.concat(Arrays.asList(args), " ");

    if (U.isWindows())
        commands = F.asArray("cmd", "/c", String.format("start %s", cmd));

    if (U.isMacOs())
        commands = F.asArray("osascript", "-e",
            String.format("tell application \"Terminal\" to do script \"%s\"", cmd));

    if (U.isUnix())
        commands = F.asArray("xterm", "-sl", "1024", "-geometry", "200x50", "-e", cmd);

    ProcessBuilder pb = new ProcessBuilder(commands);

    if (workFolder != null)
        pb.directory(workFolder);

    if (envVars != null) {
        String sep = U.isWindows() ? ";" : ":";

        Map<String, String> goalVars = pb.environment();

        for (Map.Entry<String, String> var: envVars.entrySet()) {
            String envVar = goalVars.get(var.getKey());

            if (envVar == null || envVar.isEmpty())
                envVar = var.getValue();
            else
                envVar += sep + var.getValue();

            goalVars.put(var.getKey(), envVar);
        }
    }

    return pb.start();
}
 
开发者ID:apache,项目名称:ignite,代码行数:50,代码来源:VisorTaskUtils.java

示例8: sharedMemoryIds

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Returns shared memory ids for Mac OS and Linux platforms.
 *
 * @return Collection of all shared memory IDs in the system.
 * @throws IOException If failed.
 * @throws InterruptedException If failed.
 * @throws IllegalStateException If current OS is not supported.
 */
static Collection<Integer> sharedMemoryIds() throws IOException, InterruptedException {
    if (U.isMacOs() || U.isLinux())
        return sharedMemoryIdsOnMacOS();
    else
        throw new IllegalStateException("Current OS is not supported.");
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:IpcSharedMemoryUtils.java

示例9: isMacInvalidArgumentError

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Checks if error is MAC invalid argument error which ususally requires special handling.
 *
 * @param e Exception.
 * @return {@code True} if error is invalid argument error on MAC.
 */
public static boolean isMacInvalidArgumentError(Exception e) {
    return U.isMacOs() && e instanceof SocketException && e.getMessage() != null &&
        e.getMessage().toLowerCase().contains("invalid argument");
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:IgniteUtils.java


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