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


Java U.isWindows方法代码示例

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


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

示例1: kill

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Kills the java process.
 *
 * @throws Exception If any problem occurred.
 */
public void kill() throws Exception {
    Process killProc = U.isWindows() ?
        Runtime.getRuntime().exec(new String[] {"taskkill", "/pid", pid, "/f", "/t"}) :
        Runtime.getRuntime().exec(new String[] {"kill", "-9", pid});

    killProc.waitFor();

    int exitVal = killProc.exitValue();

    if (exitVal != 0)
        log.info(String.format("Abnormal exit value of %s for pid %s", exitVal, pid));

    if (procKilledC != null)
        procKilledC.apply();

    U.interrupt(osGrabber);
    U.interrupt(esGrabber);

    U.join(osGrabber, log);
    U.join(esGrabber, log);
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:GridJavaProcess.java

示例2: 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

示例3: testLoadWithCorruptedLibFile

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Test {@link IpcSharedMemoryNativeLoader#load()} in case, when native library path was
 * already loaded, but corrupted.
 *
 * @throws Exception If failed.
 */
public void testLoadWithCorruptedLibFile() throws Exception {
    if (U.isWindows())
        return;

    Process ps = GridJavaProcess.exec(
        LoadWithCorruptedLibFileTestRunner.class,
        null,
        null,
        null,
        null,
        Collections.<String>emptyList(),
        System.getProperty("surefire.test.class.path")
    ).getProcess();

    readStreams(ps);

    int code = ps.waitFor();

    assertEquals("Returned code have to be 0.", 0, code);
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:IpcSharedMemoryNativeLoaderSelfTest.java

示例4: testListPathForSymlink

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 *
 * @throws Exception If failed.
 */
@SuppressWarnings("ConstantConditions")
public void testListPathForSymlink() throws Exception {
    if (U.isWindows())
        return;

    createSymlinks();

    assertTrue(igfs.info(DIR).isDirectory());

    Collection<IgfsPath> pathes = igfs.listPaths(DIR);
    Collection<IgfsFile> files = igfs.listFiles(DIR);

    assertEquals(1, pathes.size());
    assertEquals(1, files.size());

    assertEquals("filedest", F.first(pathes).name());
    assertEquals("filedest", F.first(files).path().name());
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java

示例5: extract

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param errs Errors collection.
 * @param src Source.
 * @param target Target.
 * @return {@code True} if resource was found and loaded.
 */
@SuppressWarnings("ResultOfMethodCallIgnored")
private static boolean extract(Collection<Throwable> errs, URL src, File target) {
    FileOutputStream os = null;
    InputStream is = null;

    try {
        if (!target.exists() || !haveEqualMD5(target, src.openStream())) {
            is = src.openStream();

            if (is != null) {
                os = new FileOutputStream(target);

                int read;

                byte[] buf = new byte[4096];

                while ((read = is.read(buf)) != -1)
                    os.write(buf, 0, read);
            }
        }

        // chmod 775.
        if (!U.isWindows())
            Runtime.getRuntime().exec(new String[] {"chmod", "775", target.getCanonicalPath()}).waitFor();

        System.load(target.getPath());

        return true;
    }
    catch (IOException | UnsatisfiedLinkError | InterruptedException | NoSuchAlgorithmException e) {
        errs.add(e);
    }
    finally {
        U.closeQuiet(os);
        U.closeQuiet(is);
    }

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

示例6: 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

示例7: testDeleteSymlinkDir

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

    createSymlinks();

    // Only symlink must be deleted. Destination content must be exist.
    igfs.delete(DIR, true);

    assertTrue(fileLinkDest.exists());
}
 
开发者ID:apache,项目名称:ignite,代码行数:16,代码来源:IgfsLocalSecondaryFileSystemProxySelfTest.java

示例8: testSymlinkToFile

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

    createSymlinks();

    checkFileContent(igfs, new IgfsPath("/file"), chunk);
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:IgfsLocalSecondaryFileSystemProxySelfTest.java

示例9: testMkdirsInsideSymlink

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

    createSymlinks();

    igfs.mkdirs(SUBSUBDIR);

    assertTrue(Files.isDirectory(dirLinkDest.toPath().resolve("subdir/subsubdir")));
    assertTrue(Files.isDirectory(dirLinkSrc.toPath().resolve("subdir/subsubdir")));
}
 
开发者ID:apache,项目名称:ignite,代码行数:16,代码来源:IgfsLocalSecondaryFileSystemProxySelfTest.java

示例10: resetShmemServer

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Creates new shared memory communication server.
 * @return Server.
 * @throws IgniteCheckedException If failed.
 */
@Nullable private IpcSharedMemoryServerEndpoint resetShmemServer() throws IgniteCheckedException {
    if (boundTcpShmemPort >= 0)
        throw new IgniteCheckedException("Shared memory server was already created on port " + boundTcpShmemPort);

    if (shmemPort == -1 || U.isWindows())
        return null;

    IgniteCheckedException lastEx = null;

    // If configured TCP port is busy, find first available in range.
    for (int port = shmemPort; port < shmemPort + locPortRange; port++) {
        try {
            IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(
                log.getLogger(IpcSharedMemoryServerEndpoint.class),
                locProcDesc.processId(), igniteInstanceName, workDir);

            srv.setPort(port);

            srv.omitOutOfResourcesWarning(true);

            srv.start();

            boundTcpShmemPort = port;

            // Ack Port the TCP server was bound to.
            if (log.isInfoEnabled())
                log.info("Successfully bound shared memory communication to TCP port [port=" + boundTcpShmemPort +
                    ", locHost=" + locHost + ']');

            return srv;
        }
        catch (IgniteCheckedException e) {
            lastEx = e;

            if (log.isDebugEnabled())
                log.debug("Failed to bind to local port (will try next port within range) [port=" + port +
                    ", locHost=" + locHost + ']');
        }
    }

    // If free port wasn't found.
    throw new IgniteCheckedException("Failed to bind shared memory communication to any port within range [startPort=" +
        locPort + ", portRange=" + locPortRange + ", locHost=" + locHost + ']', lastEx);
}
 
开发者ID:apache,项目名称:ignite,代码行数:50,代码来源:HadoopExternalCommunication.java

示例11: resetShmemServer

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Creates new shared memory communication server.
 *
 * @return Server.
 * @throws IgniteCheckedException If failed.
 */
@Nullable private IpcSharedMemoryServerEndpoint resetShmemServer() throws IgniteCheckedException {
    if (boundTcpShmemPort >= 0)
        throw new IgniteCheckedException("Shared memory server was already created on port " + boundTcpShmemPort);

    if (shmemPort == -1 || U.isWindows())
        return null;

    IgniteCheckedException lastEx = null;

    // If configured TCP port is busy, find first available in range.
    for (int port = shmemPort; port < shmemPort + locPortRange; port++) {
        try {
            IgniteConfiguration cfg = ignite.configuration();

            IpcSharedMemoryServerEndpoint srv =
                new IpcSharedMemoryServerEndpoint(log, cfg.getNodeId(), igniteInstanceName, cfg.getWorkDirectory());

            srv.setPort(port);

            srv.omitOutOfResourcesWarning(true);

            srv.start();

            boundTcpShmemPort = port;

            // Ack Port the TCP server was bound to.
            if (log.isInfoEnabled())
                log.info("Successfully bound shared memory communication to TCP port [port=" + boundTcpShmemPort +
                    ", locHost=" + locHost + ']');

            return srv;
        }
        catch (IgniteCheckedException e) {
            lastEx = e;

            if (log.isDebugEnabled())
                log.debug("Failed to bind to local port (will try next port within range) [port=" + port +
                    ", locHost=" + locHost + ']');
        }
    }

    // If free port wasn't found.
    throw new IgniteCheckedException("Failed to bind shared memory communication to any port within range [startPort=" +
        locPort + ", portRange=" + locPortRange + ", locHost=" + locHost + ']', lastEx);
}
 
开发者ID:apache,项目名称:ignite,代码行数:52,代码来源:TcpCommunicationSpi.java

示例12: start

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Starts this server.
 *
 * @throws IgniteCheckedException If failed.
 */
public void start() throws IgniteCheckedException {
    srvEndpoint = createEndpoint(endpointCfg, mgmt);

    if (U.isWindows() && srvEndpoint instanceof IpcSharedMemoryServerEndpoint)
        throw new IgniteCheckedException(IpcSharedMemoryServerEndpoint.class.getSimpleName() +
            " should not be configured on Windows (configure " +
            IpcServerTcpEndpoint.class.getSimpleName() + ")");

    if (srvEndpoint instanceof IpcServerTcpEndpoint) {
        IpcServerTcpEndpoint srvEndpoint0 = (IpcServerTcpEndpoint)srvEndpoint;

        srvEndpoint0.setManagement(mgmt);

        if (srvEndpoint0.getHost() == null) {
            if (mgmt) {
                String locHostName = igfsCtx.kernalContext().config().getLocalHost();

                try {
                    srvEndpoint0.setHost(U.resolveLocalHost(locHostName).getHostAddress());
                }
                catch (IOException e) {
                    throw new IgniteCheckedException("Failed to resolve local host: " + locHostName, e);
                }
            }
            else
                // Bind non-management endpoint to 127.0.0.1 by default.
                srvEndpoint0.setHost("127.0.0.1");
        }
    }

    igfsCtx.kernalContext().resource().injectGeneric(srvEndpoint);

    srvEndpoint.start();

    // IpcServerEndpoint.getPort contract states return -1 if there is no port to be registered.
    if (srvEndpoint.getPort() >= 0)
        igfsCtx.kernalContext().ports().registerPort(srvEndpoint.getPort(), TCP, srvEndpoint.getClass());

    hnd = new IgfsIpcHandler(igfsCtx, endpointCfg, mgmt);

    // Start client accept worker.
    acceptWorker = new AcceptWorker();
}
 
开发者ID:apache,项目名称:ignite,代码行数:49,代码来源:IgfsServer.java

示例13: 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

示例14: propertiesSupported

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected boolean propertiesSupported() {
    return !U.isWindows() && PROPERTIES_SUPPORT;
}
 
开发者ID:apache,项目名称:ignite,代码行数:5,代码来源:IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java

示例15: permissionsSupported

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected boolean permissionsSupported() {
    return !U.isWindows();
}
 
开发者ID:apache,项目名称:ignite,代码行数:5,代码来源:IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java


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