From f95e29a0e049046b066eec7e84643315dce5c0fb Mon Sep 17 00:00:00 2001 From: myPrecious Date: Thu, 9 May 2019 22:23:03 +0800 Subject: [PATCH 1/6] [Dubbo-3846] Support Nacos as config center (#3988) --- dubbo-all/pom.xml | 8 + dubbo-bom/pom.xml | 10 + .../org/apache/dubbo/common/Constants.java | 2 + .../dubbo-configcenter-nacos/pom.xml | 45 +++ .../nacos/NacosDynamicConfiguration.java | 265 ++++++++++++++++++ .../NacosDynamicConfigurationFactory.java | 40 +++ ...o.configcenter.DynamicConfigurationFactory | 1 + .../nacos/NacosDynamicConfigurationTest.java | 136 +++++++++ dubbo-configcenter/pom.xml | 1 + .../AbstractConfiguratorListener.java | 3 +- 10 files changed, 510 insertions(+), 1 deletion(-) create mode 100644 dubbo-configcenter/dubbo-configcenter-nacos/pom.xml create mode 100644 dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java create mode 100644 dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationFactory.java create mode 100644 dubbo-configcenter/dubbo-configcenter-nacos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfigurationFactory create mode 100644 dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java diff --git a/dubbo-all/pom.xml b/dubbo-all/pom.xml index c353874f88d..6dc00fbcda7 100644 --- a/dubbo-all/pom.xml +++ b/dubbo-all/pom.xml @@ -415,6 +415,13 @@ compile true + + org.apache.dubbo + dubbo-configcenter-nacos + ${project.version} + compile + true + org.apache.dubbo dubbo-configcenter-consul @@ -599,6 +606,7 @@ org.apache.dubbo:dubbo-configcenter-zookeeper org.apache.dubbo:dubbo-configcenter-consul org.apache.dubbo:dubbo-configcenter-etcd + org.apache.dubbo:dubbo-configcenter-nacos org.apache.dubbo:dubbo-metadata-report-api org.apache.dubbo:dubbo-metadata-definition org.apache.dubbo:dubbo-metadata-report-redis diff --git a/dubbo-bom/pom.xml b/dubbo-bom/pom.xml index a7e44dcf6dc..2b1e5feb2f6 100644 --- a/dubbo-bom/pom.xml +++ b/dubbo-bom/pom.xml @@ -257,6 +257,11 @@ dubbo-registry-consul ${project.version} + + org.apache.dubbo + dubbo-registry-nacos + ${project.version} + org.apache.dubbo dubbo-registry-sofa @@ -402,6 +407,11 @@ dubbo-configcenter-etcd ${project.version} + + org.apache.dubbo + dubbo-configcenter-nacos + ${project.version} + org.apache.dubbo dubbo-metadata-definition diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java index cc52e77d6f7..31d5fc73e31 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java @@ -200,6 +200,8 @@ public class Constants { public static final String PROPERTIES_CHAR_SEPERATOR = "-"; + public static final String GROUP_CHAR_SEPERATOR = ":"; + public static final String HIDE_KEY_PREFIX = "."; public static final String DEFAULT_KEY_PREFIX = "default."; diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/pom.xml b/dubbo-configcenter/dubbo-configcenter-nacos/pom.xml new file mode 100644 index 00000000000..bd5397c92b6 --- /dev/null +++ b/dubbo-configcenter/dubbo-configcenter-nacos/pom.xml @@ -0,0 +1,45 @@ + + + + + + dubbo-configcenter + org.apache.dubbo + ${revision} + + 4.0.0 + + dubbo-configcenter-nacos + jar + ${project.artifactId} + The nacos implementation of the config-center api + + + + org.apache.dubbo + dubbo-configcenter-api + ${project.parent.version} + + + com.alibaba.nacos + nacos-client + + + diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java new file mode 100644 index 00000000000..fdb536fa8a3 --- /dev/null +++ b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.configcenter.support.nacos; + +import com.alibaba.nacos.api.NacosFactory; +import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.config.listener.AbstractSharedListener; +import com.alibaba.nacos.api.exception.NacosException; +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.logger.LoggerFactory; +import org.apache.dubbo.common.utils.StringUtils; +import org.apache.dubbo.configcenter.ConfigChangeEvent; +import org.apache.dubbo.configcenter.ConfigChangeType; +import org.apache.dubbo.configcenter.ConfigurationListener; +import org.apache.dubbo.configcenter.DynamicConfiguration; + +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.Executor; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArraySet; +import static com.alibaba.nacos.api.PropertyKeyConst.ACCESS_KEY; +import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME; +import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT; +import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY; +import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR; +import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE; +import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME; +import static org.apache.dubbo.common.Constants.BACKUP_KEY; +import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY; +import static org.apache.dubbo.common.Constants.GROUP_CHAR_SEPERATOR; +import static org.apache.dubbo.common.Constants.PROPERTIES_CHAR_SEPERATOR; + +/** + * The nacos implementation of {@link DynamicConfiguration} + */ +public class NacosDynamicConfiguration implements DynamicConfiguration { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + /** + * The final root path would be: /$NAME_SPACE/config + */ + private String rootPath; + + /** + * The nacos configService + */ + + private ConfigService configService; + + /** + * The map store the key to {@link NacosConfigListener} mapping + */ + private final ConcurrentMap watchListenerMap; + + NacosDynamicConfiguration(URL url) { + rootPath = url.getParameter(CONFIG_NAMESPACE_KEY, DEFAULT_GROUP) + "-config"; + buildConfigService(url); + watchListenerMap = new ConcurrentHashMap<>(); + } + + private ConfigService buildConfigService(URL url) { + Properties nacosProperties = buildNacosProperties(url); + try { + configService = NacosFactory.createConfigService(nacosProperties); + } catch (NacosException e) { + if (logger.isErrorEnabled()) { + logger.error(e.getErrMsg(), e); + } + throw new IllegalStateException(e); + } + return configService; + } + + public void publishNacosConfig(String key, String value) { + try { + String[] keyAndGroup = getKeyAndGroup(key); + configService.publishConfig(keyAndGroup[0], keyAndGroup[1], value); + } catch (NacosException e) { + logger.error(e.getErrMsg()); + } + } + + private String[] getKeyAndGroup(String key) { + int i = key.lastIndexOf(GROUP_CHAR_SEPERATOR); + if (i < 0) { + return new String[]{key, null}; + } else { + return new String[]{key.substring(0, i), key.substring(i+1)}; + } + } + + private Properties buildNacosProperties(URL url) { + Properties properties = new Properties(); + setServerAddr(url, properties); + setProperties(url, properties); + return properties; + } + + private void setServerAddr(URL url, Properties properties) { + StringBuilder serverAddrBuilder = + new StringBuilder(url.getHost()) // Host + .append(":") + .append(url.getPort()); // Port + + // Append backup parameter as other servers + String backup = url.getParameter(BACKUP_KEY); + if (backup != null) { + serverAddrBuilder.append(",").append(backup); + } + String serverAddr = serverAddrBuilder.toString(); + properties.put(SERVER_ADDR, serverAddr); + } + + private void setProperties(URL url, Properties properties) { + putPropertyIfAbsent(url, properties, NAMESPACE); + putPropertyIfAbsent(url, properties, NACOS_NAMING_LOG_NAME); + putPropertyIfAbsent(url, properties, ENDPOINT); + putPropertyIfAbsent(url, properties, ACCESS_KEY); + putPropertyIfAbsent(url, properties, SECRET_KEY); + putPropertyIfAbsent(url, properties, CLUSTER_NAME); + } + + private void putPropertyIfAbsent(URL url, Properties properties, String propertyName) { + String propertyValue = url.getParameter(propertyName); + if (StringUtils.isNotEmpty(propertyValue)) { + properties.setProperty(propertyName, propertyValue); + } + } + + /** + * Ignores the group parameter. + * + * @param key property key the native listener will listen on + * @param group to distinguish different set of properties + * @return + */ + private NacosConfigListener createTargetListener(String key, String group) { + NacosConfigListener configListener = new NacosConfigListener(); + configListener.fillContext(key, group); + return configListener; + } + + @Override + public void addListener(String key, String group, ConfigurationListener listener) { + String[] keyAndGroup = getKeyAndGroup(key); + if (keyAndGroup[1] != null) { + group = keyAndGroup[1]; + } + String finalGroup = group; + NacosConfigListener nacosConfigListener = watchListenerMap.computeIfAbsent(generateKey(key, group), k -> createTargetListener(key, finalGroup)); + String keyInNacos = rootPath + PROPERTIES_CHAR_SEPERATOR + key; + nacosConfigListener.addListener(listener); + try { + configService.addListener(keyInNacos, group, nacosConfigListener); + System.out.println("1"); + } catch (NacosException e) { + logger.error(e.getMessage()); + } + } + + private String generateKey(String key, String group) { + if (StringUtils.isNotEmpty(group)) { + key = key + GROUP_CHAR_SEPERATOR + group; + } + return key; + } + + @Override + public void removeListener(String key, String group, ConfigurationListener listener) { + NacosConfigListener eventListener = watchListenerMap.get(generateKey(key, group)); + if (eventListener != null) { + eventListener.removeListener(listener); + } + } + + @Override + public String getConfig(String key, String group, long timeout) throws IllegalStateException { + key = generateKey(key, group); + return (String) getInternalProperty(rootPath + PROPERTIES_CHAR_SEPERATOR + key); + } + + @Override + public Object getInternalProperty(String key) { + try { + String[] keyAndGroup = getKeyAndGroup(key); + return configService.getConfig(keyAndGroup[0], keyAndGroup[1], 5000L); + } catch (NacosException e) { + logger.error(e.getMessage()); + } + return null; + } + + public class NacosConfigListener extends AbstractSharedListener { + + private Set listeners = new CopyOnWriteArraySet<>(); + /** + * cache data to store old value + */ + private Map cacheData = new ConcurrentHashMap<>(); + + @Override + public Executor getExecutor() { + return null; + } + + /** + * receive + * + * @param dataId data ID + * @param group group + * @param configInfo content + */ + @Override + public void innerReceive(String dataId, String group, String configInfo) { + String oldValue = cacheData.get(dataId); + ConfigChangeEvent event = new ConfigChangeEvent(dataId, configInfo, getChangeType(configInfo, oldValue)); + if (configInfo == null) { + cacheData.remove(dataId); + } else { + cacheData.put(dataId, configInfo); + } + listeners.forEach(listener -> listener.process(event)); + } + + void addListener(ConfigurationListener configurationListener) { + + this.listeners.add(configurationListener); + } + + void removeListener(ConfigurationListener configurationListener) { + this.listeners.remove(configurationListener); + } + + private ConfigChangeType getChangeType(String configInfo, String oldValue) { + if (StringUtils.isBlank(configInfo)) { + return ConfigChangeType.DELETED; + } + if (StringUtils.isBlank(oldValue)) { + return ConfigChangeType.ADDED; + } + return ConfigChangeType.MODIFIED; + } + } + +} diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationFactory.java b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationFactory.java new file mode 100644 index 00000000000..2246741c1cb --- /dev/null +++ b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationFactory.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.configcenter.support.nacos; + +import com.alibaba.nacos.api.PropertyKeyConst; +import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.URL; +import org.apache.dubbo.configcenter.AbstractDynamicConfigurationFactory; +import org.apache.dubbo.configcenter.DynamicConfiguration; + +/** + * The nacos implementation of {@link AbstractDynamicConfigurationFactory} + */ +public class NacosDynamicConfigurationFactory extends AbstractDynamicConfigurationFactory { + + @Override + protected DynamicConfiguration createDynamicConfiguration(URL url) { + URL nacosURL = url; + if (Constants.DUBBO.equals(url.getParameter(PropertyKeyConst.NAMESPACE))) { + // Nacos use empty string as default name space, replace default namespace "dubbo" to "" + nacosURL = url.removeParameter(PropertyKeyConst.NAMESPACE); + } + return new NacosDynamicConfiguration(nacosURL); + } +} diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfigurationFactory b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfigurationFactory new file mode 100644 index 00000000000..b9c75a4c980 --- /dev/null +++ b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.configcenter.DynamicConfigurationFactory @@ -0,0 +1 @@ +nacos=org.apache.dubbo.configcenter.support.nacos.NacosDynamicConfigurationFactory \ No newline at end of file diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java b/dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java new file mode 100644 index 00000000000..f5ac1d38ccb --- /dev/null +++ b/dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.configcenter.support.nacos; + +import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.URL; +import org.apache.dubbo.configcenter.ConfigChangeEvent; +import org.apache.dubbo.configcenter.ConfigurationListener; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Disabled; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +/** + * Unit test for nacos config center support + */ +@Disabled +public class NacosDynamicConfigurationTest { + + private static NacosDynamicConfiguration config; + + @Test + public void testGetConfig() throws Exception { + + put("dubbo-config-org.apache.dubbo.nacos.testService.configurators", "hello"); + Thread.sleep(200); + put("dubbo-config-dubbo.properties:test", "aaa=bbb"); + Thread.sleep(200); + Assertions.assertEquals("hello", config.getConfig("org.apache.dubbo.nacos.testService.configurators")); + Assertions.assertEquals("aaa=bbb", config.getConfig("dubbo.properties", "test")); + } + + @Test + public void testAddListener() throws Exception { + CountDownLatch latch = new CountDownLatch(4); + TestListener listener1 = new TestListener(latch); + TestListener listener2 = new TestListener(latch); + TestListener listener3 = new TestListener(latch); + TestListener listener4 = new TestListener(latch); + + + config.addListener("AService.configurators", listener1); + config.addListener("AService.configurators", listener2); + config.addListener("testapp.tagrouters", listener3); + config.addListener("testapp.tagrouters", listener4); + + put("dubbo-config-AService.configurators", "new value1"); + Thread.sleep(200); + put("dubbo-config-testapp.tagrouters", "new value2"); + Thread.sleep(200); + put("dubbo-config-testapp", "new value3"); + Thread.sleep(5000); + + latch.await(); + + Assertions.assertEquals(1, listener1.getCount("dubbo-config-AService.configurators")); + Assertions.assertEquals(1, listener2.getCount("dubbo-config-AService.configurators")); + Assertions.assertEquals(1, listener3.getCount("dubbo-config-testapp.tagrouters")); + Assertions.assertEquals(1, listener4.getCount("dubbo-config-testapp.tagrouters")); + + Assertions.assertEquals("new value1", listener1.getValue()); + Assertions.assertEquals("new value1", listener2.getValue()); + Assertions.assertEquals("new value2", listener3.getValue()); + Assertions.assertEquals("new value2", listener4.getValue()); + + } + + private void put(String key, String value) { + try { + config.publishNacosConfig(key, value); + } catch (Exception e) { + System.out.println("Error put value to nacos."); + } + } + + @BeforeAll + public static void setUp() { + String urlForDubbo = "nacos://" + "127.0.0.1:8848" + "/org.apache.dubbo.nacos.testService"; + // timeout in 15 seconds. + URL url = URL.valueOf(urlForDubbo) + .addParameter(Constants.SESSION_TIMEOUT_KEY, 15000); + config = new NacosDynamicConfiguration(url); + } + + @AfterAll + public static void tearDown() { + } + + private class TestListener implements ConfigurationListener { + private CountDownLatch latch; + private String value; + private Map countMap = new HashMap<>(); + + public TestListener(CountDownLatch latch) { + this.latch = latch; + } + + @Override + public void process(ConfigChangeEvent event) { + System.out.println(this + ": " + event); + Integer count = countMap.computeIfAbsent(event.getKey(), k -> new Integer(0)); + countMap.put(event.getKey(), ++count); + value = event.getValue(); + latch.countDown(); + } + + public int getCount(String key) { + return countMap.get(key); + } + + public String getValue() { + return value; + } + } + +} diff --git a/dubbo-configcenter/pom.xml b/dubbo-configcenter/pom.xml index c6fb983bb72..0de20d319c7 100644 --- a/dubbo-configcenter/pom.xml +++ b/dubbo-configcenter/pom.xml @@ -35,5 +35,6 @@ dubbo-configcenter-apollo dubbo-configcenter-consul dubbo-configcenter-etcd + dubbo-configcenter-nacos diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java index 8b0b43fad9d..3aea7e6177e 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java @@ -16,6 +16,7 @@ */ package org.apache.dubbo.registry.integration; +import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.StringUtils; @@ -41,7 +42,7 @@ public abstract class AbstractConfiguratorListener implements ConfigurationListe protected final void initWith(String key) { DynamicConfiguration dynamicConfiguration = DynamicConfiguration.getDynamicConfiguration(); dynamicConfiguration.addListener(key, this); - String rawConfig = dynamicConfiguration.getConfig(key); + String rawConfig = dynamicConfiguration.getConfig(key, Constants.DUBBO); if (!StringUtils.isEmpty(rawConfig)) { process(new ConfigChangeEvent(key, rawConfig)); } From 09d8a6ea6ed58a331115bfb5b93bda1647229e6e Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Fri, 10 May 2019 12:59:57 +0800 Subject: [PATCH 2/6] Need to enhance DecodeableRpcResult error message (#3995) Fixes #3994 --- .../apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java index fac7c64a6ca..0edfdb8f3a3 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java @@ -97,7 +97,7 @@ public Object decode(Channel channel, InputStream input) throws IOException { handleAttachment(in); break; default: - throw new IOException("Unknown result flag, expect '0' '1' '2', get " + flag); + throw new IOException("Unknown result flag, expect '0' '1' '2' '3' '4' '5', but received: " + flag); } if (in instanceof Cleanable) { ((Cleanable) in).cleanup(); From d5c517607b5bb5360c56b8d619799b2795594040 Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Fri, 10 May 2019 13:01:06 +0800 Subject: [PATCH 3/6] port #3568 into main trunk (#3993) fixes #3991 --- .../java/org/apache/dubbo/rpc/protocol/dubbo/DubboCodec.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboCodec.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboCodec.java index 38650c2b2ef..bc8c7470184 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboCodec.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboCodec.java @@ -73,12 +73,13 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro byte status = header[3]; res.setStatus(status); try { - ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto); if (status == Response.OK) { Object data; if (res.isHeartbeat()) { + ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto); data = decodeHeartbeatData(channel, in); } else if (res.isEvent()) { + ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto); data = decodeEventData(channel, in); } else { DecodeableRpcResult result; @@ -97,6 +98,7 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro } res.setResult(data); } else { + ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto); res.setErrorMessage(in.readUTF()); } } catch (Throwable t) { From 30c3c2f43190e736bf2564160509b36b3a21a8de Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Fri, 10 May 2019 14:19:52 +0800 Subject: [PATCH 4/6] Seperate Constants.java into some SubConstants Class - step 1 (#4017) see #3137 --- .../ConsistentHashLoadBalance.java | 13 +- .../org/apache/dubbo/common/Constants.java | 966 +++++++++--------- .../integration/RegistryProtocol.java | 3 +- .../remoting/transport/CodecSupport.java | 6 +- .../apache/dubbo/remoting/etcd/Constants.java | 31 + .../remoting/etcd/jetcd/JEtcdClient.java | 8 +- .../dubbo/common/serialize/Constants.java | 33 + .../serialize/avro/AvroSerialization.java | 5 +- .../fastjson/FastJsonSerialization.java | 5 +- .../serialize/fst/FstSerialization.java | 5 +- .../serialize/gson/GsonSerialization.java | 5 +- .../hessian2/Hessian2Serialization.java | 5 +- .../java/CompactedJavaSerialization.java | 5 +- .../serialize/java/JavaSerialization.java | 5 +- .../nativejava/NativeJavaSerialization.java | 5 +- .../serialize/kryo/KryoSerialization.java | 5 +- .../hessian/Hessian2Serialization.java | 4 +- .../support/GenericProtobufSerialization.java | 6 +- .../protostuff/ProtostuffSerialization.java | 5 +- .../serialize/avro/AvroSerializationTest.java | 4 +- 20 files changed, 608 insertions(+), 516 deletions(-) create mode 100644 dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java create mode 100644 dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Constants.java diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java index 03c0dc9173d..75ebc8a7682 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java @@ -31,15 +31,22 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import static org.apache.dubbo.common.Constants.HASH_ARGUMENTS; -import static org.apache.dubbo.common.Constants.HASH_NODES; - /** * ConsistentHashLoadBalance */ public class ConsistentHashLoadBalance extends AbstractLoadBalance { public static final String NAME = "consistenthash"; + /** + * Hash nodes name + */ + public static final String HASH_NODES = "hash.nodes"; + + /** + * Hash arguments name + */ + public static final String HASH_ARGUMENTS = "hash.arguments"; + private final ConcurrentMap> selectors = new ConcurrentHashMap>(); @SuppressWarnings("unchecked") diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java index 31d5fc73e31..42c9f39748f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java @@ -25,305 +25,256 @@ */ public class Constants { + // BEGIN common public static final String DUBBO = "dubbo"; public static final String PROVIDER = "provider"; public static final String CONSUMER = "consumer"; - public static final String REGISTER = "register"; - - public static final String UNREGISTER = "unregister"; - - public static final String SUBSCRIBE = "subscribe"; - - public static final String UNSUBSCRIBE = "unsubscribe"; + public static final String APPLICATION_KEY = "application"; - public static final String CATEGORY_KEY = "category"; + public static final String REMOTE_APPLICATION_KEY = "remote.application"; - public static final String PROVIDERS_CATEGORY = "providers"; + public static final String ENABLED_KEY = "enabled"; - public static final String CONSUMERS_CATEGORY = "consumers"; + public static final String DISABLED_KEY = "disabled"; - public static final String ROUTERS_CATEGORY = "routers"; + public static final String DUBBO_PROPERTIES_KEY = "dubbo.properties.file"; - public static final String DYNAMIC_ROUTERS_CATEGORY = "dynamicrouters"; + public static final String DEFAULT_DUBBO_PROPERTIES = "dubbo.properties"; - public static final String CONFIGURATORS_CATEGORY = "configurators"; + public static final String ANY_VALUE = "*"; - public static final String DYNAMIC_CONFIGURATORS_CATEGORY = "dynamicconfigurators"; - public static final String APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"; + public static final String COMMA_SEPARATOR = ","; - public static final String CONFIGURATORS_SUFFIX = ".configurators"; + public static final Pattern COMMA_SPLIT_PATTERN = Pattern.compile("\\s*[,]+\\s*"); - public static final String ROUTERS_SUFFIX = ".routers"; + public final static String PATH_SEPARATOR = "/"; - public static final String CONFIG_CLUSTER_KEY = "config.cluster"; - public static final String CONFIG_NAMESPACE_KEY = "config.namespace"; - public static final String CONFIG_GROUP_KEY = "config.group"; - public static final String CONFIG_CHECK_KEY = "config.check"; - public static final String CONFIG_CONFIGFILE_KEY = "config.config-file"; - public static final String CONFIG_ENABLE_KEY = "config.highest-priority"; - public static final String CONFIG_TIMEOUT_KEY = "config.timeout"; - public static final String CONFIG_APPNAME_KEY = "config.app-name"; + public final static String PROTOCOL_SEPARATOR = "://"; - public static final String DEFAULT_CATEGORY = PROVIDERS_CATEGORY; + public static final String REGISTRY_SEPARATOR = "|"; - public static final String ENABLED_KEY = "enabled"; + public static final Pattern REGISTRY_SPLIT_PATTERN = Pattern.compile("\\s*[|;]+\\s*"); - public static final String DISABLED_KEY = "disabled"; + public static final String SEMICOLON_SEPARATOR = ";"; - public static final String VALIDATION_KEY = "validation"; + public static final Pattern SEMICOLON_SPLIT_PATTERN = Pattern.compile("\\s*[;]+\\s*"); - public static final String CACHE_KEY = "cache"; + public static final String DEFAULT_PROXY = "javassist"; - public static final String DYNAMIC_KEY = "dynamic"; + public static final String DEFAULT_DIRECTORY = "dubbo"; - public static final String STATUS_KEY = "status"; + public static final String PROTOCOL_KEY = "protocol"; - public static final String CONTEXTPATH_KEY = "contextpath"; + public static final String DEFAULT_PROTOCOL = "dubbo"; - public static final String LISTENER_KEY = "listener"; + public static final String DEFAULT_THREAD_NAME = "Dubbo"; - public static final String LAYER_KEY = "layer"; + public static final int DEFAULT_CORE_THREADS = 0; - public static final String DUBBO_PROPERTIES_KEY = "dubbo.properties.file"; + public static final int DEFAULT_THREADS = 200; - public static final String DEFAULT_DUBBO_PROPERTIES = "dubbo.properties"; + public static final String THREADPOOL_KEY = "threadpool"; - public static final String SENT_KEY = "sent"; + public static final String THREAD_NAME_KEY = "threadname"; - public static final boolean DEFAULT_SENT = false; + public static final String CORE_THREADS_KEY = "corethreads"; - public static final String REGISTRY_PROTOCOL = "registry"; + public static final String THREADS_KEY = "threads"; - public static final String $INVOKE = "$invoke"; + public static final String QUEUES_KEY = "queues"; - public static final String $ECHO = "$echo"; + public static final String ALIVE_KEY = "alive"; - public static final int DEFAULT_IO_THREADS = Math.min(Runtime.getRuntime().availableProcessors() + 1, 32); + public static final String DEFAULT_THREADPOOL = "limited"; - public static final String DEFAULT_PROXY = "javassist"; + public static final String DEFAULT_CLIENT_THREADPOOL = "cached"; - /** - * 8M - */ - public static final int DEFAULT_PAYLOAD = 8 * 1024 * 1024; + public static final String IO_THREADS_KEY = "iothreads"; - public static final String DEFAULT_CLUSTER = "failover"; + public static final int DEFAULT_QUEUES = 0; - public static final String DEFAULT_DIRECTORY = "dubbo"; + public static final int DEFAULT_ALIVE = 60 * 1000; - public static final String DEFAULT_LOADBALANCE = "random"; + public static final String TIMEOUT_KEY = "timeout"; - public static final String DEFAULT_PROTOCOL = "dubbo"; + public static final int DEFAULT_TIMEOUT = 1000; - public static final String DEFAULT_EXCHANGER = "header"; + public static final String REMOVE_VALUE_PREFIX = "-"; - public static final String DEFAULT_TRANSPORTER = "netty"; + public static final String PROPERTIES_CHAR_SEPERATOR = "-"; + + public static final String GROUP_CHAR_SEPERATOR = ":"; - public static final String DEFAULT_REMOTING_SERVER = "netty"; + public static final String HIDE_KEY_PREFIX = "."; + + public static final String DEFAULT_KEY_PREFIX = "default."; - public static final String DEFAULT_REMOTING_CLIENT = "netty"; + public static final String DEFAULT_KEY = "default"; - public static final String DEFAULT_REMOTING_CODEC = "dubbo"; - public static final String DEFAULT_REMOTING_SERIALIZATION = "hessian2"; + /** + * Default timeout value in milliseconds for server shutdown + */ + public static final int DEFAULT_SERVER_SHUTDOWN_TIMEOUT = 10000; - public static final String DEFAULT_HTTP_SERVER = "servlet"; + public static final String SIDE_KEY = "side"; - public static final String DEFAULT_HTTP_CLIENT = "jdk"; + public static final String PROVIDER_SIDE = "provider"; - public static final String DEFAULT_HTTP_SERIALIZATION = "json"; + public static final String CONSUMER_SIDE = "consumer"; - public static final String DEFAULT_CHARSET = "UTF-8"; + public static final String ANYHOST_KEY = "anyhost"; - public static final int DEFAULT_WEIGHT = 100; + public static final String ANYHOST_VALUE = "0.0.0.0"; - public static final int DEFAULT_FORKS = 2; + public static final String LOCALHOST_KEY = "localhost"; - public static final String DEFAULT_THREAD_NAME = "Dubbo"; + public static final String LOCALHOST_VALUE = "127.0.0.1"; - public static final int DEFAULT_CORE_THREADS = 0; + public static final String METHODS_KEY = "methods"; - public static final int DEFAULT_THREADS = 200; + public static final String METHOD_KEY = "method"; - public static final boolean DEFAULT_KEEP_ALIVE = true; + public static final String PID_KEY = "pid"; - public static final int DEFAULT_QUEUES = 0; + public static final String TIMESTAMP_KEY = "timestamp"; - public static final int DEFAULT_ALIVE = 60 * 1000; + public static final String GROUP_KEY = "group"; - /** - * By default, a consumer JVM instance and a provider JVM instance share a long TCP connection (except when connections are set), - * which can set the number of long TCP connections shared to avoid the bottleneck of sharing a single long TCP connection. - */ - public static final String DEFAULT_SHARE_CONNECTIONS = "1"; + public static final String PATH_KEY = "path"; - public static final String SHARE_CONNECTIONS_KEY = "shareconnections"; + public static final String INTERFACE_KEY = "interface"; - public static final int DEFAULT_ACCEPTS = 0; + public static final String FILE_KEY = "file"; - public static final int DEFAULT_IDLE_TIMEOUT = 600 * 1000; + public static final String DUMP_DIRECTORY = "dump.directory"; - public static final int DEFAULT_HEARTBEAT = 60 * 1000; + public static final String CLASSIFIER_KEY = "classifier"; - public static final int DEFAULT_TIMEOUT = 1000; + public static final String VERSION_KEY = "version"; - public static final int DEFAULT_CONNECT_TIMEOUT = 3000; + public static final String REVISION_KEY = "revision"; /** - * public static final int DEFAULT_REGISTRY_CONNECT_TIMEOUT = 5000; + * package version in the manifest */ - public static final int DEFAULT_RETRIES = 2; + public static final String RELEASE_KEY = "release"; - public static final int DEFAULT_FAILBACK_TASKS = 100; + public static final int MAX_PROXY_COUNT = 65535; + // END common - public static final int DEFAULT_FAILBACK_TIMES = 3; + // BEGIN dubbo-remoting-api + public static final String PAYLOAD_KEY = "payload"; + /** + * 8M + */ + public static final int DEFAULT_PAYLOAD = 8 * 1024 * 1024; - public static final int MAX_PROXY_COUNT = 65535; + public static final String BUFFER_KEY = "buffer"; /** * default buffer size is 8k. */ public static final int DEFAULT_BUFFER_SIZE = 8 * 1024; - public static final Integer DEFAULT_METADATA_REPORT_RETRY_TIMES = 100; - public static final Integer DEFAULT_METADATA_REPORT_RETRY_PERIOD = 3000; - public static final Boolean DEFAULT_METADATA_REPORT_CYCLE_REPORT = true; - public static final int MAX_BUFFER_SIZE = 16 * 1024; public static final int MIN_BUFFER_SIZE = 1 * 1024; - public static final String REMOVE_VALUE_PREFIX = "-"; + public static final String CONNECT_TIMEOUT_KEY = "connect.timeout"; - public static final String PROPERTIES_CHAR_SEPERATOR = "-"; + public static final int DEFAULT_CONNECT_TIMEOUT = 3000; - public static final String GROUP_CHAR_SEPERATOR = ":"; + public static final String HEARTBEAT_KEY = "heartbeat"; - public static final String HIDE_KEY_PREFIX = "."; + public static final int DEFAULT_HEARTBEAT = 60 * 1000; - public static final String DEFAULT_KEY_PREFIX = "default."; + public static final String IDLE_TIMEOUT_KEY = "idle.timeout"; - public static final String DEFAULT_KEY = "default"; + public static final int DEFAULT_IDLE_TIMEOUT = 600 * 1000; - public static final String LOADBALANCE_KEY = "loadbalance"; + public static final String ACCEPTS_KEY = "accepts"; - /** - * key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME - */ - public static final String ROUTER_KEY = "router"; + public static final int DEFAULT_ACCEPTS = 0; - public static final String CLUSTER_KEY = "cluster"; + public static final String SERIALIZATION_KEY = "serialization"; - public static final String REGISTRY_KEY = "registry"; + public static final String DEFAULT_REMOTING_SERIALIZATION = "hessian2"; - public static final String METADATA_REPORT_KEY = "metadata"; + public static final String CODEC_KEY = "codec"; - public static final String MONITOR_KEY = "monitor"; + public static final String DEFAULT_REMOTING_CODEC = "dubbo"; - public static final String SIDE_KEY = "side"; + public static final String SERVER_KEY = "server"; - public static final String PROVIDER_SIDE = "provider"; + public static final String DEFAULT_REMOTING_SERVER = "netty"; - public static final String CONSUMER_SIDE = "consumer"; + public static final String CLIENT_KEY = "client"; - public static final String DEFAULT_REGISTRY = "dubbo"; + public static final String DEFAULT_REMOTING_CLIENT = "netty"; - public static final String BACKUP_KEY = "backup"; + public static final String TRANSPORTER_KEY = "transporter"; - public static final String DIRECTORY_KEY = "directory"; + public static final String DEFAULT_TRANSPORTER = "netty"; - public static final String DEPRECATED_KEY = "deprecated"; + public static final String EXCHANGER_KEY = "exchanger"; - public static final String ANYHOST_KEY = "anyhost"; + public static final String DEFAULT_EXCHANGER = "header"; - public static final String ANYHOST_VALUE = "0.0.0.0"; + public static final String DISPACTHER_KEY = "dispacther"; - public static final String LOCALHOST_KEY = "localhost"; + public static final int DEFAULT_IO_THREADS = Math.min(Runtime.getRuntime().availableProcessors() + 1, 32); - public static final String LOCALHOST_VALUE = "127.0.0.1"; + public static final String BIND_IP_KEY = "bind.ip"; - public static final String APPLICATION_KEY = "application"; + public static final String BIND_PORT_KEY = "bind.port"; - public static final String REMOTE_APPLICATION_KEY = "remote.application"; + public static final String SENT_KEY = "sent"; - public static final String LOCAL_KEY = "local"; + public static final boolean DEFAULT_SENT = false; - public static final String STUB_KEY = "stub"; + public static final String DISPATCHER_KEY = "dispatcher"; - public static final String MOCK_KEY = "mock"; + public static final String CHANNEL_HANDLER_KEY = "channel.handler"; - public static final String PROTOCOL_KEY = "protocol"; + public static final String DEFAULT_CHANNEL_HANDLER = "default"; - public static final String LOGSTAT_PROTOCOL = "logstat"; + public static final String SERVICE_DESCIPTOR_KEY = "serviceDescriptor"; - public static final String DUBBO_PROTOCOL = DUBBO; + public static final String CONNECT_QUEUE_CAPACITY = "connect.queue.capacity"; - public static final String ZOOKEEPER_PROTOCOL = "zookeeper"; + public static final String CONNECT_QUEUE_WARNING_SIZE = "connect.queue.warning.size"; - public static final String PROXY_KEY = "proxy"; + public static final int DEFAULT_CONNECT_QUEUE_WARNING_SIZE = 1000; - public static final String WEIGHT_KEY = "weight"; + public static final String CHANNEL_ATTRIBUTE_READONLY_KEY = "channel.readonly"; - public static final String FORKS_KEY = "forks"; + public static final String CHANNEL_READONLYEVENT_SENT_KEY = "channel.readonly.sent"; - public static final String DEFAULT_THREADPOOL = "limited"; + public static final String CHANNEL_SEND_READONLYEVENT_KEY = "channel.readonly.send"; - public static final String DEFAULT_CLIENT_THREADPOOL = "cached"; + public static final String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName(); - public static final String THREADPOOL_KEY = "threadpool"; + public static final String CHARSET_KEY = "charset"; - public static final String THREAD_NAME_KEY = "threadname"; + public static final String DEFAULT_CHARSET = "UTF-8"; - public static final String IO_THREADS_KEY = "iothreads"; + public static final String BACKUP_KEY = "backup"; - public static final String CORE_THREADS_KEY = "corethreads"; + /** + * Every heartbeat duration / HEATBEAT_CHECK_TICK, check if a heartbeat should be sent. Every heartbeat timeout + * duration / HEATBEAT_CHECK_TICK, check if a connection should be closed on server side, and if reconnect on + * client side + */ + public static final int HEARTBEAT_CHECK_TICK = 3; - public static final String THREADS_KEY = "threads"; - - public static final String QUEUES_KEY = "queues"; - - public static final String ALIVE_KEY = "alive"; - - public static final String EXECUTES_KEY = "executes"; - - public static final String BUFFER_KEY = "buffer"; - - public static final String PAYLOAD_KEY = "payload"; - - public static final String REFERENCE_FILTER_KEY = "reference.filter"; - - public static final String INVOKER_LISTENER_KEY = "invoker.listener"; - - public static final String SERVICE_FILTER_KEY = "service.filter"; - - public static final String EXPORTER_LISTENER_KEY = "exporter.listener"; - - public static final String ACCESS_LOG_KEY = "accesslog"; - - public static final String ACTIVES_KEY = "actives"; - - public static final String CONNECTIONS_KEY = "connections"; - - public static final String ACCEPTS_KEY = "accepts"; - - public static final String IDLE_TIMEOUT_KEY = "idle.timeout"; - - public static final String HEARTBEAT_KEY = "heartbeat"; - - /** - * Every heartbeat duration / HEATBEAT_CHECK_TICK, check if a heartbeat should be sent. Every heartbeat timeout - * duration / HEATBEAT_CHECK_TICK, check if a connection should be closed on server side, and if reconnect on - * client side - */ - public static final int HEARTBEAT_CHECK_TICK = 3; - - /** - * the least heartbeat during is 1000 ms. - */ - public static final long LEAST_HEARTBEAT_DURATION = 1000; + /** + * the least heartbeat during is 1000 ms. + */ + public static final long LEAST_HEARTBEAT_DURATION = 1000; /** * ticks per wheel. @@ -332,272 +283,304 @@ public class Constants { public static final String HEARTBEAT_TIMEOUT_KEY = "heartbeat.timeout"; - public static final String CONNECT_TIMEOUT_KEY = "connect.timeout"; + public static final String RECONNECT_KEY = "reconnect"; - public static final String TIMEOUT_KEY = "timeout"; + public static final int DEFAULT_RECONNECT_PERIOD = 2000; - public static final String RETRIES_KEY = "retries"; + public static final String SEND_RECONNECT_KEY = "send.reconnect"; - public static final String FAIL_BACK_TASKS_KEY = "failbacktasks"; + public static final String CHECK_KEY = "check"; public static final String PROMPT_KEY = "prompt"; public static final String DEFAULT_PROMPT = "dubbo>"; + // END dubbo-remoting-api - public static final String CODEC_KEY = "codec"; - - public static final String SERIALIZATION_KEY = "serialization"; - - public static final String EXTENSION_KEY = "extension"; - - public static final String KEEP_ALIVE_KEY = "keepalive"; - - public static final String OPTIMIZER_KEY = "optimizer"; + // BEGIN dubbo-rpc-hessian + public static final String HESSIAN2_REQUEST_KEY = "hessian2.request"; - public static final String EXCHANGER_KEY = "exchanger"; + public static final boolean DEFAULT_HESSIAN2_REQUEST = false; - public static final String DISPACTHER_KEY = "dispacther"; + public static final String HESSIAN_OVERLOAD_METHOD_KEY = "hessian.overload.method"; - public static final String TRANSPORTER_KEY = "transporter"; + public static final boolean DEFAULT_HESSIAN_OVERLOAD_METHOD = false; - public static final String SERVER_KEY = "server"; + public static final String DEFAULT_HTTP_CLIENT = "jdk"; - public static final String CLIENT_KEY = "client"; + public static final String DEFAULT_HTTP_SERVER = "servlet"; - public static final String ID_KEY = "id"; + public static final String DEFAULT_HTTP_SERIALIZATION = "json"; + // END dubbo-rpc-hessian - public static final String ASYNC_KEY = "async"; + // BEGIN dubbo-rpc-dubbo + public static final String SHARE_CONNECTIONS_KEY = "shareconnections"; - public static final String FUTURE_GENERATED_KEY = "future_generated"; - public static final String FUTURE_RETURNTYPE_KEY = "future_returntype"; + /** + * By default, a consumer JVM instance and a provider JVM instance share a long TCP connection (except when connections are set), + * which can set the number of long TCP connections shared to avoid the bottleneck of sharing a single long TCP connection. + */ + public static final String DEFAULT_SHARE_CONNECTIONS = "1"; - public static final String ASYNC_SUFFIX = "Async"; + public static final String INPUT_KEY = "input"; - public static final String RETURN_KEY = "return"; + public static final String OUTPUT_KEY = "output"; - public static final String TOKEN_KEY = "token"; + public static final String DECODE_IN_IO_THREAD_KEY = "decode.in.io"; - public static final String METHOD_KEY = "method"; + public static final boolean DEFAULT_DECODE_IN_IO_THREAD = true; - public static final String METHODS_KEY = "methods"; + /** + * callback inst id + */ + public static final String CALLBACK_SERVICE_KEY = "callback.service.instid"; - public static final String CHARSET_KEY = "charset"; + /** + * The limit of callback service instances for one interface on every client + */ + public static final String CALLBACK_INSTANCES_LIMIT_KEY = "callbacks"; - public static final String RECONNECT_KEY = "reconnect"; + /** + * The default limit number for callback service instances + * + * @see #CALLBACK_INSTANCES_LIMIT_KEY + */ + public static final int DEFAULT_CALLBACK_INSTANCES = 1; - public static final String SEND_RECONNECT_KEY = "send.reconnect"; + public static final String CALLBACK_SERVICE_PROXY_KEY = "callback.service.proxy"; - public static final int DEFAULT_RECONNECT_PERIOD = 2000; + public static final String IS_CALLBACK_SERVICE = "is_callback_service"; - public static final String SHUTDOWN_TIMEOUT_KEY = "shutdown.timeout"; + /** + * Invokers in channel's callback + */ + public static final String CHANNEL_CALLBACK_KEY = "channel.callback.invokers.key"; - public static final int DEFAULT_SHUTDOWN_TIMEOUT = 1000 * 60 * 15; + /** + * The initial state for lazy connection + */ + public static final String LAZY_CONNECT_INITIAL_STATE_KEY = "connect.lazy.initial.state"; - public static final String PID_KEY = "pid"; + /** + * The default value of lazy connection's initial state: true + * + * @see #LAZY_CONNECT_INITIAL_STATE_KEY + */ + public static final boolean DEFAULT_LAZY_CONNECT_INITIAL_STATE = true; - public static final String TIMESTAMP_KEY = "timestamp"; + public static final String OPTIMIZER_KEY = "optimizer"; + // END dubbo-rpc-dubbo - public static final String REMOTE_TIMESTAMP_KEY = "remote.timestamp"; - public static final String WARMUP_KEY = "warmup"; + // BEGIN dubbo-rpc-api + public static final String DUBBO_VERSION_KEY = "dubbo"; - public static final int DEFAULT_WARMUP = 10 * 60 * 1000; + public static final String LOCAL_KEY = "local"; - public static final String CHECK_KEY = "check"; + public static final String STUB_KEY = "stub"; - public static final String REGISTER_KEY = "register"; + public static final String MOCK_KEY = "mock"; - public static final String SUBSCRIBE_KEY = "subscribe"; + public static final String DEPRECATED_KEY = "deprecated"; - public static final String GROUP_KEY = "group"; + public static final String $INVOKE = "$invoke"; - public static final String PATH_KEY = "path"; + public static final String $ECHO = "$echo"; - public static final String INTERFACE_KEY = "interface"; + public static final String RETURN_PREFIX = "return "; - public static final String INTERFACES = "interfaces"; + public static final String THROW_PREFIX = "throw"; - public static final String GENERIC_KEY = "generic"; + public static final String FAIL_PREFIX = "fail:"; - public static final String FILE_KEY = "file"; + public static final String FORCE_PREFIX = "force:"; - public static final String DUMP_DIRECTORY = "dump.directory"; + public static final String MERGER_KEY = "merger"; - public static final String WAIT_KEY = "wait"; + public static final String IS_SERVER_KEY = "isserver"; - public static final String CLASSIFIER_KEY = "classifier"; + public static final String FORCE_USE_TAG = "dubbo.force.tag"; - public static final String VERSION_KEY = "version"; + public static final String GENERIC_SERIALIZATION_NATIVE_JAVA = "nativejava"; - public static final String REVISION_KEY = "revision"; + public static final String GENERIC_SERIALIZATION_DEFAULT = "true"; - public static final String DUBBO_VERSION_KEY = "dubbo"; + public static final String GENERIC_SERIALIZATION_BEAN = "bean"; - public static final String HESSIAN_VERSION_KEY = "hessian.version"; + public static final String GENERIC_SERIALIZATION_PROTOBUF = "protobuf-json"; - public static final String DISPATCHER_KEY = "dispatcher"; + public static final String TPS_LIMIT_RATE_KEY = "tps"; - public static final String CHANNEL_HANDLER_KEY = "channel.handler"; + public static final String TPS_LIMIT_INTERVAL_KEY = "tps.interval"; - public static final String DEFAULT_CHANNEL_HANDLER = "default"; + public static final long DEFAULT_TPS_LIMIT_INTERVAL = 60 * 1000; - public static final String SERVICE_DESCIPTOR_KEY = "serviceDescriptor"; + public static final String AUTO_ATTACH_INVOCATIONID_KEY = "invocationid.autoattach"; - public static final String ANY_VALUE = "*"; + public static final String STUB_EVENT_KEY = "dubbo.stub.event"; - public static final String COMMA_SEPARATOR = ","; + public static final boolean DEFAULT_STUB_EVENT = false; - public static final Pattern COMMA_SPLIT_PATTERN = Pattern - .compile("\\s*[,]+\\s*"); + public static final String STUB_EVENT_METHODS_KEY = "dubbo.stub.event.methods"; - public final static String PATH_SEPARATOR = "/"; + public static final String PROXY_KEY = "proxy"; - public final static String PROTOCOL_SEPARATOR = "://"; + public static final String EXECUTES_KEY = "executes"; - public static final String REGISTRY_SEPARATOR = "|"; + public static final String REFERENCE_FILTER_KEY = "reference.filter"; - public static final Pattern REGISTRY_SPLIT_PATTERN = Pattern - .compile("\\s*[|;]+\\s*"); + public static final String INVOKER_LISTENER_KEY = "invoker.listener"; - public static final String SEMICOLON_SEPARATOR = ";"; + public static final String SERVICE_FILTER_KEY = "service.filter"; - public static final Pattern SEMICOLON_SPLIT_PATTERN = Pattern - .compile("\\s*[;]+\\s*"); + public static final String EXPORTER_LISTENER_KEY = "exporter.listener"; - public static final String CONNECT_QUEUE_CAPACITY = "connect.queue.capacity"; + public static final String ACCESS_LOG_KEY = "accesslog"; - public static final String CONNECT_QUEUE_WARNING_SIZE = "connect.queue.warning.size"; + public static final String ACTIVES_KEY = "actives"; - public static final int DEFAULT_CONNECT_QUEUE_WARNING_SIZE = 1000; + public static final String CONNECTIONS_KEY = "connections"; - public static final String CHANNEL_ATTRIBUTE_READONLY_KEY = "channel.readonly"; + public static final String ID_KEY = "id"; - public static final String CHANNEL_READONLYEVENT_SENT_KEY = "channel.readonly.sent"; + public static final String ASYNC_KEY = "async"; - public static final String CHANNEL_SEND_READONLYEVENT_KEY = "channel.readonly.send"; + public static final String FUTURE_GENERATED_KEY = "future_generated"; - public static final String COUNT_PROTOCOL = "count"; + public static final String FUTURE_RETURNTYPE_KEY = "future_returntype"; - public static final String TRACE_PROTOCOL = "trace"; + public static final String RETURN_KEY = "return"; - public static final String EMPTY_PROTOCOL = "empty"; + public static final String TOKEN_KEY = "token"; - public static final String ADMIN_PROTOCOL = "admin"; + public static final String INTERFACES = "interfaces"; - public static final String PROVIDER_PROTOCOL = "provider"; + public static final String GENERIC_KEY = "generic"; - public static final String CONSUMER_PROTOCOL = "consumer"; + public static final String LOCAL_PROTOCOL = "injvm"; + // END dubbo-rpc-api - public static final String ROUTE_PROTOCOL = "route"; - public static final String SCRIPT_PROTOCOL = "script"; + // BEGIN dubbo-rpc-rest + public static final String KEEP_ALIVE_KEY = "keepalive"; - public static final String CONDITION_PROTOCOL = "condition"; + public static final boolean DEFAULT_KEEP_ALIVE = true; - public static final String MOCK_PROTOCOL = "mock"; + public static final String EXTENSION_KEY = "extension"; + // END dubbo-rpc-rest - public static final String RETURN_PREFIX = "return "; - public static final String THROW_PREFIX = "throw"; + // BEGIN dubbo-config-api + public static final String CLUSTER_KEY = "cluster"; - public static final String FAIL_PREFIX = "fail:"; + public static final String STATUS_KEY = "status"; - public static final String FORCE_PREFIX = "force:"; + public static final String CONTEXTPATH_KEY = "contextpath"; - public static final String FORCE_KEY = "force"; + public static final String LISTENER_KEY = "listener"; - public static final String MERGER_KEY = "merger"; + public static final String LAYER_KEY = "layer"; /** - * simple the registry for provider. - * - * @since 2.7.0 + * General */ - public static final String SIMPLIFIED_KEY = "simplified"; - /** - * After simplify the registry, should add some paramter individually for provider. - * - * @since 2.7.0 + * Application name; */ - public static final String EXTRA_KEYS_KEY = "extra-keys"; + public static final String NAME = "name"; /** - * To decide whether to exclude unavailable invoker from the cluster + * Application owner name; */ - public static final String CLUSTER_AVAILABLE_CHECK_KEY = "cluster.availablecheck"; + public static final String OWNER = "owner"; /** - * The default value of cluster.availablecheck - * - * @see #CLUSTER_AVAILABLE_CHECK_KEY + * Running application organization name. */ - public static final boolean DEFAULT_CLUSTER_AVAILABLE_CHECK = true; + public static final String ORGANIZATION = "organization"; /** - * To decide whether to enable sticky strategy for cluster + * Application architecture name. */ - public static final String CLUSTER_STICKY_KEY = "sticky"; + public static final String ARCHITECTURE = "architecture"; /** - * The default value of sticky - * - * @see #CLUSTER_STICKY_KEY + * Environment name */ - public static final boolean DEFAULT_CLUSTER_STICKY = false; + public static final String ENVIRONMENT = "environment"; /** - * To decide whether to make connection when the client is created + * Test environment key. */ - public static final String LAZY_CONNECT_KEY = "lazy"; + public static final String TEST_ENVIRONMENT = "test"; /** - * The initial state for lazy connection + * Development environment key. */ - public static final String LAZY_CONNECT_INITIAL_STATE_KEY = "connect.lazy.initial.state"; + public static final String DEVELOPMENT_ENVIRONMENT = "develop"; /** - * The default value of lazy connection's initial state: true - * - * @see #LAZY_CONNECT_INITIAL_STATE_KEY + * Production environment key. */ - public static final boolean DEFAULT_LAZY_CONNECT_INITIAL_STATE = true; + public static final String PRODUCTION_ENVIRONMENT = "product"; - /** - * To decide whether register center saves file synchronously, the default value is asynchronously - */ - public static final String REGISTRY_FILESAVE_SYNC_KEY = "save.file"; + public static final String CONFIG_CLUSTER_KEY = "config.cluster"; + public static final String CONFIG_NAMESPACE_KEY = "config.namespace"; + public static final String CONFIG_GROUP_KEY = "config.group"; + public static final String CONFIG_CHECK_KEY = "config.check"; - /** - * Period of registry center's retry interval - */ - public static final String REGISTRY_RETRY_PERIOD_KEY = "retry.period"; + public static final String CONFIG_CONFIGFILE_KEY = "config.config-file"; + public static final String CONFIG_ENABLE_KEY = "config.highest-priority"; + public static final String CONFIG_TIMEOUT_KEY = "config.timeout"; + public static final String CONFIG_APPNAME_KEY = "config.app-name"; - /** - * Most retry times - */ - public static final String REGISTRY_RETRY_TIMES_KEY = "retry.times"; + public static final String USERNAME_KEY = "username"; - /** - * Default value for the period of retry interval in milliseconds: 5000 - */ - public static final int DEFAULT_REGISTRY_RETRY_PERIOD = 5 * 1000; + public static final String PASSWORD_KEY = "password"; - /** - * Default value for the times of retry: 3 - */ - public static final int DEFAULT_REGISTRY_RETRY_TIMES = 3; + public static final String HOST_KEY = "host"; - /** - * Reconnection period in milliseconds for register center - */ - public static final String REGISTRY_RECONNECT_PERIOD_KEY = "reconnect.period"; + public static final String PORT_KEY = "port"; - public static final int DEFAULT_REGISTRY_RECONNECT_PERIOD = 3 * 1000; + public static final String MULTICAST = "multicast"; - public static final String SESSION_TIMEOUT_KEY = "session"; + public static final String REGISTER_IP_KEY = "register.ip"; - public static final int DEFAULT_SESSION_TIMEOUT = 60 * 1000; + public static final String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY"; + + public static final String DUBBO_PORT_TO_REGISTRY = "DUBBO_PORT_TO_REGISTRY"; + + public static final String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND"; + + public static final String DUBBO_PORT_TO_BIND = "DUBBO_PORT_TO_BIND"; + + public static final String SCOPE_KEY = "scope"; + + public static final String SCOPE_LOCAL = "local"; + + public static final String SCOPE_REMOTE = "remote"; + + public static final String SCOPE_NONE = "none"; + + public static final String ON_CONNECT_KEY = "onconnect"; + + public static final String ON_DISCONNECT_KEY = "ondisconnect"; + + public static final String ON_INVOKE_METHOD_KEY = "oninvoke.method"; + + public static final String ON_RETURN_METHOD_KEY = "onreturn.method"; + + public static final String ON_THROW_METHOD_KEY = "onthrow.method"; + + public static final String ON_INVOKE_INSTANCE_KEY = "oninvoke.instance"; + + public static final String ON_RETURN_INSTANCE_KEY = "onreturn.instance"; + + public static final String ON_THROW_INSTANCE_KEY = "onthrow.instance"; + + @Deprecated + public static final String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds"; + + public static final String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait"; /** * The key name for export URL in register center @@ -610,263 +593,248 @@ public class Constants { public static final String REFER_KEY = "refer"; /** - * callback inst id + * To decide whether to make connection when the client is created */ - public static final String CALLBACK_SERVICE_KEY = "callback.service.instid"; + public static final String LAZY_CONNECT_KEY = "lazy"; - /** - * The limit of callback service instances for one interface on every client - */ - public static final String CALLBACK_INSTANCES_LIMIT_KEY = "callbacks"; + public static final String DUBBO_PROTOCOL = DUBBO; - /** - * The default limit number for callback service instances - * - * @see #CALLBACK_INSTANCES_LIMIT_KEY - */ - public static final int DEFAULT_CALLBACK_INSTANCES = 1; + public static final String ZOOKEEPER_PROTOCOL = "zookeeper"; - public static final String CALLBACK_SERVICE_PROXY_KEY = "callback.service.proxy"; + // FIXME: is this still useful? + public static final String SHUTDOWN_TIMEOUT_KEY = "shutdown.timeout"; - public static final String IS_CALLBACK_SERVICE = "is_callback_service"; + public static final int DEFAULT_SHUTDOWN_TIMEOUT = 1000 * 60 * 15; - /** - * Invokers in channel's callback - */ - public static final String CHANNEL_CALLBACK_KEY = "channel.callback.invokers.key"; + public static final String PROTOCOLS_SUFFIX = "dubbo.protocols."; - @Deprecated - public static final String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds"; + public static final String PROTOCOL_SUFFIX = "dubbo.protocol."; - public static final String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait"; + public static final String REGISTRIES_SUFFIX = "dubbo.registries."; - public static final String IS_SERVER_KEY = "isserver"; + public static final String TELNET = "telnet"; - /** - * Default timeout value in milliseconds for server shutdown - */ - public static final int DEFAULT_SERVER_SHUTDOWN_TIMEOUT = 10000; + public static final String QOS_ENABLE = "qos.enable"; - public static final String ON_CONNECT_KEY = "onconnect"; + public static final String QOS_PORT = "qos.port"; + + public static final String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip"; + // END dubbo-congfig-api + + // BEGIN dubbo-cluster + /** + * key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME + */ + public static final String ROUTER_KEY = "router"; - public static final String ON_DISCONNECT_KEY = "ondisconnect"; + public static final String LOADBALANCE_KEY = "loadbalance"; - public static final String ON_INVOKE_METHOD_KEY = "oninvoke.method"; + public static final String DEFAULT_LOADBALANCE = "random"; - public static final String ON_RETURN_METHOD_KEY = "onreturn.method"; + public static final String FAIL_BACK_TASKS_KEY = "failbacktasks"; - public static final String ON_THROW_METHOD_KEY = "onthrow.method"; + public static final int DEFAULT_FAILBACK_TASKS = 100; - public static final String ON_INVOKE_INSTANCE_KEY = "oninvoke.instance"; + public static final String RETRIES_KEY = "retries"; - public static final String ON_RETURN_INSTANCE_KEY = "onreturn.instance"; + public static final int DEFAULT_RETRIES = 2; - public static final String ON_THROW_INSTANCE_KEY = "onthrow.instance"; + public static final int DEFAULT_FAILBACK_TIMES = 3; - public static final String OVERRIDE_PROTOCOL = "override"; + public static final String FORKS_KEY = "forks"; - public static final String CONFIG_PROTOCOL = "config"; + public static final int DEFAULT_FORKS = 2; - public static final String PRIORITY_KEY = "priority"; + public static final String WEIGHT_KEY = "weight"; - public static final String RULE_KEY = "rule"; + public static final int DEFAULT_WEIGHT = 100; - public static final String TYPE_KEY = "type"; + public static final String MOCK_PROTOCOL = "mock"; - public static final String RUNTIME_KEY = "runtime"; + public static final String FORCE_KEY = "force"; /** - * when ROUTER_KEY's value is set to ROUTER_TYPE_CLEAR, RegistryDirectory will clean all current routers + * To decide whether to exclude unavailable invoker from the cluster */ - public static final String ROUTER_TYPE_CLEAR = "clean"; + public static final String CLUSTER_AVAILABLE_CHECK_KEY = "cluster.availablecheck"; - public static final String DEFAULT_SCRIPT_TYPE_KEY = "javascript"; + /** + * The default value of cluster.availablecheck + * + * @see #CLUSTER_AVAILABLE_CHECK_KEY + */ + public static final boolean DEFAULT_CLUSTER_AVAILABLE_CHECK = true; - public static final String STUB_EVENT_KEY = "dubbo.stub.event"; + /** + * To decide whether to enable sticky strategy for cluster + */ + public static final String CLUSTER_STICKY_KEY = "sticky"; - public static final boolean DEFAULT_STUB_EVENT = false; + /** + * The default value of sticky + * + * @see #CLUSTER_STICKY_KEY + */ + public static final boolean DEFAULT_CLUSTER_STICKY = false; - public static final String STUB_EVENT_METHODS_KEY = "dubbo.stub.event.methods"; + public static final String ADDRESS_KEY = "address"; /** * When this attribute appears in invocation's attachment, mock invoker will be used */ public static final String INVOCATION_NEED_MOCK = "invocation.need.mock"; - public static final String LOCAL_PROTOCOL = "injvm"; - - public static final String AUTO_ATTACH_INVOCATIONID_KEY = "invocationid.autoattach"; - - public static final String SCOPE_KEY = "scope"; - - public static final String SCOPE_LOCAL = "local"; - - public static final String SCOPE_REMOTE = "remote"; - - public static final String SCOPE_NONE = "none"; + /** + * when ROUTER_KEY's value is set to ROUTER_TYPE_CLEAR, RegistryDirectory will clean all current routers + */ + public static final String ROUTER_TYPE_CLEAR = "clean"; - public static final String RELIABLE_PROTOCOL = "napoli"; + public static final String DEFAULT_SCRIPT_TYPE_KEY = "javascript"; - public static final String TPS_LIMIT_RATE_KEY = "tps"; + public static final String PRIORITY_KEY = "priority"; - public static final String TPS_LIMIT_INTERVAL_KEY = "tps.interval"; + public static final String RULE_KEY = "rule"; - public static final long DEFAULT_TPS_LIMIT_INTERVAL = 60 * 1000; + public static final String TYPE_KEY = "type"; - public static final String DECODE_IN_IO_THREAD_KEY = "decode.in.io"; + public static final String RUNTIME_KEY = "runtime"; - public static final boolean DEFAULT_DECODE_IN_IO_THREAD = true; + public static final String TAG_KEY = "dubbo.tag"; - public static final String INPUT_KEY = "input"; + public static final String REMOTE_TIMESTAMP_KEY = "remote.timestamp"; - public static final String OUTPUT_KEY = "output"; + public static final String WARMUP_KEY = "warmup"; - public static final String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName(); + public static final int DEFAULT_WARMUP = 10 * 60 * 1000; - public static final String GENERIC_SERIALIZATION_NATIVE_JAVA = "nativejava"; + public static final String CONFIG_VERSION_KEY = "configVersion"; - public static final String GENERIC_SERIALIZATION_DEFAULT = "true"; + public static final String OVERRIDE_PROVIDERS_KEY = "providerAddresses"; + // END dubbo-cluster - public static final String GENERIC_SERIALIZATION_BEAN = "bean"; + // BEGIN dubbo-registry-api + public static final String REGISTER_KEY = "register"; - public static final String GENERIC_SERIALIZATION_PROTOBUF = "protobuf-json"; + public static final String SUBSCRIBE_KEY = "subscribe"; - public static final String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY"; + public static final String REGISTRY_KEY = "registry"; - public static final String DUBBO_PORT_TO_REGISTRY = "DUBBO_PORT_TO_REGISTRY"; + public static final String DEFAULT_REGISTRY = "dubbo"; - public static final String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND"; + public static final String REGISTRY_PROTOCOL = "registry"; - public static final String DUBBO_PORT_TO_BIND = "DUBBO_PORT_TO_BIND"; + public static final String DYNAMIC_KEY = "dynamic"; - public static final String BIND_IP_KEY = "bind.ip"; + public static final String REGISTER = "register"; - public static final String BIND_PORT_KEY = "bind.port"; + public static final String UNREGISTER = "unregister"; - public static final String REGISTER_IP_KEY = "register.ip"; + public static final String SUBSCRIBE = "subscribe"; - public static final String QOS_ENABLE = "qos.enable"; + public static final String UNSUBSCRIBE = "unsubscribe"; - public static final String QOS_PORT = "qos.port"; + public static final String CATEGORY_KEY = "category"; - public static final String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip"; + public static final String PROVIDERS_CATEGORY = "providers"; - public static final String HESSIAN2_REQUEST_KEY = "hessian2.request"; + public static final String CONSUMERS_CATEGORY = "consumers"; - public static final boolean DEFAULT_HESSIAN2_REQUEST = false; + public static final String ROUTERS_CATEGORY = "routers"; - public static final String HESSIAN_OVERLOAD_METHOD_KEY = "hessian.overload.method"; + public static final String DYNAMIC_ROUTERS_CATEGORY = "dynamicrouters"; - public static final boolean DEFAULT_HESSIAN_OVERLOAD_METHOD = false; + public static final String DEFAULT_CATEGORY = PROVIDERS_CATEGORY; - public static final String MULTICAST = "multicast"; + public static final String CONFIGURATORS_CATEGORY = "configurators"; - public static final String TAG_KEY = "dubbo.tag"; + public static final String DYNAMIC_CONFIGURATORS_CATEGORY = "dynamicconfigurators"; - public static final String FORCE_USE_TAG = "dubbo.force.tag"; + public static final String APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"; - public static final String HOST_KEY = "host"; + public static final String CONFIGURATORS_SUFFIX = ".configurators"; - public static final String PORT_KEY = "port"; + public static final String ROUTERS_SUFFIX = ".routers"; - public static final String USERNAME_KEY = "username"; + public static final String TRACE_PROTOCOL = "trace"; - public static final String PASSWORD_KEY = "password"; + public static final String EMPTY_PROTOCOL = "empty"; - public static final String ADDRESS_KEY = "address"; + public static final String ADMIN_PROTOCOL = "admin"; - public static final String RETRY_TIMES_KEY = "retry.times"; + public static final String PROVIDER_PROTOCOL = "provider"; - public static final String RETRY_PERIOD_KEY = "retry.period"; + public static final String CONSUMER_PROTOCOL = "consumer"; - public static final String SYNC_REPORT_KEY = "sync.report"; + public static final String ROUTE_PROTOCOL = "route"; - public static final String CYCLE_REPORT_KEY = "cycle.report"; + public static final String SCRIPT_PROTOCOL = "script"; - public static final String CONFIG_VERSION_KEY = "configVersion"; + public static final String CONDITION_PROTOCOL = "condition"; - public static final String COMPATIBLE_CONFIG_KEY = "compatible_config"; /** - * package version in the manifest + * simple the registry for provider. + * + * @since 2.7.0 */ - public static final String RELEASE_KEY = "release"; - - public static final String OVERRIDE_PROVIDERS_KEY = "providerAddresses"; + public static final String SIMPLIFIED_KEY = "simplified"; - public static final String PROTOCOLS_SUFFIX = "dubbo.protocols."; + /** + * After simplify the registry, should add some paramter individually for provider. + * + * @since 2.7.0 + */ + public static final String EXTRA_KEYS_KEY = "extra-keys"; - public static final String PROTOCOL_SUFFIX = "dubbo.protocol."; + public static final String OVERRIDE_PROTOCOL = "override"; - public static final String REGISTRIES_SUFFIX = "dubbo.registries."; + public static final String COMPATIBLE_CONFIG_KEY = "compatible_config"; public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS = {APPLICATION_KEY, CODEC_KEY, EXCHANGER_KEY, SERIALIZATION_KEY, CLUSTER_KEY, CONNECTIONS_KEY, DEPRECATED_KEY, GROUP_KEY, LOADBALANCE_KEY, MOCK_KEY, PATH_KEY, TIMEOUT_KEY, TOKEN_KEY, VERSION_KEY, WARMUP_KEY, WEIGHT_KEY, TIMESTAMP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY}; public static final String[] DEFAULT_REGISTER_CONSUMER_KEYS = {APPLICATION_KEY, VERSION_KEY, GROUP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY}; - public static final String TELNET = "telnet"; - - /** - * Hash nodes name - */ - public static final String HASH_NODES = "hash.nodes"; - - /** - * Hash arguments name - */ - public static final String HASH_ARGUMENTS = "hash.arguments"; - - /** - * Application name; - */ - public static final String NAME = "name"; - - /** - * Application owner name; - */ - public static final String OWNER = "owner"; - /** - * Running application organization name. + * To decide whether register center saves file synchronously, the default value is asynchronously */ - public static final String ORGANIZATION = "organization"; + public static final String REGISTRY_FILESAVE_SYNC_KEY = "save.file"; /** - * Application architecture name. + * Period of registry center's retry interval */ - public static final String ARCHITECTURE = "architecture"; + public static final String REGISTRY_RETRY_PERIOD_KEY = "retry.period"; /** - * Environment name + * Most retry times */ - public static final String ENVIRONMENT = "environment"; + public static final String REGISTRY_RETRY_TIMES_KEY = "retry.times"; /** - * Test environment key. + * Default value for the period of retry interval in milliseconds: 5000 */ - public static final String TEST_ENVIRONMENT = "test"; + public static final int DEFAULT_REGISTRY_RETRY_PERIOD = 5 * 1000; /** - * Development environment key. + * Default value for the times of retry: 3 */ - public static final String DEVELOPMENT_ENVIRONMENT = "develop"; + public static final int DEFAULT_REGISTRY_RETRY_TIMES = 3; /** - * Production environment key. + * Reconnection period in milliseconds for register center */ - public static final String PRODUCTION_ENVIRONMENT = "product"; - - public static final String ETCD3_NOTIFY_MAXTHREADS_KEYS = "etcd3.notify.maxthreads"; + public static final String REGISTRY_RECONNECT_PERIOD_KEY = "reconnect.period"; - public static final int DEFAULT_ETCD3_NOTIFY_THREADS = DEFAULT_IO_THREADS; + public static final int DEFAULT_REGISTRY_RECONNECT_PERIOD = 3 * 1000; - public static final String DEFAULT_ETCD3_NOTIFY_QUEUES_KEY = "etcd3.notify.queues"; + public static final String SESSION_TIMEOUT_KEY = "session"; - public static final int DEFAULT_GRPC_QUEUES = 300_0000; + public static final int DEFAULT_SESSION_TIMEOUT = 60 * 1000; + // END dubbo-registry-api - /** - * metrics - */ + // BEGIN dubbo-monitor-api + public static final String MONITOR_KEY = "monitor"; + public static final String LOGSTAT_PROTOCOL = "logstat"; + public static final String COUNT_PROTOCOL = "count"; public static final String DUBBO_PROVIDER = "dubbo.provider"; public static final String DUBBO_CONSUMER = "dubbo.consumer"; public static final String DUBBO_PROVIDER_METHOD = "dubbo.provider.method"; @@ -877,20 +845,52 @@ public class Constants { public static final String METRICS_KEY = "metrics"; public static final String METRICS_PORT = "metrics.port"; public static final String METRICS_PROTOCOL = "metrics.protocol"; + // END dubbo-monitor-api + + // BEGIN dubbo-metadata-report-api + public static final String METADATA_REPORT_KEY = "metadata"; + + public static final String RETRY_TIMES_KEY = "retry.times"; + public static final Integer DEFAULT_METADATA_REPORT_RETRY_TIMES = 100; + + public static final String RETRY_PERIOD_KEY = "retry.period"; + + public static final Integer DEFAULT_METADATA_REPORT_RETRY_PERIOD = 3000; + + public static final String SYNC_REPORT_KEY = "sync.report"; + + public static final String CYCLE_REPORT_KEY = "cycle.report"; + + public static final Boolean DEFAULT_METADATA_REPORT_CYCLE_REPORT = true; + // END dubbo-metadata-report-api + + // BEGIN dubbo-filter-cache + public static final String CACHE_KEY = "cache"; + // END dubbo-filter-cache + + + // BEGIN dubbo-filter-validation + public static final String VALIDATION_KEY = "validation"; + // END dubbo-filter-validation + + public static final String DEFAULT_CLUSTER = "failover"; /** - * Serizlization ContentTypeId + * public static final int DEFAULT_REGISTRY_CONNECT_TIMEOUT = 5000; */ - public static final byte HESSIAN2_SERIALIZATION_ID = 2; - public static final byte JAVA_SERIALIZATION_ID = 3; - public static final byte COMPACTED_JAVA_SERIALIZATION_ID = 4; - public static final byte FASTJSON_SERIALIZATION_ID = 6; - public static final byte NATIVE_JAVA_SERIALIZATION_ID = 7; - public static final byte KRYO_SERIALIZATION_ID = 8; - public static final byte FST_SERIALIZATION_ID = 9; - public static final byte PROTOSTUFF_SERIALIZATION_ID = 10; - public static final byte AVRO_SERIALIZATION_ID = 11; - public static final byte GSON_SERIALIZATION_ID = 16; + public static final String DIRECTORY_KEY = "directory"; + + public static final String ASYNC_SUFFIX = "Async"; + + public static final String WAIT_KEY = "wait"; + + public static final String HESSIAN_VERSION_KEY = "hessian.version"; + + + public static final String CONFIG_PROTOCOL = "config"; + + + public static final String RELIABLE_PROTOCOL = "napoli"; } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java index a514728b62f..6c5870bd47e 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java @@ -64,7 +64,6 @@ import static org.apache.dubbo.common.Constants.CONFIGURATORS_SUFFIX; import static org.apache.dubbo.common.Constants.CONSUMERS_CATEGORY; import static org.apache.dubbo.common.Constants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.Constants.DEFAULT_DIRECTORY; import static org.apache.dubbo.common.Constants.DEFAULT_REGISTER_CONSUMER_KEYS; import static org.apache.dubbo.common.Constants.DEFAULT_REGISTER_PROVIDER_KEYS; import static org.apache.dubbo.common.Constants.DEFAULT_REGISTRY; @@ -276,7 +275,7 @@ private Registry getRegistry(final Invoker originInvoker) { private URL getRegistryUrl(Invoker originInvoker) { URL registryUrl = originInvoker.getUrl(); if (REGISTRY_PROTOCOL.equals(registryUrl.getProtocol())) { - String protocol = registryUrl.getParameter(REGISTRY_KEY, DEFAULT_DIRECTORY); + String protocol = registryUrl.getParameter(REGISTRY_KEY, DEFAULT_REGISTRY); registryUrl = registryUrl.setProtocol(protocol).removeParameter(REGISTRY_KEY); } return registryUrl; diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java index 9125f8479ac..ca48dcaf1e0 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java @@ -31,6 +31,10 @@ import java.util.Map; import java.util.Set; +import static org.apache.dubbo.common.serialize.Constants.COMPACTED_JAVA_SERIALIZATION_ID; +import static org.apache.dubbo.common.serialize.Constants.JAVA_SERIALIZATION_ID; +import static org.apache.dubbo.common.serialize.Constants.NATIVE_JAVA_SERIALIZATION_ID; + public class CodecSupport { private static final Logger logger = LoggerFactory.getLogger(CodecSupport.class); @@ -71,7 +75,7 @@ public static Serialization getSerialization(URL url, Byte id) throws IOExceptio String serializationName = url.getParameter(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); // Check if "serialization id" passed from network matches the id on this side(only take effect for JDK serialization), for security purpose. if (serialization == null - || ((id == Constants.JAVA_SERIALIZATION_ID || id == Constants.NATIVE_JAVA_SERIALIZATION_ID || id == Constants.COMPACTED_JAVA_SERIALIZATION_ID) + || ((id == JAVA_SERIALIZATION_ID || id == NATIVE_JAVA_SERIALIZATION_ID || id == COMPACTED_JAVA_SERIALIZATION_ID) && !(serializationName.equals(ID_SERIALIZATIONNAME_MAP.get(id))))) { throw new IOException("Unexpected serialization id:" + id + " received from network, please check if the peer send the right id."); } diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java new file mode 100644 index 00000000000..7bc1a98bd25 --- /dev/null +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.remoting.etcd; + +import static org.apache.dubbo.common.Constants.DEFAULT_IO_THREADS; + +public interface Constants { + String ETCD3_NOTIFY_MAXTHREADS_KEYS = "etcd3.notify.maxthreads"; + + int DEFAULT_ETCD3_NOTIFY_THREADS = DEFAULT_IO_THREADS; + + String DEFAULT_ETCD3_NOTIFY_QUEUES_KEY = "etcd3.notify.queues"; + + int DEFAULT_GRPC_QUEUES = 300_0000; +} + diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java index 634a6eda0b3..c1f8e2cb936 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java @@ -60,6 +60,10 @@ import java.util.concurrent.locks.ReentrantLock; import static java.util.stream.Collectors.toList; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_ETCD3_NOTIFY_QUEUES_KEY; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_ETCD3_NOTIFY_THREADS; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_GRPC_QUEUES; +import static org.apache.dubbo.remoting.etcd.Constants.ETCD3_NOTIFY_MAXTHREADS_KEYS; import static org.apache.dubbo.remoting.etcd.jetcd.JEtcdClientWrapper.UTF_8; /** @@ -92,10 +96,10 @@ public JEtcdClient(URL url) { notifyExecutor = new ThreadPoolExecutor( 1 - , url.getParameter(Constants.ETCD3_NOTIFY_MAXTHREADS_KEYS, Constants.DEFAULT_ETCD3_NOTIFY_THREADS) + , url.getParameter(ETCD3_NOTIFY_MAXTHREADS_KEYS, DEFAULT_ETCD3_NOTIFY_THREADS) , Constants.DEFAULT_SESSION_TIMEOUT , TimeUnit.MILLISECONDS - , new LinkedBlockingQueue(url.getParameter(Constants.DEFAULT_ETCD3_NOTIFY_QUEUES_KEY, Constants.DEFAULT_GRPC_QUEUES * 3)) + , new LinkedBlockingQueue(url.getParameter(DEFAULT_ETCD3_NOTIFY_QUEUES_KEY, DEFAULT_GRPC_QUEUES * 3)) , new NamedThreadFactory("etcd3-notify", true)); clientWrapper.start(); diff --git a/dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Constants.java b/dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Constants.java new file mode 100644 index 00000000000..56cae66891a --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Constants.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.serialize; + +public interface Constants { + byte HESSIAN2_SERIALIZATION_ID = 2; + byte JAVA_SERIALIZATION_ID = 3; + byte COMPACTED_JAVA_SERIALIZATION_ID = 4; + byte FASTJSON_SERIALIZATION_ID = 6; + byte NATIVE_JAVA_SERIALIZATION_ID = 7; + byte KRYO_SERIALIZATION_ID = 8; + byte FST_SERIALIZATION_ID = 9; + byte NATIVE_HESSIAN_SERIALIZATION_ID = 10; + byte PROTOSTUFF_SERIALIZATION_ID = 12; + byte AVRO_SERIALIZATION_ID = 11; + byte GSON_SERIALIZATION_ID = 16; + byte PROTOBUF_JSON_SERIALIZATION_ID = 21; +} diff --git a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java index 37eb320f19b..7eb291ec343 100644 --- a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java +++ b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.avro; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,11 +25,13 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.AVRO_SERIALIZATION_ID; + public class AvroSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.AVRO_SERIALIZATION_ID; + return AVRO_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java index d1d804e14d0..84c5721ce5b 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java +++ b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.fastjson; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.FASTJSON_SERIALIZATION_ID; + /** * FastJson serialization implementation * @@ -37,7 +38,7 @@ public class FastJsonSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.FASTJSON_SERIALIZATION_ID; + return FASTJSON_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java b/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java index c9201d22a3d..b8862f377ce 100644 --- a/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java +++ b/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.fst; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.FST_SERIALIZATION_ID; + /** * Fst serialization implementation * @@ -37,7 +38,7 @@ public class FstSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.FST_SERIALIZATION_ID; + return FST_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java b/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java index cb4c2f9b088..a22769a2802 100644 --- a/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java +++ b/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java @@ -17,7 +17,6 @@ package org.apache.dubbo.common.serialize.gson; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -27,12 +26,14 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.GSON_SERIALIZATION_ID; + public class GsonSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.GSON_SERIALIZATION_ID; + return GSON_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java b/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java index 2c46c5b1933..010a5b6f31a 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java +++ b/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.hessian2; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.HESSIAN2_SERIALIZATION_ID; + /** * Hessian2 serialization implementation, hessian2 is the default serialization protocol for dubbo * @@ -37,7 +38,7 @@ public class Hessian2Serialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.HESSIAN2_SERIALIZATION_ID; + return HESSIAN2_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java index e1b75abf0a1..2df9db1aa2a 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java +++ b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.java; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.COMPACTED_JAVA_SERIALIZATION_ID; + /** * Compacted java serialization implementation * @@ -37,7 +38,7 @@ public class CompactedJavaSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.COMPACTED_JAVA_SERIALIZATION_ID; + return COMPACTED_JAVA_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java index 01d29ee7c04..2045e4efa45 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java +++ b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.java; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.JAVA_SERIALIZATION_ID; + /** * Java serialization implementation * @@ -37,7 +38,7 @@ public class JavaSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.JAVA_SERIALIZATION_ID; + return JAVA_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java index 2d89161ead9..6617d29f6ad 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java +++ b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java @@ -17,7 +17,6 @@ package org.apache.dubbo.common.serialize.nativejava; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -27,6 +26,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.NATIVE_JAVA_SERIALIZATION_ID; + /** * Native java serialization implementation * @@ -39,7 +40,7 @@ public class NativeJavaSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.NATIVE_JAVA_SERIALIZATION_ID; + return NATIVE_JAVA_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java b/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java index 4f903ff707b..369192a9cd0 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java +++ b/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.kryo; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.KRYO_SERIALIZATION_ID; + /** * TODO for now kryo serialization doesn't deny classes that don't implement the serializable interface * @@ -37,7 +38,7 @@ public class KryoSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.KRYO_SERIALIZATION_ID; + return KRYO_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java b/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java index aeda121d015..ee5887682d1 100644 --- a/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java +++ b/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java @@ -26,11 +26,13 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.NATIVE_HESSIAN_SERIALIZATION_ID; + public class Hessian2Serialization implements Serialization { @Override public byte getContentTypeId() { - return 10; + return NATIVE_HESSIAN_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java index 8b9395c95b7..d3d23300173 100644 --- a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java @@ -24,6 +24,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.PROTOBUF_JSON_SERIALIZATION_ID; + /** * This serizalization is use for google protobuf generic reference. * The entity be transported between client and server by json string. @@ -33,7 +35,7 @@ public class GenericProtobufSerialization implements Serialization { @Override public byte getContentTypeId() { - return 21; + return PROTOBUF_JSON_SERIALIZATION_ID; } @Override @@ -50,4 +52,4 @@ public ObjectOutput serialize(URL url, OutputStream output) { public ObjectInput deserialize(URL url, InputStream input) { return new GenericProtobufObjectInput(input); } -} \ No newline at end of file +} diff --git a/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java b/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java index 66b6833ba41..5218cef9835 100644 --- a/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java +++ b/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java @@ -17,7 +17,6 @@ package org.apache.dubbo.common.serialize.protostuff; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -27,6 +26,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.PROTOSTUFF_SERIALIZATION_ID; + /** * Protostuff serialization implementation * @@ -37,7 +38,7 @@ public class ProtostuffSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.PROTOSTUFF_SERIALIZATION_ID; + return PROTOSTUFF_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java index ee591cba4af..d679f384b2c 100644 --- a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.avro; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; import org.hamcrest.Matchers; @@ -28,6 +27,7 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.AVRO_SERIALIZATION_ID; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.mock; @@ -47,7 +47,7 @@ public void testContentType() { @Test public void testContentTypeId() { - assertThat(avroSerialization.getContentTypeId(), is(Constants.AVRO_SERIALIZATION_ID)); + assertThat(avroSerialization.getContentTypeId(), is(AVRO_SERIALIZATION_ID)); } @Test From 951ad3687adf286e6d483ee833ecfb1e8151d669 Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Fri, 10 May 2019 15:50:08 +0800 Subject: [PATCH 5/6] Solve #3137, step 2, seperate constants for cluster, common, filter, monitor, and registry (#4020) --- .../common/constants/ClusterConstants.java | 109 ++++++++++++ .../common/constants/CommonConstants.java | 160 ++++++++++++++++++ .../common/constants/FilterConstants.java | 24 +++ .../constants/MetadataReportConstants.java | 36 ++++ .../common/constants/MonitorConstants.java | 46 +++++ .../common/constants/RegistryConstants.java | 157 +++++++++++++++++ 6 files changed, 532 insertions(+) create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/ClusterConstants.java create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/FilterConstants.java create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetadataReportConstants.java create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/MonitorConstants.java create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ClusterConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ClusterConstants.java new file mode 100644 index 00000000000..269fd75a340 --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ClusterConstants.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +public interface ClusterConstants { + /** + * key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME + */ + String ROUTER_KEY = "router"; + + String LOADBALANCE_KEY = "loadbalance"; + + String DEFAULT_LOADBALANCE = "random"; + + String FAIL_BACK_TASKS_KEY = "failbacktasks"; + + int DEFAULT_FAILBACK_TASKS = 100; + + String RETRIES_KEY = "retries"; + + int DEFAULT_RETRIES = 2; + + int DEFAULT_FAILBACK_TIMES = 3; + + String FORKS_KEY = "forks"; + + int DEFAULT_FORKS = 2; + + String WEIGHT_KEY = "weight"; + + int DEFAULT_WEIGHT = 100; + + String MOCK_PROTOCOL = "mock"; + + String FORCE_KEY = "force"; + + /** + * To decide whether to exclude unavailable invoker from the cluster + */ + String CLUSTER_AVAILABLE_CHECK_KEY = "cluster.availablecheck"; + + /** + * The default value of cluster.availablecheck + * + * @see #CLUSTER_AVAILABLE_CHECK_KEY + */ + boolean DEFAULT_CLUSTER_AVAILABLE_CHECK = true; + + /** + * To decide whether to enable sticky strategy for cluster + */ + String CLUSTER_STICKY_KEY = "sticky"; + + /** + * The default value of sticky + * + * @see #CLUSTER_STICKY_KEY + */ + boolean DEFAULT_CLUSTER_STICKY = false; + + String ADDRESS_KEY = "address"; + + /** + * When this attribute appears in invocation's attachment, mock invoker will be used + */ + String INVOCATION_NEED_MOCK = "invocation.need.mock"; + + /** + * when ROUTER_KEY's value is set to ROUTER_TYPE_CLEAR, RegistryDirectory will clean all current routers + */ + String ROUTER_TYPE_CLEAR = "clean"; + + String DEFAULT_SCRIPT_TYPE_KEY = "javascript"; + + String PRIORITY_KEY = "priority"; + + String RULE_KEY = "rule"; + + String TYPE_KEY = "type"; + + String RUNTIME_KEY = "runtime"; + + String TAG_KEY = "dubbo.tag"; + + String REMOTE_TIMESTAMP_KEY = "remote.timestamp"; + + String WARMUP_KEY = "warmup"; + + int DEFAULT_WARMUP = 10 * 60 * 1000; + + String CONFIG_VERSION_KEY = "configVersion"; + + String OVERRIDE_PROVIDERS_KEY = "providerAddresses"; +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java new file mode 100644 index 00000000000..3ce4f83ac0e --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +import java.util.regex.Pattern; + +public interface CommonConstants { + String DUBBO = "dubbo"; + + String PROVIDER = "provider"; + + String CONSUMER = "consumer"; + + String APPLICATION_KEY = "application"; + + String REMOTE_APPLICATION_KEY = "remote.application"; + + String ENABLED_KEY = "enabled"; + + String DISABLED_KEY = "disabled"; + + String DUBBO_PROPERTIES_KEY = "dubbo.properties.file"; + + String DEFAULT_DUBBO_PROPERTIES = "dubbo.properties"; + + String ANY_VALUE = "*"; + + String COMMA_SEPARATOR = ","; + + Pattern COMMA_SPLIT_PATTERN = Pattern.compile("\\s*[,]+\\s*"); + + public final static String PATH_SEPARATOR = "/"; + + public final static String PROTOCOL_SEPARATOR = "://"; + + String REGISTRY_SEPARATOR = "|"; + + Pattern REGISTRY_SPLIT_PATTERN = Pattern.compile("\\s*[|;]+\\s*"); + + String SEMICOLON_SEPARATOR = ";"; + + Pattern SEMICOLON_SPLIT_PATTERN = Pattern.compile("\\s*[;]+\\s*"); + + String DEFAULT_PROXY = "javassist"; + + String DEFAULT_DIRECTORY = "dubbo"; + + String PROTOCOL_KEY = "protocol"; + + String DEFAULT_PROTOCOL = "dubbo"; + + String DEFAULT_THREAD_NAME = "Dubbo"; + + int DEFAULT_CORE_THREADS = 0; + + int DEFAULT_THREADS = 200; + + String THREADPOOL_KEY = "threadpool"; + + String THREAD_NAME_KEY = "threadname"; + + String CORE_THREADS_KEY = "corethreads"; + + String THREADS_KEY = "threads"; + + String QUEUES_KEY = "queues"; + + String ALIVE_KEY = "alive"; + + String DEFAULT_THREADPOOL = "limited"; + + String DEFAULT_CLIENT_THREADPOOL = "cached"; + + String IO_THREADS_KEY = "iothreads"; + + int DEFAULT_QUEUES = 0; + + int DEFAULT_ALIVE = 60 * 1000; + + String TIMEOUT_KEY = "timeout"; + + int DEFAULT_TIMEOUT = 1000; + + String REMOVE_VALUE_PREFIX = "-"; + + String PROPERTIES_CHAR_SEPERATOR = "-"; + + String GROUP_CHAR_SEPERATOR = ":"; + + String HIDE_KEY_PREFIX = "."; + + String DEFAULT_KEY_PREFIX = "default."; + + String DEFAULT_KEY = "default"; + + /** + * Default timeout value in milliseconds for server shutdown + */ + int DEFAULT_SERVER_SHUTDOWN_TIMEOUT = 10000; + + String SIDE_KEY = "side"; + + String PROVIDER_SIDE = "provider"; + + String CONSUMER_SIDE = "consumer"; + + String ANYHOST_KEY = "anyhost"; + + String ANYHOST_VALUE = "0.0.0.0"; + + String LOCALHOST_KEY = "localhost"; + + String LOCALHOST_VALUE = "127.0.0.1"; + + String METHODS_KEY = "methods"; + + String METHOD_KEY = "method"; + + String PID_KEY = "pid"; + + String TIMESTAMP_KEY = "timestamp"; + + String GROUP_KEY = "group"; + + String PATH_KEY = "path"; + + String INTERFACE_KEY = "interface"; + + String FILE_KEY = "file"; + + String DUMP_DIRECTORY = "dump.directory"; + + String CLASSIFIER_KEY = "classifier"; + + String VERSION_KEY = "version"; + + String REVISION_KEY = "revision"; + + /** + * package version in the manifest + */ + String RELEASE_KEY = "release"; + + int MAX_PROXY_COUNT = 65535; +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/FilterConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/FilterConstants.java new file mode 100644 index 00000000000..f4199ffe418 --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/FilterConstants.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +public interface FilterConstants { + String CACHE_KEY = "cache"; + + String VALIDATION_KEY = "validation"; +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetadataReportConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetadataReportConstants.java new file mode 100644 index 00000000000..ee1119d4e6e --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetadataReportConstants.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +public interface MetadataReportConstants { + String METADATA_REPORT_KEY = "metadata"; + + String RETRY_TIMES_KEY = "retry.times"; + + Integer DEFAULT_METADATA_REPORT_RETRY_TIMES = 100; + + String RETRY_PERIOD_KEY = "retry.period"; + + Integer DEFAULT_METADATA_REPORT_RETRY_PERIOD = 3000; + + String SYNC_REPORT_KEY = "sync.report"; + + String CYCLE_REPORT_KEY = "cycle.report"; + + Boolean DEFAULT_METADATA_REPORT_CYCLE_REPORT = true; +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MonitorConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MonitorConstants.java new file mode 100644 index 00000000000..94079bf5f95 --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MonitorConstants.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +public interface MonitorConstants { + String MONITOR_KEY = "monitor"; + + String LOGSTAT_PROTOCOL = "logstat"; + + String COUNT_PROTOCOL = "count"; + + String DUBBO_PROVIDER = "dubbo.provider"; + + String DUBBO_CONSUMER = "dubbo.consumer"; + + String DUBBO_PROVIDER_METHOD = "dubbo.provider.method"; + + String DUBBO_CONSUMER_METHOD = "dubbo.consumer.method"; + + String SERVICE = "service"; + + String METHOD = "method"; + + String DUBBO_GROUP = "dubbo"; + + String METRICS_KEY = "metrics"; + + String METRICS_PORT = "metrics.port"; + + String METRICS_PROTOCOL = "metrics.protocol"; +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java new file mode 100644 index 00000000000..bcfc9dcc436 --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +import static org.apache.dubbo.common.Constants.APPLICATION_KEY; +import static org.apache.dubbo.common.Constants.CLUSTER_KEY; +import static org.apache.dubbo.common.Constants.CODEC_KEY; +import static org.apache.dubbo.common.Constants.CONNECTIONS_KEY; +import static org.apache.dubbo.common.Constants.DEPRECATED_KEY; +import static org.apache.dubbo.common.Constants.DUBBO_VERSION_KEY; +import static org.apache.dubbo.common.Constants.EXCHANGER_KEY; +import static org.apache.dubbo.common.Constants.GROUP_KEY; +import static org.apache.dubbo.common.Constants.LOADBALANCE_KEY; +import static org.apache.dubbo.common.Constants.MOCK_KEY; +import static org.apache.dubbo.common.Constants.PATH_KEY; +import static org.apache.dubbo.common.Constants.RELEASE_KEY; +import static org.apache.dubbo.common.Constants.SERIALIZATION_KEY; +import static org.apache.dubbo.common.Constants.TIMEOUT_KEY; +import static org.apache.dubbo.common.Constants.TIMESTAMP_KEY; +import static org.apache.dubbo.common.Constants.TOKEN_KEY; +import static org.apache.dubbo.common.Constants.VERSION_KEY; +import static org.apache.dubbo.common.Constants.WARMUP_KEY; +import static org.apache.dubbo.common.Constants.WEIGHT_KEY; + +public interface RegistryConstants { + String REGISTER_KEY = "register"; + + String SUBSCRIBE_KEY = "subscribe"; + + String REGISTRY_KEY = "registry"; + + String DEFAULT_REGISTRY = "dubbo"; + + String REGISTRY_PROTOCOL = "registry"; + + String DYNAMIC_KEY = "dynamic"; + + String REGISTER = "register"; + + String UNREGISTER = "unregister"; + + String SUBSCRIBE = "subscribe"; + + String UNSUBSCRIBE = "unsubscribe"; + + String CATEGORY_KEY = "category"; + + String PROVIDERS_CATEGORY = "providers"; + + String CONSUMERS_CATEGORY = "consumers"; + + String ROUTERS_CATEGORY = "routers"; + + String DYNAMIC_ROUTERS_CATEGORY = "dynamicrouters"; + + String DEFAULT_CATEGORY = PROVIDERS_CATEGORY; + + String CONFIGURATORS_CATEGORY = "configurators"; + + String DYNAMIC_CONFIGURATORS_CATEGORY = "dynamicconfigurators"; + + String APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"; + + String CONFIGURATORS_SUFFIX = ".configurators"; + + String ROUTERS_SUFFIX = ".routers"; + + String TRACE_PROTOCOL = "trace"; + + String EMPTY_PROTOCOL = "empty"; + + String ADMIN_PROTOCOL = "admin"; + + String PROVIDER_PROTOCOL = "provider"; + + String CONSUMER_PROTOCOL = "consumer"; + + String ROUTE_PROTOCOL = "route"; + + String SCRIPT_PROTOCOL = "script"; + + String CONDITION_PROTOCOL = "condition"; + + /** + * simple the registry for provider. + * + * @since 2.7.0 + */ + String SIMPLIFIED_KEY = "simplified"; + + /** + * After simplify the registry, should add some paramter individually for provider. + * + * @since 2.7.0 + */ + String EXTRA_KEYS_KEY = "extra-keys"; + + String OVERRIDE_PROTOCOL = "override"; + + String COMPATIBLE_CONFIG_KEY = "compatible_config"; + + String[] DEFAULT_REGISTER_PROVIDER_KEYS = {APPLICATION_KEY, CODEC_KEY, EXCHANGER_KEY, SERIALIZATION_KEY, CLUSTER_KEY, CONNECTIONS_KEY, DEPRECATED_KEY, + GROUP_KEY, LOADBALANCE_KEY, MOCK_KEY, PATH_KEY, TIMEOUT_KEY, TOKEN_KEY, VERSION_KEY, WARMUP_KEY, WEIGHT_KEY, TIMESTAMP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY}; + + String[] DEFAULT_REGISTER_CONSUMER_KEYS = {APPLICATION_KEY, VERSION_KEY, GROUP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY}; + + /** + * To decide whether register center saves file synchronously, the default value is asynchronously + */ + String REGISTRY_FILESAVE_SYNC_KEY = "save.file"; + + /** + * Period of registry center's retry interval + */ + String REGISTRY_RETRY_PERIOD_KEY = "retry.period"; + + /** + * Most retry times + */ + String REGISTRY_RETRY_TIMES_KEY = "retry.times"; + + /** + * Default value for the period of retry interval in milliseconds: 5000 + */ + int DEFAULT_REGISTRY_RETRY_PERIOD = 5 * 1000; + + /** + * Default value for the times of retry: 3 + */ + int DEFAULT_REGISTRY_RETRY_TIMES = 3; + + /** + * Reconnection period in milliseconds for register center + */ + String REGISTRY_RECONNECT_PERIOD_KEY = "reconnect.period"; + + int DEFAULT_REGISTRY_RECONNECT_PERIOD = 3 * 1000; + + String SESSION_TIMEOUT_KEY = "session"; + + int DEFAULT_SESSION_TIMEOUT = 60 * 1000; +} From 6a1dd65088d92af401106dcacf2a3b44b0cbaff1 Mon Sep 17 00:00:00 2001 From: huazhongming Date: Fri, 10 May 2019 16:06:19 +0800 Subject: [PATCH 6/6] [DUBBO-3137]: step2 - seperate constants for config, remoting, rpc (#4021) * constants step2 * change interface --- .../common/constants/ConfigConstants.java | 175 ++++++++++++++++ .../common/constants/RemotingConstants.java | 154 ++++++++++++++ .../dubbo/common/constants/RpcConstants.java | 195 ++++++++++++++++++ 3 files changed, 524 insertions(+) create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/ConfigConstants.java create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java create mode 100644 dubbo-common/src/main/java/org/apache/dubbo/common/constants/RpcConstants.java diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ConfigConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ConfigConstants.java new file mode 100644 index 00000000000..5899641a625 --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ConfigConstants.java @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +/** + * ConfigConstants + */ +public interface ConfigConstants { + // BEGIN dubbo-config-api + String CLUSTER_KEY = "cluster"; + + String STATUS_KEY = "status"; + + String CONTEXTPATH_KEY = "contextpath"; + + String LISTENER_KEY = "listener"; + + String LAYER_KEY = "layer"; + + /** + * General + */ + /** + * Application name; + */ + String NAME = "name"; + + /** + * Application owner name; + */ + String OWNER = "owner"; + + /** + * Running application organization name. + */ + String ORGANIZATION = "organization"; + + /** + * Application architecture name. + */ + String ARCHITECTURE = "architecture"; + + /** + * Environment name + */ + String ENVIRONMENT = "environment"; + + /** + * Test environment key. + */ + String TEST_ENVIRONMENT = "test"; + + /** + * Development environment key. + */ + String DEVELOPMENT_ENVIRONMENT = "develop"; + + /** + * Production environment key. + */ + String PRODUCTION_ENVIRONMENT = "product"; + + String CONFIG_CLUSTER_KEY = "config.cluster"; + String CONFIG_NAMESPACE_KEY = "config.namespace"; + String CONFIG_GROUP_KEY = "config.group"; + String CONFIG_CHECK_KEY = "config.check"; + + String CONFIG_CONFIGFILE_KEY = "config.config-file"; + String CONFIG_ENABLE_KEY = "config.highest-priority"; + String CONFIG_TIMEOUT_KEY = "config.timeout"; + String CONFIG_APPNAME_KEY = "config.app-name"; + + String USERNAME_KEY = "username"; + + String PASSWORD_KEY = "password"; + + String HOST_KEY = "host"; + + String PORT_KEY = "port"; + + String MULTICAST = "multicast"; + + String REGISTER_IP_KEY = "register.ip"; + + String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY"; + + String DUBBO_PORT_TO_REGISTRY = "DUBBO_PORT_TO_REGISTRY"; + + String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND"; + + String DUBBO_PORT_TO_BIND = "DUBBO_PORT_TO_BIND"; + + String SCOPE_KEY = "scope"; + + String SCOPE_LOCAL = "local"; + + String SCOPE_REMOTE = "remote"; + + String SCOPE_NONE = "none"; + + String ON_CONNECT_KEY = "onconnect"; + + String ON_DISCONNECT_KEY = "ondisconnect"; + + String ON_INVOKE_METHOD_KEY = "oninvoke.method"; + + String ON_RETURN_METHOD_KEY = "onreturn.method"; + + String ON_THROW_METHOD_KEY = "onthrow.method"; + + String ON_INVOKE_INSTANCE_KEY = "oninvoke.instance"; + + String ON_RETURN_INSTANCE_KEY = "onreturn.instance"; + + String ON_THROW_INSTANCE_KEY = "onthrow.instance"; + + @Deprecated + String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds"; + + String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait"; + + /** + * The key name for export URL in register center + */ + String EXPORT_KEY = "export"; + + /** + * The key name for reference URL in register center + */ + String REFER_KEY = "refer"; + + /** + * To decide whether to make connection when the client is created + */ + String LAZY_CONNECT_KEY = "lazy"; + + String DUBBO_PROTOCOL = "dubbo"; + + String ZOOKEEPER_PROTOCOL = "zookeeper"; + + // FIXME: is this still useful? + String SHUTDOWN_TIMEOUT_KEY = "shutdown.timeout"; + + int DEFAULT_SHUTDOWN_TIMEOUT = 1000 * 60 * 15; + + String PROTOCOLS_SUFFIX = "dubbo.protocols."; + + String PROTOCOL_SUFFIX = "dubbo.protocol."; + + String REGISTRIES_SUFFIX = "dubbo.registries."; + + String TELNET = "telnet"; + + String QOS_ENABLE = "qos.enable"; + + String QOS_PORT = "qos.port"; + + String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip"; + // END dubbo-congfig-api +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java new file mode 100644 index 00000000000..4e50feea1c9 --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +import java.util.concurrent.ExecutorService; + +/** + * RemotingConstants + */ +public interface RemotingConstants { + + String PAYLOAD_KEY = "payload"; + /** + * 8M + */ + int DEFAULT_PAYLOAD = 8 * 1024 * 1024; + + String BUFFER_KEY = "buffer"; + + /** + * default buffer size is 8k. + */ + int DEFAULT_BUFFER_SIZE = 8 * 1024; + + int MAX_BUFFER_SIZE = 16 * 1024; + + int MIN_BUFFER_SIZE = 1 * 1024; + + String CONNECT_TIMEOUT_KEY = "connect.timeout"; + + int DEFAULT_CONNECT_TIMEOUT = 3000; + + String HEARTBEAT_KEY = "heartbeat"; + + int DEFAULT_HEARTBEAT = 60 * 1000; + + String IDLE_TIMEOUT_KEY = "idle.timeout"; + + int DEFAULT_IDLE_TIMEOUT = 600 * 1000; + + String ACCEPTS_KEY = "accepts"; + + int DEFAULT_ACCEPTS = 0; + + String SERIALIZATION_KEY = "serialization"; + + String DEFAULT_REMOTING_SERIALIZATION = "hessian2"; + + String CODEC_KEY = "codec"; + + String DEFAULT_REMOTING_CODEC = "dubbo"; + + String SERVER_KEY = "server"; + + String DEFAULT_REMOTING_SERVER = "netty"; + + String CLIENT_KEY = "client"; + + String DEFAULT_REMOTING_CLIENT = "netty"; + + String TRANSPORTER_KEY = "transporter"; + + String DEFAULT_TRANSPORTER = "netty"; + + String EXCHANGER_KEY = "exchanger"; + + String DEFAULT_EXCHANGER = "header"; + + String DISPACTHER_KEY = "dispacther"; + + int DEFAULT_IO_THREADS = Math.min(Runtime.getRuntime().availableProcessors() + 1, 32); + + String BIND_IP_KEY = "bind.ip"; + + String BIND_PORT_KEY = "bind.port"; + + String SENT_KEY = "sent"; + + boolean DEFAULT_SENT = false; + + String DISPATCHER_KEY = "dispatcher"; + + String CHANNEL_HANDLER_KEY = "channel.handler"; + + String DEFAULT_CHANNEL_HANDLER = "default"; + + String SERVICE_DESCIPTOR_KEY = "serviceDescriptor"; + + String CONNECT_QUEUE_CAPACITY = "connect.queue.capacity"; + + String CONNECT_QUEUE_WARNING_SIZE = "connect.queue.warning.size"; + + int DEFAULT_CONNECT_QUEUE_WARNING_SIZE = 1000; + + String CHANNEL_ATTRIBUTE_READONLY_KEY = "channel.readonly"; + + String CHANNEL_READONLYEVENT_SENT_KEY = "channel.readonly.sent"; + + String CHANNEL_SEND_READONLYEVENT_KEY = "channel.readonly.send"; + + String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName(); + + String CHARSET_KEY = "charset"; + + String DEFAULT_CHARSET = "UTF-8"; + + String BACKUP_KEY = "backup"; + + /** + * Every heartbeat duration / HEATBEAT_CHECK_TICK, check if a heartbeat should be sent. Every heartbeat timeout + * duration / HEATBEAT_CHECK_TICK, check if a connection should be closed on server side, and if reconnect on + * client side + */ + int HEARTBEAT_CHECK_TICK = 3; + + /** + * the least heartbeat during is 1000 ms. + */ + long LEAST_HEARTBEAT_DURATION = 1000; + + /** + * ticks per wheel. + */ + int TICKS_PER_WHEEL = 128; + + String HEARTBEAT_TIMEOUT_KEY = "heartbeat.timeout"; + + String RECONNECT_KEY = "reconnect"; + + int DEFAULT_RECONNECT_PERIOD = 2000; + + String SEND_RECONNECT_KEY = "send.reconnect"; + + String CHECK_KEY = "check"; + + String PROMPT_KEY = "prompt"; + + String DEFAULT_PROMPT = "dubbo>"; +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RpcConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RpcConstants.java new file mode 100644 index 00000000000..9e7302ff0ad --- /dev/null +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RpcConstants.java @@ -0,0 +1,195 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.constants; + +/** + * RpcConstants + */ +public interface RpcConstants { + // BEGIN dubbo-rpc-hessian + String HESSIAN2_REQUEST_KEY = "hessian2.request"; + + boolean DEFAULT_HESSIAN2_REQUEST = false; + + String HESSIAN_OVERLOAD_METHOD_KEY = "hessian.overload.method"; + + boolean DEFAULT_HESSIAN_OVERLOAD_METHOD = false; + + String DEFAULT_HTTP_CLIENT = "jdk"; + + String DEFAULT_HTTP_SERVER = "servlet"; + + String DEFAULT_HTTP_SERIALIZATION = "json"; + // END dubbo-rpc-hessian + + // BEGIN dubbo-rpc-dubbo + String SHARE_CONNECTIONS_KEY = "shareconnections"; + + /** + * By default, a consumer JVM instance and a provider JVM instance share a long TCP connection (except when connections are set), + * which can set the number of long TCP connections shared to avoid the bottleneck of sharing a single long TCP connection. + */ + String DEFAULT_SHARE_CONNECTIONS = "1"; + + String INPUT_KEY = "input"; + + String OUTPUT_KEY = "output"; + + String DECODE_IN_IO_THREAD_KEY = "decode.in.io"; + + boolean DEFAULT_DECODE_IN_IO_THREAD = true; + + /** + * callback inst id + */ + String CALLBACK_SERVICE_KEY = "callback.service.instid"; + + /** + * The limit of callback service instances for one interface on every client + */ + String CALLBACK_INSTANCES_LIMIT_KEY = "callbacks"; + + /** + * The default limit number for callback service instances + * + * @see #CALLBACK_INSTANCES_LIMIT_KEY + */ + int DEFAULT_CALLBACK_INSTANCES = 1; + + String CALLBACK_SERVICE_PROXY_KEY = "callback.service.proxy"; + + String IS_CALLBACK_SERVICE = "is_callback_service"; + + /** + * Invokers in channel's callback + */ + String CHANNEL_CALLBACK_KEY = "channel.callback.invokers.key"; + + /** + * The initial state for lazy connection + */ + String LAZY_CONNECT_INITIAL_STATE_KEY = "connect.lazy.initial.state"; + + /** + * The default value of lazy connection's initial state: true + * + * @see #LAZY_CONNECT_INITIAL_STATE_KEY + */ + boolean DEFAULT_LAZY_CONNECT_INITIAL_STATE = true; + + String OPTIMIZER_KEY = "optimizer"; + // END dubbo-rpc-dubbo + + + // BEGIN dubbo-rpc-api + String DUBBO_VERSION_KEY = "dubbo"; + + String LOCAL_KEY = "local"; + + String STUB_KEY = "stub"; + + String MOCK_KEY = "mock"; + + String DEPRECATED_KEY = "deprecated"; + + String $INVOKE = "$invoke"; + + String $ECHO = "$echo"; + + String RETURN_PREFIX = "return "; + + String THROW_PREFIX = "throw"; + + String FAIL_PREFIX = "fail:"; + + String FORCE_PREFIX = "force:"; + + String MERGER_KEY = "merger"; + + String IS_SERVER_KEY = "isserver"; + + String FORCE_USE_TAG = "dubbo.force.tag"; + + String GENERIC_SERIALIZATION_NATIVE_JAVA = "nativejava"; + + String GENERIC_SERIALIZATION_DEFAULT = "true"; + + String GENERIC_SERIALIZATION_BEAN = "bean"; + + String GENERIC_SERIALIZATION_PROTOBUF = "protobuf-json"; + + String TPS_LIMIT_RATE_KEY = "tps"; + + String TPS_LIMIT_INTERVAL_KEY = "tps.interval"; + + long DEFAULT_TPS_LIMIT_INTERVAL = 60 * 1000; + + String AUTO_ATTACH_INVOCATIONID_KEY = "invocationid.autoattach"; + + String STUB_EVENT_KEY = "dubbo.stub.event"; + + boolean DEFAULT_STUB_EVENT = false; + + String STUB_EVENT_METHODS_KEY = "dubbo.stub.event.methods"; + + String PROXY_KEY = "proxy"; + + String EXECUTES_KEY = "executes"; + + String REFERENCE_FILTER_KEY = "reference.filter"; + + String INVOKER_LISTENER_KEY = "invoker.listener"; + + String SERVICE_FILTER_KEY = "service.filter"; + + String EXPORTER_LISTENER_KEY = "exporter.listener"; + + String ACCESS_LOG_KEY = "accesslog"; + + String ACTIVES_KEY = "actives"; + + String CONNECTIONS_KEY = "connections"; + + String ID_KEY = "id"; + + String ASYNC_KEY = "async"; + + String FUTURE_GENERATED_KEY = "future_generated"; + + String FUTURE_RETURNTYPE_KEY = "future_returntype"; + + String RETURN_KEY = "return"; + + String TOKEN_KEY = "token"; + + String INTERFACES = "interfaces"; + + String GENERIC_KEY = "generic"; + + String LOCAL_PROTOCOL = "injvm"; + // END dubbo-rpc-api + + + // BEGIN dubbo-rpc-rest + String KEEP_ALIVE_KEY = "keepalive"; + + boolean DEFAULT_KEEP_ALIVE = true; + + String EXTENSION_KEY = "extension"; + // END dubbo-rpc-rest +}