enhance application discovery toString (#12953)
This commit is contained in:
parent
39fc67387b
commit
c12a57eb3c
|
|
@ -224,10 +224,8 @@ public abstract class AbstractDirectory<T> implements Directory<T> {
|
|||
|
||||
logger.warn(CLUSTER_NO_VALID_PROVIDER, "provider server or registry center crashed", "",
|
||||
"No provider available after connectivity filter for the service " + getConsumerUrl().getServiceKey()
|
||||
+ " All validInvokers' size: " + validInvokers.size()
|
||||
+ " All routed invokers' size: " + routedResult.size()
|
||||
+ " All invokers' size: " + invokers.size()
|
||||
+ " from registry " + getUrl().getAddress()
|
||||
+ " from registry " + this
|
||||
+ " on the consumer " + NetUtils.getLocalHost()
|
||||
+ " using the dubbo version " + Version.getVersion() + ".");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,10 +133,8 @@ public class ServiceDiscoveryRegistry extends FailbackRegistry {
|
|||
|
||||
boolean should = PROVIDER_SIDE.equals(side); // Only register the Provider.
|
||||
|
||||
if (!should) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("The URL[%s] should not be registered.", providerURL));
|
||||
}
|
||||
if (!should && logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("The URL[%s] should not be registered.", providerURL));
|
||||
}
|
||||
|
||||
if (!acceptable(providerURL)) {
|
||||
|
|
@ -394,7 +392,7 @@ public class ServiceDiscoveryRegistry extends FailbackRegistry {
|
|||
Lock mappingLock = serviceNameMapping.getMappingLock(event.getServiceKey());
|
||||
try {
|
||||
mappingLock.lock();
|
||||
if (CollectionUtils.isEmpty(tempOldApps) && newApps.size() > 0) {
|
||||
if (CollectionUtils.isEmpty(tempOldApps) && !newApps.isEmpty()) {
|
||||
serviceNameMapping.putCachedMapping(ServiceNameMapping.buildMappingKey(url), newApps);
|
||||
subscribeURLs(url, listener, newApps);
|
||||
oldApps = newApps;
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
}
|
||||
|
||||
void addNotifyListener(ServiceDiscoveryRegistryDirectory<?> listener) {
|
||||
if (listeners.size() == 0) {
|
||||
if (listeners.isEmpty()) {
|
||||
this.initWith(moduleModel.getApplicationModel().getApplicationName() + CONFIGURATORS_SUFFIX);
|
||||
}
|
||||
this.listeners.add(listener);
|
||||
|
|
@ -592,7 +592,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
|
||||
void removeNotifyListener(ServiceDiscoveryRegistryDirectory<?> listener) {
|
||||
this.listeners.remove(listener);
|
||||
if (listeners.size() == 0) {
|
||||
if (listeners.isEmpty()) {
|
||||
this.stopListen(moduleModel.getApplicationModel().getApplicationName() + CONFIGURATORS_SUFFIX);
|
||||
}
|
||||
}
|
||||
|
|
@ -693,4 +693,12 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServiceDiscoveryRegistryDirectory(" +
|
||||
"registry: " + getUrl().getAddress() +
|
||||
", subscribed key: " + (serviceListener == null || CollectionUtils.isEmpty(serviceListener.getServiceNames())
|
||||
? getConsumerUrl().getServiceKey() : serviceListener.getServiceNames().toString()) +
|
||||
")-" + super.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public abstract class DynamicDirectory<T> extends AbstractDirectory<T> implement
|
|||
if (forbidden && shouldFailFast) {
|
||||
// 1. No service provider 2. Service providers are disabled
|
||||
throw new RpcException(RpcException.FORBIDDEN_EXCEPTION, "No provider available from registry " +
|
||||
getUrl().getAddress() + " for service " + getConsumerUrl().getServiceKey() + " on consumer " +
|
||||
this + " for service " + getConsumerUrl().getServiceKey() + " on consumer " +
|
||||
NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() +
|
||||
", please check status of providers(disabled, not registered or in blacklist).");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue