private boolean poke(final int port) { try (Socket ignored = new Socket(DOCKER_HOST.address(), port)) { return true; } catch (IOException e) { return false; } } }
private boolean poke(final int port) { try (Socket ignored = new Socket(DOCKER_HOST.address(), port)) { return true; } catch (IOException e) { return false; } } }
@Override public byte[] call() { try (final Socket s = new Socket(DOCKER_HOST.address(), port)) { final byte[] bytes = new byte[numBytes]; final InputStream is = s.getInputStream(); final int first = is.read(); // Check if the uml kernel slirp driver did an accept->close on us, // i.e. the actual listener is not up yet if (first == -1) { return null; } bytes[0] = (byte) first; for (int i = 1; i < numBytes; i++) { bytes[i] = (byte) is.read(); } return bytes; } catch (IOException e) { return null; } } });
@Override public byte[] call() { try (final Socket s = new Socket(DOCKER_HOST.address(), port)) { final byte[] bytes = new byte[numBytes]; final InputStream is = s.getInputStream(); final int first = is.read(); // Check if the uml kernel slirp driver did an accept->close on us, // i.e. the actual listener is not up yet if (first == -1) { return null; } bytes[0] = (byte) first; for (int i = 1; i < numBytes; i++) { bytes[i] = (byte) is.read(); } return bytes; } catch (IOException e) { return null; } } });
@Override public boolean check(final String containerId) throws InterruptedException, DockerException { final Integer port = taskConfig.ports().get(healthCheck.getPort()).getExternalPort(); InetSocketAddress address = new InetSocketAddress(dockerHost.address(), port); if (address.getAddress().isLoopbackAddress()) { // tcp connections to a container-mapped port on loopback always succeed, // regardless of if the container is listening or not. use the bridge address instead. address = new InetSocketAddress(getBridgeAddress(containerId), port); } log.info("about to tcp healthcheck containerId={} with address={} for task={}", containerId, address, taskConfig); try (final Socket s = new Socket()) { s.connect(address, CONNECT_TIMEOUT_MILLIS); } catch (Exception e) { log.warn("tcp healthcheck failed for containerId={} due to exception={}", containerId, e.toString()); return false; } return true; } }
log.info("Using bridge address {} for healthchecks", host); } else { host = dockerHost.address();