Checkstyle fixes
This commit is contained in:
@@ -47,8 +47,8 @@ import org.springframework.context.annotation.Lazy;
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry", name = { "username",
|
||||
"password" })
|
||||
@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry",
|
||||
name = { "username", "password" })
|
||||
@ConditionalOnClass(name = { "reactor.core.publisher.Flux",
|
||||
"org.cloudfoundry.operations.DefaultCloudFoundryOperations",
|
||||
"org.cloudfoundry.reactor.client.ReactorCloudFoundryClient",
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -6,6 +22,7 @@ import java.util.List;
|
||||
import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
import org.cloudfoundry.operations.applications.ApplicationDetail;
|
||||
import org.cloudfoundry.operations.applications.InstanceDetail;
|
||||
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
@@ -13,15 +30,15 @@ import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
/**
|
||||
*
|
||||
* Discovery Client implementation using Cloud Foundry's Native DNS based Service
|
||||
* Discovery
|
||||
* Discovery.
|
||||
*
|
||||
* @author Toshiaki Maki
|
||||
*
|
||||
* @see <a href="https://github.com/cloudfoundry/cf-app-sd-release">CF App Service
|
||||
* Discovery Release</a>
|
||||
* @see <a href=
|
||||
* "https://www.cloudfoundry.org/blog/polyglot-service-discovery-container-networking-cloud-foundry/">Polyglot
|
||||
* Service Discovery for Container Networking in Cloud Foundry</a>
|
||||
*
|
||||
* @author Toshiaki Maki
|
||||
*/
|
||||
public class CloudFoundryAppServiceDiscoveryClient extends CloudFoundryDiscoveryClient {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -38,12 +39,19 @@ import org.springframework.context.annotation.Configuration;
|
||||
@EnableConfigurationProperties(CloudFoundryDiscoveryProperties.class)
|
||||
public class CloudFoundryDiscoveryClientConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(CloudFoundryDiscoveryClient.class)
|
||||
public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender(
|
||||
CloudFoundryDiscoveryClient client) {
|
||||
return new CloudFoundryHeartbeatSender(client);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "spring.cloud.cloudfoundry.discovery.use-dns", havingValue = "false", matchIfMissing = true)
|
||||
public static class CloudFoundryDiscoveryClientConfig {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(DiscoveryClient.class)
|
||||
public DiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf,
|
||||
public CloudFoundryDiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf,
|
||||
CloudFoundryService svc,
|
||||
CloudFoundryDiscoveryProperties cloudFoundryDiscoveryProperties) {
|
||||
return new CloudFoundryDiscoveryClient(cf, svc,
|
||||
@@ -58,7 +66,7 @@ public class CloudFoundryDiscoveryClientConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.cloudfoundry.discovery.use-container-ip", havingValue = "true")
|
||||
@ConditionalOnMissingBean(DiscoveryClient.class)
|
||||
public DiscoveryClient discoveryClient(
|
||||
public SimpleDnsBasedDiscoveryClient discoveryClient(
|
||||
ObjectProvider<ServiceIdToHostnameConverter> provider) {
|
||||
ServiceIdToHostnameConverter converter = provider.getIfAvailable();
|
||||
return converter == null ? new SimpleDnsBasedDiscoveryClient()
|
||||
@@ -68,7 +76,7 @@ public class CloudFoundryDiscoveryClientConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.cloudfoundry.discovery.use-container-ip", havingValue = "false", matchIfMissing = true)
|
||||
@ConditionalOnMissingBean(DiscoveryClient.class)
|
||||
public DiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf,
|
||||
public CloudFoundryAppServiceDiscoveryClient cloudFoundryDiscoveryClient(CloudFoundryOperations cf,
|
||||
CloudFoundryService svc,
|
||||
CloudFoundryDiscoveryProperties cloudFoundryDiscoveryProperties) {
|
||||
return new CloudFoundryAppServiceDiscoveryClient(cf, svc,
|
||||
@@ -76,11 +84,4 @@ public class CloudFoundryDiscoveryClientConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(CloudFoundryDiscoveryClient.class)
|
||||
public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender(
|
||||
CloudFoundryDiscoveryClient client) {
|
||||
return new CloudFoundryHeartbeatSender(client);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
@@ -9,19 +24,20 @@ import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
|
||||
/**
|
||||
* Discovery Client implementation using Cloud Foundry's Native DNS based Service
|
||||
* Discovery
|
||||
* Discovery.
|
||||
*
|
||||
* @author Toshiaki Maki
|
||||
*
|
||||
* @see <a href=
|
||||
* "https://www.cloudfoundry.org/blog/polyglot-service-discovery-container-networking-cloud-foundry/">Polyglot
|
||||
* Service Discovery for Container Networking in Cloud Foundry</a>
|
||||
*
|
||||
* @author Toshiaki Maki
|
||||
*/
|
||||
public class SimpleDnsBasedDiscoveryClient implements DiscoveryClient {
|
||||
public static final String INTERNAL_DOMAIN = "apps.internal";
|
||||
@@ -77,4 +93,4 @@ public class SimpleDnsBasedDiscoveryClient implements DiscoveryClient {
|
||||
public interface ServiceIdToHostnameConverter {
|
||||
String toHostname(String serviceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -8,6 +24,9 @@ import org.cloudfoundry.operations.applications.ApplicationDetail;
|
||||
import org.cloudfoundry.operations.applications.InstanceDetail;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.util.function.Tuples;
|
||||
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
@@ -16,9 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.util.function.Tuples;
|
||||
|
||||
/**
|
||||
* @author Toshiaki Maki
|
||||
*/
|
||||
@@ -113,4 +129,4 @@ public class CloudFoundryAppServiceDiscoveryClientTest {
|
||||
|
||||
assertThat(instances).isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
@@ -95,4 +112,4 @@ public class CloudFoundryDiscoveryClientConfigurationTest {
|
||||
return Mockito.mock(CloudFoundryService.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user