You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2020/12/29 07:18:44 UTC
[shardingsphere] branch master updated: Minor refactor of agent
module (#8803)
This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 40bb135 Minor refactor of agent module (#8803)
40bb135 is described below
commit 40bb135c39db39b4687aaeedf52303ac056770fb
Author: Liang Zhang <te...@163.com>
AuthorDate: Tue Dec 29 15:18:05 2020 +0800
Minor refactor of agent module (#8803)
* Rename ReflectiveUtil package
* Rename ReflectiveUtil package
* Refactor AgentConfigurationLoader
* Refactor AgentPathBuilder
* Refactor PluginLoader
* Refactor advance package
* For code format
* Revise PrometheusPluginBootService's log content
* Refactor ZipkinTracingPluginBootService
* Refactor ZipkinTracingPluginBootService
* Refactor PluginBootService
* Refactor JaegerTracingPluginBootService
---
.../core/config/loader/AgentConfigurationLoader.java | 9 +++++----
.../agent/core/path/AgentPathBuilder.java | 13 +++++--------
.../plugin/advice/ConstructorMethodInterceptor.java | 2 +-
.../core/plugin/advice/MethodAroundInterceptor.java | 6 +++---
.../plugin/advice/StaticMethodAroundInterceptor.java | 8 ++++----
.../agent/core/plugin/loader/PluginLoader.java | 2 +-
.../agent/core/plugin/service/PluginBootService.java | 4 ++--
.../agent/core/config/AgentConfigurationLoaderTest.java | 9 +++++----
.../agent/core/{base => util}/ReflectiveUtil.java | 7 +++++--
.../src/main/resources/conf/agent.yaml | 1 -
.../shardingsphere-agent-plugin-logging/pom.xml | 13 ++++++-------
.../shardingsphere-agent-logging-base/pom.xml | 6 +++---
.../shardingsphere-agent-metrics-api/pom.xml | 4 ++--
.../prometheus/service/PrometheusPluginBootService.java | 17 +++++++++--------
.../jaeger/service/JaegerTracingPluginBootService.java | 14 ++++----------
.../zipkin/service/ZipkinTracingPluginBootService.java | 8 ++------
.../transaction/xa/fixture/ReflectiveUtil.java | 17 +----------------
17 files changed, 58 insertions(+), 82 deletions(-)
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java
index 236e73f..4de642c 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java
@@ -18,8 +18,6 @@
package org.apache.shardingsphere.agent.core.config.loader;
import com.google.common.base.Preconditions;
-import java.io.File;
-import java.io.IOException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.agent.core.config.AgentConfiguration;
@@ -28,6 +26,9 @@ import org.apache.shardingsphere.agent.core.config.yaml.swapper.YamlAgentConfigu
import org.apache.shardingsphere.agent.core.path.AgentPathBuilder;
import org.apache.shardingsphere.agent.core.yaml.YamlEngine;
+import java.io.File;
+import java.io.IOException;
+
/**
* Agent configuration loader.
*/
@@ -44,11 +45,11 @@ public final class AgentConfigurationLoader {
*/
public static AgentConfiguration load() throws IOException {
File configFile = new File(AgentPathBuilder.getAgentPath(), DEFAULT_CONFIG_PATH);
- YamlAgentConfiguration yamlAgentConfiguration = loadAgentConfiguration(configFile);
+ YamlAgentConfiguration yamlAgentConfiguration = load(configFile);
return YamlAgentConfigurationSwapper.swap(yamlAgentConfiguration);
}
- private static YamlAgentConfiguration loadAgentConfiguration(final File yamlFile) throws IOException {
+ private static YamlAgentConfiguration load(final File yamlFile) throws IOException {
YamlAgentConfiguration result = YamlEngine.unmarshal(yamlFile, YamlAgentConfiguration.class);
Preconditions.checkNotNull(result, "Agent configuration file `%s` is invalid.", yamlFile.getName());
return result;
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/path/AgentPathBuilder.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/path/AgentPathBuilder.java
index e69d619..7007dfa 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/path/AgentPathBuilder.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/path/AgentPathBuilder.java
@@ -18,13 +18,14 @@
package org.apache.shardingsphere.agent.core.path;
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.agent.core.exception.ShardingSphereAgentException;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
-import lombok.Getter;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.agent.core.exception.ShardingSphereAgentException;
/**
* Agent path builder.
@@ -51,11 +52,7 @@ public final class AgentPathBuilder {
log.debug("The beacon class location is {}.", url);
int insideIndex = url.indexOf('!');
boolean isInJar = insideIndex > -1;
- if (isInJar) {
- return getFileInJar(url, insideIndex);
- } else {
- return getFileInResource(url, classResourcePath);
- }
+ return isInJar ? getFileInJar(url, insideIndex) : getFileInResource(url, classResourcePath);
}
throw new ShardingSphereAgentException("Can not locate agent jar file.");
}
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/ConstructorMethodInterceptor.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/ConstructorMethodInterceptor.java
index ed48394..5483918 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/ConstructorMethodInterceptor.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/ConstructorMethodInterceptor.java
@@ -42,7 +42,7 @@ public class ConstructorMethodInterceptor {
* @param args the all constructor arguments
*/
@RuntimeType
- public void intercept(final @This TargetObject target, final @AllArguments Object[] args) {
+ public void intercept(@This final TargetObject target, @AllArguments final Object[] args) {
try {
advice.onConstructor(target, args);
// CHECKSTYLE:OFF
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundInterceptor.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundInterceptor.java
index 17a859a..03983d2 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundInterceptor.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundInterceptor.java
@@ -52,9 +52,9 @@ public class MethodAroundInterceptor {
*/
@RuntimeType
@SneakyThrows
- public Object intercept(final @This Object target, final @Origin Method method, final @AllArguments Object[] args, final @SuperCall Callable<?> callable) {
- final TargetObject instance = (TargetObject) target;
- final MethodInvocationResult methodResult = new MethodInvocationResult();
+ public Object intercept(@This final Object target, @Origin final Method method, @AllArguments final Object[] args, @SuperCall final Callable<?> callable) {
+ TargetObject instance = (TargetObject) target;
+ MethodInvocationResult methodResult = new MethodInvocationResult();
Object result;
try {
advice.beforeMethod(instance, method, args, methodResult);
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/StaticMethodAroundInterceptor.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/StaticMethodAroundInterceptor.java
index 0304da7..f72f19b 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/StaticMethodAroundInterceptor.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/StaticMethodAroundInterceptor.java
@@ -51,13 +51,13 @@ public class StaticMethodAroundInterceptor {
*/
@RuntimeType
@SneakyThrows
- public Object intercept(final @Origin Class<?> klass, final @Origin Method method, final @AllArguments Object[] args, final @SuperCall Callable<?> callable) {
- final MethodInvocationResult invocationResult = new MethodInvocationResult();
- final Object result;
+ public Object intercept(@Origin final Class<?> klass, @Origin final Method method, @AllArguments final Object[] args, @SuperCall final Callable<?> callable) {
+ MethodInvocationResult invocationResult = new MethodInvocationResult();
+ Object result;
try {
advice.beforeMethod(klass, method, args, invocationResult);
// CHECKSTYLE:OFF
- } catch (Throwable ex) {
+ } catch (final Throwable ex) {
// CHECKSTYLE:ON
log.error("Failed to execute the pre-method of method[{}] in class[{}].", method.getName(), klass, ex);
}
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoader.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoader.java
index 314d756..44ecadf 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoader.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoader.java
@@ -283,7 +283,7 @@ public final class PluginLoader extends ClassLoader implements Closeable {
String implTitle = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
String implVersion = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
String implVendor = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
- super.definePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, null);
+ definePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, null);
}
private void buildPluginInterceptorPointMap(final PluginDefinition pluginDefinition, final Map<String, PluginInterceptorPoint> pointMap) {
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/service/PluginBootService.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/service/PluginBootService.java
index 02831a7..b232e49 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/service/PluginBootService.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/service/PluginBootService.java
@@ -28,7 +28,7 @@ public interface PluginBootService extends AgentTypedSPI, AutoCloseable {
/**
* Setup plugin boot service, like to configure or to initial.
*
- * @param pluginConfiguration plugin configuration
+ * @param pluginConfig plugin configuration
*/
- void start(PluginConfiguration pluginConfiguration);
+ void start(PluginConfiguration pluginConfig);
}
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/config/AgentConfigurationLoaderTest.java b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/config/AgentConfigurationLoaderTest.java
index 457e8f1..2dfd9e3 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/config/AgentConfigurationLoaderTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/config/AgentConfigurationLoaderTest.java
@@ -17,14 +17,15 @@
package org.apache.shardingsphere.agent.core.config;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import org.apache.shardingsphere.agent.core.base.ReflectiveUtil;
import org.apache.shardingsphere.agent.core.config.loader.AgentConfigurationLoader;
import org.apache.shardingsphere.agent.core.path.AgentPathBuilder;
+import org.apache.shardingsphere.agent.core.util.ReflectiveUtil;
import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
import static org.junit.Assert.assertNotNull;
public final class AgentConfigurationLoaderTest {
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/base/ReflectiveUtil.java b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/util/ReflectiveUtil.java
similarity index 96%
rename from shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/base/ReflectiveUtil.java
rename to shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/util/ReflectiveUtil.java
index 5a59e52..0be10d9 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/base/ReflectiveUtil.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/util/ReflectiveUtil.java
@@ -15,14 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.core.base;
+package org.apache.shardingsphere.agent.core.util;
import com.google.common.base.Preconditions;
-import java.lang.reflect.Field;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
+import java.lang.reflect.Field;
+
/**
* Reflective utility.
*/
@@ -31,6 +32,7 @@ public final class ReflectiveUtil {
/**
* Get field.
+ *
* @param target target
* @param fieldName field name
* @return field
@@ -49,6 +51,7 @@ public final class ReflectiveUtil {
/**
* Set value to specified field.
+ *
* @param target target
* @param fieldName field name
* @param value value
diff --git a/shardingsphere-agent/shardingsphere-agent-distribution/src/main/resources/conf/agent.yaml b/shardingsphere-agent/shardingsphere-agent-distribution/src/main/resources/conf/agent.yaml
index 100a4df..f83a13c 100644
--- a/shardingsphere-agent/shardingsphere-agent-distribution/src/main/resources/conf/agent.yaml
+++ b/shardingsphere-agent/shardingsphere-agent-distribution/src/main/resources/conf/agent.yaml
@@ -39,4 +39,3 @@ plugins:
port: 15775
props:
name: "Zipkin"
-
\ No newline at end of file
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/pom.xml b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/pom.xml
index a5d45e7..9d119cb 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/pom.xml
@@ -28,23 +28,23 @@
<artifactId>shardingsphere-agent-plugin-logging</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
-
+
<modules>
<module>shardingsphere-agent-logging-base</module>
</modules>
-
+
<properties>
- <entrypoint.class/>
+ <entrypoint.class />
<logging.target.directory>${project.basedir}/../target/plugins</logging.target.directory>
</properties>
-
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-agent-core</artifactId>
</dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>
@@ -66,5 +66,4 @@
</plugin>
</plugins>
</build>
-
-</project>
\ No newline at end of file
+</project>
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/pom.xml b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/pom.xml
index 0479ae1..6021a6b 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/pom.xml
@@ -28,11 +28,11 @@
<artifactId>shardingsphere-agent-logging-base</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
-
+
<properties>
<entrypoint.class>org.apache.shardingsphere.agent.plugin.logging.base.definition.BaseLoggingPluginDefinition</entrypoint.class>
</properties>
-
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
@@ -41,4 +41,4 @@
<scope>provided</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/pom.xml b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/pom.xml
index d9ab28c..ad4fe55 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>shardingsphere-agent-metrics-api</artifactId>
<name>${project.artifactId}</name>
-
+
<properties>
<entrypoint.class>org.apache.shardingsphere.agent.metrics.api.definition.MetricsPluginDefinition</entrypoint.class>
</properties>
@@ -40,7 +40,7 @@
<scope>provided</scope>
</dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootService.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootService.java
index e4c5de0..7f0b95d 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootService.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootService.java
@@ -20,13 +20,14 @@ package org.apache.shardingsphere.agent.metrics.prometheus.service;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.exporter.HTTPServer;
import io.prometheus.client.hotspot.DefaultExports;
-import java.io.IOException;
-import java.net.InetSocketAddress;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.agent.core.config.PluginConfiguration;
import org.apache.shardingsphere.agent.core.plugin.service.PluginBootService;
import org.apache.shardingsphere.agent.metrics.prometheus.collector.BuildInfoCollector;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
/**
* Prometheus plugin boot service.
*/
@@ -36,10 +37,10 @@ public class PrometheusPluginBootService implements PluginBootService {
private HTTPServer httpServer;
@Override
- public void start(final PluginConfiguration configuration) {
- boolean enabled = Boolean.parseBoolean(configuration.getProps().getProperty("jvmInformationCollectorEnabled"));
+ public void start(final PluginConfiguration pluginConfig) {
+ boolean enabled = Boolean.parseBoolean(pluginConfig.getProps().getProperty("jvmInformationCollectorEnabled"));
registerJvm(enabled);
- startServer(configuration);
+ startServer(pluginConfig);
}
@Override
@@ -72,9 +73,9 @@ public class PrometheusPluginBootService implements PluginBootService {
}
try {
httpServer = new HTTPServer(inetSocketAddress, CollectorRegistry.defaultRegistry, true);
- log.info(String.format("you start prometheus metrics http server host is: %s , port is: %s", inetSocketAddress.getHostString(), inetSocketAddress.getPort()));
- } catch (final IOException exception) {
- log.error("you start prometheus metrics http server is error", exception);
+ log.info(String.format("Prometheus metrics HTTP server `%s:%s` start success.", inetSocketAddress.getHostString(), inetSocketAddress.getPort()));
+ } catch (final IOException ex) {
+ log.error("Prometheus metrics HTTP server start fail", ex);
}
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
index 7cd4bbd..67e89fb 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
@@ -28,18 +28,12 @@ import org.apache.shardingsphere.agent.core.plugin.service.PluginBootService;
public final class JaegerTracingPluginBootService implements PluginBootService {
@Override
- public void start(final PluginConfiguration pluginConfiguration) {
- pluginConfiguration.getProps().forEach((key, value) -> System.setProperty(String.valueOf(key), String.valueOf(value)));
+ public void start(final PluginConfiguration pluginConfig) {
+ pluginConfig.getProps().forEach((key, value) -> System.setProperty(String.valueOf(key), String.valueOf(value)));
Configuration.SamplerConfiguration samplerConfig = Configuration.SamplerConfiguration.fromEnv();
Configuration.ReporterConfiguration reporterConfig = Configuration.ReporterConfiguration.fromEnv()
- .withSender(
- Configuration.SenderConfiguration.fromEnv()
- .withAgentHost(pluginConfiguration.getHost())
- .withAgentPort(pluginConfiguration.getPort())
- );
- Configuration config = new Configuration("ShardingSphere-Jaeger")
- .withSampler(samplerConfig)
- .withReporter(reporterConfig);
+ .withSender(Configuration.SenderConfiguration.fromEnv().withAgentHost(pluginConfig.getHost()).withAgentPort(pluginConfig.getPort()));
+ Configuration config = new Configuration("ShardingSphere-Jaeger").withSampler(samplerConfig).withReporter(reporterConfig);
GlobalTracer.register(config.getTracer());
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootService.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootService.java
index f70d7f8..afe43c5 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootService.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootService.java
@@ -35,8 +35,8 @@ public final class ZipkinTracingPluginBootService implements PluginBootService {
private Tracing tracing;
@Override
- public void start(final PluginConfiguration configuration) {
- sender = OkHttpSender.create(buildHttpPath(configuration));
+ public void start(final PluginConfiguration pluginConfig) {
+ sender = OkHttpSender.create(String.format("http://%s:%s", pluginConfig.getHost(), pluginConfig.getPort()));
zipkinSpanHandler = AsyncZipkinSpanHandler.create(sender);
tracing = Tracing.newBuilder().localServiceName("shardingsphere-agent").addSpanHandler(zipkinSpanHandler).build();
}
@@ -52,8 +52,4 @@ public final class ZipkinTracingPluginBootService implements PluginBootService {
public String getType() {
return "Zipkin";
}
-
- private String buildHttpPath(final PluginConfiguration configuration) {
- return String.format("http://%s:%s", configuration.getHost(), configuration.getPort());
- }
}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/ReflectiveUtil.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/ReflectiveUtil.java
index 648a17e..04dce5c 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/ReflectiveUtil.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/ReflectiveUtil.java
@@ -17,10 +17,8 @@
package org.apache.shardingsphere.transaction.xa.fixture;
-import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import lombok.SneakyThrows;
import java.lang.reflect.Field;
@@ -32,6 +30,7 @@ public final class ReflectiveUtil {
/**
* Get field.
+ *
* @param target target
* @param fieldName field name
* @return field
@@ -47,18 +46,4 @@ public final class ReflectiveUtil {
}
return null;
}
-
- /**
- * Set value to specified field.
- * @param target target
- * @param fieldName field name
- * @param value value
- */
- @SneakyThrows(ReflectiveOperationException.class)
- public static void setProperty(final Object target, final String fieldName, final Object value) {
- Field field = getField(target, fieldName);
- Preconditions.checkNotNull(field);
- field.setAccessible(true);
- field.set(target, value);
- }
}