fix:fix checkstyle error.

pull/77/head
skyehtzhang 3 years ago
parent 2f0d6a0d6e
commit 9c99474e84

@ -37,7 +37,8 @@ import org.springframework.test.context.junit4.SpringRunner;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = TestPolarisFeignApp.class) @SpringBootTest(classes = TestPolarisFeignApp.class)
@ContextConfiguration(classes = { PolarisFeignClientAutoConfiguration.class, PolarisContextConfiguration.class }) @ContextConfiguration(classes = { PolarisFeignClientAutoConfiguration.class,
PolarisContextConfiguration.class })
public class PolarisFeignClientTest { public class PolarisFeignClientTest {
@Autowired @Autowired

@ -17,11 +17,12 @@
package com.tencent.cloud.polaris.util; package com.tencent.cloud.polaris.util;
import java.util.Map;
import java.util.Objects;
import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request; import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response; import com.squareup.okhttp.Response;
import java.util.Map;
import java.util.Objects;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

@ -17,6 +17,10 @@
package com.tencent.cloud.polaris.router; package com.tencent.cloud.polaris.router;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.netflix.client.config.IClientConfig; import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.DynamicServerListLoadBalancer; import com.netflix.loadbalancer.DynamicServerListLoadBalancer;
import com.netflix.loadbalancer.IPing; import com.netflix.loadbalancer.IPing;
@ -37,10 +41,8 @@ import com.tencent.polaris.api.pojo.ServiceKey;
import com.tencent.polaris.router.api.core.RouterAPI; import com.tencent.polaris.router.api.core.RouterAPI;
import com.tencent.polaris.router.api.rpc.ProcessRoutersRequest; import com.tencent.polaris.router.api.rpc.ProcessRoutersRequest;
import com.tencent.polaris.router.api.rpc.ProcessRoutersResponse; import com.tencent.polaris.router.api.rpc.ProcessRoutersResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
/** /**
@ -71,7 +73,8 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer<Se
else { else {
String serviceName; String serviceName;
// notice the difference between different service registries // notice the difference between different service registries
if (StringUtils.isNotBlank(allServers.get(0).getMetaInfo().getServiceIdForDiscovery())) { if (StringUtils.isNotBlank(
allServers.get(0).getMetaInfo().getServiceIdForDiscovery())) {
serviceName = allServers.get(0).getMetaInfo().getServiceIdForDiscovery(); serviceName = allServers.get(0).getMetaInfo().getServiceIdForDiscovery();
} }
else { else {
@ -81,7 +84,8 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer<Se
throw new IllegalStateException( throw new IllegalStateException(
"PolarisRoutingLoadBalancer only Server with AppName or ServiceIdForDiscovery attribute"); "PolarisRoutingLoadBalancer only Server with AppName or ServiceIdForDiscovery attribute");
} }
ServiceKey serviceKey = new ServiceKey(MetadataContext.LOCAL_NAMESPACE, serviceName); ServiceKey serviceKey = new ServiceKey(MetadataContext.LOCAL_NAMESPACE,
serviceName);
List<Instance> instances = new ArrayList<>(8); List<Instance> instances = new ArrayList<>(8);
for (Server server : allServers) { for (Server server : allServers) {
DefaultInstance instance = new DefaultInstance(); DefaultInstance instance = new DefaultInstance();
@ -102,8 +106,10 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer<Se
processRoutersRequest.setDstInstances(serviceInstances); processRoutersRequest.setDstInstances(serviceInstances);
String srcNamespace = MetadataContext.LOCAL_NAMESPACE; String srcNamespace = MetadataContext.LOCAL_NAMESPACE;
String srcService = MetadataContext.LOCAL_SERVICE; String srcService = MetadataContext.LOCAL_SERVICE;
Map<String, String> transitiveCustomMetadata = MetadataContextHolder.get().getAllTransitiveCustomMetadata(); Map<String, String> transitiveCustomMetadata = MetadataContextHolder.get()
String method = MetadataContextHolder.get().getSystemMetadata(SystemMetadataKey.PEER_PATH); .getAllTransitiveCustomMetadata();
String method = MetadataContextHolder.get()
.getSystemMetadata(SystemMetadataKey.PEER_PATH);
processRoutersRequest.setMethod(method); processRoutersRequest.setMethod(method);
if (StringUtils.isNotBlank(srcNamespace) && StringUtils.isNotBlank(srcService)) { if (StringUtils.isNotBlank(srcNamespace) && StringUtils.isNotBlank(srcService)) {
ServiceInfo serviceInfo = new ServiceInfo(); ServiceInfo serviceInfo = new ServiceInfo();
@ -112,7 +118,8 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer<Se
serviceInfo.setMetadata(transitiveCustomMetadata); serviceInfo.setMetadata(transitiveCustomMetadata);
processRoutersRequest.setSourceService(serviceInfo); processRoutersRequest.setSourceService(serviceInfo);
} }
ProcessRoutersResponse processRoutersResponse = routerAPI.processRouters(processRoutersRequest); ProcessRoutersResponse processRoutersResponse = routerAPI
.processRouters(processRoutersRequest);
ServiceInstances filteredServiceInstances = processRoutersResponse ServiceInstances filteredServiceInstances = processRoutersResponse
.getServiceInstances(); .getServiceInstances();
List<Server> filteredInstances = new ArrayList<>(); List<Server> filteredInstances = new ArrayList<>();

@ -43,8 +43,7 @@ public class ModifyAddress implements PolarisConfigModifier {
return; return;
} }
List<String> addresses = AddressUtils List<String> addresses = AddressUtils.parseAddressList(properties.getAddress());
.parseAddressList(properties.getAddress());
configuration.getGlobal().getServerConnector().setAddresses(addresses); configuration.getGlobal().getServerConnector().setAddresses(addresses);
} }

@ -45,4 +45,5 @@ public class PolarisContextConfiguration {
public ModifyAddress polarisConfigModifier() { public ModifyAddress polarisConfigModifier() {
return new ModifyAddress(); return new ModifyAddress();
} }
} }

Loading…
Cancel
Save