Commit 1bbda364 by Nepxion

修正拼写错误

parent b02f1dc4
...@@ -32,7 +32,7 @@ public class DiscoveryClientDecorator implements DiscoveryClient { ...@@ -32,7 +32,7 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
@Override @Override
public List<ServiceInstance> getInstances(String serviceId) { public List<ServiceInstance> getInstances(String serviceId) {
List<ServiceInstance> instances = discoveryClient.getInstances(serviceId); List<ServiceInstance> instances = getRealInstances(serviceId);
Boolean discoveryControlEnabled = PluginContextAware.isDiscoveryControlEnabled(environment); Boolean discoveryControlEnabled = PluginContextAware.isDiscoveryControlEnabled(environment);
if (discoveryControlEnabled) { if (discoveryControlEnabled) {
...@@ -43,9 +43,13 @@ public class DiscoveryClientDecorator implements DiscoveryClient { ...@@ -43,9 +43,13 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
return instances; return instances;
} }
public List<ServiceInstance> getRealInstances(String serviceId) {
return discoveryClient.getInstances(serviceId);
}
@Override @Override
public List<String> getServices() { public List<String> getServices() {
List<String> services = discoveryClient.getServices(); List<String> services = getRealServices();
Boolean discoveryControlEnabled = PluginContextAware.isDiscoveryControlEnabled(environment); Boolean discoveryControlEnabled = PluginContextAware.isDiscoveryControlEnabled(environment);
if (discoveryControlEnabled) { if (discoveryControlEnabled) {
...@@ -56,6 +60,10 @@ public class DiscoveryClientDecorator implements DiscoveryClient { ...@@ -56,6 +60,10 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
return services; return services;
} }
public List<String> getRealServices() {
return discoveryClient.getServices();
}
@Deprecated @Deprecated
@Override @Override
public ServiceInstance getLocalServiceInstance() { public ServiceInstance getLocalServiceInstance() {
......
...@@ -11,36 +11,34 @@ package com.nepxion.discovery.plugin.framework.event; ...@@ -11,36 +11,34 @@ package com.nepxion.discovery.plugin.framework.event;
import java.io.Serializable; import java.io.Serializable;
import com.nepxion.discovery.plugin.framework.entity.FilterType; public class RegisterFailureEvent implements Serializable {
public class RegisterFaiureEvent implements Serializable {
private static final long serialVersionUID = -1343084923958294246L; private static final long serialVersionUID = -1343084923958294246L;
private FilterType filterType; private String eventType;
private String serviceId; private String serviceId;
private String ipAddress; private String ipAddress;
private int port; private int port;
public RegisterFaiureEvent(FilterType filterType, String serviceId, String ipAddress, int port) { public RegisterFailureEvent(String eventType, String serviceId, String ipAddress, int port) {
this.filterType = filterType; this.eventType = eventType;
this.serviceId = serviceId; this.serviceId = serviceId;
this.ipAddress = ipAddress; this.ipAddress = ipAddress;
this.port = port; this.port = port;
} }
public String getIpAddress() { public String getEventType() {
return ipAddress; return eventType;
} }
public String getServiceId() { public String getServiceId() {
return serviceId; return serviceId;
} }
public int getPort() { public String getIpAddress() {
return port; return ipAddress;
} }
public FilterType getFilterType() { public int getPort() {
return filterType; return port;
} }
} }
\ No newline at end of file
...@@ -24,7 +24,7 @@ import com.nepxion.discovery.plugin.framework.entity.FilterType; ...@@ -24,7 +24,7 @@ import com.nepxion.discovery.plugin.framework.entity.FilterType;
import com.nepxion.discovery.plugin.framework.entity.RegisterEntity; import com.nepxion.discovery.plugin.framework.entity.RegisterEntity;
import com.nepxion.discovery.plugin.framework.entity.RuleEntity; import com.nepxion.discovery.plugin.framework.entity.RuleEntity;
import com.nepxion.discovery.plugin.framework.event.PluginPublisher; import com.nepxion.discovery.plugin.framework.event.PluginPublisher;
import com.nepxion.discovery.plugin.framework.event.RegisterFaiureEvent; import com.nepxion.discovery.plugin.framework.event.RegisterFailureEvent;
import com.nepxion.discovery.plugin.framework.exception.PluginException; import com.nepxion.discovery.plugin.framework.exception.PluginException;
import com.nepxion.discovery.plugin.framework.listener.AbstractRegisterListener; import com.nepxion.discovery.plugin.framework.listener.AbstractRegisterListener;
...@@ -86,7 +86,7 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener { ...@@ -86,7 +86,7 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
private void validateBlacklist(FilterType filterType, List<String> allFilterValueList, String serviceId, String ipAddress, int port) { private void validateBlacklist(FilterType filterType, List<String> allFilterValueList, String serviceId, String ipAddress, int port) {
for (String filterValue : allFilterValueList) { for (String filterValue : allFilterValueList) {
if (ipAddress.startsWith(filterValue)) { if (ipAddress.startsWith(filterValue)) {
onRegisterFaiure(filterType, allFilterValueList, serviceId, ipAddress, port); onRegisterFailure(filterType, allFilterValueList, serviceId, ipAddress, port);
} }
} }
} }
...@@ -101,14 +101,14 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener { ...@@ -101,14 +101,14 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
} }
if (matched) { if (matched) {
onRegisterFaiure(filterType, allFilterValueList, serviceId, ipAddress, port); onRegisterFailure(filterType, allFilterValueList, serviceId, ipAddress, port);
} }
} }
private void onRegisterFaiure(FilterType filterType, List<String> allFilterValueList, String serviceId, String ipAddress, int port) { private void onRegisterFailure(FilterType filterType, List<String> allFilterValueList, String serviceId, String ipAddress, int port) {
Boolean registerFailureEventEnabled = environment.getProperty(PluginConstant.SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED, Boolean.class, Boolean.FALSE); Boolean registerFailureEventEnabled = environment.getProperty(PluginConstant.SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED, Boolean.class, Boolean.FALSE);
if (registerFailureEventEnabled) { if (registerFailureEventEnabled) {
pluginPublisher.asyncPublish(new RegisterFaiureEvent(filterType, serviceId, ipAddress, port)); pluginPublisher.asyncPublish(new RegisterFailureEvent(filterType.toString(), serviceId, ipAddress, port));
} }
throw new PluginException(ipAddress + " isn't allowed to register to Register server, not match IP address " + filterType + "=" + allFilterValueList); throw new PluginException(ipAddress + " isn't allowed to register to Register server, not match IP address " + filterType + "=" + allFilterValueList);
......
...@@ -10,13 +10,13 @@ package com.nepxion.discovery.plugin.example.extension; ...@@ -10,13 +10,13 @@ package com.nepxion.discovery.plugin.example.extension;
*/ */
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.nepxion.discovery.plugin.framework.event.RegisterFaiureEvent; import com.nepxion.discovery.plugin.framework.event.RegisterFailureEvent;
import com.nepxion.eventbus.annotation.EventBus; import com.nepxion.eventbus.annotation.EventBus;
@EventBus @EventBus
public class MySubscriber { public class MySubscriber {
@Subscribe @Subscribe
public void subscribeRegisterFaiure(RegisterFaiureEvent registerFaiureEvent) { public void subscribeRegisterFailure(RegisterFailureEvent registerFailureEvent) {
System.out.println("========== 注册失败:filterType=" + registerFaiureEvent.getFilterType() + ", serviceId=" + registerFaiureEvent.getServiceId() + ", ipAddress=" + registerFaiureEvent.getIpAddress() + ", port=" + registerFaiureEvent.getPort()); System.out.println("========== 注册失败:eventType=" + registerFailureEvent.getEventType() + ", serviceId=" + registerFailureEvent.getServiceId() + ", ipAddress=" + registerFailureEvent.getIpAddress() + ", port=" + registerFailureEvent.getPort());
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment