Merge branch 'apache-3.1' into apache-3.2

# Conflicts:
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/CacheableFailbackRegistry.java
This commit is contained in:
Albumen Kevin 2022-12-21 23:25:53 +08:00
commit eba39fd65b
19 changed files with 77 additions and 39 deletions

View File

@ -22,7 +22,7 @@ import org.apache.dubbo.common.logger.LoggerFactory;
import java.util.NoSuchElementException;
import static org.apache.dubbo.common.config.ConfigurationUtils.isEmptyValue;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_MISSPELLING;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH;
/**
* Configuration interface, to fetch the value for the specified key.
@ -74,7 +74,7 @@ public interface Configuration {
return convert(Integer.class, key, defaultValue);
} catch (NumberFormatException e) {
// 0-2 Property type mismatch.
interfaceLevelLogger.error(COMMON_PROPERTY_MISSPELLING, "typo in property value",
interfaceLevelLogger.error(COMMON_PROPERTY_TYPE_MISMATCH, "typo in property value",
"This property requires an integer value.",
"Actual Class: " + getClass().getName(), e);

View File

@ -25,7 +25,7 @@ public interface LoggerCodeConstants {
// common module
String COMMON_THREAD_POOL_EXHAUSTED = "0-1";
String COMMON_PROPERTY_MISSPELLING = "0-2";
String COMMON_PROPERTY_TYPE_MISMATCH = "0-2";
String COMMON_CACHE_PATH_INACCESSIBLE = "0-3";

View File

@ -90,7 +90,7 @@ public class GlobalResourcesRepository {
synchronized (this) {
if (executorService == null || executorService.isShutdown()) {
if (logger.isInfoEnabled()) {
logger.error("Creating global shared handler ...");
logger.info("Creating global shared handler ...");
}
executorService = Executors.newCachedThreadPool(new NamedThreadFactory("Dubbo-global-shared-handler", true));
}

View File

@ -110,10 +110,10 @@ public abstract class AbstractConfig implements Serializable {
* <b>NOTE:</b> the model maybe changed during config processing,
* the extension spi instance needs to be reinitialized after changing the model!
*/
protected ScopeModel scopeModel;
private volatile ScopeModel scopeModel;
public AbstractConfig() {
this(ApplicationModel.defaultModel());
this(null);
}
public AbstractConfig(ScopeModel scopeModel) {
@ -384,6 +384,9 @@ public abstract class AbstractConfig implements Serializable {
}
public ApplicationModel getApplicationModel() {
if (scopeModel == null) {
setScopeModel(getDefaultModel());
}
if (scopeModel instanceof ApplicationModel) {
return (ApplicationModel) scopeModel;
} else if (scopeModel instanceof ModuleModel) {
@ -394,11 +397,18 @@ public abstract class AbstractConfig implements Serializable {
}
public ScopeModel getScopeModel() {
if (scopeModel == null) {
setScopeModel(getDefaultModel());
}
return scopeModel;
}
protected ScopeModel getDefaultModel() {
return ApplicationModel.defaultModel();
}
public final void setScopeModel(ScopeModel scopeModel) {
if (this.scopeModel != scopeModel) {
if (scopeModel != null && this.scopeModel != scopeModel) {
checkScopeModel(scopeModel);
ScopeModel oldScopeModel = this.scopeModel;
this.scopeModel = scopeModel;
@ -444,7 +454,7 @@ public abstract class AbstractConfig implements Serializable {
protected <T> ExtensionLoader<T> getExtensionLoader(Class<T> type) {
if (scopeModel == null) {
throw new IllegalStateException("scopeModel is not initialized");
setScopeModel(getScopeModel());
}
return scopeModel.getExtensionLoader(type);
}

View File

@ -226,7 +226,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
protected void postProcessAfterScopeModelChanged(ScopeModel oldScopeModel, ScopeModel newScopeModel) {
super.postProcessAfterScopeModelChanged(oldScopeModel, newScopeModel);
// change referenced config's scope model
ApplicationModel applicationModel = ScopeModelUtil.getApplicationModel(scopeModel);
ApplicationModel applicationModel = ScopeModelUtil.getApplicationModel(getScopeModel());
if (this.configCenter != null && this.configCenter.getScopeModel() != applicationModel) {
this.configCenter.setScopeModel(applicationModel);
}

View File

@ -100,7 +100,7 @@ public abstract class AbstractMethodConfig extends AbstractConfig {
protected Integer forks;
public AbstractMethodConfig() {
super(ApplicationModel.defaultModel().getDefaultModule());
super();
}
public AbstractMethodConfig(ModuleModel moduleModel) {
@ -109,7 +109,12 @@ public abstract class AbstractMethodConfig extends AbstractConfig {
@Override
public ModuleModel getScopeModel() {
return (ModuleModel) scopeModel;
return (ModuleModel) super.getScopeModel();
}
@Override
protected ScopeModel getDefaultModel() {
return ApplicationModel.defaultModel().getDefaultModule();
}
@Override

View File

@ -93,7 +93,7 @@ public class ModuleConfig extends AbstractConfig {
private Integer exportThreadNum;
public ModuleConfig() {
super(ApplicationModel.defaultModel().getDefaultModule());
super();
}
public ModuleConfig(ModuleModel moduleModel) {
@ -129,6 +129,16 @@ public class ModuleConfig extends AbstractConfig {
}
}
@Override
public ModuleModel getScopeModel() {
return (ModuleModel) super.getScopeModel();
}
@Override
protected ScopeModel getDefaultModel() {
return ApplicationModel.defaultModel().getDefaultModule();
}
@Parameter(key = "module")
public String getName() {
return name;

View File

@ -240,8 +240,8 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
@Override
protected void postProcessAfterScopeModelChanged(ScopeModel oldScopeModel, ScopeModel newScopeModel) {
super.postProcessAfterScopeModelChanged(oldScopeModel, newScopeModel);
if (this.consumer != null && this.consumer.getScopeModel() != scopeModel) {
this.consumer.setScopeModel(scopeModel);
if (this.consumer != null && this.consumer.getScopeModel() != getScopeModel()) {
this.consumer.setScopeModel(getScopeModel());
}
}

View File

@ -111,8 +111,8 @@ public abstract class ServiceConfigBase<T> extends AbstractServiceConfig {
@Override
protected void postProcessAfterScopeModelChanged(ScopeModel oldScopeModel, ScopeModel newScopeModel) {
super.postProcessAfterScopeModelChanged(oldScopeModel, newScopeModel);
if (this.provider != null && this.provider.getScopeModel() != scopeModel) {
this.provider.setScopeModel(scopeModel);
if (this.provider != null && this.provider.getScopeModel() != getScopeModel()) {
this.provider.setScopeModel(getScopeModel());
}
}

View File

@ -60,7 +60,7 @@ import static java.lang.Boolean.TRUE;
import static java.util.Collections.emptyMap;
import static java.util.Optional.ofNullable;
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_MISSPELLING;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.config.AbstractConfig.getTagName;
@ -121,7 +121,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
}
} catch (Exception e) {
String msg = "Illegal '" + ConfigKeys.DUBBO_CONFIG_MODE + "' config value [" + configModeStr + "], available values " + Arrays.toString(ConfigMode.values());
logger.error(COMMON_PROPERTY_MISSPELLING, "", "", msg, e);
logger.error(COMMON_PROPERTY_TYPE_MISMATCH, "", "", msg, e);
throw new IllegalArgumentException(msg, e);
}
@ -506,7 +506,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
this.addConfig(config);
tmpConfigs.add(config);
} catch (Exception e) {
logger.error(COMMON_PROPERTY_MISSPELLING, "", "", "load config failed, id: " + id + ", type:" + cls.getSimpleName(), e);
logger.error(COMMON_PROPERTY_TYPE_MISMATCH, "", "", "load config failed, id: " + id + ", type:" + cls.getSimpleName(), e);
throw new IllegalStateException("load config failed, id: " + id + ", type:" + cls.getSimpleName());
} finally {
if (addDefaultNameConfig && key != null) {

View File

@ -608,7 +608,7 @@ public class ReferenceConfig<T> extends ReferenceConfigBase<T> {
!curUrl.getParameter(UNLOAD_CLUSTER_RELATED, false)) {
List<Invoker<?>> invokers = new ArrayList<>();
invokers.add(invoker);
invoker = Cluster.getCluster(scopeModel, Cluster.DEFAULT).join(new StaticDirectory(curUrl, invokers), true);
invoker = Cluster.getCluster(getScopeModel(), Cluster.DEFAULT).join(new StaticDirectory(curUrl, invokers), true);
}
} else {
List<Invoker<?>> invokers = new ArrayList<>();
@ -638,7 +638,7 @@ public class ReferenceConfig<T> extends ReferenceConfigBase<T> {
}
URL curUrl = invokers.get(0).getUrl();
String cluster = curUrl.getParameter(CLUSTER_KEY, Cluster.DEFAULT);
invoker = Cluster.getCluster(scopeModel, cluster).join(new StaticDirectory(curUrl, invokers), true);
invoker = Cluster.getCluster(getScopeModel(), cluster).join(new StaticDirectory(curUrl, invokers), true);
}
}
}

View File

@ -306,6 +306,7 @@ class MultiInstanceTest {
@Test
void testMultiProviderApplicationsStopOneByOne() {
FrameworkModel.destroyAll();
String version1 = "1.0";
String version2 = "2.0";

View File

@ -51,10 +51,6 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-dubbo</artifactId>

View File

@ -1947,7 +1947,14 @@
]
},
{
"name": "org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperTransporter"
"name": "org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperTransporter",
"allPublicMethods": true,
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "org.apache.dubbo.rpc.Invoker",
@ -2556,6 +2563,10 @@
}
]
},
{
"name": "org.apache.logging.log4j.Level",
"allPublicMethods": true
},
{
"name": "org.apache.log4j.helpers.Loader"
},
@ -2565,6 +2576,10 @@
{
"name": "org.apache.zookeeper.ClientCnxnSocketNIO",
"methods": [
{
"name": "<init>",
"parameterTypes": ["org.apache.zookeeper.client.ZKClientConfig"]
},
{
"name": "<init>",
"parameterTypes": []

View File

@ -25,6 +25,7 @@ import org.apache.dubbo.registry.client.ServiceInstance;
import org.apache.dubbo.registry.client.ServiceInstanceCustomizer;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.common.constants.LoggerCodeConstants;
import java.util.HashMap;
import java.util.Map;
@ -55,8 +56,8 @@ public class ProtocolPortsMetadataCustomizer implements ServiceInstanceCustomize
Integer oldPort = protocols.get(protocol);
int newPort = url.getPort();
if (oldPort != null) {
LOGGER.warn("same protocol " + "[" + protocol + "]" + " listen on different ports " + "[" + oldPort + "," + newPort + "]" + " will override with each other" +
".Override port [" + oldPort + "] with port [" + newPort + "]");
LOGGER.warn(LoggerCodeConstants.PROTOCOL_INCORRECT_PARAMETER_VALUES, "the protocol is listening multiple ports", "", "Same protocol " + "[" + protocol + "]" + " listens on different ports " + "[" + oldPort + "," + newPort + "]" + " will override with each other" +
". The port [" + oldPort + "] is overridden with port [" + newPort + "].");
}
protocols.put(protocol, newPort);
});

View File

@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_INCORRECT_PARAMETER_VALUES;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH;
public class DefaultMigrationAddressComparator implements MigrationAddressComparator {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DefaultMigrationAddressComparator.class);
@ -75,7 +75,7 @@ public class DefaultMigrationAddressComparator implements MigrationAddressCompar
try {
threshold = Float.parseFloat(rawThreshold);
} catch (Exception e) {
logger.error(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", "Invalid migration threshold " + rawThreshold);
logger.error(COMMON_PROPERTY_TYPE_MISMATCH, "", "", "Invalid migration threshold " + rawThreshold);
threshold = DEFAULT_THREAD;
}

View File

@ -50,7 +50,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_THREAD_INTERRUPTED_EXCEPTION;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_INCORRECT_PARAMETER_VALUES;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_EMPTY_ADDRESS;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.common.constants.RegistryConstants.INIT;
@ -135,7 +135,7 @@ public class MigrationRuleListener implements RegistryProtocolListener, Configur
try {
delay = Integer.parseInt(delayStr);
} catch (Exception e) {
logger.warn(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", "Invalid migration delay param " + delayStr);
logger.warn(COMMON_PROPERTY_TYPE_MISMATCH, "", "", "Invalid migration delay param " + delayStr);
}
return delay;
}
@ -146,7 +146,7 @@ public class MigrationRuleListener implements RegistryProtocolListener, Configur
if (StringUtils.isEmpty(rawRule)) {
// fail back to startup status
rawRule = INIT;
//logger.warn(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", "Received empty migration rule, will ignore.");
//logger.warn(COMMON_PROPERTY_TYPE_MISMATCH, "", "", "Received empty migration rule, will ignore.");
}
try {
ruleQueue.put(rawRule);
@ -226,7 +226,7 @@ public class MigrationRuleListener implements RegistryProtocolListener, Configur
try {
tmpRule = MigrationRule.parse(rawRule);
} catch (Exception e) {
logger.error(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", "Failed to parse migration rule...", e);
logger.error(COMMON_PROPERTY_TYPE_MISMATCH, "", "", "Failed to parse migration rule...", e);
}
}
return tmpRule;

View File

@ -56,11 +56,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.CHECK_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO;
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_SEPARATOR_ENCODED;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_MISSPELLING;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ADDRESS_INVALID;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_EMPTY_ADDRESS;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_CLEAR_CACHED_URLS;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_URL_EVICTING;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_NO_PARAMETERS_URL;
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_ENABLE_EMPTY_PROTECTION;
@ -115,7 +115,7 @@ public abstract class CacheableFailbackRegistry extends FailbackRegistry {
} catch (NumberFormatException e) {
// 0-2 Property type mismatch.
logger.warn(COMMON_PROPERTY_MISSPELLING, "typo in property value", "This property requires an integer value.",
logger.warn(COMMON_PROPERTY_TYPE_MISMATCH, "typo in property value", "This property requires an integer value.",
"Invalid registry properties configuration key " + key + ", value " + str);
}
}

View File

@ -54,7 +54,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DESTROY_INVOKER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_LOAD_MODEL;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_INCORRECT_PARAMETER_VALUES;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH;
import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_KEY;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_PROXY_KEY;
@ -286,7 +286,7 @@ public class CallbackServiceCodec {
}
channel.setAttribute(countkey, count);
} catch (Exception e) {
logger.error(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", e.getMessage(), e);
logger.error(COMMON_PROPERTY_TYPE_MISMATCH, "", "", e.getMessage(), e);
}
}
@ -300,7 +300,7 @@ public class CallbackServiceCodec {
}
channel.setAttribute(countkey, count);
} catch (Exception e) {
logger.error(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", e.getMessage(), e);
logger.error(COMMON_PROPERTY_TYPE_MISMATCH, "", "", e.getMessage(), e);
}
}