private Set<String> validateJobHealthCheck(final Job job) {
    final HealthCheck healthCheck = job.getHealthCheck();

    if (healthCheck == null) {
      return emptySet();
    }

    final Set<String> errors = Sets.newHashSet();

    if (healthCheck instanceof ExecHealthCheck) {
      final List<String> command = ((ExecHealthCheck) healthCheck).getCommand();
      if (command == null || command.isEmpty()) {
        errors.add("A command must be defined for `docker exec`-based health checks.");
      }
    } else if (healthCheck instanceof HttpHealthCheck || healthCheck instanceof TcpHealthCheck) {
      final String port;
      if (healthCheck instanceof HttpHealthCheck) {
        port = ((HttpHealthCheck) healthCheck).getPort();
      } else {
        port = ((TcpHealthCheck) healthCheck).getPort();
      }

      final Map<String, PortMapping> ports = job.getPorts();
      if (isNullOrEmpty(port)) {
        errors.add("A port must be defined for HTTP and TCP health checks.");
      } else if (!ports.containsKey(port)) {
        errors.add(format("Health check port '%s' not defined in the job. Known ports are '%s'",
            port, Joiner.on(", ").join(ports.keySet())));
      }
    }

    return errors;
  }
private Set < String > validateJobHealthCheck ( final Job job ) { final HealthCheck healthCheck = job . getHealthCheck ( ) ; if ( healthCheck == null ) { return emptySet ( ) ; } final Set < String > errors = Sets . newHashSet ( ) ; if ( healthCheck instanceof ExecHealthCheck ) { final List < String > command = ( ( ExecHealthCheck ) healthCheck ) . getCommand ( ) ; if ( command == null || command . isEmpty ( ) ) { errors . add ( "A command must be defined for `docker exec`-based health checks." ) ; } } else if ( healthCheck instanceof HttpHealthCheck || healthCheck instanceof TcpHealthCheck ) { final String port ; if ( healthCheck instanceof HttpHealthCheck ) { port = ( ( HttpHealthCheck ) healthCheck ) . getPort ( ) ; } else { port = ( ( TcpHealthCheck ) healthCheck ) . getPort ( ) ; } final Map < String , PortMapping > ports = job . getPorts ( ) ; if ( isNullOrEmpty ( port ) ) { errors . add ( "A port must be defined for HTTP and TCP health checks." ) ; } else if ( ! ports . containsKey ( port ) ) { errors . add ( format ( "Health check port '%s' not defined in the job. Known ports are '%s'" , port , Joiner . on ( ", " ) . join ( ports . keySet ( ) ) ) ) ; } } return errors ; }
Validate the Job's health check.

@param job The Job to check.

@return A set of error Strings