org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties Java Examples

The following examples show how to use org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties. 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: ServiceDefinitionToZookeeperRegistration.java    From camel-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
public ZookeeperRegistration convert(ServiceDefinition source) {
    ZookeeperInstance instance = new ZookeeperInstance(
        source.getId(),
        source.getName(),
        source.getMetadata()
    );

    return ServiceInstanceRegistration.builder()
        .address(properties.getServiceRegistry().getServiceHost())
        .port(source.getPort())
        .name(source.getName())
        .payload(instance)
        .uriSpec(ZookeeperDiscoveryProperties.DEFAULT_URI_SPEC)
        .build();
}
 
Example #2
Source File: ZookeeperAutoServiceRegistrationAutoConfiguration.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ZookeeperRegistration.class)
public ServiceInstanceRegistration serviceInstanceRegistration(
		ApplicationContext context, ZookeeperDiscoveryProperties properties) {
	String appName = context.getEnvironment().getProperty("spring.application.name",
			"application");
	String host = properties.getInstanceHost();
	if (!StringUtils.hasText(host)) {
		throw new IllegalStateException("instanceHost must not be empty");
	}

	ZookeeperInstance zookeeperInstance = new ZookeeperInstance(context.getId(),
			appName, properties.getMetadata());
	RegistrationBuilder builder = ServiceInstanceRegistration.builder().address(host)
			.name(appName).payload(zookeeperInstance)
			.uriSpec(properties.getUriSpec());

	if (properties.getInstanceSslPort() != null) {
		builder.sslPort(properties.getInstanceSslPort());
	}
	if (properties.getInstanceId() != null) {
		builder.id(properties.getInstanceId());
	}

	// TODO add customizer?

	return builder.build();
}
 
Example #3
Source File: DiscoveryClientConfigServiceAutoConfigurationTests.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
@Bean
public ZookeeperDiscoveryClient zookeeperDiscoveryClient(
		ZookeeperDiscoveryProperties properties) {
	ZookeeperDiscoveryClient client = mock(ZookeeperDiscoveryClient.class);
	ServiceInstance instance = new DefaultServiceInstance("configserver1",
			"configserver", properties.getInstanceHost(),
			properties.getInstancePort(), false);
	given(client.getInstances("configserver"))
			.willReturn(Arrays.asList(instance));
	return client;
}
 
Example #4
Source File: ZookeeperConfigServerAutoConfigurationTests.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
private void setup(String... env) {
	this.context = new SpringApplicationBuilder(
			PropertyPlaceholderAutoConfiguration.class,
			ZookeeperConfigServerAutoConfiguration.class,
			ConfigServerProperties.class, ZookeeperDiscoveryProperties.class)
					.web(WebApplicationType.NONE).properties(env).run();
}
 
Example #5
Source File: ZookeeperConfigServerAutoConfigurationTests.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
@Test
public void onWhenRequested() {
	setup("spring.cloud.config.server.prefix=/config");
	assertThat(this.context
			.getBeanNamesForType(ZookeeperDiscoveryProperties.class).length)
			.isEqualTo(1);
	ZookeeperDiscoveryProperties properties = this.context
			.getBean(ZookeeperDiscoveryProperties.class);
	assertThat(properties.getMetadata()).containsEntry("configPath", "/config");
}
 
Example #6
Source File: ZookeeperConfigServerAutoConfigurationTests.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
@Test
public void offByDefault() {
	this.context = new AnnotationConfigApplicationContext(
			ZookeeperConfigServerAutoConfiguration.class);
	assertThat(this.context
			.getBeanNamesForType(ZookeeperDiscoveryProperties.class).length)
			.isEqualTo(0);
}
 
Example #7
Source File: DefaultServiceDiscoveryCustomizer.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
public DefaultServiceDiscoveryCustomizer(CuratorFramework curator,
		ZookeeperDiscoveryProperties properties,
		InstanceSerializer<ZookeeperInstance> instanceSerializer) {
	this.curator = curator;
	this.properties = properties;
	this.instanceSerializer = instanceSerializer;
}
 
Example #8
Source File: CuratorServiceDiscoveryAutoConfiguration.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ServiceDiscoveryCustomizer.class)
public DefaultServiceDiscoveryCustomizer defaultServiceDiscoveryCustomizer(
		CuratorFramework curator, ZookeeperDiscoveryProperties properties,
		InstanceSerializer<ZookeeperInstance> serializer) {
	return new DefaultServiceDiscoveryCustomizer(curator, properties, serializer);
}
 
Example #9
Source File: ZookeeperDiscoveryClientConfigServiceBootstrapConfiguration.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
@Bean
public ZookeeperDiscoveryProperties zookeeperDiscoveryProperties(
		InetUtils inetUtils) {
	ZookeeperDiscoveryProperties properties = new ZookeeperDiscoveryProperties(
			inetUtils);
	// for bootstrap, registration is not needed, just discovery client
	properties.setRegister(false);
	return properties;
}
 
Example #10
Source File: ZookeeperAutoServiceRegistration.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
public ZookeeperAutoServiceRegistration(ZookeeperServiceRegistry registry,
		ZookeeperRegistration registration, ZookeeperDiscoveryProperties properties,
		AutoServiceRegistrationProperties arProperties) {
	super(registry, arProperties);
	this.registration = registration;
	this.properties = properties;
	if (this.properties.getInstancePort() != null) {
		this.registration.setPort(this.properties.getInstancePort());
	}
}
 
Example #11
Source File: StubRunnerSpringCloudZookeeperAutoConfiguration.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
@Bean(initMethod = "registerStubs")
public StubsRegistrar stubsRegistrar(StubRunning stubRunning,
		CuratorFramework curatorFramework, StubMapperProperties stubMapperProperties,
		ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	return new ZookeeperStubsRegistrar(stubRunning, curatorFramework,
			stubMapperProperties, zookeeperDiscoveryProperties);
}
 
Example #12
Source File: ZookeeperStubsRegistrar.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
public ZookeeperStubsRegistrar(StubRunning stubRunning,
		CuratorFramework curatorFramework, StubMapperProperties stubMapperProperties,
		ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	this.stubRunning = stubRunning;
	this.curatorFramework = curatorFramework;
	this.stubMapperProperties = stubMapperProperties;
	this.zookeeperDiscoveryProperties = zookeeperDiscoveryProperties;
}
 
Example #13
Source File: DubboServiceDiscoveryAutoConfiguration.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
ZookeeperConfiguration(ZookeeperDiscoveryProperties zookeeperDiscoveryProperties,
		ZookeeperServiceWatch zookeeperServiceWatch) {
	this.zookeeperServiceWatch = zookeeperServiceWatch;
	this.rootPath = zookeeperDiscoveryProperties.getRoot();
	this.pathMatcher = new AntPathMatcher(NODE_PATH_SEPARATOR);
	this.serviceInstancePathPattern = rootPath + NODE_PATH_SEPARATOR + "{"
			+ SERVICE_NAME_PATH_VARIABLE_NAME + "}" + NODE_PATH_SEPARATOR + "{"
			+ SERVICE_INSTANCE_ID_PATH_VARIABLE_NAME + "}";
	this.processedServiceNameThreadLocal = new ThreadLocal<>();
}
 
Example #14
Source File: ZookeeperAutoServiceRegistrationAutoConfiguration.java    From spring-cloud-zookeeper with Apache License 2.0 4 votes vote down vote up
@Bean
public ZookeeperAutoServiceRegistration zookeeperAutoServiceRegistration(
		ZookeeperServiceRegistry registry, ZookeeperRegistration registration,
		ZookeeperDiscoveryProperties properties) {
	return new ZookeeperAutoServiceRegistration(registry, registration, properties);
}
 
Example #15
Source File: ZookeeperAutoServiceRegistration.java    From spring-cloud-zookeeper with Apache License 2.0 4 votes vote down vote up
public ZookeeperAutoServiceRegistration(ZookeeperServiceRegistry registry,
		ZookeeperRegistration registration, ZookeeperDiscoveryProperties properties) {
	this(registry, registration, properties, null);
}
 
Example #16
Source File: ZookeeperServiceRegistryAutoConfiguration.java    From spring-cloud-zookeeper with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ZookeeperDiscoveryProperties zookeeperDiscoveryProperties(
		InetUtils inetUtils) {
	return new ZookeeperDiscoveryProperties(inetUtils);
}
 
Example #17
Source File: ZookeeperReactiveDiscoveryClient.java    From spring-cloud-zookeeper with Apache License 2.0 4 votes vote down vote up
public ZookeeperReactiveDiscoveryClient(ServiceDiscovery<ZookeeperInstance> serviceDiscovery,
		ZookeeperDependencies zookeeperDependencies, ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	this.serviceDiscovery = serviceDiscovery;
	this.zookeeperDependencies = zookeeperDependencies;
	this.zookeeperDiscoveryProperties = zookeeperDiscoveryProperties;
}
 
Example #18
Source File: ZookeeperReactiveDiscoveryClientConfiguration.java    From spring-cloud-zookeeper with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ZookeeperReactiveDiscoveryClient zookeeperReactiveDiscoveryClient(ServiceDiscovery<ZookeeperInstance> serviceDiscovery,
		ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	return new ZookeeperReactiveDiscoveryClient(serviceDiscovery, zookeeperDependencies, zookeeperDiscoveryProperties);
}
 
Example #19
Source File: ZooKeeperClientAutoConfiguartion.java    From Moss with Apache License 2.0 4 votes vote down vote up
@Bean
public ZooKeeperAutoRegistrationCustomizer zooKeeperAutoRegistrationCustomizer(CuratorFramework curator,
                                                                               ZookeeperDiscoveryProperties properties,
                                                                               InstanceSerializer<ZookeeperInstance> serializer) {
    return new ZooKeeperAutoRegistrationCustomizer(curator, properties, serializer);
}
 
Example #20
Source File: ZooKeeperAutoRegistrationCustomizer.java    From Moss with Apache License 2.0 4 votes vote down vote up
public ZooKeeperAutoRegistrationCustomizer(CuratorFramework curator, ZookeeperDiscoveryProperties properties, InstanceSerializer<ZookeeperInstance> serializer) {
    super(curator, properties, serializer);
}
 
Example #21
Source File: ZooKeeperClientAutoConfiguartion.java    From Moss with Apache License 2.0 4 votes vote down vote up
@Bean
public ZooKeeperAutoRegistrationCustomizer zooKeeperAutoRegistrationCustomizer(CuratorFramework curator,
                                                                               ZookeeperDiscoveryProperties properties,
                                                                               InstanceSerializer<ZookeeperInstance> serializer) {
    return new ZooKeeperAutoRegistrationCustomizer(curator, properties, serializer);
}
 
Example #22
Source File: ZooKeeperAutoRegistrationCustomizer.java    From Moss with Apache License 2.0 4 votes vote down vote up
public ZooKeeperAutoRegistrationCustomizer(CuratorFramework curator, ZookeeperDiscoveryProperties properties, InstanceSerializer<ZookeeperInstance> serializer) {
    super(curator, properties, serializer);
}