Java Code Examples for com.ecwid.consul.v1.agent.model.NewService#getPort()

The following examples show how to use com.ecwid.consul.v1.agent.model.NewService#getPort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceDefinitionToConsulRegistration.java    From camel-spring-boot with Apache License 2.0 7 votes vote down vote up
@Override
public ConsulRegistration convert(ServiceDefinition source) {
    NewService service = new NewService();
    service.setName(source.getName());
    service.setId(source.getId());
    service.setAddress(properties.getServiceRegistry().getServiceHost());
    service.setPort(source.getPort());

    service.setTags(
        source.getMetadata().entrySet().stream()
            .map(e -> e.getKey() + "=" + e.getValue())
            .collect(Collectors.toList())
    );

    return new ConsulRegistration(service, null) {
        @Override
        public boolean isSecure() {
            return service.getPort() == 443 || Objects.equals("https", source.getMetadata().get(ServiceDefinition.SERVICE_META_PROTOCOL));
        }
    };
}
 
Example 2
Source File: ConsulAutoRegistration.java    From spring-cloud-consul with Apache License 2.0 7 votes vote down vote up
public static void setCheck(NewService service,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext context,
		HeartbeatProperties heartbeatProperties) {
	if (properties.isRegisterHealthCheck() && service.getCheck() == null) {
		Integer checkPort;
		if (shouldRegisterManagement(autoServiceRegistrationProperties, properties,
				context)) {
			checkPort = getManagementPort(properties, context);
		}
		else {
			checkPort = service.getPort();
		}
		Assert.notNull(checkPort, "checkPort may not be null");
		service.setCheck(createCheck(checkPort, heartbeatProperties, properties));
	}
}
 
Example 3
Source File: DubboServiceRegistrationNonWebApplicationAutoConfiguration.java    From spring-cloud-alibaba with Apache License 2.0 6 votes vote down vote up
/**
 * Set port on Non-Web Application.
 * @param consulRegistration {@link ConsulRegistration}
 */
private void setPort(ConsulAutoRegistration consulRegistration) {
	int port = consulRegistration.getPort();
	NewService newService = consulRegistration.getService();
	if (newService.getPort() == null) {
		newService.setPort(port);
	}
}