/** * Checks if address can be reached using one argument InetAddress.isReachable() version or ping command if failed. * * @param addr Address to check. * @param reachTimeout Timeout for the check. * @return {@code True} if address is reachable. */ public static boolean reachableByPing(InetAddress addr, int reachTimeout) { try { if (addr.isReachable(reachTimeout)) return true; String cmd = String.format("ping -%s 1 %s", U.isWindows() ? "n" : "c", addr.getHostAddress()); Process myProcess = Runtime.getRuntime().exec(cmd); myProcess.waitFor(); return myProcess.exitValue() == 0; } catch (IOException ignore) { return false; } catch (InterruptedException ignored) { Thread.currentThread().interrupt(); return false; } }
if (!U.isWindows()) Runtime.getRuntime().exec(new String[] {"chmod", "775", target.getCanonicalPath()}).waitFor();
/** * 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(); assert killProc.exitValue() == 0 : "Process killing was not successful"; if (procKilledC != null) procKilledC.apply(); U.interrupt(osGrabber); U.interrupt(esGrabber); U.join(osGrabber, log); U.join(esGrabber, log); }
@Nullable GridInClosure<String> printC, @Nullable GridAbsClosure procKilledC, @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception { if (!(U.isLinux() || U.isMacOs() || U.isWindows())) throw new Exception("Your OS is not supported.");
if (U.isWindows()) commands = F.asArray("cmd", "/c", String.format("start %s", cmd));
/** {@inheritDoc} */ @Override protected void start0() throws GridException { GridGgfsConfiguration ggfsCfg = ggfsCtx.configuration(); Map<String,String> cfg = ggfsCfg.getIpcEndpointConfiguration(); if (F.isEmpty(cfg)) { // Set default configuration. cfg = new HashMap<>(); cfg.put("type", U.isWindows() ? "tcp" : "shmem"); cfg.put("port", String.valueOf(DFLT_IPC_PORT)); } if (ggfsCfg.isIpcEndpointEnabled()) bind(cfg, /*management*/false); if (ggfsCfg.getManagementPort() >= 0) { cfg = new HashMap<>(); cfg.put("type", "tcp"); cfg.put("port", String.valueOf(ggfsCfg.getManagementPort())); bind(cfg, /*management*/true); } if (bindWorker != null) new GridThread(bindWorker).start(); }
/** {@inheritDoc} */ @Override protected void start0() throws GridException { GridGgfsConfiguration ggfsCfg = ggfsCtx.configuration(); Map<String,String> cfg = ggfsCfg.getIpcEndpointConfiguration(); if (F.isEmpty(cfg)) { // Set default configuration. cfg = new HashMap<>(); cfg.put("type", U.isWindows() ? "tcp" : "shmem"); cfg.put("port", String.valueOf(DFLT_IPC_PORT)); } if (ggfsCfg.isIpcEndpointEnabled()) bind(cfg, /*management*/false); if (ggfsCfg.getManagementPort() >= 0) { cfg = new HashMap<>(); cfg.put("type", "tcp"); cfg.put("port", String.valueOf(ggfsCfg.getManagementPort())); bind(cfg, /*management*/true); } if (bindWorker != null) new GridThread(bindWorker).start(); }
if (!U.isWindows()) throw e;
throw new GridException("Shared memory server was already created on port " + boundTcpShmemPort); if (shmemPort == -1 || U.isWindows()) return null;
srvEndpoint = GridIpcServerEndpointDeserializer.deserialize(endpointCfg); if (U.isWindows() && srvEndpoint instanceof GridIpcSharedMemoryServerEndpoint) throw new GridException(GridIpcSharedMemoryServerEndpoint.class.getSimpleName() + " should not be configured on Windows (configure " +
srvEndpoint = GridIpcServerEndpointDeserializer.deserialize(endpointCfg); if (U.isWindows() && srvEndpoint instanceof GridIpcSharedMemoryServerEndpoint) throw new GridException(GridIpcSharedMemoryServerEndpoint.class.getSimpleName() + " should not be configured on Windows (configure " +