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

The following examples show how to use org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties. These examples are extracted from open source projects. 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
@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
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 3
public ZookeeperStubsRegistrar(StubRunning stubRunning,
		CuratorFramework curatorFramework, StubMapperProperties stubMapperProperties,
		ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	this.stubRunning = stubRunning;
	this.curatorFramework = curatorFramework;
	this.stubMapperProperties = stubMapperProperties;
	this.zookeeperDiscoveryProperties = zookeeperDiscoveryProperties;
}
 
Example 4
@Bean(initMethod = "registerStubs")
public StubsRegistrar stubsRegistrar(StubRunning stubRunning,
		CuratorFramework curatorFramework, StubMapperProperties stubMapperProperties,
		ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	return new ZookeeperStubsRegistrar(stubRunning, curatorFramework,
			stubMapperProperties, zookeeperDiscoveryProperties);
}
 
Example 5
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 6
@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 7
@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 8
@Bean
@ConditionalOnMissingBean(ServiceDiscoveryCustomizer.class)
public DefaultServiceDiscoveryCustomizer defaultServiceDiscoveryCustomizer(
		CuratorFramework curator, ZookeeperDiscoveryProperties properties,
		InstanceSerializer<ZookeeperInstance> serializer) {
	return new DefaultServiceDiscoveryCustomizer(curator, properties, serializer);
}
 
Example 9
public DefaultServiceDiscoveryCustomizer(CuratorFramework curator,
		ZookeeperDiscoveryProperties properties,
		InstanceSerializer<ZookeeperInstance> instanceSerializer) {
	this.curator = curator;
	this.properties = properties;
	this.instanceSerializer = instanceSerializer;
}
 
Example 10
@Test
public void offByDefault() {
	this.context = new AnnotationConfigApplicationContext(
			ZookeeperConfigServerAutoConfiguration.class);
	assertThat(this.context
			.getBeanNamesForType(ZookeeperDiscoveryProperties.class).length)
			.isEqualTo(0);
}
 
Example 11
@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 12
private void setup(String... env) {
	this.context = new SpringApplicationBuilder(
			PropertyPlaceholderAutoConfiguration.class,
			ZookeeperConfigServerAutoConfiguration.class,
			ConfigServerProperties.class, ZookeeperDiscoveryProperties.class)
					.web(WebApplicationType.NONE).properties(env).run();
}
 
Example 13
@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 14
Source Project: Moss   Source File: ZooKeeperAutoRegistrationCustomizer.java    License: Apache License 2.0 4 votes vote down vote up
public ZooKeeperAutoRegistrationCustomizer(CuratorFramework curator, ZookeeperDiscoveryProperties properties, InstanceSerializer<ZookeeperInstance> serializer) {
    super(curator, properties, serializer);
}
 
Example 15
Source Project: Moss   Source File: ZooKeeperClientAutoConfiguartion.java    License: 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 16
Source Project: Moss   Source File: ZooKeeperAutoRegistrationCustomizer.java    License: Apache License 2.0 4 votes vote down vote up
public ZooKeeperAutoRegistrationCustomizer(CuratorFramework curator, ZookeeperDiscoveryProperties properties, InstanceSerializer<ZookeeperInstance> serializer) {
    super(curator, properties, serializer);
}
 
Example 17
Source Project: Moss   Source File: ZooKeeperClientAutoConfiguartion.java    License: 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 18
public ZookeeperAutoServiceRegistration(ZookeeperServiceRegistry registry,
		ZookeeperRegistration registration, ZookeeperDiscoveryProperties properties) {
	this(registry, registration, properties, null);
}
 
Example 19
@Bean
public ZookeeperAutoServiceRegistration zookeeperAutoServiceRegistration(
		ZookeeperServiceRegistry registry, ZookeeperRegistration registration,
		ZookeeperDiscoveryProperties properties) {
	return new ZookeeperAutoServiceRegistration(registry, registration, properties);
}
 
Example 20
@Bean
@ConditionalOnMissingBean
public ZookeeperDiscoveryProperties zookeeperDiscoveryProperties(
		InetUtils inetUtils) {
	return new ZookeeperDiscoveryProperties(inetUtils);
}
 
Example 21
public ZookeeperReactiveDiscoveryClient(ServiceDiscovery<ZookeeperInstance> serviceDiscovery,
		ZookeeperDependencies zookeeperDependencies, ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	this.serviceDiscovery = serviceDiscovery;
	this.zookeeperDependencies = zookeeperDependencies;
	this.zookeeperDiscoveryProperties = zookeeperDiscoveryProperties;
}
 
Example 22
@Bean
@ConditionalOnMissingBean
public ZookeeperReactiveDiscoveryClient zookeeperReactiveDiscoveryClient(ServiceDiscovery<ZookeeperInstance> serviceDiscovery,
		ZookeeperDiscoveryProperties zookeeperDiscoveryProperties) {
	return new ZookeeperReactiveDiscoveryClient(serviceDiscovery, zookeeperDependencies, zookeeperDiscoveryProperties);
}