@Override public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) { RegCheck regCheck = null; try { /** * Deal with health check tcp */ String healthCheckTcp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP); if (healthCheckTcp != null && !healthCheckTcp.trim().isEmpty()) { healthCheckTcp = healthCheckTcp.replaceAll(TCP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress()) .replaceAll(TCP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort())); Long healthCheckTcpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP_INTERVAL_SECONDS)); regCheck = Registration.RegCheck.tcp(healthCheckTcp, healthCheckTcpIntervalSeconds); } } catch(Exception e) { logger.severe("Unexpected error occured trying to build TCP health check : " + e.getMessage(), e); } return regCheck; }
@Override public RegCheck buildRegistrationCheck(Map<String, Object> registratorConfig, Address localAddress) { RegCheck regCheck = null; try { /** * Deal with health check tcp */ String healthCheckTcp = (String)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP); if (healthCheckTcp != null && !healthCheckTcp.trim().isEmpty()) { healthCheckTcp = healthCheckTcp.replaceAll(TCP_TEMPLATE_MYIP, localAddress.getInetAddress().getHostAddress()) .replaceAll(TCP_TEMPLATE_MYPORT, String.valueOf(localAddress.getPort())); Long healthCheckTcpIntervalSeconds = Long.valueOf((Integer)registratorConfig.get(CONFIG_PROP_HEALTH_CHECK_TCP_INTERVAL_SECONDS)); regCheck = Registration.RegCheck.tcp(healthCheckTcp, healthCheckTcpIntervalSeconds); } } catch(Exception e) { logger.severe("Unexpected error occured trying to build TCP health check : " + e.getMessage(), e); } return regCheck; }
/** * Registers the client as a service with Consul with a TCP based check * * @param port The public facing port of the service to register with Consul. * @param tcp Health check TCP host and port. * @param interval Health script run interval in seconds. * @param name Service name to register. * @param id Service id to register. * @param tags Tags to register with. * @param meta Meta to register with. */ public void register(int port, HostAndPort tcp, long interval, String name, String id, List<String> tags, Map<String, String> meta) { Registration.RegCheck check = Registration.RegCheck.tcp(tcp.toString(), interval); register(port, check, name, id, tags, meta); }