Checks if VM is running.
@param hostIpPort
@param id
@return
@throws TargetException
8522
public static boolean isVMRunning(String hostIpPort, String id)
	throws TargetException {
		boolean result = false;
		String ip = OcciVMUtils.getVMIP(hostIpPort, id);
		try {
			InetAddress inet = InetAddress.getByName(ip);
			result = inet.isReachable(5000);

		} catch (Exception e) {
			result = false;
			final Logger logger = Logger.getLogger( OcciVMUtils.class.getName());
			logger.info(e.getMessage());
		}

		return result;
	}
596195
private static boolean isAvailable(int thePort) {
		ourLog.info("Testing a bind on thePort {}", thePort);
		try (ServerSocket ss = new ServerSocket()) {
			ss.setReuseAddress(true);
			ss.bind(new InetSocketAddress("0.0.0.0", thePort));
			try (DatagramSocket ds = new DatagramSocket()) {
				ds.setReuseAddress(true);
				ds.connect(new InetSocketAddress("127.0.0.1", thePort));
				ourLog.info("Successfully bound thePort {}", thePort);
			} catch (IOException e) {
				ourLog.info("Failed to bind thePort {}: {}", thePort, e.toString());
				return false;
			}
		} catch (IOException e) {
			ourLog.info("Failed to bind thePort {}: {}", thePort, e.toString());
			return false;
		}

		try (ServerSocket ss = new ServerSocket()) {
			ss.setReuseAddress(true);
			ss.bind(new InetSocketAddress("localhost", thePort));
		} catch (IOException e) {
			ourLog.info("Failed to bind thePort {}: {}", thePort, e.toString());
			return false;
		}

		return true;
	}
157729
@Override
	public boolean connect(HostPort hostPort, IAgentCommand[] startupCommandAry ) throws ConnectionTimeout, ConnectionException {
		boolean ynRC = false;
		setHostPort( hostPort );
		List<String> errors = getHostPort().validate();
		
		if (errors.size()>0) { 
			ConnectionException e = new ConnectionException(getHostPort(), errors.toString() ); 
			throw e;
		} else {
	        HumanReadableMessages msgs = DefaultFactory.getFactory().getMessages();
	        long lngTimeoutMs = DefaultFactory.getFactory().getConfig().getConnectWaitMs();
			setCommandArray(startupCommandAry);
		
	        ExecutorService executor = Executors.newSingleThreadExecutor();
	        Future<Boolean> future = executor.submit(new Task());
	        try {
	            getMasterCallback().setConnectionStatusMsg(msgs.getAttemptingToConnect( getHostPort()) );
	            getMasterCallback().setConnectState(ConnectState.CONNECTING);

	            Boolean ynTaskRC = future.get(lngTimeoutMs, TimeUnit.MILLISECONDS); 
	            if (ynTaskRC.equals(Boolean.TRUE)) {
	        		NetworkDataReceiverThread2 ntt2 = getConnectionDetail().getNetworkTraceThread2();
	        		ntt2.addTraceWriter(m_traceWriter);
	        		ynRC = true;
	            }
	        } catch (TimeoutException e) {
	            getMasterCallback().setConnectionStatusMsg( e.toString() ); 
	            getMasterCallback().setConnectState(ConnectState.DISCONNECTED_ERR);
	        } catch (InterruptedException e) {
	            getMasterCallback().setConnectionStatusMsg( e.toString() ); 
	            getMasterCallback().setConnectState(ConnectState.DISCONNECTED_ERR);
			} catch (ExecutionException e) {
	            getMasterCallback().setConnectionStatusMsg( e.toString() ); 
	            getMasterCallback().setConnectState(ConnectState.DISCONNECTED_ERR);
			} finally {
		        executor.shutdownNow();
			}
		}
        return ynRC;
	}
781188
public static InetSocketAddress createSocketAddr(String target,
      int defaultPort) {
    // Format [IPv6 Address]:Port
    int colonIndex = target.indexOf(':');
    if (colonIndex < 0 && defaultPort == -1) {
      throw new RuntimeException("Not a host:port pair: " + target);
    }
    String hostname;
    int port = -1;
    if (!target.contains("/")) {
      target = "hdfs://" + target;
    }
    // a new uri
    URI addr = new Path(target).toUri();
    hostname = addr.getHost();
    port = addr.getPort();
    

    if (port == -1) {
      port = defaultPort;
    }

    if (getStaticResolution(hostname) != null) {
      hostname = getStaticResolution(hostname);
    }

    return InetSocketAddressFactory.createWithResolveRetry(hostname, port);
  }
391470
public static function isPortInUse($port, $hostname = null)
    {
        $fp = @fsockopen($hostname !== null ? $hostname : '127.0.0.1', $port, $errno, $errstr, 10);
        if ($fp !== false) {
            fclose($fp);

            return true;
        }

        return false;
    }
346799
public static boolean isServiceExported(Configuration configuration, int port, String serviceName) {
        if (serviceName == null)
            return false;
        try {
            final Registry registry = RegistryFinder.getInstance().getRegistry(configuration, port);
            String[] list = registry.list();

            if (list != null) {
                for (int i = 0; i < list.length; i++) {
                    if (serviceName.equals(list[i]))
                        return true;
                }
            }
        } catch (RemoteException ex) {
            return false;
        } catch (Exception e) {
            return false;
        }
        return false;
    }
317013
private boolean checkIfHostHasChanged(EventChannelStruct event_channel_struct) {
        boolean retVal = false;
        try {
            IORdump dump = new IORdump(event_channel_struct.adm_device_proxy);
            String server_host = dump.get_hostname();

            //	Keep server_host name without Fully Qualify Domain Name
            int idx = server_host.indexOf('.');
            if (idx > 0)
                server_host = server_host.substring(0, idx);

            if (!event_channel_struct.host.equals(server_host))
                retVal = true;
        } catch (DevFailed e) { /* */ }
        return retVal;
    }
1110957
public boolean checkIfChanged(Collection<Host> hostsUp, Collection<Host> hostsDown) {
		boolean changed = activeSetChanged(hostsUp) || inactiveSetChanged(hostsUp, hostsDown);

		if (changed && logger.isDebugEnabled()) {
			Set<Host> changedHostsUp = new HashSet<>(hostsUp);
			changedHostsUp.removeAll(activeHosts);
			changedHostsUp.forEach(x -> logger.debug("New host up: {}", x.getHostAddress()));

			Set<Host> changedHostsDown = new HashSet<>(hostsDown);
			changedHostsDown.removeAll(inactiveHosts);
			changedHostsDown.forEach(x -> logger.debug("New host down: {}", x.getHostAddress()));
		}
		return changed;
	}
1342929
@SuppressWarnings("deprecation")
    public boolean cancelOnTargetHosts(List<String> targetHosts) {

        boolean success = false;

        try {

            switch (state) {

            case IN_PROGRESS:
                if (executionManager != null
                        && !executionManager.isTerminated()) {
                    executionManager.tell(new CancelTaskOnHostRequest(
                            targetHosts), executionManager);
                    logger.info(
                            "asked task to stop from running on target hosts with count {}...",
                            targetHosts.size());
                } else {
                    logger.info("manager already killed or not exist.. NO OP");
                }
                success = true;
                break;
            case COMPLETED_WITHOUT_ERROR:
            case COMPLETED_WITH_ERROR:
            case WAITING:
                logger.info("will NO OP for cancelOnTargetHost as it is not in IN_PROGRESS state");
                success = true;
                break;
            default:
                break;

            }

        } catch (Exception e) {
            logger.error(
                    "cancel task {} on hosts with count {} error with exception details ",
                    this.getTaskId(), targetHosts.size(), e);
        }

        return success;
    }
484184
def report_usage_to_host(host_ip, vmid):
	
	#base value
	cpu_usage = 0.0
	os_mem_usage = 0.0
	task_mem_usage = 0.0
	io_usage = 0.0

	cpu_usage = get_cpu_usage()
	os_mem_usage = get_os_mem_usage()
	task_mem_usage = get_task_mem_usage()
	io_usage = get_io_usage()

	usage = str(vmid.strip())+' | '+str(cpu_usage)+' | '+str(os_mem_usage)+' | '+str(task_mem_usage)+' | '+str(io_usage)
	#usage = "'cpu |sdbfsj |sdfsdhf |sdfvsdvfgdfvj'"
	#cmd = 'python /var/lib/virtdc/vmonere/host/vmonere_listener.py '+usage
	

	''''''

	#report usage via socket
	start_client_socket(host_ip, usage)
892620
def check_transport_host(self):
        
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        result = sock.connect_ex(('events-server', 8080))
        if result == 0:
            logging.info('port 8080 on zmq is open!')
            return True
        return False
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}
764607
def is_server_running(host, port):
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        return s.connect_ex((host, port)) == 0
    finally:
        s.close()
901564
public static boolean isPortAvailable(int port) {
		try {
			ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(port, 1,
					InetAddress.getByName("localhost"));
			serverSocket.close();
			return true;
		} catch (Exception ex) { // NOSONAR
			return false;
		}
	}
1186034
@Trivial
    public static boolean validLocalHostName(String hostName) {
        InetAddress addr = findLocalHostAddress(hostName, PREFER_IPV6);
        return addr != null;
    }
653068
public static InetSocketAddress createSocketAddr(String target, int defaultPort) {
		int colonIndex = target.indexOf(':');
		if (colonIndex < 0 && defaultPort == -1) {
			throw new RuntimeException("Not a host:port pair: " + target);
		}
		String hostname = "";
		int port = -1;
		if (!target.contains("/")) {
			if (colonIndex == -1) {
				hostname = target;
			} else {
				// must be the old style <host>:<port>
				hostname = target.substring(0, colonIndex);
				port = Integer.parseInt(target.substring(colonIndex + 1));
			}
		} else {
			// a new uri
			try {
				URI addr = new URI(target);
				hostname = addr.getHost();
				port = addr.getPort();
			} catch (URISyntaxException use) {
				LOG.fatal(use);
			}
		}

		if (port == -1) {
			port = defaultPort;
		}

		if (getStaticResolution(hostname) != null) {
			hostname = getStaticResolution(hostname);
		}
		return new InetSocketAddress(hostname, port);
	}
518957
private static boolean isPortOpen(InetAddress pAddress, int pPort) {
        Socket socket = null;
        try {
            socket = new Socket();
            socket.setReuseAddress(true);
            SocketAddress sa = new InetSocketAddress(pAddress, pPort);
            socket.connect(sa, 200);
            return socket.isConnected();
        } catch (IOException e) {
            return false;
        } finally {
            if (socket != null) {
                try {
                    socket.close();
                } catch (IOException e) {
                    // Best effort. Hate that close throws an IOException, btw. Never saw a real use case for that.
                }
            }
        }
    }