Commit 1bbda364 by Nepxion

修正拼写错误

parent b02f1dc4
......@@ -32,7 +32,7 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
@Override
public List<ServiceInstance> getInstances(String serviceId) {
List<ServiceInstance> instances = discoveryClient.getInstances(serviceId);
List<ServiceInstance> instances = getRealInstances(serviceId);
Boolean discoveryControlEnabled = PluginContextAware.isDiscoveryControlEnabled(environment);
if (discoveryControlEnabled) {
......@@ -43,9 +43,13 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
return instances;
}
public List<ServiceInstance> getRealInstances(String serviceId) {
return discoveryClient.getInstances(serviceId);
}
@Override
public List<String> getServices() {
List<String> services = discoveryClient.getServices();
List<String> services = getRealServices();
Boolean discoveryControlEnabled = PluginContextAware.isDiscoveryControlEnabled(environment);
if (discoveryControlEnabled) {
......@@ -56,6 +60,10 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
return services;
}
public List<String> getRealServices() {
return discoveryClient.getServices();
}
@Deprecated
@Override
public ServiceInstance getLocalServiceInstance() {
......
......@@ -11,36 +11,34 @@ package com.nepxion.discovery.plugin.framework.event;
import java.io.Serializable;
import com.nepxion.discovery.plugin.framework.entity.FilterType;
public class RegisterFaiureEvent implements Serializable {
public class RegisterFailureEvent implements Serializable {
private static final long serialVersionUID = -1343084923958294246L;
private FilterType filterType;
private String eventType;
private String serviceId;
private String ipAddress;
private int port;
public RegisterFaiureEvent(FilterType filterType, String serviceId, String ipAddress, int port) {
this.filterType = filterType;
public RegisterFailureEvent(String eventType, String serviceId, String ipAddress, int port) {
this.eventType = eventType;
this.serviceId = serviceId;
this.ipAddress = ipAddress;
this.port = port;
}
public String getIpAddress() {
return ipAddress;
public String getEventType() {
return eventType;
}
public String getServiceId() {
return serviceId;
}
public int getPort() {
return port;
public String getIpAddress() {
return ipAddress;
}
public FilterType getFilterType() {
return filterType;
public int getPort() {
return port;
}
}
\ No newline at end of file
......@@ -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.RuleEntity;
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.listener.AbstractRegisterListener;
......@@ -86,7 +86,7 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
private void validateBlacklist(FilterType filterType, List<String> allFilterValueList, String serviceId, String ipAddress, int port) {
for (String filterValue : allFilterValueList) {
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 {
}
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);
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);
......
......@@ -10,13 +10,13 @@ package com.nepxion.discovery.plugin.example.extension;
*/
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;
@EventBus
public class MySubscriber {
@Subscribe
public void subscribeRegisterFaiure(RegisterFaiureEvent registerFaiureEvent) {
System.out.println("========== 注册失败:filterType=" + registerFaiureEvent.getFilterType() + ", serviceId=" + registerFaiureEvent.getServiceId() + ", ipAddress=" + registerFaiureEvent.getIpAddress() + ", port=" + registerFaiureEvent.getPort());
public void subscribeRegisterFailure(RegisterFailureEvent registerFailureEvent) {
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