Merge branch 'apache-3.1' into apache-3.2

# Conflicts:
#	dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/FilterChainBuilder.java
#	dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/MergeableClusterInvoker.java
#	dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
#	dubbo-common/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/metadata/ConfigurableMetadataServiceExporter.java
#	dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/CompatibleFilter.java
#	dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
#	dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java
#	dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/TripleClientCall.java
#	dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2FrameServerHandler.java
#	dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioEnv.java
This commit is contained in:
Albumen Kevin 2022-11-07 17:40:15 +08:00
commit 71b9f6aa06
239 changed files with 2145 additions and 1382 deletions

View File

@ -141,7 +141,7 @@ jobs:
timeout-minutes: 70
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=5 -DskipTests=false -DskipIntegrationTests=false -Dcheckstyle.skip=false -Dcheckstyle_unix.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true -DembeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
integration-test-prepare:
runs-on: ubuntu-latest

View File

@ -161,7 +161,7 @@ jobs:
if: ${{ startsWith( matrix.os, 'windows') }}
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" -D"maven.wagon.http.retryHandler.count=5" -DskipTests=false -DskipIntegrationTests=true -D"checkstyle.skip=false" -D"checkstyle_unix.skip=true" -D"rat.skip=false" -D"maven.javadoc.skip=true" -D"embeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
integration-test-prepare:
runs-on: ubuntu-latest

View File

@ -171,7 +171,7 @@ jobs:
if: ${{ startsWith( matrix.os, 'windows') }}
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" -D"maven.wagon.http.retryHandler.count=5" -DskipTests=false -DskipIntegrationTests=true -D"checkstyle.skip=false" -D"checkstyle_unix.skip=true" -D"rat.skip=false" -D"maven.javadoc.skip=true" -D"embeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
unit-test-fastjson2:
needs: [build-source, unit-test-prepare]
@ -211,7 +211,7 @@ jobs:
if: ${{ startsWith( matrix.os, 'windows') }}
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" -D"maven.wagon.http.retryHandler.count=5" -DskipTests=false -DskipIntegrationTests=true -D"checkstyle.skip=false" -D"checkstyle_unix.skip=true" -D"rat.skip=false" -D"maven.javadoc.skip=true" -D"embeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
integration-test-prepare:
runs-on: ubuntu-latest

View File

@ -171,7 +171,7 @@ jobs:
if: ${{ startsWith( matrix.os, 'windows') }}
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" -D"maven.wagon.http.retryHandler.count=5" -DskipTests=false -DskipIntegrationTests=true -D"checkstyle.skip=false" -D"checkstyle_unix.skip=true" -D"rat.skip=false" -D"maven.javadoc.skip=true" -D"embeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
unit-test-fastjson2:
needs: [build-source, unit-test-prepare]
@ -211,7 +211,7 @@ jobs:
if: ${{ startsWith( matrix.os, 'windows') }}
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" -D"maven.wagon.http.retryHandler.count=5" -DskipTests=false -DskipIntegrationTests=true -D"checkstyle.skip=false" -D"checkstyle_unix.skip=true" -D"rat.skip=false" -D"maven.javadoc.skip=true" -D"embeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
integration-test-prepare:
runs-on: ubuntu-latest

View File

@ -23,25 +23,26 @@ env:
jobs:
license:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Check License
uses: apache/skywalking-eyes@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-source:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
version: ${{ steps.dubbo-version.outputs.version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: dubbo
- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 8
- uses: actions/cache@v2
- uses: actions/cache@v3
name: "Cache local Maven repository"
with:
path: ~/.m2/repository
@ -50,7 +51,7 @@ jobs:
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-maven-
- name: "Dubbo cache"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository/org/apache/dubbo
key: ${{ runner.os }}-dubbo-snapshot-${{ github.sha }}-${{ github.run_id }}
@ -80,7 +81,7 @@ jobs:
id: dubbo-version
run: |
REVISION=`awk '/<revision>[^<]+<\/revision>/{gsub(/<revision>|<\/revision>/,"",$1);print $1;exit;}' ./dubbo/pom.xml`
echo "::set-output name=version::$REVISION"
echo "version=$REVISION" >> $GITHUB_OUTPUT
echo "dubbo version: $REVISION"
unit-test-prepare:
@ -89,11 +90,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019 ]
os: [ ubuntu-latest, windows-latest ]
env:
ZOOKEEPER_VERSION: 3.6.3
steps:
- uses: actions/cache@v2
- uses: actions/cache@v3
name: "Cache zookeeper binary archive"
id: "cache-zookeeper"
with:
@ -139,17 +140,18 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019 ]
os: [ ubuntu-latest, windows-latest ]
jdk: [ 8, 11, 17, 19 ]
env:
DISABLE_FILE_SYSTEM_TEST: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: "Set up JDK ${{ matrix.jdk }}"
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.jdk }}
- uses: actions/cache@v2
distribution: 'zulu'
- uses: actions/cache@v3
name: "Cache local Maven repository"
with:
path: ~/.m2/repository
@ -166,7 +168,7 @@ jobs:
if: ${{ startsWith( matrix.os, 'windows') }}
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" -D"maven.wagon.http.retryHandler.count=5" -DskipTests=false -DskipIntegrationTests=true -D"checkstyle.skip=false" -D"checkstyle_unix.skip=true" -D"rat.skip=false" -D"maven.javadoc.skip=true" -D"embeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
unit-test-fastjson2:
needs: [build-source, unit-test-prepare]
@ -175,19 +177,20 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019 ]
os: [ ubuntu-latest, windows-latest ]
jdk: [ 8, 11, 17, 19 ]
env:
DISABLE_FILE_SYSTEM_TEST: true
DUBBO_DEFAULT_SERIALIZATION: fastjson2
MAVEN_SUREFIRE_ADD_OPENS: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: "Set up JDK ${{ matrix.jdk }}"
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.jdk }}
- uses: actions/cache@v2
- uses: actions/cache@v3
name: "Cache local Maven repository"
with:
path: ~/.m2/repository
@ -204,14 +207,14 @@ jobs:
if: ${{ startsWith( matrix.os, 'windows') }}
run: ./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Pjacoco -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" -D"maven.wagon.http.retryHandler.count=5" -DskipTests=false -DskipIntegrationTests=true -D"checkstyle.skip=false" -D"checkstyle_unix.skip=true" -D"rat.skip=false" -D"maven.javadoc.skip=true" -D"embeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
integration-test-prepare:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
JOB_COUNT: 3
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: 'apache/dubbo-samples'
ref: master
@ -226,8 +229,8 @@ jobs:
integration-test-job:
needs: [build-source, integration-test-prepare]
name: "Integration Test on ubuntu-20.04 (JobId: ${{matrix.job_id}})"
runs-on: ubuntu-20.04
name: "Integration Test on ubuntu-latest (JobId: ${{matrix.job_id}})"
runs-on: ubuntu-latest
timeout-minutes: 30
env:
JAVA_VER: 8
@ -237,12 +240,12 @@ jobs:
matrix:
job_id: [1, 2, 3]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: 'apache/dubbo-samples'
ref: master
- name: "Cache local Maven repository"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.run_id }}
@ -250,7 +253,7 @@ jobs:
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-maven-
- name: "Restore Dubbo cache"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository/org/apache/dubbo
key: ${{ runner.os }}-dubbo-snapshot-${{ github.sha }}-${{ github.run_id }}
@ -263,9 +266,10 @@ jobs:
name: test-list
path: test/jobs/
- name: "Set up JDK 8"
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
- name: "Init Candidate Versions"
run: |
DUBBO_VERSION="${{needs.build-source.outputs.version}}"
@ -286,11 +290,11 @@ jobs:
integration-test-result:
needs: [integration-test-job]
if: always()
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
JAVA_VER: 8
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: 'apache/dubbo-samples'
ref: master
@ -306,20 +310,21 @@ jobs:
error-code-inspecting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: "./dubbo"
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: 'apache/dubbo-test-tools'
ref: main
path: "./dubbo-test-tools"
- name: "Set up JDK 17"
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
- name: "Compile Dubbo (Linux)"
run: |

View File

@ -35,7 +35,7 @@ import org.apache.dubbo.rpc.cluster.Directory;
import java.util.List;
import java.util.stream.Collectors;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_ASYN_INVOKE_FAILED;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_EXECUTE_FILTER_EXCEPTION;
import static org.apache.dubbo.common.extension.ExtensionScope.APPLICATION;
@SPI(value = "default", scope = APPLICATION)
@ -221,7 +221,7 @@ public interface FilterChainBuilder {
}
}
} catch (RuntimeException runtimeException) {
LOGGER.error(CLUSTER_ASYN_INVOKE_FAILED,"asyn Invoke exception","",String.format("Exception occurred while executing the %s filter named %s.", i, filter.getClass().getSimpleName()),runtimeException);
LOGGER.error(CLUSTER_EXECUTE_FILTER_EXCEPTION, "the custom filter is abnormal", "", String.format("Exception occurred while executing the %s filter named %s.", i, filter.getClass().getSimpleName()));
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Whole filter list is: %s", filters.stream().map(tmpFilter -> tmpFilter.getClass().getSimpleName()).collect(Collectors.toList())));
}

View File

@ -28,6 +28,7 @@ import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
/**
@ -96,15 +97,21 @@ public class ConsistentHashLoadBalance extends AbstractLoadBalance {
}
public Invoker<T> select(Invocation invocation) {
String key = toKey(invocation.getArguments());
boolean isGeneric = invocation.getMethodName().equals($INVOKE);
String key = toKey(invocation.getArguments(),isGeneric);
byte[] digest = Bytes.getMD5(key);
return selectForKey(hash(digest, 0));
}
private String toKey(Object[] args, boolean isGeneric) {
return isGeneric ? toKey((Object[]) args[1]) : toKey(args);
}
private String toKey(Object[] args) {
StringBuilder buf = new StringBuilder();
for (int i : argumentIndex) {
if (i >= 0 && i < args.length) {
if (i >= 0 && args != null && i < args.length) {
buf.append(args[i]);
}
}

View File

@ -41,7 +41,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_ASYN_INVOKE_FAILED;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_FAILED_GROUP_MERGE;
import static org.apache.dubbo.rpc.Constants.ASYNC_KEY;
import static org.apache.dubbo.rpc.Constants.MERGER_KEY;
@ -102,8 +102,8 @@ public class MergeableClusterInvoker<T> extends AbstractClusterInvoker<T> {
try {
Result r = asyncResult.get(Integer.MAX_VALUE, TimeUnit.MILLISECONDS);
if (r.hasException()) {
log.error(CLUSTER_ASYN_INVOKE_FAILED,"asyn Invoke exception","","Invoke " + getGroupDescFromServiceKey(entry.getKey()) +
" failed: " + r.getException().getMessage(),r.getException());
log.error(CLUSTER_FAILED_GROUP_MERGE, "Invoke " + getGroupDescFromServiceKey(entry.getKey()) +
" failed: " + r.getException().getMessage(), "", r.getException().getMessage());
} else {
resultList.add(r);
}

View File

@ -33,6 +33,34 @@ import java.util.concurrent.atomic.AtomicLong;
@SuppressWarnings("rawtypes")
public class ConsistentHashLoadBalanceTest extends LoadBalanceBaseTest {
@Test
public void testConsistentHashLoadBalanceInGenericCall() {
int runs = 10000;
Map<Invoker, AtomicLong> genericInvokeCounter = getGenericInvokeCounter(runs, ConsistentHashLoadBalance.NAME);
Map<Invoker, AtomicLong> invokeCounter = getInvokeCounter(runs, ConsistentHashLoadBalance.NAME);
Invoker genericHitted = findHitted(genericInvokeCounter);
Invoker hitted = findHitted(invokeCounter);
Assertions.assertEquals(hitted,
genericHitted, "hitted should equals to genericHitted");
}
private Invoker findHitted(Map<Invoker,AtomicLong> invokerCounter) {
Invoker invoker = null;
for (Map.Entry<Invoker,AtomicLong> entry : invokerCounter.entrySet()) {
if (entry.getValue().longValue() > 0) {
invoker = entry.getKey();
break;
}
}
Assertions.assertNotNull(invoker,"invoker should be found");
return null;
}
@Test
public void testConsistentHashLoadBalance() {
int runs = 10000;

View File

@ -48,6 +48,7 @@ import static org.mockito.Mockito.mock;
@SuppressWarnings({"unchecked", "rawtypes"})
public class LoadBalanceBaseTest {
Invocation invocation;
Invocation genericInvocation;
List<Invoker<LoadBalanceBaseTest>> invokers = new ArrayList<Invoker<LoadBalanceBaseTest>>();
Invoker<LoadBalanceBaseTest> invoker1;
Invoker<LoadBalanceBaseTest> invoker2;
@ -79,6 +80,14 @@ public class LoadBalanceBaseTest {
given(invocation.getMethodName()).willReturn("method1");
given(invocation.getArguments()).willReturn(new Object[] {"arg1","arg2","arg3"});
genericInvocation = mock(Invocation.class);
String methodName = "method1";
given(genericInvocation.getMethodName()).willReturn("$invoke");
String[] paraTypes = new String[] {String.class.getName(),String.class.getName(),String.class.getName()};
Object[] argsObject = new Object[] {"arg1","arg2","arg3"};
Object[] args = new Object[] {methodName,paraTypes,argsObject};
given(genericInvocation.getArguments()).willReturn(args);
invoker1 = mock(Invoker.class);
invoker2 = mock(Invoker.class);
invoker3 = mock(Invoker.class);
@ -132,6 +141,20 @@ public class LoadBalanceBaseTest {
return counter;
}
public Map<Invoker, AtomicLong> getGenericInvokeCounter(int runs, String loadbalanceName) {
Map<Invoker, AtomicLong> counter = new ConcurrentHashMap<Invoker, AtomicLong>();
LoadBalance lb = getLoadBalance(loadbalanceName);
for (Invoker invoker : invokers) {
counter.put(invoker, new AtomicLong(0));
}
URL url = invokers.get(0).getUrl();
for (int i = 0; i < runs; i++) {
Invoker sinvoker = lb.select(invokers, url, genericInvocation);
counter.get(sinvoker).incrementAndGet();
}
return counter;
}
protected AbstractLoadBalance getLoadBalance(String loadbalanceName) {
return (AbstractLoadBalance) ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(loadbalanceName);
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.common;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -30,6 +30,7 @@ import java.util.Map;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY_PREFIX;
import static org.apache.dubbo.common.constants.CommonConstants.HIDE_KEY_PREFIX;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* Parameters for backward compatibility for version prior to 2.0.5
@ -38,7 +39,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.HIDE_KEY_PREFIX;
*/
@Deprecated
public class Parameters {
protected static final Logger logger = LoggerFactory.getLogger(Parameters.class);
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Parameters.class);
private final Map<String, String> parameters;
public Parameters(String... pairs) {
@ -91,7 +92,7 @@ public class Parameters {
try {
value = URLDecoder.decode(value, "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage(), e);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
}
}
return value;

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.common;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -32,11 +32,13 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* Version
*/
public final class Version {
private static final Logger logger = LoggerFactory.getLogger(Version.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Version.class);
private static final Pattern PREFIX_DIGITS_PATTERN = Pattern.compile("^([0-9]*).*");
@ -74,9 +76,10 @@ public final class Version {
/**
* Compare versions
*
* @return the value {@code 0} if {@code version1 == version2};
* a value less than {@code 0} if {@code version1 < version2}; and
* a value greater than {@code 0} if {@code version1 > version2}
* a value less than {@code 0} if {@code version1 < version2}; and
* a value greater than {@code 0} if {@code version1 > version2}
*/
public static int compare(String version1, String version2) {
return Integer.compare(getIntVersion(version1), getIntVersion(version2));
@ -131,9 +134,9 @@ public final class Version {
v = v * 100;
}
} catch (Exception e) {
logger.warn("Please make sure your version value has the right format: " +
"\n 1. only contains digital number: 2.0.0; \n 2. with string suffix: 2.6.7-stable. " +
"\nIf you are using Dubbo before v2.6.2, the version value is the same with the jar version.");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Please make sure your version value has the right format: " +
"\n 1. only contains digital number: 2.0.0; \n 2. with string suffix: 2.6.7-stable. " +
"\nIf you are using Dubbo before v2.6.2, the version value is the same with the jar version.");
v = LEGACY_DUBBO_PROTOCOL_VERSION;
}
VERSION2INT.put(version, v);
@ -190,11 +193,11 @@ public final class Version {
}
URL location = codeSource.getLocation();
if (location == null){
if (location == null) {
logger.info("No location for class " + cls.getName() + " when getVersion, use default version " + defaultVersion);
return defaultVersion;
}
String file = location.getFile();
String file = location.getFile();
if (!StringUtils.isEmpty(file) && file.endsWith(".jar")) {
version = getFromFile(file);
}
@ -203,7 +206,7 @@ public final class Version {
return StringUtils.isEmpty(version) ? defaultVersion : version;
} catch (Throwable e) {
// return default version when any exception is thrown
logger.error("return default version, ignore exception " + e.getMessage(), e);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "return default version, ignore exception " + e.getMessage(), e);
return defaultVersion;
}
}
@ -257,11 +260,11 @@ public final class Version {
if (failOnError) {
throw new IllegalStateException(error);
} else {
logger.error(error);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", error);
}
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
}
}

View File

@ -21,7 +21,7 @@ import org.apache.dubbo.common.beans.support.InstantiationStrategy;
import org.apache.dubbo.common.extension.ExtensionAccessor;
import org.apache.dubbo.common.extension.ExtensionAccessorAware;
import org.apache.dubbo.common.extension.ExtensionPostProcessor;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.resource.Disposable;
import org.apache.dubbo.common.utils.StringUtils;
@ -37,12 +37,14 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_DESTROY_INVOKER;
/**
* A bean factory for internal sharing.
*/
public class ScopeBeanFactory {
protected static final Logger LOGGER = LoggerFactory.getLogger(ScopeBeanFactory.class);
protected static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ScopeBeanFactory.class);
private final ScopeBeanFactory parent;
private ExtensionAccessor extensionAccessor;
@ -239,14 +241,14 @@ public class ScopeBeanFactory {
}
public void destroy() {
if (destroyed.compareAndSet(false, true)){
if (destroyed.compareAndSet(false, true)) {
for (BeanInfo beanInfo : registeredBeanInfos) {
if (beanInfo.instance instanceof Disposable) {
try {
Disposable beanInstance = (Disposable) beanInfo.instance;
beanInstance.destroy();
} catch (Throwable e) {
LOGGER.error("An error occurred when destroy bean [name=" + beanInfo.name + ", bean=" + beanInfo.instance + "]: " + e, e);
LOGGER.error(CONFIG_FAILED_DESTROY_INVOKER, "", "", "An error occurred when destroy bean [name=" + beanInfo.name + ", bean=" + beanInfo.instance + "]: " + e, e);
}
}
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.common.config;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ArrayUtils;
@ -24,11 +24,13 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_LOAD_ENV_VARIABLE;
/**
* This is an abstraction specially customized for the sequence Dubbo retrieves properties.
*/
public class CompositeConfiguration implements Configuration {
private final Logger logger = LoggerFactory.getLogger(CompositeConfiguration.class);
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CompositeConfiguration.class);
/**
* List holding all the configuration
@ -80,7 +82,7 @@ public class CompositeConfiguration implements Configuration {
return value;
}
} catch (Exception e) {
logger.error("Error when trying to get value for key " + key + " from " + config + ", " +
logger.error(CONFIG_FAILED_LOAD_ENV_VARIABLE, "", "", "Error when trying to get value for key " + key + " from " + config + ", " +
"will continue to try the next one.");
}
}

View File

@ -20,7 +20,7 @@ package org.apache.dubbo.common.config;
import org.apache.dubbo.common.config.configcenter.DynamicConfigurationFactory;
import org.apache.dubbo.common.extension.ExtensionAccessor;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -44,6 +44,7 @@ import java.util.Set;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_SECONDS_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* Utilities for manipulating configurations from different sources
@ -57,7 +58,7 @@ public final class ConfigurationUtils {
throw new UnsupportedOperationException("No instance of 'ConfigurationUtils' for you! ");
}
private static final Logger logger = LoggerFactory.getLogger(ConfigurationUtils.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ConfigurationUtils.class);
private static final List<String> securityKey;
static {
@ -108,6 +109,7 @@ public final class ConfigurationUtils {
/**
* Server shutdown wait timeout mills
*
* @return
*/
@SuppressWarnings("deprecation")
@ -172,30 +174,30 @@ public final class ConfigurationUtils {
public static Map<String, String> parseProperties(String content) throws IOException {
Map<String, String> map = new HashMap<>();
if (StringUtils.isEmpty(content)) {
logger.warn("Config center was specified, but no config item found.");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Config center was specified, but no config item found.");
} else {
Properties properties = new Properties();
properties.load(new StringReader(content));
properties.stringPropertyNames().forEach(
k -> {
boolean deny = false;
for (String key : securityKey) {
if (k.contains(key)) {
deny = true;
break;
}
k -> {
boolean deny = false;
for (String key : securityKey) {
if (k.contains(key)) {
deny = true;
break;
}
if (!deny) {
map.put(k, properties.getProperty(k));
}
});
}
if (!deny) {
map.put(k, properties.getProperty(k));
}
});
}
return map;
}
public static boolean isEmptyValue(Object value) {
return value == null ||
value instanceof String && StringUtils.isBlank((String) value);
value instanceof String && StringUtils.isBlank((String) value);
}
/**
@ -212,6 +214,7 @@ public final class ConfigurationUtils {
* props: {"name": "dubbo", "port" : "1234"}
*
* </pre>
*
* @param configMaps
* @param prefix
* @param <V>
@ -239,11 +242,11 @@ public final class ConfigurationUtils {
}
if (CollectionUtils.isNotEmptyMap(configMap)) {
Map<String,V> copy ;
synchronized (configMap){
Map<String, V> copy;
synchronized (configMap) {
copy = new HashMap<>(configMap);
}
for(Map.Entry<String, V> entry : copy.entrySet()) {
for (Map.Entry<String, V> entry : copy.entrySet()) {
String key = entry.getKey();
V val = entry.getValue();
if (StringUtils.startsWithIgnoreCase(key, prefix)
@ -280,8 +283,8 @@ public final class ConfigurationUtils {
if (!prefix.endsWith(".")) {
prefix += ".";
}
Map<String,V> copy ;
synchronized (configMap){
Map<String, V> copy;
synchronized (configMap) {
copy = new HashMap<>(configMap);
}
for (Map.Entry<String, V> entry : copy.entrySet()) {
@ -319,8 +322,8 @@ public final class ConfigurationUtils {
}
Set<String> ids = new LinkedHashSet<>();
for (Map<String, V> configMap : configMaps) {
Map<String,V> copy ;
synchronized (configMap){
Map<String, V> copy;
synchronized (configMap) {
copy = new HashMap<>(configMap);
}
for (Map.Entry<String, V> entry : copy.entrySet()) {
@ -357,6 +360,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getSystemConfiguration(ScopeModel)}
*/
@Deprecated
@ -366,6 +370,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getEnvConfiguration(ScopeModel)}
*/
@Deprecated
@ -375,6 +380,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getGlobalConfiguration(ScopeModel)}
*/
@Deprecated
@ -384,6 +390,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicGlobalConfiguration(ScopeModel)}
*/
@Deprecated
@ -393,6 +400,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getCachedDynamicProperty(ScopeModel, String, String)}
*/
@Deprecated
@ -402,6 +410,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicProperty(ScopeModel, String)}
*/
@Deprecated
@ -411,6 +420,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicProperty(ScopeModel, String, String)}
*/
@Deprecated
@ -420,6 +430,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getProperty(ScopeModel, String)}
*/
@Deprecated
@ -429,6 +440,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#getProperty(ScopeModel, String, String)}
*/
@Deprecated
@ -438,6 +450,7 @@ public final class ConfigurationUtils {
/**
* For compact single instance
*
* @deprecated Replaced to {@link ConfigurationUtils#get(ScopeModel, String, int)}
*/
@Deprecated

View File

@ -21,7 +21,7 @@ import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.context.ApplicationExt;
import org.apache.dubbo.common.context.LifecycleAdapter;
import org.apache.dubbo.common.extension.DisableInject;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ConfigUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -35,8 +35,10 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
public class Environment extends LifecycleAdapter implements ApplicationExt {
private static final Logger logger = LoggerFactory.getLogger(Environment.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Environment.class);
public static final String NAME = "environment";
@ -160,6 +162,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
/**
* Merge target map properties into app configuration
*
* @param map
*/
public void updateAppConfigMap(Map<String, String> map) {
@ -215,6 +218,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
/**
* Get configuration map list for target instance
*
* @param config
* @param prefix
* @return
@ -238,6 +242,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
/**
* Get global configuration as map list
*
* @return
*/
public List<Map<String, String>> getConfigurationMaps() {
@ -263,7 +268,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
try {
defaultDynamicConfiguration.close();
} catch (Exception e) {
logger.warn("close dynamic configuration failed: " + e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "close dynamic configuration failed: " + e.getMessage(), e);
}
defaultDynamicConfiguration = null;
}
@ -322,7 +327,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
if (defaultDynamicGlobalConfiguration == null) {
if (defaultDynamicConfiguration == null) {
if (logger.isWarnEnabled()) {
logger.warn("dynamicConfiguration is null , return globalConfiguration.");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "dynamicConfiguration is null , return globalConfiguration.");
}
return getConfiguration();
}

View File

@ -19,7 +19,7 @@ package org.apache.dubbo.common.config;
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.context.ModuleExt;
import org.apache.dubbo.common.extension.DisableInject;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.config.AbstractConfig;
import org.apache.dubbo.rpc.model.ModuleModel;
@ -29,11 +29,13 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
public class ModuleEnvironment extends Environment implements ModuleExt {
// delegate
private static final Logger logger = LoggerFactory.getLogger(ModuleEnvironment.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ModuleEnvironment.class);
public static final String NAME = "moduleEnvironment";
@ -97,7 +99,7 @@ public class ModuleEnvironment extends Environment implements ModuleExt {
if (dynamicGlobalConfiguration == null) {
if (dynamicConfiguration == null) {
if (logger.isWarnEnabled()) {
logger.warn("dynamicConfiguration is null , return globalConfiguration.");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "dynamicConfiguration is null , return globalConfiguration.");
}
return getConfiguration();
}

View File

@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* The abstract implementation of {@link DynamicConfiguration}
@ -88,14 +89,14 @@ public abstract class AbstractDynamicConfiguration implements DynamicConfigurati
protected AbstractDynamicConfiguration(URL url) {
this(getThreadPoolPrefixName(url), getThreadPoolSize(url), getThreadPoolKeepAliveTime(url), getGroup(url),
getTimeout(url));
getTimeout(url));
}
protected AbstractDynamicConfiguration(String threadPoolPrefixName,
int threadPoolSize,
long keepAliveTime,
String group,
long timeout) {
int threadPoolSize,
long keepAliveTime,
String group,
long timeout) {
this.workersThreadPool = initWorkersThreadPool(threadPoolPrefixName, threadPoolSize, keepAliveTime);
this.group = group;
this.timeout = timeout;
@ -212,7 +213,7 @@ public abstract class AbstractDynamicConfiguration implements DynamicConfigurati
}
} catch (Exception e) {
if (logger.isErrorEnabled()) {
logger.error(e.getMessage(), e);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
}
}
return value;
@ -236,7 +237,7 @@ public abstract class AbstractDynamicConfiguration implements DynamicConfigurati
int threadPoolSize,
long keepAliveTime) {
return new ThreadPoolExecutor(threadPoolSize, threadPoolSize, keepAliveTime,
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory(threadPoolPrefixName, true));
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory(threadPoolPrefixName, true));
}
protected static String getThreadPoolPrefixName(URL url) {

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.common.config.configcenter.wrapper;
import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.util.HashSet;
@ -26,6 +26,8 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNEXPECTED_EXCEPTION;
/**
* support multiple config center, simply iterating each concrete config center.
*/
@ -33,7 +35,7 @@ public class CompositeDynamicConfiguration implements DynamicConfiguration {
public static final String NAME = "COMPOSITE";
private static final Logger logger = LoggerFactory.getLogger(CompositeDynamicConfiguration.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CompositeDynamicConfiguration.class);
private Set<DynamicConfiguration> configurations = new HashSet<>();
@ -90,7 +92,7 @@ public class CompositeDynamicConfiguration implements DynamicConfiguration {
try {
configuration.close();
} catch (Exception e) {
logger.warn("close dynamic configuration " + configuration.getClass().getName() + "failed: " + e.getMessage(), e);
logger.warn(REGISTRY_UNEXPECTED_EXCEPTION, "", "", "close dynamic configuration " + configuration.getClass().getName() + "failed: " + e.getMessage(), e);
}
}
configurations.clear();

View File

@ -22,7 +22,7 @@ package org.apache.dubbo.common.constants;
*/
public interface LoggerCodeConstants {
// common module 0-1 ~ 0-4
// common module
String COMMON_THREAD_POOL_EXHAUSTED = "0-1";
String COMMON_PROPERTY_MISSPELLING = "0-2";
@ -31,9 +31,50 @@ public interface LoggerCodeConstants {
String COMMON_CACHE_MAX_FILE_SIZE_LIMIT_EXCEED = "0-4";
String COMMON_CACHE_MAX_ENTRY_COUNT_LIMIT_EXCEED = "0-5";
String COMMON_THREAD_INTERRUPTED_EXCEPTION = "0-6";
String COMMON_CLASS_NOT_FOUND = "0-7";
String COMMON_FAILED_REFLECT = "0-8";
String COMMON_FAILED_NOTIFY_EVENT = "0-9";
String COMMON_UNSUPPORTED_INVOKER = "0-10";
String COMMON_FAILED_STOP_HTTP_SERVER = "0-11";
String COMMON_UNEXPECTED_EXCEPTION = "0-12";
String COMMON_METRICS_COLLECTOR_EXCEPTION = "0-13";
String COMMON_MONITOR_EXCEPTION = "0-14";
String COMMON_ERROR_LOAD_EXTENSION = "0-15";
String COMMON_EXECUTORS_NO_FOUND = "0-16";
String COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN = "0-17";
String COMMON_ERROR_USE_THREAD_POOL = "0-18";
String COMMON_ERROR_RUN_THREAD_TASK = "0-19";
String COMMON_UNEXPECTED_CREATE_DUMP = "0-20";
String COMMON_ERROR_TOO_MANY_INSTANCES = "0-21";
String COMMON_IO_EXCEPTION = "0-22";
String COMMON_JSON_CONVERT_EXCEPTION = "0-23";
String COMMON_FAILED_OVERRIDE_FIELD = "0-24";
String COMMON_FAILED_LOAD_MAPPING_CACHE = "0-24";
String COMMON_METADATA_PROCESSOR = "0-25";
// registry module
String REGISTRY_ADDRESS_INVALID = "1-1";
@ -71,9 +112,51 @@ public interface LoggerCodeConstants {
String REGISTRY_MISSING_METADATA_CONFIG_PORT = "1-18";
String REGISTRY_ROUTER_WAIT_LONG = "1-19";
String REGISTRY_ERROR_LISTEN_KUBERNETES = "1-19";
// cluster module 2-1 ~ 2-18
String REGISTRY_UNABLE_MATCH_KUBERNETES = "1-20";
String REGISTRY_UNABLE_FIND_SERVICE_KUBERNETES = "1-21";
String REGISTRY_UNABLE_ACCESS_KUBERNETES = "1-22";
String REGISTRY_FAILED_DOWNLOAD_FILE = "1-23";
String REGISTRY_FAILED_START_ZOOKEEPER = "1-24";
String REGISTRY_FAILED_STOP_ZOOKEEPER = "1-25";
String REGISTRY_FAILED_GENERATE_CERT_ISTIO = "1-26";
String REGISTRY_FAILED_GENERATE_KEY_ISTIO = "1-27";
String REGISTRY_RECEIVE_ERROR_MSG_ISTIO = "1-28";
String REGISTRY_ERROR_READ_FILE_ISTIO = "1-29";
String REGISTRY_ERROR_REQUEST_XDS = "1-30";
String REGISTRY_ERROR_RESPONSE_XDS = "1-31";
String REGISTRY_ERROR_CREATE_CHANNEL_XDS = "1-32";
String REGISTRY_ERROR_INITIALIZE_XDS = "1-33";
String REGISTRY_ERROR_PARSING_XDS = "1-34";
String REGISTRY_ZOOKEEPER_EXCEPTION = "1-35";
String REGISTRY_UNEXPECTED_EXCEPTION = "1-36";
String REGISTRY_NACOS_EXCEPTION = "1-37";
String REGISTRY_SOCKET_EXCEPTION = "1-38";
String REGISTRY_FAILED_LOAD_METADATA = "1-39";
String REGISTRY_ROUTER_WAIT_LONG = "1-40";
// cluster module 2-x
String CLUSTER_FAILED_SITE_SELECTION = "2-1";
String CLUSTER_NO_VALID_PROVIDER = "2-2";
@ -110,19 +193,67 @@ public interface LoggerCodeConstants {
String CLUSTER_NO_RULE_LISTENER = "2-18";
String CLUSTER_ASYN_INVOKE_FAILED = "2-19";
String CLUSTER_EXECUTE_FILTER_EXCEPTION = "2-19";
String CLUSTER_FAILED_GROUP_MERGE = "2-20";
// proxy module 3-1
String PROXY_FAILED_CONVERT_URL = "3-1";
// protocol module 4-1 ~ 4-3
String PROXY_FAILED_EXPORT_SERVICE = "3-2";
String PROXY_FAILED_JAVASSIST = "3-3";
String PROXY_TIMEOUT_REQUEST = "3-4";
String PROXY_ERROR_ASYNC_RESPONSE = "3-5";
String PROXY_UNSUPPORTED_INVOKER = "3-6";
String PROXY_TIMEOUT_RESPONSE = "3-7";
// protocol module
String PROTOCOL_UNSUPPORTED = "4-1";
String PROTOCOL_FAILED_INIT_SERIALIZATION_OPTIMIZER = "4-2";
String PROTOCOL_FAILED_REFER_INVOKER = "4-3";
// config module 5-1 ~ 5-20
String PROTOCOL_UNSAFE_SERIALIZATION = "4-4";
String PROTOCOL_FAILED_CLOSE_STREAM = "4-5";
String PROTOCOL_ERROR_DESERIALIZE = "4-6";
String PROTOCOL_ERROR_CLOSE_CLIENT = "4-7";
String PROTOCOL_ERROR_CLOSE_SERVER = "4-8";
String PROTOCOL_FAILED_PARSE = "4-9";
String PROTOCOL_FAILED_SERIALIZE_TRIPLE = "4-10";
String PROTOCOL_FAILED_REQUEST = "4-11";
String PROTOCOL_FAILED_CREATE_STREAM_TRIPLE = "4-12";
String PROTOCOL_TIMEOUT_SERVER = "4-13";
String PROTOCOL_FAILED_RESPONSE = "4-14";
String PROTOCOL_STREAM_LISTENER = "4-15";
String PROTOCOL_CLOSED_SERVER = "4-16";
String PROTOCOL_FAILED_DESTROY_INVOKER = "4-17";
String PROTOCOL_FAILED_LOAD_MODEL = "4-18";
String PROTOCOL_INCORRECT_PARAMETER_VALUES = "4-19";
String PROTOCOL_FAILED_DECODE = "4-20";
// config module
String CONFIG_FAILED_CONNECT_REGISTRY = "5-1";
String CONFIG_FAILED_SHUTDOWN_HOOK = "5-2";
@ -163,12 +294,83 @@ public interface LoggerCodeConstants {
String CONFIG_STOP_DUBBO_ERROR = "5-20";
// transport module 6-1 ~ 6-2
String CONFIG_FAILED_EXECUTE_DESTORY = "5-21";
String CONFIG_FAILED_INIT_CONFIG_CENTER = "5-22";
String CONFIG_FAILED_WAIT_EXPORT_REFER = "5-23";
String CONFIG_FAILED_REFER_SERVICE = "5-24";
String CONFIG_UNDEFINED_PROTOCOL = "5-25";
String CONFIG_METADATA_SERVICE_EXPORTED = "5-26";
String CONFIG_API_WRONG_USE = "5-27";
String CONFIG_NO_ANNOTATIONS_FOUND = "5-28";
String CONFIG_NO_BEANS_SCANNED = "5-29";
String CONFIG_DUPLICATED_BEAN_DEFINITION = "5-30";
String CONFIG_WARN_STATUS_CHECKER = "5-31";
String CONFIG_FAILED_CLOSE_CONNECT_APOLLO = "5-32";
String CONFIG_NOT_EFFECT_EMPTY_RULE_APOLLO = "5-33";
String CONFIG_ERROR_NACOS = "5-34";
String CONFIG_START_DUBBO_ERROR = "5-35";
String CONFIG_FILTER_VALIDATION_EXCEPTION = "5-36";
// transport module
String TRANSPORT_FAILED_CONNECT_PROVIDER = "6-1";
String TRANSPORT_CLIENT_CONNECT_TIMEOUT = "6-2";
String INTERNAL_SERVICE_CONFIG_ERROR = "6-3";
String TRANSPORT_FAILED_CLOSE = "6-3";
String TRANSPORT_UNEXPECTED_EXCEPTION = "6-4";
String TRANSPORT_FAILED_DISCONNECT_PROVIDER = "6-5";
String TRANSPORT_UNSUPPORTED_MESSAGE = "6-6";
String TRANSPORT_CONNECTION_LIMIT_EXCEED = "6-7";
String TRANSPORT_FAILED_DECODE = "6-8";
String TRANSPORT_FAILED_SERIALIZATION = "6-9";
String TRANSPORT_EXCEED_PAYLOAD_LIMIT = "6-10";
String TRANSPORT_UNSUPPORTED_CHARSET = "6-11";
String TRANSPORT_FAILED_DESTROY_ZOOKEEPER = "6-12";
String TRANSPORT_FAILED_CLOSE_STREAM = "6-13";
String TRANSPORT_FAILED_RESPONSE = "6-14";
String TRANSPORT_SKIP_UNUSED_STREAM = "6-15";
String TRANSPORT_FAILED_RECONNECT = "6-3";
// qos plugin
String QOS_PROFILER_DISABLED = "7-1";
String QOS_PROFILER_ENABLED = "7-2";
String QOS_PROFILER_WARN_PERCENT = "7-3";
String QOS_FAILED_START_SERVER = "7-4";
String QOS_COMMAND_NOT_FOUND = "7-5";
String QOS_UNEXPECTED_EXCEPTION = "7-6";
// Internal unknown error.

View File

@ -16,13 +16,14 @@
*/
package org.apache.dubbo.common.deploy;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.rpc.model.ScopeModel;
import java.util.ArrayList;
import java.util.List;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
import static org.apache.dubbo.common.deploy.DeployState.FAILED;
import static org.apache.dubbo.common.deploy.DeployState.PENDING;
import static org.apache.dubbo.common.deploy.DeployState.STARTED;
@ -32,7 +33,7 @@ import static org.apache.dubbo.common.deploy.DeployState.STOPPING;
public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer<E> {
private static final Logger logger = LoggerFactory.getLogger(AbstractDeployer.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractDeployer.class);
private volatile DeployState state = PENDING;
@ -108,7 +109,7 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
try {
listener.onStarting(scopeModel);
} catch (Throwable e) {
logger.error(getIdentifier() + " an exception occurred when handle starting event", e);
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle starting event", e);
}
}
}
@ -119,17 +120,18 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
try {
listener.onStarted(scopeModel);
} catch (Throwable e) {
logger.error(getIdentifier() + " an exception occurred when handle started event", e);
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle started event", e);
}
}
}
protected void setStopping() {
this.state = STOPPING;
for (DeployListener<E> listener : listeners) {
try {
listener.onStopping(scopeModel);
} catch (Throwable e) {
logger.error(getIdentifier() + " an exception occurred when handle stopping event", e);
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle stopping event", e);
}
}
}
@ -140,7 +142,7 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
try {
listener.onStopped(scopeModel);
} catch (Throwable e) {
logger.error(getIdentifier() + " an exception occurred when handle stopped event", e);
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle stopped event", e);
}
}
}
@ -152,7 +154,7 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
try {
listener.onFailure(scopeModel, error);
} catch (Throwable e) {
logger.error(getIdentifier() + " an exception occurred when handle failed event", e);
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle failed event", e);
}
}
}

View File

@ -23,7 +23,7 @@ import org.apache.dubbo.common.context.Lifecycle;
import org.apache.dubbo.common.extension.support.ActivateComparator;
import org.apache.dubbo.common.extension.support.WrapperComparator;
import org.apache.dubbo.common.lang.Prioritized;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.resource.Disposable;
import org.apache.dubbo.common.utils.ArrayUtils;
@ -80,6 +80,8 @@ import static java.util.stream.StreamSupport.stream;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.REMOVE_VALUE_PREFIX;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_LOAD_EXTENSION;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_LOAD_ENV_VARIABLE;
/**
* {@link org.apache.dubbo.rpc.model.ApplicationModel}, {@code DubboBootstrap} and this class are
@ -101,7 +103,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.REMOVE_VALUE_PRE
*/
public class ExtensionLoader<T> {
private static final Logger logger = LoggerFactory.getLogger(ExtensionLoader.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ExtensionLoader.class);
private static final Pattern NAME_SEPARATOR = Pattern.compile("\\s*[,]+\\s*");
private static final String SPECIAL_SPI_PROPERTIES = "special_spi.properties";
@ -131,9 +133,9 @@ public class ExtensionLoader<T> {
private static volatile LoadingStrategy[] strategies = loadLoadingStrategies();
private static Map<String,String> specialSPILoadingStrategyMap = getSpecialSPILoadingStrategyMap();
private static Map<String, String> specialSPILoadingStrategyMap = getSpecialSPILoadingStrategyMap();
private static SoftReference<Map<java.net.URL,List<String>>> urlListMapCache = new SoftReference<>(new ConcurrentHashMap<>());
private static SoftReference<Map<java.net.URL, List<String>>> urlListMapCache = new SoftReference<>(new ConcurrentHashMap<>());
private static List<String> ignoredInjectMethodsDesc = getIgnoredInjectMethodsDesc();
@ -169,6 +171,7 @@ public class ExtensionLoader<T> {
/**
* some spi are implements by dubbo framework only and scan multi classloaders resources may cause
* application startup very slow
*
* @return
*/
private static Map<String, String> getSpecialSPILoadingStrategyMap() {
@ -243,7 +246,7 @@ public class ExtensionLoader<T> {
try {
disposable.destroy();
} catch (Exception e) {
logger.error("Error destroying extension " + disposable, e);
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Error destroying extension " + disposable, e);
}
}
});
@ -257,7 +260,7 @@ public class ExtensionLoader<T> {
try {
disposable.destroy();
} catch (Exception e) {
logger.error("Error destroying extension " + disposable, e);
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Error destroying extension " + disposable, e);
}
}
}
@ -875,12 +878,12 @@ public class ExtensionLoader<T> {
method.invoke(instance, object);
}
} catch (Exception e) {
logger.error("Failed to inject via method " + method.getName()
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Failed to inject via method " + method.getName()
+ " of interface " + type.getName() + ": " + e.getMessage(), e);
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", e.getMessage(), e);
}
return instance;
}
@ -935,7 +938,7 @@ public class ExtensionLoader<T> {
try {
classes = loadExtensionClasses();
} catch (InterruptedException e) {
logger.error("Exception occurred when loading extension class (interface: " + type + ")", e);
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Exception occurred when loading extension class (interface: " + type + ")", e);
throw new IllegalStateException("Exception occurred when loading extension class (interface: " + type + ")", e);
}
cachedClasses.set(classes);
@ -1017,16 +1020,16 @@ public class ExtensionLoader<T> {
}
}
if (specialSPILoadingStrategyMap.containsKey(type)){
if (specialSPILoadingStrategyMap.containsKey(type)) {
String internalDirectoryType = specialSPILoadingStrategyMap.get(type);
//skip to load spi when name don't match
if (!LoadingStrategy.ALL.equals(internalDirectoryType)
&& !internalDirectoryType.equals(loadingStrategy.getName())){
&& !internalDirectoryType.equals(loadingStrategy.getName())) {
return;
}
classLoadersToLoad.clear();
classLoadersToLoad.add(ExtensionLoader.class.getClassLoader());
}else {
} else {
// load from scope model
Set<ClassLoader> classLoaders = scopeModel.getClassLoaders();
@ -1055,7 +1058,7 @@ public class ExtensionLoader<T> {
} catch (InterruptedException e) {
throw e;
} catch (Throwable t) {
logger.error("Exception occurred when loading extension class (interface: " +
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Exception occurred when loading extension class (interface: " +
type + ", description file: " + fileName + ").", t);
}
}
@ -1095,7 +1098,7 @@ public class ExtensionLoader<T> {
}
}
} catch (Throwable t) {
logger.error("Exception occurred when loading extension class (interface: " +
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Exception occurred when loading extension class (interface: " +
type + ", class file: " + resourceURL + ") in " + resourceURL, t);
}
}
@ -1111,7 +1114,7 @@ public class ExtensionLoader<T> {
}
}
List<String> contentList = urlListMap.computeIfAbsent(resourceURL,key->{
List<String> contentList = urlListMap.computeIfAbsent(resourceURL, key -> {
List<String> newContentList = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceURL.openStream(), StandardCharsets.UTF_8))) {
@ -1222,7 +1225,7 @@ public class ExtensionLoader<T> {
// duplicate implementation is unacceptable
unacceptableExceptions.add(name);
String duplicateMsg = "Duplicate extension " + type.getName() + " name " + name + " on " + c.getName() + " and " + clazz.getName();
logger.error(duplicateMsg);
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", duplicateMsg);
throw new IllegalStateException(duplicateMsg);
}
}
@ -1360,7 +1363,7 @@ public class ExtensionLoader<T> {
}
}
} catch (IOException ex) {
logger.error("load properties failed.", ex);
logger.error(CONFIG_FAILED_LOAD_ENV_VARIABLE, "", "", "load properties failed.", ex);
}
}

View File

@ -16,16 +16,18 @@
*/
package org.apache.dubbo.common.reference;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_CLOSE_CLIENT;
/**
* inspired by Netty
*/
public abstract class ReferenceCountedResource implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(ReferenceCountedResource.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ReferenceCountedResource.class);
private static final AtomicLongFieldUpdater<ReferenceCountedResource> COUNTER_UPDATER
= AtomicLongFieldUpdater.newUpdater(ReferenceCountedResource.class, "counter");
@ -53,7 +55,7 @@ public abstract class ReferenceCountedResource implements AutoCloseable {
destroy();
return true;
} else if (remainingCount <= -1) {
logger.warn("This instance has been destroyed");
logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", "This instance has been destroyed");
return false;
} else {
return false;

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.common.resource;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NamedThreadFactory;
@ -26,13 +26,15 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* Global resource repository between all framework models.
* It will be destroyed only after all framework model is destroyed.
*/
public class GlobalResourcesRepository {
private static final Logger logger = LoggerFactory.getLogger(GlobalResourcesRepository.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(GlobalResourcesRepository.class);
private volatile static GlobalResourcesRepository instance;
private volatile ExecutorService executorService;
@ -56,6 +58,7 @@ public class GlobalResourcesRepository {
/**
* Register a global reused disposable. The disposable will be executed when all dubbo FrameworkModels are destroyed.
* Note: the global disposable should be registered in static code, it's reusable and will not be removed when dubbo shutdown.
*
* @param disposable
*/
public static void registerGlobalDisposable(Disposable disposable) {
@ -107,7 +110,7 @@ public class GlobalResourcesRepository {
try {
disposable.destroy();
} catch (Exception e) {
logger.warn("destroy resources failed: " + e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "destroy resources failed: " + e.getMessage(), e);
}
}
// clear one-off disposable
@ -118,7 +121,7 @@ public class GlobalResourcesRepository {
try {
disposable.destroy();
} catch (Exception e) {
logger.warn("destroy resources failed: " + e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "destroy resources failed: " + e.getMessage(), e);
}
}
@ -129,6 +132,7 @@ public class GlobalResourcesRepository {
/**
* Register a one-off disposable, the disposable is removed automatically on first shutdown.
*
* @param disposable
*/
public void registerDisposable(Disposable disposable) {

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.common.system;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.MethodUtils;
@ -28,19 +28,21 @@ import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_CLASS_NOT_FOUND;
/**
* OperatingSystemBeanManager related.
*/
public class OperatingSystemBeanManager {
private static final Logger LOGGER = LoggerFactory.getLogger(OperatingSystemBeanManager.class);
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(OperatingSystemBeanManager.class);
/**
* com.ibm for J9
* com.sun for HotSpot
*/
private static final List<String> OPERATING_SYSTEM_BEAN_CLASS_NAMES = Arrays.asList(
"com.sun.management.OperatingSystemMXBean", "com.ibm.lang.management.OperatingSystemMXBean");
"com.sun.management.OperatingSystemMXBean", "com.ibm.lang.management.OperatingSystemMXBean");
private static final OperatingSystemMXBean OPERATING_SYSTEM_BEAN;
@ -57,7 +59,8 @@ public class OperatingSystemBeanManager {
PROCESS_CPU_USAGE_METHOD = deduceMethod("getProcessCpuLoad");
}
private OperatingSystemBeanManager() {}
private OperatingSystemBeanManager() {
}
public static OperatingSystemMXBean getOperatingSystemBean() {
return OPERATING_SYSTEM_BEAN;
@ -76,7 +79,7 @@ public class OperatingSystemBeanManager {
try {
return Class.forName(className);
} catch (ClassNotFoundException e) {
LOGGER.warn("[OperatingSystemBeanManager] Failed to load operating system bean class.", e);
LOGGER.warn(COMMON_CLASS_NOT_FOUND, "", "", "[OperatingSystemBeanManager] Failed to load operating system bean class.", e);
}
}
return null;

View File

@ -19,7 +19,7 @@ package org.apache.dubbo.common.threadpool.manager;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionAccessor;
import org.apache.dubbo.common.extension.ExtensionAccessorAware;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.store.DataStore;
import org.apache.dubbo.common.threadpool.ThreadPool;
@ -53,12 +53,15 @@ import static org.apache.dubbo.common.constants.CommonConstants.INTERNAL_EXECUTO
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_USE_THREAD_POOL;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_EXECUTORS_NO_FOUND;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN;
/**
* Consider implementing {@code Lifecycle} to enable executors shutdown when the process stops.
*/
public class DefaultExecutorRepository implements ExecutorRepository, ExtensionAccessorAware {
private static final Logger logger = LoggerFactory.getLogger(DefaultExecutorRepository.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DefaultExecutorRepository.class);
private volatile ScheduledExecutorService serviceExportExecutor;
@ -153,7 +156,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
}
if (CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(SIDE_KEY))){
if (CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(SIDE_KEY))) {
executorKey = CONSUMER_SHARED_EXECUTOR_SERVICE_COMPONENT_KEY;
}
return executorKey;
@ -172,7 +175,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
* have Executor instances generated and stored.
*/
if (executors == null) {
logger.warn("No available executors, this is not expected, framework should call createExecutorIfAbsent first " +
logger.warn(COMMON_EXECUTORS_NO_FOUND, "", "", "No available executors, this is not expected, framework should call createExecutorIfAbsent first" +
"before coming to here.");
return null;
@ -218,7 +221,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
}
}
} catch (Throwable t) {
logger.error(t.getMessage(), t);
logger.error(COMMON_ERROR_USE_THREAD_POOL, "", "", t.getMessage(), t);
}
}
@ -244,7 +247,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
serviceExportExecutor.shutdown();
} catch (Throwable ignored) {
// ignored
logger.warn(ignored.getMessage(), ignored);
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", ignored.getMessage(), ignored);
}
}
serviceExportExecutor = null;
@ -272,7 +275,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
try {
serviceReferExecutor.shutdown();
} catch (Throwable ignored) {
logger.warn(ignored.getMessage(), ignored);
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", ignored.getMessage(), ignored);
}
}
serviceReferExecutor = null;
@ -357,7 +360,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
ExecutorUtil.shutdownNow(executor, 100);
} catch (Throwable ignored) {
// ignored
logger.warn(ignored.getMessage(), ignored);
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", ignored.getMessage(), ignored);
}
}
});
@ -371,7 +374,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
executorService.shutdownNow();
} catch (Exception e) {
String msg = "shutdown executor service [" + name + "] failed: ";
logger.warn(msg + e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", msg + e.getMessage(), e);
}
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.common.threadpool.manager;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.resource.Disposable;
import org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory;
@ -30,8 +30,10 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN;
public class FrameworkExecutorRepository implements Disposable {
private static final Logger logger = LoggerFactory.getLogger(FrameworkExecutorRepository.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(FrameworkExecutorRepository.class);
private final ExecutorService sharedExecutor;
private final ScheduledExecutorService sharedScheduledExecutor;
@ -211,7 +213,7 @@ public class FrameworkExecutorRepository implements Disposable {
executorService.shutdownNow();
} catch (Exception e) {
String msg = "shutdown executor service [" + name + "] failed: ";
logger.warn(msg + e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", msg + e.getMessage(), e);
}
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.common.threadpool.serial;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadlocal.InternalThreadLocal;
@ -26,6 +26,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_RUN_THREAD_TASK;
/**
* Executor ensuring that all {@link Runnable} tasks submitted are executed in order
* using the provided {@link Executor}, and serially such that no two will ever be
@ -33,7 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public final class SerializingExecutor implements Executor, Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(SerializingExecutor.class);
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(SerializingExecutor.class);
/**
* Use false to stop and true to run
@ -100,7 +102,7 @@ public final class SerializingExecutor implements Executor, Runnable {
InternalThreadLocal.removeAll();
r.run();
} catch (RuntimeException e) {
LOGGER.error("Exception while executing runnable " + r, e);
LOGGER.error(COMMON_ERROR_RUN_THREAD_TASK, "", "", "Exception while executing runnable " + r, e);
} finally {
InternalThreadLocal.removeAll();
}

View File

@ -46,6 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.OS_NAME_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.OS_WIN_PREFIX;
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_POOL_EXHAUSTED_LISTENERS_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_THREAD_POOL_EXHAUSTED;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_CREATE_DUMP;
/**
* Abort Policy.
@ -162,7 +163,7 @@ public class AbortPolicyWithReport extends ThreadPoolExecutor.AbortPolicy {
new File(dumpPath, "Dubbo_JStack.log" + "." + dateStr))) {
JVMUtil.jstack(jStackStream);
} catch (Throwable t) {
logger.error("dump jStack error", t);
logger.error(COMMON_UNEXPECTED_CREATE_DUMP, "", "", "dump jStack error", t);
} finally {
guard.release();
}
@ -183,7 +184,7 @@ public class AbortPolicyWithReport extends ThreadPoolExecutor.AbortPolicy {
if (dumpDirectory.mkdirs()) {
logger.info(format("Dubbo dump directory[%s] created", dumpDirectory.getAbsolutePath()));
} else {
logger.warn(format("Dubbo dump directory[%s] can't be created, use the 'user.home'[%s]",
logger.warn(COMMON_UNEXPECTED_CREATE_DUMP, "", "", format("Dubbo dump directory[%s] can't be created, use the 'user.home'[%s]",
dumpDirectory.getAbsolutePath(), USER_HOME));
return USER_HOME;
}

View File

@ -16,7 +16,7 @@
package org.apache.dubbo.common.timer;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ClassUtils;
@ -38,6 +38,8 @@ import java.util.concurrent.atomic.AtomicLong;
import static org.apache.dubbo.common.constants.CommonConstants.OS_NAME_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.OS_WIN_PREFIX;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_RUN_THREAD_TASK;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_TOO_MANY_INSTANCES;
/**
* A {@link Timer} optimized for approximated I/O timeout scheduling.
@ -87,13 +89,13 @@ public class HashedWheelTimer implements Timer {
*/
public static final String NAME = "hased";
private static final Logger logger = LoggerFactory.getLogger(HashedWheelTimer.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(HashedWheelTimer.class);
private static final AtomicInteger INSTANCE_COUNTER = new AtomicInteger();
private static final AtomicBoolean WARNED_TOO_MANY_INSTANCES = new AtomicBoolean();
private static final int INSTANCE_COUNT_LIMIT = 64;
private static final AtomicIntegerFieldUpdater<HashedWheelTimer> WORKER_STATE_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimer.class, "workerState");
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimer.class, "workerState");
private final Worker worker = new Worker();
private final Thread workerThread;
@ -181,7 +183,7 @@ public class HashedWheelTimer implements Timer {
* @throws IllegalArgumentException if {@code tickDuration} is &lt;= 0
*/
public HashedWheelTimer(
ThreadFactory threadFactory, long tickDuration, TimeUnit unit) {
ThreadFactory threadFactory, long tickDuration, TimeUnit unit) {
this(threadFactory, tickDuration, unit, 512);
}
@ -198,8 +200,8 @@ public class HashedWheelTimer implements Timer {
* @throws IllegalArgumentException if either of {@code tickDuration} and {@code ticksPerWheel} is &lt;= 0
*/
public HashedWheelTimer(
ThreadFactory threadFactory,
long tickDuration, TimeUnit unit, int ticksPerWheel) {
ThreadFactory threadFactory,
long tickDuration, TimeUnit unit, int ticksPerWheel) {
this(threadFactory, tickDuration, unit, ticksPerWheel, -1);
}
@ -221,9 +223,9 @@ public class HashedWheelTimer implements Timer {
* @throws IllegalArgumentException if either of {@code tickDuration} and {@code ticksPerWheel} is &lt;= 0
*/
public HashedWheelTimer(
ThreadFactory threadFactory,
long tickDuration, TimeUnit unit, int ticksPerWheel,
long maxPendingTimeouts) {
ThreadFactory threadFactory,
long tickDuration, TimeUnit unit, int ticksPerWheel,
long maxPendingTimeouts) {
if (threadFactory == null) {
throw new NullPointerException("threadFactory");
@ -248,15 +250,15 @@ public class HashedWheelTimer implements Timer {
// Prevent overflow.
if (this.tickDuration >= Long.MAX_VALUE / wheel.length) {
throw new IllegalArgumentException(String.format(
"tickDuration: %d (expected: 0 < tickDuration in nanos < %d",
tickDuration, Long.MAX_VALUE / wheel.length));
"tickDuration: %d (expected: 0 < tickDuration in nanos < %d",
tickDuration, Long.MAX_VALUE / wheel.length));
}
workerThread = threadFactory.newThread(worker);
this.maxPendingTimeouts = maxPendingTimeouts;
if (INSTANCE_COUNTER.incrementAndGet() > INSTANCE_COUNT_LIMIT &&
WARNED_TOO_MANY_INSTANCES.compareAndSet(false, true)) {
WARNED_TOO_MANY_INSTANCES.compareAndSet(false, true)) {
reportTooManyInstances();
}
}
@ -277,11 +279,11 @@ public class HashedWheelTimer implements Timer {
private static HashedWheelBucket[] createWheel(int ticksPerWheel) {
if (ticksPerWheel <= 0) {
throw new IllegalArgumentException(
"ticksPerWheel must be greater than 0: " + ticksPerWheel);
"ticksPerWheel must be greater than 0: " + ticksPerWheel);
}
if (ticksPerWheel > 1073741824) {
throw new IllegalArgumentException(
"ticksPerWheel may not be greater than 2^30: " + ticksPerWheel);
"ticksPerWheel may not be greater than 2^30: " + ticksPerWheel);
}
ticksPerWheel = normalizeTicksPerWheel(ticksPerWheel);
@ -338,9 +340,9 @@ public class HashedWheelTimer implements Timer {
public Set<Timeout> stop() {
if (Thread.currentThread() == workerThread) {
throw new IllegalStateException(
HashedWheelTimer.class.getSimpleName() +
".stop() cannot be called from " +
TimerTask.class.getSimpleName());
HashedWheelTimer.class.getSimpleName() +
".stop() cannot be called from " +
TimerTask.class.getSimpleName());
}
if (!WORKER_STATE_UPDATER.compareAndSet(this, WORKER_STATE_STARTED, WORKER_STATE_SHUTDOWN)) {
@ -391,8 +393,8 @@ public class HashedWheelTimer implements Timer {
if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) {
pendingTimeouts.decrementAndGet();
throw new RejectedExecutionException("Number of pending timeouts ("
+ pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending "
+ "timeouts (" + maxPendingTimeouts + ")");
+ pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending "
+ "timeouts (" + maxPendingTimeouts + ")");
}
start();
@ -419,9 +421,9 @@ public class HashedWheelTimer implements Timer {
private static void reportTooManyInstances() {
String resourceType = ClassUtils.simpleClassName(HashedWheelTimer.class);
logger.error("You are creating too many " + resourceType + " instances. " +
resourceType + " is a shared resource that must be reused across the JVM," +
"so that only a few instances are created.");
logger.error(COMMON_ERROR_TOO_MANY_INSTANCES, "", "", "You are creating too many " + resourceType + " instances. " +
resourceType + " is a shared resource that must be reused across the JVM," +
"so that only a few instances are created.");
}
private final class Worker implements Runnable {
@ -447,7 +449,7 @@ public class HashedWheelTimer implements Timer {
int idx = (int) (tick & mask);
processCancelledTasks();
HashedWheelBucket bucket =
wheel[idx];
wheel[idx];
transferTimeoutsToBuckets();
bucket.expireTimeouts(deadline);
tick++;
@ -507,7 +509,7 @@ public class HashedWheelTimer implements Timer {
timeout.remove();
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("An exception was thrown while process a cancellation task", t);
logger.warn(COMMON_ERROR_RUN_THREAD_TASK, "", "", "An exception was thrown while process a cancellation task", t);
}
}
}
@ -559,7 +561,7 @@ public class HashedWheelTimer implements Timer {
private static final int ST_CANCELLED = 1;
private static final int ST_EXPIRED = 2;
private static final AtomicIntegerFieldUpdater<HashedWheelTimeout> STATE_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimeout.class, "state");
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimeout.class, "state");
private final HashedWheelTimer timer;
private final TimerTask task;
@ -651,7 +653,7 @@ public class HashedWheelTimer implements Timer {
task.run(this);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("An exception was thrown by " + TimerTask.class.getSimpleName() + '.', t);
logger.warn(COMMON_ERROR_RUN_THREAD_TASK, "", "", "An exception was thrown by " + TimerTask.class.getSimpleName() + '.', t);
}
}
}
@ -663,15 +665,15 @@ public class HashedWheelTimer implements Timer {
String simpleClassName = ClassUtils.simpleClassName(this.getClass());
StringBuilder buf = new StringBuilder(192)
.append(simpleClassName)
.append('(')
.append("deadline: ");
.append(simpleClassName)
.append('(')
.append("deadline: ");
if (remaining > 0) {
buf.append(remaining)
.append(" ns later");
.append(" ns later");
} else if (remaining < 0) {
buf.append(-remaining)
.append(" ns ago");
.append(" ns ago");
} else {
buf.append("now");
}
@ -681,9 +683,9 @@ public class HashedWheelTimer implements Timer {
}
return buf.append(", task: ")
.append(task())
.append(')')
.toString();
.append(task())
.append(')')
.toString();
}
}
@ -731,7 +733,7 @@ public class HashedWheelTimer implements Timer {
} else {
// The timeout was placed into a wrong slot. This should never happen.
throw new IllegalStateException(String.format(
"timeout.deadline (%d) > deadline (%d)", timeout.deadline, deadline));
"timeout.deadline (%d) > deadline (%d)", timeout.deadline, deadline));
}
} else if (timeout.isCancelled()) {
next = remove(timeout);
@ -808,9 +810,9 @@ public class HashedWheelTimer implements Timer {
return head;
}
}
private static final boolean IS_OS_WINDOWS = System.getProperty(OS_NAME_KEY, "").toLowerCase(Locale.US).contains(OS_WIN_PREFIX);
private boolean isWindows() {
return IS_OS_WINDOWS;
}

View File

@ -16,6 +16,7 @@
*/
package org.apache.dubbo.common.utils;
import java.lang.reflect.Field;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
@ -237,6 +238,22 @@ public class CollectionUtils {
return ret;
}
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> objToMap(Object object) throws IllegalAccessException {
Map<K, V> ret = new HashMap<>();
if (object != null) {
Field[] fields = object.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
Object value = field.get(object);
if (value != null) {
ret.put((K)field.getName(), (V)value);
}
}
}
return ret;
}
/**
* Return {@code true} if the supplied Collection is {@code null} or empty.
* Otherwise, return {@code false}.

View File

@ -20,7 +20,7 @@ import org.apache.dubbo.common.config.Configuration;
import org.apache.dubbo.common.config.InmemoryConfiguration;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.ExtensionDirector;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.io.BufferedReader;
@ -46,10 +46,11 @@ import java.util.regex.Pattern;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.REMOVE_VALUE_PREFIX;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_IO_EXCEPTION;
public class ConfigUtils {
private static final Logger logger = LoggerFactory.getLogger(ConfigUtils.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ConfigUtils.class);
private static Pattern VARIABLE_PATTERN = Pattern.compile(
"\\$\\s*\\{?\\s*([\\._0-9a-zA-Z]+)\\s*\\}?");
private static int PID = -1;
@ -136,7 +137,7 @@ public class ConfigUtils {
}
public static String replaceProperty(String expression, Configuration configuration) {
if (StringUtils.isEmpty(expression)|| expression.indexOf('$') < 0) {
if (StringUtils.isEmpty(expression) || expression.indexOf('$') < 0) {
return expression;
}
Matcher matcher = VARIABLE_PATTERN.matcher(expression);
@ -221,7 +222,7 @@ public class ConfigUtils {
input.close();
}
} catch (Throwable e) {
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
}
return properties;
}
@ -236,12 +237,12 @@ public class ConfigUtils {
return a;
});
} catch (Throwable t) {
logger.warn("Fail to load " + fileName + " file: " + t.getMessage(), t);
logger.warn(COMMON_IO_EXCEPTION, "", "", "Fail to load " + fileName + " file: " + t.getMessage(), t);
}
if (CollectionUtils.isEmpty(set)) {
if (!optional) {
logger.warn("No " + fileName + " found on the class path.");
logger.warn(COMMON_IO_EXCEPTION, "", "", "No " + fileName + " found on the class path.");
}
return properties;
}
@ -250,14 +251,14 @@ public class ConfigUtils {
if (set.size() > 1) {
String errMsg = String.format("only 1 %s file is expected, but %d dubbo.properties files found on class path: %s",
fileName, set.size(), set);
logger.warn(errMsg);
logger.warn(COMMON_IO_EXCEPTION, "", "", errMsg);
}
// fall back to use method getResourceAsStream
try {
properties.load(ClassUtils.getClassLoader().getResourceAsStream(fileName));
} catch (Throwable e) {
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
}
return properties;
}
@ -280,7 +281,7 @@ public class ConfigUtils {
}
}
} catch (Throwable e) {
logger.warn("Fail to load " + fileName + " file from " + url + "(ignore this file): " + e.getMessage(), e);
logger.warn(COMMON_IO_EXCEPTION, "", "", "Fail to load " + fileName + " file from " + url + "(ignore this file): " + e.getMessage(), e);
}
}
@ -295,7 +296,7 @@ public class ConfigUtils {
return readString(input);
}
} catch (Throwable e) {
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
}
}
@ -312,7 +313,7 @@ public class ConfigUtils {
}
}
} catch (Throwable e) {
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
}
return rawRule;
}
@ -330,7 +331,7 @@ public class ConfigUtils {
buffer = new char[10];
}
} catch (IOException e) {
logger.error("Read migration file error.", e);
logger.error(COMMON_IO_EXCEPTION, "", "", "Read migration file error.", e);
}
return stringBuilder.toString();

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.util.concurrent.Executor;
@ -28,13 +28,14 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN;
public class ExecutorUtil {
private static final Logger logger = LoggerFactory.getLogger(ExecutorUtil.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ExecutorUtil.class);
private static final ThreadPoolExecutor SHUTDOWN_EXECUTOR = new ThreadPoolExecutor(0, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(100),
new NamedThreadFactory("Close-ExecutorService-Timer", true));
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(100),
new NamedThreadFactory("Close-ExecutorService-Timer", true));
public static boolean isTerminated(Executor executor) {
if (executor instanceof ExecutorService) {
@ -110,7 +111,7 @@ public class ExecutorUtil {
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", e.getMessage(), e);
}
});
}

View File

@ -17,23 +17,24 @@
package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* MD5 util.
*/
public class MD5Utils {
private static final Logger logger = LoggerFactory.getLogger(MD5Utils.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MD5Utils.class);
private static final char[] hexDigits = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
private MessageDigest mdInst;
@ -42,12 +43,13 @@ public class MD5Utils {
try {
mdInst = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
logger.error("Failed to obtain md5", e);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "Failed to obtain md5", e);
}
}
/**
* Calculation md5 value of specify string
*
* @param input
*/
public String getMd5(String input) {

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.lang.reflect.Array;
@ -58,6 +58,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.Consumer;
import java.util.function.Supplier;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_REFLECT;
import static org.apache.dubbo.common.utils.ClassUtils.isAssignableFrom;
/**
@ -71,12 +72,12 @@ import static org.apache.dubbo.common.utils.ClassUtils.isAssignableFrom;
* </ul>
* <p/>
* Other type will be covert to a map which contains the attributes and value pair of object.
*
* <p>
* TODO: exact PojoUtils to scope bean
*/
public class PojoUtils {
private static final Logger logger = LoggerFactory.getLogger(PojoUtils.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(PojoUtils.class);
private static final ConcurrentMap<String, Method> NAME_METHODS_CACHE = new ConcurrentHashMap<String, Method>();
private static final ConcurrentMap<Class<?>, ConcurrentMap<String, Field>> CLASS_FIELD_CACHE = new ConcurrentHashMap<Class<?>, ConcurrentMap<String, Field>>();
@ -144,7 +145,7 @@ public class PojoUtils {
if (ReflectUtils.isPrimitives(pojo.getClass())) {
return pojo;
}
if (pojo instanceof LocalDate || pojo instanceof LocalDateTime || pojo instanceof LocalTime) {
return pojo.toString();
}
@ -525,7 +526,7 @@ public class PojoUtils {
} catch (Exception e) {
String exceptionDescription = "Failed to set pojo " + dest.getClass().getSimpleName() + " property " + name
+ " value " + value.getClass() + ", cause: " + e.getMessage();
logger.error(exceptionDescription, e);
logger.error(COMMON_FAILED_REFLECT, "", "", exceptionDescription, e);
throw new RuntimeException(exceptionDescription, e);
}
} else if (field != null) {

View File

@ -19,7 +19,7 @@ package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.beanutil.JavaBeanSerializeUtil;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.io.IOException;
@ -32,9 +32,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZ
import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZE_BLOCKED_LIST;
import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZE_BLOCK_ALL;
import static org.apache.dubbo.common.constants.CommonConstants.SERIALIZE_BLOCKED_LIST_FILE_PATH;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_IO_EXCEPTION;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNSAFE_SERIALIZATION;
public class SerializeClassChecker {
private static final Logger logger = LoggerFactory.getLogger(SerializeClassChecker.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SerializeClassChecker.class);
private static volatile SerializeClassChecker INSTANCE = null;
@ -54,7 +56,7 @@ public class SerializeClassChecker {
OPEN_CHECK_CLASS = Boolean.parseBoolean(openCheckClass);
String blockAllClassExceptAllow = ConfigurationUtils.getProperty(CLASS_DESERIALIZE_BLOCK_ALL, "false");
BLOCK_ALL_CLASS_EXCEPT_ALLOW = Boolean.parseBoolean(blockAllClassExceptAllow);
String[] lines;
@ -74,7 +76,7 @@ public class SerializeClassChecker {
}
} catch (IOException e) {
logger.error("Failed to load blocked class list! Will ignore default blocked list.", e);
logger.error(COMMON_IO_EXCEPTION, "", "", "Failed to load blocked class list! Will ignore default blocked list.", e);
}
String allowedClassList = ConfigurationUtils.getProperty(CLASS_DESERIALIZE_ALLOWED_LIST, "").trim().toLowerCase(Locale.ROOT);
@ -114,11 +116,11 @@ public class SerializeClassChecker {
/**
* Check if a class is in block list, using prefix match
*
* @throws IllegalArgumentException if class is blocked
* @param name class name ( all are convert to lower case )
* @throws IllegalArgumentException if class is blocked
*/
public void validateClass(String name) {
if(!OPEN_CHECK_CLASS){
if (!OPEN_CHECK_CLASS) {
return;
}
@ -150,14 +152,14 @@ public class SerializeClassChecker {
private void error(String name) {
String notice = "Trigger the safety barrier! " +
"Catch not allowed serialize class. " +
"Class name: " + name + " . " +
"This means currently maybe being attacking by others." +
"If you are sure this is a mistake, " +
"please add this class name to `" + CLASS_DESERIALIZE_ALLOWED_LIST +
"` as a system environment property.";
"Catch not allowed serialize class. " +
"Class name: " + name + " . " +
"This means currently maybe being attacking by others." +
"If you are sure this is a mistake, " +
"please add this class name to `" + CLASS_DESERIALIZE_ALLOWED_LIST +
"` as a system environment property.";
if (counter.incrementAndGet() % 1000 == 0 || counter.get() < 100) {
logger.error(notice);
logger.error(PROTOCOL_UNSAFE_SERIALIZATION, "", "", notice);
}
throw new IllegalArgumentException(notice);
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.io.UnsafeStringWriter;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.io.PrintWriter;
@ -46,6 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.SEPARATOR_REGEX;
import static org.apache.dubbo.common.constants.CommonConstants.UNDERLINE_SEPARATOR;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_JSON_CONVERT_EXCEPTION;
/**
* StringUtils
@ -57,7 +58,7 @@ public final class StringUtils {
public static final int INDEX_NOT_FOUND = -1;
public static final String[] EMPTY_STRING_ARRAY = new String[0];
private static final Logger logger = LoggerFactory.getLogger(StringUtils.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(StringUtils.class);
private static final Pattern KVP_PATTERN = Pattern.compile("([_.a-zA-Z0-9][-_.a-zA-Z0-9]*)[=](.*)"); //key value pair pattern.
private static final Pattern NUM_PATTERN = Pattern.compile("^\\d+$");
private static final Pattern PARAMETERS_PATTERN = Pattern.compile("^\\[((\\s*\\{\\s*[\\w_\\-\\.]+\\s*:\\s*.+?\\s*\\}\\s*,?\\s*)+)\\s*\\]$");
@ -1031,7 +1032,7 @@ public final class StringUtils {
try {
buf.append(JsonUtils.getJson().toJson(arg));
} catch (Exception e) {
logger.warn(e.getMessage(), e);
logger.warn(COMMON_JSON_CONVERT_EXCEPTION, "", "", e.getMessage(), e);
buf.append(arg);
}
}

View File

@ -22,7 +22,7 @@ import org.apache.dubbo.common.config.Environment;
import org.apache.dubbo.common.config.InmemoryConfiguration;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.CollectionUtils;
@ -60,6 +60,9 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_OVERRIDE_FIELD;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_REFLECT;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.common.utils.ClassUtils.isSimpleType;
import static org.apache.dubbo.common.utils.ReflectUtils.findMethodByMethodSignature;
import static org.apache.dubbo.config.Constants.PARAMETERS;
@ -71,7 +74,7 @@ import static org.apache.dubbo.config.Constants.PARAMETERS;
*/
public abstract class AbstractConfig implements Serializable {
protected static final Logger logger = LoggerFactory.getLogger(AbstractConfig.class);
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractConfig.class);
private static final long serialVersionUID = 4267533505537413570L;
/**
@ -494,7 +497,7 @@ public abstract class AbstractConfig implements Serializable {
}
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
logger.error(COMMON_FAILED_REFLECT, "", "", e.getMessage(), e);
}
}
}
@ -648,7 +651,7 @@ public abstract class AbstractConfig implements Serializable {
}
} catch (Throwable t) {
logger.error("Failed to override field value of config bean: " + this, t);
logger.error(COMMON_FAILED_OVERRIDE_FIELD, "", "", "Failed to override field value of config bean: " + this, t);
throw new IllegalStateException("Failed to override field value of config bean: " + this, t);
}
}
@ -703,7 +706,7 @@ public abstract class AbstractConfig implements Serializable {
processExtraRefresh(preferredPrefix, subPropsConfiguration);
} catch (Exception e) {
logger.error("Failed to override field value of config bean: " + this, e);
logger.error(COMMON_FAILED_OVERRIDE_FIELD, "", "", "Failed to override field value of config bean: " + this, e);
throw new IllegalStateException("Failed to override field value of config bean: " + this, e);
}
@ -811,7 +814,7 @@ public abstract class AbstractConfig implements Serializable {
private boolean isPropertySet(Method[] methods, String propertyName) {
try {
String getterName = calculatePropertyToGetter(propertyName);
Method getterMethod = findGetMethod(methods,getterName);
Method getterMethod = findGetMethod(methods, getterName);
if (getterMethod == null) {
return false;
}
@ -943,13 +946,13 @@ public abstract class AbstractConfig implements Serializable {
buf.append('\"');
}
} catch (Exception e) {
logger.warn(e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
}
}
buf.append(" />");
return buf.toString();
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
return super.toString();
}
}

View File

@ -53,6 +53,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER
import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TAG_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_NO_METHOD_FOUND;
import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMETHEUS;
@ -84,7 +85,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
* The remote service group the customer/provider side will reference
*/
protected String group;
protected ServiceMetadata serviceMetadata;
/**
* Local impl class name for the service interface
@ -253,7 +254,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
for (RegistryConfig registryConfig : registries) {
if (!registryConfig.isValid()) {
throw new IllegalStateException("No registry config found or it's not a valid config! " +
"The registry config is: " + registryConfig);
"The registry config is: " + registryConfig);
}
}
}
@ -285,6 +286,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
/**
* To obtain the method list in the port, use reflection when in native mode and javassist otherwise.
*
* @param interfaceClass
* @return
*/
@ -312,7 +314,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
return;
}
if (!interfaceClass.isInterface()) {
throw new IllegalStateException(interfaceName+" is not an interface");
throw new IllegalStateException(interfaceName + " is not an interface");
}
// Auto create MethodConfig/ArgumentConfig according to config props
@ -378,7 +380,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
"<dubbo:service interface=\"" + interfaceName + "\" ... >" +
"<dubbo:method name=\"\" ... /></<dubbo:reference>";
if (ignoreInvalidMethodConfig) {
logger.warn(msg);
logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
return false;
} else {
throw new IllegalStateException(msg);
@ -390,7 +392,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
String msg = "Found invalid method config, the interface " + interfaceClass.getName() + " not found method \""
+ methodName + "\" : [" + methodConfig + "]";
if (ignoreInvalidMethodConfig) {
logger.warn(msg);
logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
return false;
} else {
throw new IllegalStateException(msg);
@ -437,18 +439,18 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
verifyStubAndLocal(stub, "Stub", interfaceClass);
}
private void verifyStubAndLocal(String className, String label, Class<?> interfaceClass){
private void verifyStubAndLocal(String className, String label, Class<?> interfaceClass) {
if (ConfigUtils.isNotEmpty(className)) {
Class<?> localClass = ConfigUtils.isDefault(className) ?
ReflectUtils.forName(interfaceClass.getName() + label) : ReflectUtils.forName(className);
verify(interfaceClass, localClass);
}
ReflectUtils.forName(interfaceClass.getName() + label) : ReflectUtils.forName(className);
verify(interfaceClass, localClass);
}
}
private void verify(Class<?> interfaceClass, Class<?> localClass) {
if (!interfaceClass.isAssignableFrom(localClass)) {
throw new IllegalStateException("The local implementation class " + localClass.getName() +
" not implement interface " + interfaceClass.getName());
" not implement interface " + interfaceClass.getName());
}
try {
@ -456,7 +458,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
ReflectUtils.findConstructor(localClass, interfaceClass);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("No such constructor \"public " + localClass.getSimpleName() +
"(" + interfaceClass.getName() + ")\" in local implementation class " + localClass.getName());
"(" + interfaceClass.getName() + ")\" in local implementation class " + localClass.getName());
}
}
@ -524,7 +526,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
}
}
}
protected void computeValidRegistryIds() {
if (application != null && notHasSelfRegistryProperty()) {
setRegistries(application.getRegistries());
@ -640,8 +642,8 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
}
/**
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
* @param application
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
*/
@Deprecated
public void setApplication(ApplicationConfig application) {
@ -659,8 +661,8 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
}
/**
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
* @param module
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
*/
@Deprecated
public void setModule(ModuleConfig module) {
@ -877,7 +879,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
public String getVersion(AbstractInterfaceConfig interfaceConfig) {
return StringUtils.isEmpty(getVersion()) ? (interfaceConfig != null ? interfaceConfig.getVersion() : getVersion()) : getVersion();
}
public String getVersion() {
return version;
}
@ -893,11 +895,11 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
public void setGroup(String group) {
this.group = group;
}
public String getInterface() {
return interfaceName;
}
public void setInterface(String interfaceName) {
this.interfaceName = interfaceName;
}

View File

@ -32,6 +32,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.READINESS_PROBE_
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_LOCAL_FILE_CACHE_ENABLED;
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.STARTUP_PROBE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP;
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP_COMPATIBLE;
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
@ -56,7 +57,7 @@ import java.util.Set;
import org.apache.dubbo.common.compiler.support.AdaptiveCompiler;
import org.apache.dubbo.common.infra.InfraAdapter;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -70,7 +71,7 @@ import org.apache.dubbo.rpc.model.ApplicationModel;
* @export
*/
public class ApplicationConfig extends AbstractConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationConfig.class);
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ApplicationConfig.class);
private static final long serialVersionUID = 5508512956753757169L;
@ -236,7 +237,7 @@ public class ApplicationConfig extends AbstractConfig {
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
LOGGER.warn("Failed to get the hostname of current instance.", e);
LOGGER.warn(COMMON_UNEXPECTED_EXCEPTION,"","","Failed to get the hostname of current instance.", e);
hostname = "UNKNOWN";
}
}

View File

@ -16,11 +16,14 @@
*/
package org.apache.dubbo.config;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Optional;
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_PROTOCOL;
import static org.apache.dubbo.common.constants.CommonConstants.SSL_ENABLED_KEY;
@ -579,4 +582,29 @@ public class ProtocolConfig extends AbstractConfig {
public void setExtProtocol(String extProtocol) {
this.extProtocol = extProtocol;
}
public void mergeProtocol(ProtocolConfig sourceConfig) {
if (sourceConfig == null) {
return;
}
Field[] targetFields = this.getClass().getDeclaredFields();
try {
Map<String, Object> protocolConfigMap = CollectionUtils.objToMap(sourceConfig);
for (Field targetField : targetFields) {
Optional.ofNullable(protocolConfigMap.get(targetField.getName())).ifPresent(value -> {
try {
targetField.setAccessible(true);
if (targetField.get(this) == null) {
targetField.set(this, value);
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
});
}
} catch (Exception e) {
logger.error("merge protocol config fail, error: ", e);
}
}
}

View File

@ -39,6 +39,7 @@ import java.util.Properties;
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO;
import static org.apache.dubbo.common.constants.CommonConstants.UNLOAD_CLUSTER_RELATED;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* ReferenceConfig
@ -130,8 +131,8 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
super.preProcessRefresh();
if (consumer == null) {
consumer = getModuleConfigManager()
.getDefaultConsumer()
.orElseThrow(() -> new IllegalStateException("Default consumer is not initialized"));
.getDefaultConsumer()
.orElseThrow(() -> new IllegalStateException("Default consumer is not initialized"));
}
}
@ -166,6 +167,7 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
/**
* Get service interface class of this reference.
* The actual service type of remote provider.
*
* @return
*/
public Class<?> getServiceInterfaceClass() {
@ -187,6 +189,7 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
/**
* Get proxy interface class of this reference.
* The proxy interface class is used to create proxy instance.
*
* @return
*/
public Class<?> getInterfaceClass() {
@ -208,6 +211,7 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
/**
* Determine the interface of the proxy class
*
* @param generic
* @param interfaceName
* @return
@ -303,9 +307,9 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
url = resolve;
if (logger.isWarnEnabled()) {
if (resolveFile != null) {
logger.warn("Using default dubbo resolve file " + resolveFile + " replace " + interfaceName + "" + resolve + " to p2p invoke remote service.");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Using default dubbo resolve file " + resolveFile + " replace " + interfaceName + "" + resolve + " to p2p invoke remote service.");
} else {
logger.warn("Using -D" + interfaceName + "=" + resolve + " to p2p invoke remote service.");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Using -D" + interfaceName + "=" + resolve + " to p2p invoke remote service.");
}
}
}

View File

@ -22,7 +22,7 @@ import org.apache.dubbo.common.config.Environment;
import org.apache.dubbo.common.config.PropertiesConfiguration;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.context.LifecycleAdapter;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.ConcurrentHashSet;
@ -60,13 +60,15 @@ import static java.lang.Boolean.TRUE;
import static java.util.Collections.emptyMap;
import static java.util.Optional.ofNullable;
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_MISSPELLING;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.config.AbstractConfig.getTagName;
public abstract class AbstractConfigManager extends LifecycleAdapter {
private static final String CONFIG_NAME_READ_METHOD = "getName";
private static final Logger logger = LoggerFactory.getLogger(AbstractConfigManager.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractConfigManager.class);
private static Set<Class<? extends AbstractConfig>> uniqueConfigTypes = new ConcurrentHashSet<>();
final Map<String, Map<String, AbstractConfig>> configsCache = new ConcurrentHashMap<>();
@ -119,7 +121,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
}
} catch (Exception e) {
String msg = "Illegal '" + ConfigKeys.DUBBO_CONFIG_MODE + "' config value [" + configModeStr + "], available values " + Arrays.toString(ConfigMode.values());
logger.error(msg, e);
logger.error(COMMON_PROPERTY_MISSPELLING, "", "", msg, e);
throw new IllegalArgumentException(msg, e);
}
@ -213,7 +215,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
C existedConfig = configsMap.get(key);
if (existedConfig != null && !isEquals(existedConfig, config)) {
String type = config.getClass().getSimpleName();
logger.warn(String.format("Duplicate %s found, there already has one default %s or more than two %ss have the same id, " +
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", String.format("Duplicate %s found, there already has one default %s or more than two %ss have the same id, " +
"you can try to give each %s a different id, override previous config with later config. id: %s, prev: %s, later: %s",
type, type, type, type, key, existedConfig, config));
}
@ -224,7 +226,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
}
protected <C extends AbstractConfig> boolean removeIfAbsent(C config, Map<String, C> configsMap) {
if(config.getId() != null) {
if (config.getId() != null) {
return configsMap.remove(config.getId(), config);
}
return configsMap.values().removeIf(c -> config == c);
@ -439,7 +441,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
case IGNORE: {
// ignore later config
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
logger.warn(msgPrefix + "keep previous config and ignore later config");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "keep previous config and ignore later config");
}
return Optional.of(oldOne);
}
@ -447,7 +449,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
// clear previous config, add new config
configsMap.clear();
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
logger.warn(msgPrefix + "override previous config with later config");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "override previous config with later config");
}
break;
}
@ -455,7 +457,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
// override old one's properties with the new one
oldOne.overrideWithConfig(config, true);
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
logger.warn(msgPrefix + "override previous config with later config");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "override previous config with later config");
}
return Optional.of(oldOne);
}
@ -463,7 +465,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
// override old one's properties with the new one
oldOne.overrideWithConfig(config, false);
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
logger.warn(msgPrefix + "override previous config with later config");
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "override previous config with later config");
}
return Optional.of(oldOne);
}
@ -504,7 +506,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
this.addConfig(config);
tmpConfigs.add(config);
} catch (Exception e) {
logger.error("load config failed, id: " + id + ", type:" + cls.getSimpleName(), e);
logger.error(COMMON_PROPERTY_MISSPELLING, "", "", "load config failed, id: " + id + ", type:" + cls.getSimpleName(), e);
throw new IllegalStateException("load config failed, id: " + id + ", type:" + cls.getSimpleName());
} finally {
if (addDefaultNameConfig && key != null) {

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.config.context;
import org.apache.dubbo.common.context.ModuleExt;
import org.apache.dubbo.common.extension.DisableInject;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.config.AbstractConfig;
@ -46,6 +46,7 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import static java.util.Optional.ofNullable;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.config.AbstractConfig.getTagName;
/**
@ -53,7 +54,7 @@ import static org.apache.dubbo.config.AbstractConfig.getTagName;
*/
public class ModuleConfigManager extends AbstractConfigManager implements ModuleExt {
private static final Logger logger = LoggerFactory.getLogger(ModuleConfigManager.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ModuleConfigManager.class);
public static final String NAME = "moduleConfig";
@ -204,7 +205,7 @@ public class ModuleConfigManager extends AbstractConfigManager implements Module
@Override
protected <C extends AbstractConfig> boolean removeIfAbsent(C config, Map<String, C> configsMap) {
if(super.removeIfAbsent(config, configsMap)) {
if (super.removeIfAbsent(config, configsMap)) {
if (config instanceof ReferenceConfigBase || config instanceof ServiceConfigBase) {
removeInterfaceConfig((AbstractInterfaceConfig) config);
}
@ -240,7 +241,7 @@ public class ModuleConfigManager extends AbstractConfigManager implements Module
if (prevConfig.equals(config)) {
// Is there any problem with ignoring duplicate and equivalent but different ReferenceConfig instances?
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
logger.warn("Ignore duplicated and equal config: " + config);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Ignore duplicated and equal config: " + config);
}
return prevConfig;
}
@ -252,7 +253,7 @@ public class ModuleConfigManager extends AbstractConfigManager implements Module
"If multiple instances are required for the same interface, please use a different group or version.";
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
logger.warn(msg);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msg);
}
if (!this.ignoreDuplicatedInterface) {
throw new IllegalStateException(msg);

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.metadata.definition.builder;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.metadata.definition.TypeDefinitionBuilder;
import org.apache.dubbo.metadata.definition.model.TypeDefinition;
@ -25,11 +25,13 @@ import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Map;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
/**
* 2015/1/27.
*/
public class EnumTypeBuilder implements TypeBuilder {
private static final Logger logger = LoggerFactory.getLogger(TypeDefinitionBuilder.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(TypeDefinitionBuilder.class);
@Override
public boolean accept(Class<?> clazz) {
@ -61,7 +63,7 @@ public class EnumTypeBuilder implements TypeBuilder {
}
return td;
} catch (Throwable t) {
logger.error("There is an error while process class " + clazz, t);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "There is an error while process class " + clazz, t);
}
return td;
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.model;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.common.utils.ReflectUtils;
@ -32,9 +32,10 @@ import java.util.stream.Stream;
import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE;
import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE_ASYNC;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_REFLECT;
public class ReflectionMethodDescriptor implements MethodDescriptor {
private static final Logger logger = LoggerFactory.getLogger(ReflectionMethodDescriptor.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ReflectionMethodDescriptor.class);
private final ConcurrentMap<String, Object> attributeMap = new ConcurrentHashMap<>();
public final String methodName;
@ -57,7 +58,7 @@ public class ReflectionMethodDescriptor implements MethodDescriptor {
try {
returnTypesResult = ReflectUtils.getReturnTypes(method);
} catch (Throwable throwable) {
logger.error(
logger.error(COMMON_FAILED_REFLECT, "", "",
"fail to get return types. Method name: " + methodName + " Declaring class:" + method.getDeclaringClass()
.getName(), throwable);
returnTypesResult = new Type[]{returnClass, returnClass};

View File

@ -21,7 +21,7 @@ import org.apache.dubbo.common.config.Environment;
import org.apache.dubbo.common.extension.ExtensionAccessor;
import org.apache.dubbo.common.extension.ExtensionDirector;
import org.apache.dubbo.common.extension.ExtensionScope;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ConcurrentHashSet;
import org.apache.dubbo.common.utils.StringUtils;
@ -35,8 +35,10 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_UNABLE_DESTROY_MODEL;
public abstract class ScopeModel implements ExtensionAccessor {
protected static final Logger LOGGER = LoggerFactory.getLogger(ScopeModel.class);
protected static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ScopeModel.class);
/**
* The internal id is used to represent the hierarchy of the model tree, such as:
@ -122,7 +124,7 @@ public abstract class ScopeModel implements ExtensionAccessor {
extensionDirector.destroy();
}
} catch (Throwable t) {
LOGGER.error("Error happened when destroying ScopeModel.", t);
LOGGER.error(CONFIG_UNABLE_DESTROY_MODEL, "", "", "Error happened when destroying ScopeModel.", t);
}
}
}

View File

@ -24,6 +24,7 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ADDRESS_INVALID;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doThrow;
@ -45,8 +46,8 @@ public class FailsafeErrorTypeAwareLoggerTest {
doThrow(new RuntimeException()).when(failLogger).debug(anyString());
doThrow(new RuntimeException()).when(failLogger).trace(anyString());
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error");
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn");
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error");
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn");
doThrow(new RuntimeException()).when(failLogger).error(any(Throwable.class));
doThrow(new RuntimeException()).when(failLogger).warn(any(Throwable.class));
@ -54,8 +55,8 @@ public class FailsafeErrorTypeAwareLoggerTest {
doThrow(new RuntimeException()).when(failLogger).debug(any(Throwable.class));
doThrow(new RuntimeException()).when(failLogger).trace(any(Throwable.class));
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error", new Exception("error"));
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn", new Exception("warn"));
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error", new Exception("error"));
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn", new Exception("warn"));
}
@Test
@ -63,14 +64,14 @@ public class FailsafeErrorTypeAwareLoggerTest {
Logger successLogger = mock(Logger.class);
FailsafeErrorTypeAwareLogger failsafeLogger = new FailsafeErrorTypeAwareLogger(successLogger);
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error");
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn");
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error");
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn");
verify(successLogger).error(anyString());
verify(successLogger).warn(anyString());
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error", new Exception("error"));
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn", new Exception("warn"));
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error", new Exception("error"));
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn", new Exception("warn"));
}
@Test
@ -90,10 +91,10 @@ public class FailsafeErrorTypeAwareLoggerTest {
ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(FailsafeErrorTypeAwareLoggerTest.class);
logger.error("1-1", "Registry center", "May be it's offline.",
logger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.",
"error message", new Exception("error"));
logger.error("-1", "Registry center", "May be it's offline.",
logger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.",
"error message", new Exception("error"));
}
}

View File

@ -16,6 +16,7 @@
*/
package org.apache.dubbo.common.utils;
import org.apache.dubbo.config.ProtocolConfig;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -200,6 +201,14 @@ public class CollectionUtilsTest {
assertEquals(expected, CollectionUtils.toMap("a", 1, "b", 2, "c", 3));
}
@Test
public void testObjectToMap() throws Exception {
ProtocolConfig protocolConfig=new ProtocolConfig();
protocolConfig.setSerialization("fastjson2");
assertFalse(CollectionUtils.objToMap(protocolConfig).isEmpty());
}
@Test
public void testToMap2() throws Exception {
Assertions.assertThrows(IllegalArgumentException.class, () -> toMap("a", "b", "c"));

View File

@ -41,6 +41,7 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMET
import static org.apache.dubbo.config.context.ConfigManager.DUBBO_CONFIG_MODE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@ -192,6 +193,14 @@ public class ConfigManagerTest {
assertEquals(config, configs.iterator().next());
assertFalse(configManager.getDefaultProtocols().isEmpty());
assertEquals(configs, moduleConfigManager.getProtocols());
assertNotEquals(20881, config.getPort());
assertNotEquals(config.getSerialization(),"fastjson2");
ProtocolConfig defaultConfig = new ProtocolConfig();
defaultConfig.setPort(20881);
defaultConfig.setSerialization("fastjson2");
config.mergeProtocol(defaultConfig);
assertEquals(config.getPort(),20881);
assertEquals(config.getSerialization(),"fastjson2");
}
// Test RegistryConfig correlative methods

View File

@ -80,6 +80,9 @@ import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_SPLIT_P
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_REFRESH_INSTANCE_ERROR;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_REGISTER_INSTANCE_ERROR;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_START_MODEL;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_EXECUTE_DESTORY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_INIT_CONFIG_CENTER;
import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMETHEUS;
import static org.apache.dubbo.common.utils.StringUtils.isEmpty;
import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;
@ -659,7 +662,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
}
public void prepareInternalModule() {
if(hasPreparedInternalModule){
if (hasPreparedInternalModule) {
return;
}
synchronized (internalModuleLock) {
@ -675,7 +678,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
try {
future.get(5, TimeUnit.SECONDS);
} catch (Exception e) {
logger.warn("wait for internal module startup failed: " + e.getMessage(), e);
logger.warn(CONFIG_FAILED_START_MODEL, "", "", "wait for internal module startup failed: " + e.getMessage(), e);
}
}
}
@ -729,7 +732,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
dynamicConfiguration = getDynamicConfiguration(configCenter.toUrl());
} catch (Exception e) {
if (!configCenter.isCheck()) {
logger.warn("The configuration center failed to initialize", e);
logger.warn(CONFIG_FAILED_INIT_CONFIG_CENTER, "", "","The configuration center failed to initialize", e);
configCenter.setInitialized(false);
return null;
} else {
@ -825,8 +828,6 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
unexportMetricsService();
unregisterServiceInstance();
destroyRegistries();
destroyMetadataReports();
unRegisterShutdownHook();
if (asyncMetadataFuture != null) {
@ -844,6 +845,9 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
return;
}
try {
destroyRegistries();
destroyMetadataReports();
executeShutdownCallbacks();
// TODO should we close unused protocol server which only used by this application?
@ -983,7 +987,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
((ApplicationDeployListener) listener).onModuleStarted(applicationModel);
}
} catch (Throwable e) {
logger.error(getIdentifier() + " an exception occurred when handle starting event", e);
logger.error(CONFIG_FAILED_START_MODEL, "", "", getIdentifier() + " an exception occurred when handle starting event", e);
}
}
}
@ -1062,7 +1066,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
private void onFailed(String msg, Throwable ex) {
try {
setFailed(ex);
logger.error(msg, ex);
logger.error(CONFIG_FAILED_START_MODEL, "", "", msg, ex);
} finally {
completeStartFuture(false);
}
@ -1084,7 +1088,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
try {
serviceDiscovery.destroy();
} catch (Throwable ignored) {
logger.warn(ignored.getMessage(), ignored);
logger.warn(CONFIG_FAILED_EXECUTE_DESTORY, "", "", ignored.getMessage(), ignored);
}
});
if (logger.isDebugEnabled()) {

View File

@ -50,6 +50,8 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILE
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_UNABLE_DESTROY_MODEL;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_REFERENCE_MODEL;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_EXPORT_SERVICE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_WAIT_EXPORT_REFER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_REFER_SERVICE;
/**
* Export/refer services of module
@ -175,7 +177,7 @@ public class DefaultModuleDeployer extends AbstractDeployer<ModuleModel> impleme
// wait for refer finish
waitReferFinish();
} catch (Throwable e) {
logger.warn("wait for export/refer services occurred an exception", e);
logger.warn(CONFIG_FAILED_WAIT_EXPORT_REFER, "", "", "wait for export/refer services occurred an exception", e);
} finally {
onModuleStarted();
}
@ -421,7 +423,7 @@ public class DefaultModuleDeployer extends AbstractDeployer<ModuleModel> impleme
exportFuture = CompletableFuture.allOf(asyncExportingFutures.toArray(new CompletableFuture[0]));
exportFuture.get();
} catch (Throwable e) {
logger.warn(getIdentifier() + " export services occurred an exception: " + e.toString());
logger.warn(CONFIG_FAILED_EXPORT_SERVICE, "","",getIdentifier() + " export services occurred an exception: " + e.toString());
} finally {
logger.info(getIdentifier() + " export services finished.");
asyncExportingFutures.clear();
@ -434,7 +436,7 @@ public class DefaultModuleDeployer extends AbstractDeployer<ModuleModel> impleme
referFuture = CompletableFuture.allOf(asyncReferringFutures.toArray(new CompletableFuture[0]));
referFuture.get();
} catch (Throwable e) {
logger.warn(getIdentifier() + " refer services occurred an exception: " + e.toString());
logger.warn(CONFIG_FAILED_REFER_SERVICE, "", "", getIdentifier() + " refer services occurred an exception: " + e.toString());
} finally {
logger.info(getIdentifier() + " refer services finished.");
asyncReferringFutures.clear();

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.config.deploy;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.model.FrameworkModel;
@ -25,12 +25,14 @@ import org.apache.dubbo.rpc.model.ScopeModelDestroyListener;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_UNDEFINED_PROTOCOL;
/**
* A cleaner to release resources of framework model
*/
public class FrameworkModelCleaner implements ScopeModelDestroyListener<FrameworkModel> {
private static final Logger logger = LoggerFactory.getLogger(FrameworkModelCleaner.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(FrameworkModelCleaner.class);
private final AtomicBoolean protocolDestroyed = new AtomicBoolean(false);
@ -65,7 +67,7 @@ public class FrameworkModelCleaner implements ScopeModelDestroyListener<Framewor
protocol.destroy();
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(CONFIG_UNDEFINED_PROTOCOL, "", "", t.getMessage(), t);
}
}
}

View File

@ -16,25 +16,38 @@
*/
package org.apache.dubbo.config.metadata;
import static java.util.Collections.emptyList;
import static org.apache.dubbo.common.constants.CommonConstants.METADATA_SERVICE_PORT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.METADATA_SERVICE_PROTOCOL_KEY;
import java.util.Collections;
import java.util.List;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ArgumentConfig;
import org.apache.dubbo.config.MethodConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.bootstrap.builders.InternalServiceConfigBuilder;
import org.apache.dubbo.metadata.MetadataService;
import org.apache.dubbo.registry.client.metadata.MetadataServiceDelegation;
import org.apache.dubbo.rpc.ProtocolServer;
import org.apache.dubbo.rpc.model.ApplicationModel;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import static java.util.Collections.emptyList;
import static org.apache.dubbo.common.constants.CommonConstants.CORE_THREADS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_PROTOCOL;
import static org.apache.dubbo.common.constants.CommonConstants.METADATA_SERVICE_PORT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.METADATA_SERVICE_PROTOCOL_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_FIND_PROTOCOL;
import static org.apache.dubbo.remoting.Constants.BIND_PORT_KEY;
/**
* Export metadata service
*/
@ -71,7 +84,7 @@ public class ConfigurableMetadataServiceExporter {
}
} else {
if (logger.isWarnEnabled()) {
logger.warn("The MetadataService has been exported : " + serviceConfig.getExportedUrls());
logger.warn(CONFIG_METADATA_SERVICE_EXPORTED, "", "", "The MetadataService has been exported : " + serviceConfig.getExportedUrls());
}
}

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.config.utils;
import org.apache.dubbo.common.BaseServiceMetadata;
import org.apache.dubbo.common.config.ReferenceCache;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.config.ReferenceConfigBase;
import org.apache.dubbo.rpc.model.ApplicationModel;
@ -27,12 +27,14 @@ import org.apache.dubbo.rpc.model.ModuleModel;
import java.util.ArrayList;
import java.util.List;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_API_WRONG_USE;
/**
* A impl of ReferenceCache for Application
*/
public class CompositeReferenceCache implements ReferenceCache {
private static final Logger logger = LoggerFactory.getLogger(CompositeReferenceCache.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CompositeReferenceCache.class);
private final ApplicationModel applicationModel;
@ -51,7 +53,7 @@ public class CompositeReferenceCache implements ReferenceCache {
if (singleton) {
proxy = get(key, (Class<T>) type);
} else {
logger.warn("Using non-singleton ReferenceConfig and ReferenceCache at the same time may cause memory leak. " +
logger.warn(CONFIG_API_WRONG_USE, "the api method is being used incorrectly", "", "Using non-singleton ReferenceConfig and ReferenceCache at the same time may cause memory leak. " +
"Call ReferenceConfig#get() directly for non-singleton ReferenceConfig instead of using ReferenceCache#get(ReferenceConfig)");
}
if (proxy == null) {

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.config.utils;
import org.apache.dubbo.common.BaseServiceMetadata;
import org.apache.dubbo.common.config.ReferenceCache;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -33,6 +33,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_API_WRONG_USE;
/**
* A simple util class for cache {@link ReferenceConfigBase}.
* <p>
@ -42,7 +44,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* You can implement and use your own {@link ReferenceConfigBase} cache if you need use complicate strategy.
*/
public class SimpleReferenceCache implements ReferenceCache {
private static final Logger logger = LoggerFactory.getLogger(SimpleReferenceCache.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SimpleReferenceCache.class);
public static final String DEFAULT_NAME = "_DEFAULT_";
/**
* Create the key with the <b>Group</b>, <b>Interface</b> and <b>version</b> attribute of {@link ReferenceConfigBase}.
@ -117,7 +119,7 @@ public class SimpleReferenceCache implements ReferenceCache {
if (singleton) {
proxy = get(key, (Class<T>) type);
} else {
logger.warn("Using non-singleton ReferenceConfig and ReferenceCache at the same time may cause memory leak. " +
logger.warn(CONFIG_API_WRONG_USE, "", "", "Using non-singleton ReferenceConfig and ReferenceCache at the same time may cause memory leak. " +
"Call ReferenceConfig#get() directly for non-singleton ReferenceConfig instead of using ReferenceCache#get(ReferenceConfig)");
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.config.spring.beans.factory.annotation;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.ReflectUtils;
@ -81,6 +81,9 @@ import java.util.Set;
import static com.alibaba.spring.util.ObjectUtils.of;
import static java.util.Arrays.asList;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_NO_ANNOTATIONS_FOUND;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_NO_BEANS_SCANNED;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_DUPLICATED_BEAN_DEFINITION;
import static org.apache.dubbo.common.utils.AnnotationUtils.filterDefaultValues;
import static org.apache.dubbo.config.spring.beans.factory.annotation.ServiceBeanNameBuilder.create;
import static org.apache.dubbo.config.spring.util.DubboAnnotationUtils.resolveInterfaceName;
@ -111,7 +114,7 @@ public class ServiceAnnotationPostProcessor implements BeanDefinitionRegistryPos
com.alibaba.dubbo.config.annotation.Service.class
);
private final Logger logger = LoggerFactory.getLogger(getClass());
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
protected final Set<String> packagesToScan;
@ -187,7 +190,7 @@ public class ServiceAnnotationPostProcessor implements BeanDefinitionRegistryPos
scanned = true;
if (CollectionUtils.isEmpty(packagesToScan)) {
if (logger.isWarnEnabled()) {
logger.warn("packagesToScan is empty , ServiceBean registry will be ignored!");
logger.warn(CONFIG_NO_BEANS_SCANNED, "", "", "packagesToScan is empty , ServiceBean registry will be ignored!");
}
return;
}
@ -236,7 +239,7 @@ public class ServiceAnnotationPostProcessor implements BeanDefinitionRegistryPos
}
} else {
if (logger.isWarnEnabled()) {
logger.warn("No class annotated by Dubbo @Service was found under package ["
logger.warn(CONFIG_NO_ANNOTATIONS_FOUND,"No annotations were found on the class","","No class annotated by Dubbo @Service was found under package ["
+ packageToScan + "], ignore re-scanned classes: " + scanExcludeFilter.getExcludedCount());
}
}
@ -590,7 +593,7 @@ public class ServiceAnnotationPostProcessor implements BeanDefinitionRegistryPos
String msg = "Found duplicated BeanDefinition of service interface [" + serviceInterface + "] with bean name [" + serviceBeanName +
"], existing definition [ " + existingDefinition + "], new definition [" + serviceBeanDefinition + "]";
logger.error(msg);
logger.error(CONFIG_DUPLICATED_BEAN_DEFINITION, "", "", msg);
throw new BeanDefinitionStoreException(serviceBeanDefinition.getResourceDescription(), serviceBeanName, msg);
}

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.config.spring.context;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_STOP_DUBBO_ERROR;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_START_MODEL;
import static org.springframework.util.ObjectUtils.nullSafeEquals;
import java.util.concurrent.Future;
@ -116,9 +117,9 @@ public class DubboDeployApplicationListener implements ApplicationListener<Appli
try {
future.get();
} catch (InterruptedException e) {
logger.warn("Interrupted while waiting for dubbo module start: " + e.getMessage());
logger.warn(CONFIG_FAILED_START_MODEL, "", "", "Interrupted while waiting for dubbo module start: " + e.getMessage());
} catch (Exception e) {
logger.warn("An error occurred while waiting for dubbo module start: " + e.getMessage(), e);
logger.warn(CONFIG_FAILED_START_MODEL, "", "", "An error occurred while waiting for dubbo module start: " + e.getMessage(), e);
}
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.config.spring.status;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.status.Status;
import org.apache.dubbo.common.status.StatusChecker;
@ -33,13 +33,15 @@ import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.Map;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_WARN_STATUS_CHECKER;
/**
* DataSourceStatusChecker
*/
@Activate
public class DataSourceStatusChecker implements StatusChecker {
private static final Logger logger = LoggerFactory.getLogger(DataSourceStatusChecker.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DataSourceStatusChecker.class);
private ApplicationModel applicationModel;
@ -92,7 +94,7 @@ public class DataSourceStatusChecker implements StatusChecker {
buf.append(metaData.getDatabaseProductVersion());
buf.append(')');
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
logger.warn(CONFIG_WARN_STATUS_CHECKER, "", "", e.getMessage(), e);
return new Status(level, e.getMessage());
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.config.spring.status;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.status.Status;
import org.apache.dubbo.common.status.StatusChecker;
@ -29,13 +29,15 @@ import org.springframework.context.Lifecycle;
import java.lang.reflect.Method;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_WARN_STATUS_CHECKER;
/**
* SpringStatusChecker
*/
@Activate
public class SpringStatusChecker implements StatusChecker {
private static final Logger logger = LoggerFactory.getLogger(SpringStatusChecker.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SpringStatusChecker.class);
private ApplicationModel applicationModel;
@ -100,7 +102,7 @@ public class SpringStatusChecker implements StatusChecker {
if (t.getCause() instanceof UnsupportedOperationException){
logger.debug(t.getMessage(), t);
}else {
logger.warn(t.getMessage(), t);
logger.warn(CONFIG_WARN_STATUS_CHECKER, "", "", t.getMessage(), t);
}
}
return new Status(level, buf.toString());

View File

@ -48,6 +48,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.CommonConstants.CONFIG_NAMESPACE_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_CONNECT_REGISTRY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_CLOSE_CONNECT_APOLLO;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_NOT_EFFECT_EMPTY_RULE_APOLLO;
/**
* Apollo implementation, https://github.com/ctripcorp/apollo
@ -122,7 +124,7 @@ public class ApolloDynamicConfiguration implements DynamicConfiguration {
try {
listeners.clear();
} catch (UnsupportedOperationException e) {
logger.warn("Failed to close connect from config center, the config center is Apollo");
logger.warn(CONFIG_FAILED_CLOSE_CONNECT_APOLLO, "", "", "Failed to close connect from config center, the config center is Apollo");
}
}
@ -236,7 +238,7 @@ public class ApolloDynamicConfiguration implements DynamicConfiguration {
for (String key : changeEvent.changedKeys()) {
ConfigChange change = changeEvent.getChange(key);
if ("".equals(change.getNewValue())) {
logger.warn("an empty rule is received for " + key + ", the current working rule is " +
logger.warn(CONFIG_NOT_EFFECT_EMPTY_RULE_APOLLO, "", "", "an empty rule is received for " + key + ", the current working rule is " +
change.getOldValue() + ", the empty rule will not take effect.");
return;
}

View File

@ -23,7 +23,7 @@ import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
import org.apache.dubbo.common.config.configcenter.ConfigItem;
import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.MD5Utils;
import org.apache.dubbo.common.utils.StringUtils;
@ -44,6 +44,7 @@ import java.util.concurrent.Executor;
import static com.alibaba.nacos.api.PropertyKeyConst.PASSWORD;
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
import static com.alibaba.nacos.api.PropertyKeyConst.USERNAME;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_ERROR_NACOS;
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
import static org.apache.dubbo.common.utils.StringConstantFieldValuePredicate.of;
import static org.apache.dubbo.common.utils.StringUtils.HYPHEN_CHAR;
@ -55,7 +56,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
private static final String GET_CONFIG_KEYS_PATH = "/v1/cs/configs";
private final Logger logger = LoggerFactory.getLogger(getClass());
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
/**
* the default timeout in millis to get config from nacos
*/
@ -87,7 +88,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
configService = NacosFactory.createConfigService(nacosProperties);
} catch (NacosException e) {
if (logger.isErrorEnabled()) {
logger.error(e.getErrMsg(), e);
logger.error(CONFIG_ERROR_NACOS, "", "", e.getMessage(), e);
}
throw new IllegalStateException(e);
}
@ -172,7 +173,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
try {
configService.addListener(key, group, nacosConfigListener);
} catch (NacosException e) {
logger.error(e.getMessage());
logger.error(CONFIG_ERROR_NACOS, "", "", e.getMessage(), e);
}
}
@ -194,7 +195,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
}
return configService.getConfig(key, group, nacosTimeout);
} catch (NacosException e) {
logger.error(e.getMessage());
logger.error(CONFIG_ERROR_NACOS, "", "", e.getMessage(), e);
}
return null;
}
@ -214,7 +215,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
try {
return configService.getConfig(key, DEFAULT_GROUP, getDefaultTimeout());
} catch (NacosException e) {
logger.error(e.getMessage());
logger.error(CONFIG_ERROR_NACOS, "", "", e.getMessage(), e);
}
return null;
}
@ -225,7 +226,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
try {
published = configService.publishConfig(key, group, content);
} catch (NacosException e) {
logger.error(e.getErrMsg(), e);
logger.error(CONFIG_ERROR_NACOS, "", "", e.getMessage(), e);
}
return published;
}
@ -238,7 +239,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
}
return configService.publishConfigCas(key, group, content, (String) ticket);
} catch (NacosException e) {
logger.warn("nacos publishConfigCas failed.", e);
logger.warn(CONFIG_ERROR_NACOS, "nacos publishConfigCas failed.", "", e.getMessage(), e);
return false;
}
}
@ -255,7 +256,7 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
removed = configService.removeConfig(key, group);
} catch (NacosException e) {
if (logger.isErrorEnabled()) {
logger.error(e.getMessage(), e);
logger.error(CONFIG_ERROR_NACOS, "", "", e.getMessage(), e);
}
}
return removed;

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.container;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ArrayUtils;
@ -30,6 +30,9 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_START_DUBBO_ERROR;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_STOP_DUBBO_ERROR;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_THREAD_INTERRUPTED_EXCEPTION;
/**
* Main. (API, Static, ThreadSafe)
@ -42,7 +45,7 @@ public class Main {
public static final String SHUTDOWN_HOOK_KEY = "dubbo.shutdown.hook";
private static final Logger logger = LoggerFactory.getLogger(Main.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Main.class);
private static final ExtensionLoader<Container> LOADER = ExtensionLoader.getExtensionLoader(Container.class);
@ -72,7 +75,7 @@ public class Main {
container.stop();
logger.info("Dubbo " + container.getClass().getSimpleName() + " stopped!");
} catch (Throwable t) {
logger.error(t.getMessage(), t);
logger.error(CONFIG_STOP_DUBBO_ERROR, "", "", t.getMessage(), t);
}
try {
LOCK.lock();
@ -91,14 +94,14 @@ public class Main {
}
System.out.println(new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]").format(new Date()) + " Dubbo service server started!");
} catch (RuntimeException e) {
logger.error(e.getMessage(), e);
logger.error(CONFIG_START_DUBBO_ERROR, "", "", e.getMessage(), e);
System.exit(1);
}
try {
LOCK.lock();
STOP.await();
} catch (InterruptedException e) {
logger.warn("Dubbo service server stopped, interrupted by other thread!", e);
logger.warn(COMMON_THREAD_INTERRUPTED_EXCEPTION, "", "", "Dubbo service server stopped, interrupted by other thread!", e);
} finally {
LOCK.unlock();
}

View File

@ -16,13 +16,15 @@
*/
package org.apache.dubbo.container.spring;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.container.Container;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_STOP_DUBBO_ERROR;
/**
* SpringContainer. (SPI, Singleton, ThreadSafe)
*
@ -32,7 +34,7 @@ public class SpringContainer implements Container {
public static final String SPRING_CONFIG = "dubbo.spring.config";
public static final String DEFAULT_SPRING_CONFIG = "classpath*:META-INF/spring/*.xml";
private static final Logger logger = LoggerFactory.getLogger(SpringContainer.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SpringContainer.class);
static ClassPathXmlApplicationContext context;
public static ClassPathXmlApplicationContext getContext() {
@ -59,7 +61,7 @@ public class SpringContainer implements Container {
context = null;
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
logger.error(CONFIG_STOP_DUBBO_ERROR, "", "", e.getMessage(), e);
}
}

View File

@ -14,7 +14,9 @@
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.
--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -139,7 +141,7 @@
<resteasy_version>3.0.19.Final</resteasy_version>
<tomcat_embed_version>8.5.78</tomcat_embed_version>
<jetcd_version>0.5.3</jetcd_version>
<nacos_version>2.1.0</nacos_version>
<nacos_version>2.1.2</nacos_version>
<grpc.version>1.47.0</grpc.version>
<grpc_contrib_verdion>0.8.1</grpc_contrib_verdion>
<jprotoc_version>1.2.1</jprotoc_version>
@ -193,6 +195,18 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>${netty4_version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty4_version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
@ -203,11 +217,6 @@
<artifactId>netty</artifactId>
<version>${netty_version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty4_version}</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.validation.support.jvalidation;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.bytecode.ClassGenerator;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ReflectUtils;
import org.apache.dubbo.validation.MethodValidated;
@ -67,6 +67,8 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FILTER_VALIDATION_EXCEPTION;
/**
* Implementation of JValidation. JValidation is invoked if configuration validation attribute value is 'jvalidation'.
* <pre>
@ -75,7 +77,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class JValidator implements Validator {
private static final Logger logger = LoggerFactory.getLogger(JValidator.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(JValidator.class);
private final Class<?> clazz;
@ -116,7 +118,7 @@ public class JValidator implements Validator {
}
return parameterBean;
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
logger.warn(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", e.getMessage(), e);
return null;
}
}

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.validation.support.jvalidation;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.bytecode.ClassGenerator;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ReflectUtils;
import org.apache.dubbo.validation.MethodValidated;
@ -67,6 +67,8 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FILTER_VALIDATION_EXCEPTION;
/**
* Implementation of JValidationNew. JValidationNew is invoked if configuration validation attribute value is 'jvalidationNew'.
* <pre>
@ -75,7 +77,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class JValidatorNew implements Validator {
private static final Logger logger = LoggerFactory.getLogger(JValidatorNew.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(JValidatorNew.class);
private final Class<?> clazz;
@ -116,7 +118,7 @@ public class JValidatorNew implements Validator {
}
return parameterBean;
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
logger.warn(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", e.getMessage(), e);
return null;
}
}

View File

@ -49,11 +49,6 @@
<artifactId>dubbo-metadata-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.registry.kubernetes;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshAppRuleListener;
import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListener;
@ -32,8 +32,10 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_LISTEN_KUBERNETES;
public class KubernetesMeshEnvListener implements MeshEnvListener {
public static final Logger logger = LoggerFactory.getLogger(KubernetesMeshEnvListener.class);
public static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(KubernetesMeshEnvListener.class);
private volatile static boolean usingApiServer = false;
private volatile static KubernetesClient kubernetesClient;
private volatile static String namespace;
@ -119,7 +121,7 @@ public class KubernetesMeshEnvListener implements MeshEnvListener {
}
} catch (Exception e) {
logger.error("Error occurred when listen kubernetes crd.", e);
logger.error(REGISTRY_ERROR_LISTEN_KUBERNETES, "", "", "Error occurred when listen kubernetes crd.", e);
}
}
@ -178,7 +180,7 @@ public class KubernetesMeshEnvListener implements MeshEnvListener {
}
} catch (Exception e) {
logger.error("Error occurred when listen kubernetes crd.", e);
logger.error(REGISTRY_ERROR_LISTEN_KUBERNETES, "", "", "Error occurred when listen kubernetes crd.", e);
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.registry.kubernetes;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.registry.client.AbstractServiceDiscovery;
@ -53,8 +53,12 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNABLE_FIND_SERVICE_KUBERNETES;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNABLE_MATCH_KUBERNETES;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNABLE_ACCESS_KUBERNETES;
public class KubernetesServiceDiscovery extends AbstractServiceDiscovery {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
private KubernetesClient kubernetesClient;
@ -96,7 +100,7 @@ public class KubernetesServiceDiscovery extends AbstractServiceDiscovery {
"Please check your url config." +
" Master URL: " + config.getMasterUrl() +
" Hostname: " + currentHostname;
logger.error(message);
logger.error(REGISTRY_UNABLE_ACCESS_KUBERNETES,"","",message);
} else {
KubernetesMeshEnvListener.injectKubernetesEnv(kubernetesClient, namespace);
}
@ -403,8 +407,8 @@ public class KubernetesServiceDiscovery extends AbstractServiceDiscovery {
Pod pod = pods.get(address.getTargetRef().getName());
String ip = address.getIp();
if (pod == null) {
logger.warn("Unable to match Kubernetes Endpoint address with Pod. " +
"EndpointAddress Hostname: " + address.getTargetRef().getName());
logger.warn(REGISTRY_UNABLE_MATCH_KUBERNETES, "", "", "Unable to match Kubernetes Endpoint address with Pod. " +
"EndpointAddress Hostname: " + address.getTargetRef().getName());
continue;
}
instancePorts.forEach(port -> {
@ -415,7 +419,7 @@ public class KubernetesServiceDiscovery extends AbstractServiceDiscovery {
serviceInstance.getMetadata().putAll(JSONObject.parseObject(properties, Map.class));
instances.add(serviceInstance);
} else {
logger.warn("Unable to find Service Instance metadata in Pod Annotations. " +
logger.warn(REGISTRY_UNABLE_FIND_SERVICE_KUBERNETES, "", "", "Unable to find Service Instance metadata in Pod Annotations. " +
"Possibly cause: provider has not been initialized successfully. " +
"EndpointAddress Hostname: " + address.getTargetRef().getName());
}

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.metadata;
import org.apache.dubbo.common.cache.FileCacheStore;
import org.apache.dubbo.common.cache.FileCacheStoreFactory;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.resource.Disposable;
import org.apache.dubbo.common.utils.JsonUtils;
@ -32,8 +32,10 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_LOAD_MAPPING_CACHE;
public abstract class AbstractCacheManager<V> implements Disposable {
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
private ScheduledExecutorService executorService;
@ -61,7 +63,7 @@ public abstract class AbstractCacheManager<V> implements Disposable {
this.executorService.scheduleWithFixedDelay(new CacheRefreshTask<>(this.cacheStore, this.cache, this, fileSize), 10, interval, TimeUnit.MINUTES);
} catch (Exception e) {
logger.error("Load mapping from local cache file error ", e);
logger.error(COMMON_FAILED_LOAD_MAPPING_CACHE, "", "", "Load mapping from local cache file error ", e);
}
}
@ -117,7 +119,7 @@ public abstract class AbstractCacheManager<V> implements Disposable {
}
public static class CacheRefreshTask<V> implements Runnable {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
private static final String DEFAULT_COMMENT = "Dubbo cache";
private final FileCacheStore cacheStore;
private final LRUCache<String, V> cache;

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.metadata;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
import org.apache.dubbo.common.utils.CollectionUtils;
@ -43,6 +43,7 @@ import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet;
import static java.util.stream.Collectors.toSet;
import static java.util.stream.Stream.of;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_LOAD_MAPPING_CACHE;
import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDED_BY;
import static org.apache.dubbo.common.constants.RegistryConstants.SUBSCRIBED_SERVICE_NAMES_KEY;
import static org.apache.dubbo.common.utils.CollectionUtils.isEmpty;
@ -50,7 +51,7 @@ import static org.apache.dubbo.common.utils.CollectionUtils.toTreeSet;
import static org.apache.dubbo.common.utils.StringUtils.isBlank;
public abstract class AbstractServiceNameMapping implements ServiceNameMapping {
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
protected ApplicationModel applicationModel;
private final MappingCacheManager mappingCacheManager;
private final Map<String, Set<MappingListener>> mappingListeners = new ConcurrentHashMap<>();
@ -63,13 +64,13 @@ public abstract class AbstractServiceNameMapping implements ServiceNameMapping {
this.applicationModel = applicationModel;
boolean enableFileCache = true;
Optional<ApplicationConfig> application = applicationModel.getApplicationConfigManager().getApplication();
if(application.isPresent()) {
if (application.isPresent()) {
enableFileCache = Boolean.TRUE.equals(application.get().getEnableFileCache()) ? true : false;
}
this.mappingCacheManager = new MappingCacheManager(enableFileCache,
applicationModel.tryGetApplicationName(),
applicationModel.getFrameworkModel().getBeanFactory()
.getBean(FrameworkExecutorRepository.class).getCacheRefreshingScheduledExecutor());
.getBean(FrameworkExecutorRepository.class).getCacheRefreshingScheduledExecutor());
}
// just for test
@ -293,7 +294,7 @@ public abstract class AbstractServiceNameMapping implements ServiceNameMapping {
}
}
} catch (Exception e) {
logger.error("Failed getting mapping info from remote center. ", e);
logger.error(COMMON_FAILED_LOAD_MAPPING_CACHE, "", "", "Failed getting mapping info from remote center. ", e);
}
return mappedServices;
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.metadata.report.support;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.ConfigUtils;
@ -67,6 +67,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.REPORT_METADATA_
import static org.apache.dubbo.common.constants.CommonConstants.RETRY_PERIOD_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.RETRY_TIMES_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.SYNC_REPORT_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED_EXPORT_SERVICE;
import static org.apache.dubbo.common.utils.StringUtils.replace;
import static org.apache.dubbo.metadata.report.support.Constants.CACHE;
import static org.apache.dubbo.metadata.report.support.Constants.DEFAULT_METADATA_REPORT_CYCLE_REPORT;
@ -82,7 +84,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
private static final int ONE_DAY_IN_MILLISECONDS = 60 * 24 * 60 * 1000;
private static final int FOUR_HOURS_IN_MILLISECONDS = 60 * 4 * 60 * 1000;
// Log output
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
// Local disk cache, where the special key value.registries records the list of metadata centers, and the others are the list of notified service providers
final Properties properties = new Properties();
@ -203,7 +205,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
} else {
reportCacheExecutor.execute(new SaveProperties(lastCacheChanged.incrementAndGet()));
}
logger.warn("Failed to save service store file, cause: " + e.getMessage(), e);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Failed to save service store file, cause: " + e.getMessage(), e);
}
}
@ -215,7 +217,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
logger.info("Load service store file " + file + ", data: " + properties);
}
} catch (Throwable e) {
logger.warn("Failed to load service store file " + file, e);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Failed to load service store file" + file, e);
}
}
}
@ -239,7 +241,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
}
}
@ -284,7 +286,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
// retry again. If failed again, throw exception.
failedReports.put(providerMetadataIdentifier, serviceDefinition);
metadataReportRetry.startRetryTask();
logger.error("Failed to put provider metadata " + providerMetadataIdentifier + " in " + serviceDefinition + ", cause: " + e.getMessage(), e);
logger.error(PROXY_FAILED_EXPORT_SERVICE, "", "", "Failed to put provider metadata " + providerMetadataIdentifier + " in " + serviceDefinition + ", cause: " + e.getMessage(), e);
}
}
@ -312,7 +314,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
// retry again. If failed again, throw exception.
failedReports.put(consumerMetadataIdentifier, serviceParameterMap);
metadataReportRetry.startRetryTask();
logger.error("Failed to put consumer metadata " + consumerMetadataIdentifier + "; " + serviceParameterMap + ", cause: " + e.getMessage(), e);
logger.error(PROXY_FAILED_EXPORT_SERVICE, "", "", "Failed to put consumer metadata " + consumerMetadataIdentifier + "; " + serviceParameterMap + ", cause: " + e.getMessage(), e);
}
}
@ -435,7 +437,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
}
class MetadataReportRetry {
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
final ScheduledExecutorService retryExecutor = Executors.newScheduledThreadPool(0, new NamedThreadFactory("DubboMetadataReportRetryTimer", true));
volatile ScheduledFuture retryScheduledFuture;
@ -468,7 +470,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
cancelRetryTask();
}
} catch (Throwable t) { // Defensive fault tolerance
logger.error("Unexpected error occur at failed retry, cause: " + t.getMessage(), t);
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "Unexpected error occur at failed retry, cause: " + t.getMessage(), t);
}
}, 500, retryPeriod, TimeUnit.MILLISECONDS);
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.metadata.report.support;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.metadata.report.MetadataReport;
import org.apache.dubbo.metadata.report.MetadataReportFactory;
@ -27,10 +27,12 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import static org.apache.dubbo.common.constants.CommonConstants.CHECK_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED_EXPORT_SERVICE;
public abstract class AbstractMetadataReportFactory implements MetadataReportFactory {
private static final Logger logger = LoggerFactory.getLogger(AbstractMetadataReportFactory.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractMetadataReportFactory.class);
private static final String EXPORT_KEY = "export";
private static final String REFER_KEY = "refer";
@ -67,7 +69,7 @@ public abstract class AbstractMetadataReportFactory implements MetadataReportFac
metadataReport = createMetadataReport(url);
} catch (Exception e) {
if (!check) {
logger.warn("The metadata reporter failed to initialize", e);
logger.warn(PROXY_FAILED_EXPORT_SERVICE, "", "", "The metadata reporter failed to initialize", e);
} else {
throw e;
}
@ -91,11 +93,11 @@ public abstract class AbstractMetadataReportFactory implements MetadataReportFac
lock.lock();
try {
for (MetadataReport metadataReport : serviceStoreMap.values()) {
try{
try {
metadataReport.destroy();
}catch (Throwable ignored){
} catch (Throwable ignored) {
// ignored
logger.warn(ignored.getMessage(),ignored);
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", ignored.getMessage(), ignored);
}
}
serviceStoreMap.clear();

View File

@ -17,10 +17,11 @@
package org.apache.dubbo.metadata.annotation.processing.util;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import static java.lang.String.format;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METADATA_PROCESSOR;
/**
* Logger Utils
@ -29,7 +30,7 @@ import static java.lang.String.format;
*/
public interface LoggerUtils {
Logger LOGGER = LoggerFactory.getLogger("dubbo-metadata-processor");
ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger("dubbo-metadata-processor");
static void info(String format, Object... args) {
if (LOGGER.isInfoEnabled()) {
@ -39,7 +40,7 @@ public interface LoggerUtils {
static void warn(String format, Object... args) {
if (LOGGER.isWarnEnabled()) {
LOGGER.warn(format(format, args));
LOGGER.warn(COMMON_METADATA_PROCESSOR, "", "", format(format, args));
}
}
}

View File

@ -55,6 +55,7 @@ import java.util.concurrent.Executor;
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION;
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
import static org.apache.dubbo.common.utils.StringConstantFieldValuePredicate.of;
import static org.apache.dubbo.common.utils.StringUtils.HYPHEN_CHAR;
@ -108,9 +109,9 @@ public class NacosMetadataReport extends AbstractMetadataReport {
private void setServerAddr(URL url, Properties properties) {
StringBuilder serverAddrBuilder =
new StringBuilder(url.getHost()) // Host
.append(':')
.append(url.getPort()); // Port
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) {
@ -227,7 +228,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
}
return configService.publishConfigCas(key, group, content, (String) ticket);
} catch (NacosException e) {
logger.warn("nacos publishConfigCas failed.", e);
logger.warn(REGISTRY_NACOS_EXCEPTION, "", "", "nacos publishConfigCas failed.", e);
return false;
}
}
@ -273,7 +274,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
try {
return configService.getConfig(dataId, group);
} catch (NacosException e) {
logger.error(e.getMessage());
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", e.getMessage());
}
return null;
}
@ -298,12 +299,12 @@ public class NacosMetadataReport extends AbstractMetadataReport {
public void addListener(String key, String group, ConfigurationListener listener) {
String listenerKey = buildListenerKey(key, group);
NacosConfigListener nacosConfigListener =
watchListenerMap.computeIfAbsent(listenerKey, k -> createTargetListener(key, group));
watchListenerMap.computeIfAbsent(listenerKey, k -> createTargetListener(key, group));
nacosConfigListener.addListener(listener);
try {
configService.addListener(key, group, nacosConfigListener);
} catch (NacosException e) {
logger.error(e.getMessage());
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", e.getMessage());
}
}
@ -319,7 +320,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
}
}
} catch (NacosException e) {
logger.error(e.getMessage());
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", e.getMessage());
}
}
@ -341,7 +342,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
throw new RuntimeException("publish nacos metadata failed");
}
} catch (Throwable t) {
logger.error("Failed to put " + identifier + " to nacos " + value + ", cause: " + t.getMessage(), t);
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "Failed to put " + identifier + " to nacos " + value + ", cause: " + t.getMessage(), t);
throw new RuntimeException("Failed to put " + identifier + " to nacos " + value + ", cause: " + t.getMessage(), t);
}
}
@ -353,7 +354,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
throw new RuntimeException("remove nacos metadata failed");
}
} catch (Throwable t) {
logger.error("Failed to remove " + identifier + " from nacos , cause: " + t.getMessage(), t);
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "Failed to remove " + identifier + " from nacos , cause: " + t.getMessage(), t);
throw new RuntimeException("Failed to remove " + identifier + " from nacos , cause: " + t.getMessage(), t);
}
}
@ -362,7 +363,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
try {
return configService.getConfig(identifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY), group, 3000L);
} catch (Throwable t) {
logger.error("Failed to get " + identifier + " from nacos , cause: " + t.getMessage(), t);
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "Failed to get " + identifier + " from nacos , cause: " + t.getMessage(), t);
throw new RuntimeException("Failed to get " + identifier + " from nacos , cause: " + t.getMessage(), t);
}
}

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.metadata.store.zookeeper;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.configcenter.ConfigItem;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.JsonUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -47,6 +47,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
import static org.apache.dubbo.metadata.ServiceNameMapping.DEFAULT_MAPPING_GROUP;
import static org.apache.dubbo.metadata.ServiceNameMapping.getAppNames;
@ -55,7 +56,7 @@ import static org.apache.dubbo.metadata.ServiceNameMapping.getAppNames;
*/
public class ZookeeperMetadataReport extends AbstractMetadataReport {
private final static Logger logger = LoggerFactory.getLogger(ZookeeperMetadataReport.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ZookeeperMetadataReport.class);
private final String root;
@ -200,7 +201,7 @@ public class ZookeeperMetadataReport extends AbstractMetadataReport {
zkClient.createOrUpdate(pathKey, content, false, ticket == null ? 0 : ((Stat) ticket).getVersion());
return true;
} catch (Exception e) {
logger.warn("zookeeper publishConfigCas failed.", e);
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "zookeeper publishConfigCas failed.", e);
return false;
}
}

View File

@ -28,7 +28,7 @@ import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.lang.ShutdownHookCallbacks;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.metrics.MetricsReporter;
import org.apache.dubbo.common.metrics.collector.DefaultMetricsCollector;
@ -46,6 +46,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
import static org.apache.dubbo.common.constants.MetricsConstants.ENABLE_JVM_METRICS_KEY;
/**
@ -53,7 +54,7 @@ import static org.apache.dubbo.common.constants.MetricsConstants.ENABLE_JVM_METR
*/
public abstract class AbstractMetricsReporter implements MetricsReporter {
private final Logger logger = LoggerFactory.getLogger(AbstractMetricsReporter.class);
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractMetricsReporter.class);
private final AtomicBoolean initialized = new AtomicBoolean(false);
@ -144,7 +145,7 @@ public abstract class AbstractMetricsReporter implements MetricsReporter {
break;
}
} catch (Exception e) {
logger.error("error occurred when synchronize metrics collector.", e);
logger.error(COMMON_METRICS_COLLECTOR_EXCEPTION, "", "", "error occurred when synchronize metrics collector.", e);
}
}
});

View File

@ -23,7 +23,7 @@ import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.exporter.BasicAuthHttpConnectionFactory;
import io.prometheus.client.exporter.PushGateway;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.common.utils.StringUtils;
@ -37,6 +37,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_EXPORTER_ENABLED_KEY;
import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_EXPORTER_METRICS_PORT_KEY;
import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_DEFAULT_METRICS_PORT;
@ -56,7 +57,7 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_PUSH
*/
public class PrometheusMetricsReporter extends AbstractMetricsReporter {
private final Logger logger = LoggerFactory.getLogger(PrometheusMetricsReporter.class);
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(PrometheusMetricsReporter.class);
private final PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
private ScheduledExecutorService pushJobExecutor = null;
@ -125,7 +126,7 @@ public class PrometheusMetricsReporter extends AbstractMetricsReporter {
try {
pushGateway.pushAdd(prometheusRegistry.getPrometheusRegistry(), job);
} catch (IOException e) {
logger.error("Error occurred when pushing metrics to prometheus: ", e);
logger.error(COMMON_METRICS_COLLECTOR_EXCEPTION, "", "", "Error occurred when pushing metrics to prometheus: ", e);
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.monitor.support;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.monitor.Monitor;
@ -36,12 +36,13 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
/**
* AbstractMonitorFactory. (SPI, Singleton, ThreadSafe)
*/
public abstract class AbstractMonitorFactory implements MonitorFactory {
private static final Logger logger = LoggerFactory.getLogger(AbstractMonitorFactory.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractMonitorFactory.class);
/**
* The lock for getting monitor center
@ -90,7 +91,7 @@ public abstract class AbstractMonitorFactory implements MonitorFactory {
FUTURES.remove(key);
return m;
} catch (Throwable e) {
logger.warn("Create monitor failed, monitor data will not be collected until you fix this problem. monitorUrl: " + monitorUrl, e);
logger.warn(COMMON_MONITOR_EXCEPTION, "", "", "Create monitor failed, monitor data will not be collected until you fix this problem. monitorUrl: " + monitorUrl, e);
return null;
}
});

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.monitor.support;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
@ -46,6 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
import static org.apache.dubbo.monitor.Constants.CONCURRENT_KEY;
import static org.apache.dubbo.monitor.Constants.COUNT_PROTOCOL;
import static org.apache.dubbo.monitor.Constants.ELAPSED_KEY;
@ -60,7 +61,7 @@ import static org.apache.dubbo.rpc.Constants.OUTPUT_KEY;
@Activate(group = {PROVIDER})
public class MonitorFilter implements Filter, Filter.Listener {
private static final Logger logger = LoggerFactory.getLogger(MonitorFilter.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MonitorFilter.class);
private static final String MONITOR_FILTER_START_TIME = "monitor_filter_start_time";
private static final String MONITOR_REMOTE_HOST_STORE = "monitor_remote_host_store";
@ -158,7 +159,7 @@ public class MonitorFilter implements Filter, Filter.Listener {
monitor.collect(statisticsUrl.toSerializableURL());
}
} catch (Throwable t) {
logger.warn("Failed to monitor count service " + invoker.getUrl() + ", cause: " + t.getMessage(), t);
logger.warn(COMMON_MONITOR_EXCEPTION, "", "", "Failed to monitor count service " + invoker.getUrl() + ", cause: " + t.getMessage(), t);
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.monitor.dubbo;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
import org.apache.dubbo.common.utils.ExecutorUtil;
@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_PROTOCOL;
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
import static org.apache.dubbo.monitor.Constants.CONCURRENT_KEY;
import static org.apache.dubbo.monitor.Constants.DEFAULT_MONITOR_SEND_DATA_INTERVAL;
import static org.apache.dubbo.monitor.Constants.ELAPSED_KEY;
@ -54,7 +55,7 @@ import static org.apache.dubbo.monitor.Constants.SUCCESS_KEY;
*/
public class DubboMonitor implements Monitor {
private static final Logger logger = LoggerFactory.getLogger(DubboMonitor.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DubboMonitor.class);
/**
* The timer for sending statistics
@ -85,7 +86,7 @@ public class DubboMonitor implements Monitor {
// collect data
send();
} catch (Throwable t) {
logger.error("Unexpected error occur at send statistic, cause: " + t.getMessage(), t);
logger.error(COMMON_MONITOR_EXCEPTION, "", "", "Unexpected error occur at send statistic, cause: " + t.getMessage(), t);
}
}, monitorInterval, monitorInterval, TimeUnit.MILLISECONDS);
}
@ -196,7 +197,7 @@ public class DubboMonitor implements Monitor {
try {
ExecutorUtil.cancelScheduledFuture(sendFuture);
} catch (Throwable t) {
logger.error("Unexpected error occur at cancel sender timer, cause: " + t.getMessage(), t);
logger.error(COMMON_MONITOR_EXCEPTION, "", "", "Unexpected error occur at cancel sender timer, cause: " + t.getMessage(), t);
}
monitorInvoker.destroy();
}

View File

@ -56,15 +56,18 @@ public class ClassFinder {
private void findClassesByFile(String packageName, String resource, Set<String> result) {
File directory = new File(resource);
File[] listFiles = directory.listFiles();
for (File file : listFiles) {
if (file.isDirectory()) {
findClassesByFile(packageName, file.getPath(), result);
} else {
String path = file.getPath();
if (path.endsWith(".class")) {
int packageIndex = path.indexOf(packageName.replace("/", File.separator));
String classPath = path.substring(packageIndex, path.length() - 6);
result.add(classPath.replace(File.separator, "."));
// null check
if (listFiles != null) {
for (File file : listFiles) {
if (file.isDirectory()) {
findClassesByFile(packageName, file.getPath(), result);
} else {
String path = file.getPath();
if (path.endsWith(".class")) {
int packageIndex = path.indexOf(packageName.replace("/", File.separator));
String classPath = path.substring(packageIndex, path.length() - 6);
result.add(classPath.replace(File.separator, "."));
}
}
}
}

View File

@ -56,15 +56,17 @@ public class ClassFinder {
private void findClassesByFile(String packageName, String resource, Set<String> result) {
File directory = new File(resource);
File[] listFiles = directory.listFiles();
for (File file : listFiles) {
if (file.isDirectory()) {
findClassesByFile(packageName, file.getPath(), result);
} else {
String path = file.getPath();
if (path.endsWith(".class")) {
int packageIndex = path.indexOf(packageName.replace("/", File.separator));
String classPath = path.substring(packageIndex, path.length() - 6);
result.add(classPath.replace(File.separator, "."));
if (listFiles != null) {
for (File file : listFiles) {
if (file.isDirectory()) {
findClassesByFile(packageName, file.getPath(), result);
} else {
String path = file.getPath();
if (path.endsWith(".class")) {
int packageIndex = path.indexOf(packageName.replace("/", File.separator));
String classPath = path.substring(packageIndex, path.length() - 6);
result.add(classPath.replace(File.separator, "."));
}
}
}
}

View File

@ -70,9 +70,5 @@
<artifactId>dubbo-serialization-fastjson2</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -16,21 +16,23 @@
*/
package org.apache.dubbo.qos.command.impl;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.profiler.ProfilerSwitch;
import org.apache.dubbo.qos.command.BaseCommand;
import org.apache.dubbo.qos.command.CommandContext;
import org.apache.dubbo.qos.command.annotation.Cmd;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_DISABLED;
@Cmd(name = "disableDetailProfiler", summary = "Disable Dubbo Invocation Profiler.")
public class DisableDetailProfiler implements BaseCommand {
private final static Logger logger = LoggerFactory.getLogger(DisableDetailProfiler.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DisableDetailProfiler.class);
@Override
public String execute(CommandContext commandContext, String[] args) {
ProfilerSwitch.disableDetailProfiler();
logger.warn("Dubbo Invocation Profiler has been disabled.");
logger.warn(QOS_PROFILER_DISABLED, "", "", "Dubbo Invocation Profiler has been disabled.");
return "OK";
}
}

View File

@ -16,21 +16,23 @@
*/
package org.apache.dubbo.qos.command.impl;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.profiler.ProfilerSwitch;
import org.apache.dubbo.qos.command.BaseCommand;
import org.apache.dubbo.qos.command.CommandContext;
import org.apache.dubbo.qos.command.annotation.Cmd;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_DISABLED;
@Cmd(name = "disableSimpleProfiler", summary = "Disable Dubbo Invocation Profiler.")
public class DisableSimpleProfiler implements BaseCommand {
private final static Logger logger = LoggerFactory.getLogger(DisableSimpleProfiler.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DisableSimpleProfiler.class);
@Override
public String execute(CommandContext commandContext, String[] args) {
ProfilerSwitch.disableSimpleProfiler();
logger.warn("Dubbo Invocation Profiler has been disabled.");
logger.warn(QOS_PROFILER_DISABLED, "", "", "Dubbo Invocation Profiler has been disabled.");
return "OK";
}
}

View File

@ -16,21 +16,23 @@
*/
package org.apache.dubbo.qos.command.impl;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.profiler.ProfilerSwitch;
import org.apache.dubbo.qos.command.BaseCommand;
import org.apache.dubbo.qos.command.CommandContext;
import org.apache.dubbo.qos.command.annotation.Cmd;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_ENABLED;
@Cmd(name = "enableDetailProfiler", summary = "Enable Dubbo Invocation Profiler.")
public class EnableDetailProfiler implements BaseCommand {
private final static Logger logger = LoggerFactory.getLogger(EnableDetailProfiler.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(EnableDetailProfiler.class);
@Override
public String execute(CommandContext commandContext, String[] args) {
ProfilerSwitch.enableDetailProfiler();
logger.warn("Dubbo Invocation Profiler has been enabled.");
logger.warn(QOS_PROFILER_ENABLED, "", "", "Dubbo Invocation Profiler has been enabled.");
return "OK. This will cause performance degradation, please be careful!";
}
}

View File

@ -16,21 +16,23 @@
*/
package org.apache.dubbo.qos.command.impl;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.profiler.ProfilerSwitch;
import org.apache.dubbo.qos.command.BaseCommand;
import org.apache.dubbo.qos.command.CommandContext;
import org.apache.dubbo.qos.command.annotation.Cmd;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_ENABLED;
@Cmd(name = "enableSimpleProfiler", summary = "Enable Dubbo Invocation Profiler.")
public class EnableSimpleProfiler implements BaseCommand {
private final static Logger logger = LoggerFactory.getLogger(EnableSimpleProfiler.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(EnableSimpleProfiler.class);
@Override
public String execute(CommandContext commandContext, String[] args) {
ProfilerSwitch.enableSimpleProfiler();
logger.warn("Dubbo Invocation Profiler has been enabled.");
logger.warn(QOS_PROFILER_ENABLED, "", "", "Dubbo Invocation Profiler has been enabled.");
return "OK";
}
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.qos.command.impl;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
import org.apache.dubbo.common.utils.ArrayUtils;
@ -30,12 +30,14 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_PARAMETER_FORMAT_ERROR;
@Cmd(name = "publishMetadata", summary = "update service metadata and service instance", example = {
"publishMetadata",
"publishMetadata 5"
"publishMetadata",
"publishMetadata 5"
})
public class PublishMetadata implements BaseCommand {
private static final Logger logger = LoggerFactory.getLogger(PublishMetadata.class);
public class PublishMetadata implements BaseCommand {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(PublishMetadata.class);
private final FrameworkModel frameworkModel;
public PublishMetadata(FrameworkModel frameworkModel) {
@ -60,7 +62,7 @@ public class PublishMetadata implements BaseCommand {
frameworkExecutorRepository.nextScheduledExecutor()
.schedule(() -> ServiceInstanceMetadataUtils.refreshMetadataAndInstance(applicationModel), delay, TimeUnit.SECONDS);
} catch (NumberFormatException e) {
logger.error("Wrong delay param", e);
logger.error(CONFIG_PARAMETER_FORMAT_ERROR, "", "", "Wrong delay param", e);
return "publishMetadata failed! Wrong delay param!";
}
stringBuilder.append("publish task submitted, will publish in ").append(args[0]).append(" seconds. App:").append(applicationModel.getApplicationName()).append("\n");

View File

@ -16,16 +16,18 @@
*/
package org.apache.dubbo.qos.command.impl;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.profiler.ProfilerSwitch;
import org.apache.dubbo.qos.command.BaseCommand;
import org.apache.dubbo.qos.command.CommandContext;
import org.apache.dubbo.qos.command.annotation.Cmd;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_WARN_PERCENT;
@Cmd(name = "setProfilerWarnPercent", example = "setProfilerWarnPercent 0.75", summary = "Disable Dubbo Invocation Profiler.")
public class SetProfilerWarnPercent implements BaseCommand {
private final static Logger logger = LoggerFactory.getLogger(SetProfilerWarnPercent.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SetProfilerWarnPercent.class);
@Override
public String execute(CommandContext commandContext, String[] args) {
@ -33,7 +35,7 @@ public class SetProfilerWarnPercent implements BaseCommand {
return "args error. example: setProfilerWarnPercent 0.75";
}
ProfilerSwitch.setWarnPercent(Double.parseDouble(args[0]));
logger.warn("Dubbo Invocation Profiler warn percent has been set to " + args[0]);
logger.warn(QOS_PROFILER_WARN_PERCENT, "", "", "Dubbo Invocation Profiler warn percent has been set to " + args[0]);
return "OK";
}
}

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.qos.protocol;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.qos.common.QosConstants;
import org.apache.dubbo.qos.pu.QosWireProtocol;
@ -35,6 +35,7 @@ import org.apache.dubbo.rpc.model.ScopeModelAware;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_FAILED_START_SERVER;
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP;
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
import static org.apache.dubbo.common.constants.QosConstants.QOS_HOST;
@ -43,7 +44,7 @@ import static org.apache.dubbo.common.constants.QosConstants.QOS_PORT;
@Activate(order = 200)
public class QosProtocolWrapper implements Protocol, ScopeModelAware {
private final Logger logger = LoggerFactory.getLogger(QosProtocolWrapper.class);
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(QosProtocolWrapper.class);
private AtomicBoolean hasStarted = new AtomicBoolean(false);
@ -99,7 +100,7 @@ public class QosProtocolWrapper implements Protocol, ScopeModelAware {
boolean qosEnable = url.getParameter(QOS_ENABLE, true);
WireProtocol qosWireProtocol = frameworkModel.getExtensionLoader(WireProtocol.class).getExtension("qos");
if(qosWireProtocol != null) {
if (qosWireProtocol != null) {
((QosWireProtocol) qosWireProtocol).setQosEnable(qosEnable);
}
if (!qosEnable) {
@ -124,7 +125,7 @@ public class QosProtocolWrapper implements Protocol, ScopeModelAware {
server.start();
} catch (Throwable throwable) {
logger.warn("Fail to start qos server: ", throwable);
logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to start qos server: ", throwable);
}
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.qos.server;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.qos.server.handler.QosProcessHandler;
@ -33,6 +33,8 @@ import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_FAILED_START_SERVER;
/**
* A server serves for both telnet access and http access
* <ul>
@ -43,7 +45,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class Server {
private static final Logger logger = LoggerFactory.getLogger(Server.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Server.class);
private String host;
@ -107,7 +109,7 @@ public class Server {
logger.info("qos-server bind localhost:" + port);
} catch (Throwable throwable) {
logger.error("qos-server can not bind localhost:" + port, throwable);
logger.error(QOS_FAILED_START_SERVER, "", "", "qos-server can not bind localhost:" + port, throwable);
throw throwable;
}
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.qos.server.handler;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.qos.command.CommandContext;
import org.apache.dubbo.qos.command.CommandExecutor;
@ -37,6 +37,9 @@ import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_COMMAND_NOT_FOUND;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_UNEXPECTED_EXCEPTION;
/**
* Parse HttpRequest for uri and parameters
* <p>
@ -50,7 +53,7 @@ import io.netty.handler.codec.http.HttpVersion;
*/
public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest> {
private static final Logger log = LoggerFactory.getLogger(HttpProcessHandler.class);
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(HttpProcessHandler.class);
private CommandExecutor commandExecutor;
public HttpProcessHandler(FrameworkModel frameworkModel) {
@ -59,7 +62,7 @@ public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest>
private static FullHttpResponse http(int httpCode, String result) {
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.valueOf(httpCode)
, Unpooled.wrappedBuffer(result.getBytes()));
, Unpooled.wrappedBuffer(result.getBytes()));
HttpHeaders httpHeaders = response.headers();
httpHeaders.set(HttpHeaderNames.CONTENT_TYPE, "text/plain");
httpHeaders.set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
@ -79,7 +82,7 @@ public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest>
CommandContext commandContext = HttpCommandDecoder.decode(msg);
// return 404 when fail to construct command context
if (commandContext == null) {
log.warn("can not found commandContext, url: " + msg.uri());
log.warn(QOS_UNEXPECTED_EXCEPTION, "", "", "can not found commandContext, url: " + msg.uri());
FullHttpResponse response = http404();
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} else {
@ -90,11 +93,11 @@ public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest>
FullHttpResponse response = http(httpCode, result);
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} catch (NoSuchCommandException ex) {
log.error("can not find command: " + commandContext, ex);
log.error(QOS_COMMAND_NOT_FOUND, "", "", "can not find command: " + commandContext, ex);
FullHttpResponse response = http404();
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} catch (Exception qosEx) {
log.error("execute commandContext: " + commandContext + " got exception", qosEx);
log.error(QOS_UNEXPECTED_EXCEPTION, "", "", "execute commandContext: " + commandContext + " got exception", qosEx);
FullHttpResponse response = http(500, qosEx.getMessage());
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.qos.server.handler;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.qos.command.CommandContext;
@ -31,12 +31,15 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_COMMAND_NOT_FOUND;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_UNEXPECTED_EXCEPTION;
/**
* Telnet process handler
*/
public class TelnetProcessHandler extends SimpleChannelInboundHandler<String> {
private static final Logger log = LoggerFactory.getLogger(TelnetProcessHandler.class);
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(TelnetProcessHandler.class);
private final CommandExecutor commandExecutor;
public TelnetProcessHandler(FrameworkModel frameworkModel) {
@ -62,11 +65,11 @@ public class TelnetProcessHandler extends SimpleChannelInboundHandler<String> {
} catch (NoSuchCommandException ex) {
ctx.writeAndFlush(msg + " :no such command");
ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.PROMPT);
log.error("can not found command " + commandContext, ex);
log.error(QOS_COMMAND_NOT_FOUND, "", "", "can not found command " + commandContext, ex);
} catch (Exception ex) {
ctx.writeAndFlush(msg + " :fail to execute commandContext by " + ex.getMessage());
ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.PROMPT);
log.error("execute commandContext got exception " + commandContext, ex);
log.error(QOS_UNEXPECTED_EXCEPTION, "", "", "execute commandContext got exception " + commandContext, ex);
}
}
}

View File

@ -26,6 +26,8 @@ import org.apache.dubbo.common.utils.UrlUtils;
import java.util.List;
import java.util.function.Consumer;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNEXPECTED_EXCEPTION;
public class ListenerRegistryWrapper implements Registry {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ListenerRegistryWrapper.class);
@ -123,7 +125,7 @@ public class ListenerRegistryWrapper implements Registry {
try {
consumer.accept(listener);
} catch (RuntimeException t) {
logger.error(t.getMessage(), t);
logger.error(REGISTRY_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
exception = t;
}
}

View File

@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_DELAY_EXECUTE_TIMES;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_NOTIFY_EVENT;
public abstract class RegistryNotifier {
@ -111,7 +112,7 @@ public abstract class RegistryNotifier {
}
}
} catch (Throwable t) {
logger.error("Error occurred when notify directory. ", t);
logger.error(REGISTRY_FAILED_NOTIFY_EVENT, "", "", "Error occurred when notify directory. ", t);
}
}
}

View File

@ -40,6 +40,8 @@ import java.util.Set;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_METADATA_STORAGE_TYPE;
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_LOCAL_FILE_CACHE_ENABLED;
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_FETCH_INSTANCE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_LOAD_METADATA;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_CLUSTER_KEY;
import static org.apache.dubbo.metadata.RevisionResolver.EMPTY_REVISION;
import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.EXPORTED_SERVICES_REVISION_PROPERTY_NAME;
@ -96,7 +98,7 @@ public abstract class AbstractServiceDiscovery implements ServiceDiscovery {
}
this.serviceInstance = createServiceInstance(this.metadataInfo);
if (!isValidInstance(this.serviceInstance)) {
logger.warn("No valid instance found, stop registering instance address to registry.");
logger.warn(REGISTRY_FAILED_FETCH_INSTANCE, "", "", "No valid instance found, stop registering instance address to registry.");
return;
}
@ -195,7 +197,7 @@ public abstract class AbstractServiceDiscovery implements ServiceDiscovery {
}
if (metadata == MetadataInfo.EMPTY) {
logger.error("Failed to get metadata for revision after 3 retries, revision=" + revision);
logger.error(REGISTRY_FAILED_LOAD_METADATA, "", "", "Failed to get metadata for revision after 3 retries, revision=" + revision);
} else {
metaCacheManager.put(revision, metadata);
}
@ -205,7 +207,7 @@ public abstract class AbstractServiceDiscovery implements ServiceDiscovery {
@Override
public MetadataInfo getRemoteMetadata(String revision) {
return metaCacheManager.get(revision);
return metaCacheManager.get(revision);
}
@Override
@ -242,7 +244,7 @@ public abstract class AbstractServiceDiscovery implements ServiceDiscovery {
@Override
public List<URL> lookup(URL url) {
throw new UnsupportedOperationException("Service discovery implementation does not support lookup of url list.");
throw new UnsupportedOperationException("Service discovery implementation does not support lookup of url list.");
}
protected void doUpdate(ServiceInstance serviceInstance) throws RuntimeException {
@ -310,7 +312,7 @@ public abstract class AbstractServiceDiscovery implements ServiceDiscovery {
}
StringBuilder stringBuilder = new StringBuilder(128);
Optional<ApplicationConfig> application = applicationModel.getApplicationConfigManager().getApplication();
if(application.isPresent()) {
if (application.isPresent()) {
stringBuilder.append(application.get().getName());
stringBuilder.append(".");
}

View File

@ -41,6 +41,7 @@ import java.util.concurrent.locks.ReentrantLock;
import static org.apache.dubbo.common.constants.CommonConstants.CHECK_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNEXPECTED_EXCEPTION;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_CLUSTER_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE;
@ -202,7 +203,7 @@ public class ServiceDiscoveryRegistry extends FailbackRegistry {
subscribedServices = serviceNameMapping.getAndListen(this.getUrl(), url, mappingListener);
mappingListeners.put(url.getProtocolServiceKey(), mappingListener);
} catch (Exception e) {
logger.warn("Cannot find app mapping for service " + url.getServiceInterface() + ", will not migrate.", e);
logger.warn(REGISTRY_UNEXPECTED_EXCEPTION, "", "", "Cannot find app mapping for service " + url.getServiceInterface() + ", will not migrate.", e);
}
if (CollectionUtils.isEmpty(subscribedServices)) {
@ -365,7 +366,7 @@ public class ServiceDiscoveryRegistry extends FailbackRegistry {
logger.info("Received mapping notification from meta server, " + event);
if (stopped) {
logger.warn("Listener has been stopped, ignore mapping notification, check why listener is not removed.");
logger.warn(REGISTRY_UNEXPECTED_EXCEPTION, "", "", "Listener has been stopped, ignore mapping notification, check why listener is not removed.");
return;
}
Set<String> newApps = event.getApps();

View File

@ -61,6 +61,8 @@ import java.util.stream.Collectors;
import static org.apache.dubbo.common.constants.CommonConstants.DISABLED_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DESTROY_INVOKER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REFER_INVOKER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNSUPPORTED;
import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_HASHMAP_LOAD_FACTOR;
import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL;
@ -229,14 +231,14 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
this.originalUrls = invokerUrls;
if (invokerUrls.size() == 1 && EMPTY_PROTOCOL.equals(invokerUrls.get(0).getProtocol())) {
logger.warn("Received url with EMPTY protocol, will clear all available addresses.");
logger.warn(PROTOCOL_UNSUPPORTED, "", "", "Received url with EMPTY protocol, will clear all available addresses.");
this.forbidden = true; // Forbid to access
routerChain.setInvokers(BitList.emptyList());
destroyAllInvokers(); // Close all invokers
} else {
this.forbidden = false; // Allow accessing
if (CollectionUtils.isEmpty(invokerUrls)) {
logger.warn("Received empty url list, will ignore for protection purpose.");
logger.warn(PROTOCOL_UNSUPPORTED, "", "", "Received empty url list, will ignore for protection purpose.");
return;
}
@ -253,7 +255,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
logger.info("Refreshed invoker size " + newUrlInvokerMap.size());
if (CollectionUtils.isEmptyMap(newUrlInvokerMap)) {
logger.error(new IllegalStateException("Cannot create invokers from url address list (total " + invokerUrls.size() + ")"));
logger.error(PROTOCOL_UNSUPPORTED, "", "", "Unsupported protocol.", new IllegalStateException("Cannot create invokers from url address list (total " + invokerUrls.size() + ")"));
return;
}
List<Invoker<T>> newInvokers = Collections.unmodifiableList(new ArrayList<>(newUrlInvokerMap.values()));
@ -266,7 +268,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
try {
destroyUnusedInvokers(oldUrlInvokerMap, newUrlInvokerMap); // Close the unused Invoker
} catch (Exception e) {
logger.warn("destroyUnusedInvokers error. ", e);
logger.warn(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", "destroyUnusedInvokers error. ", e);
}
}
}
@ -300,9 +302,9 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
logger.error(PROTOCOL_UNSUPPORTED, "protocol extension does not installed", "", "Unsupported protocol.",
new IllegalStateException("Unsupported protocol " + instanceAddressURL.getProtocol() +
" in notified url: " + instanceAddressURL + " from registry " + getUrl().getAddress() +
" to consumer " + NetUtils.getLocalHost() + ", supported protocol: " +
getUrl().getOrDefaultFrameworkModel().getExtensionLoader(Protocol.class).getSupportedExtensions()));
" in notified url: " + instanceAddressURL + " from registry " + getUrl().getAddress() +
" to consumer " + NetUtils.getLocalHost() + ", supported protocol: " +
getUrl().getOrDefaultFrameworkModel().getExtensionLoader(Protocol.class).getSupportedExtensions()));
continue;
}
@ -351,7 +353,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
}
}
} catch (Throwable t) {
logger.error("Failed to refer invoker for interface:" + serviceType + ",url:(" + instanceAddressURL + ")" + t.getMessage(), t);
logger.error(PROTOCOL_FAILED_REFER_INVOKER, "", "", "Failed to refer invoker for interface:" + serviceType + ",url:(" + instanceAddressURL + ")" + t.getMessage(), t);
}
if (invoker != null) { // Put new invoker in cache
newUrlInvokerMap.put(protocolServiceKeyWithAddress, invoker);
@ -425,7 +427,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
try {
invoker.destroyAll();
} catch (Throwable t) {
logger.warn("Failed to destroy service " + serviceKey + " to provider " + invoker.getUrl(), t);
logger.warn(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", "Failed to destroy service " + serviceKey + " to provider " + invoker.getUrl(), t);
}
}
localUrlInvokerMap.clear();
@ -461,7 +463,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
logger.debug("destroy invoker[" + invoker.getUrl() + "] success. ");
}
} catch (Exception e) {
logger.warn("destroy invoker[" + invoker.getUrl() + "] failed. " + e.getMessage(), e);
logger.warn(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", "destroy invoker[" + invoker.getUrl() + "]failed." + e.getMessage(), e);
}
}
}

Some files were not shown because too many files have changed in this diff Show More