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/25 07:43:55 UTC
[shardingsphere] branch master updated: agent add logging plugin
(#8776)
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 86ac820 agent add logging plugin (#8776)
86ac820 is described below
commit 86ac8205950143778989e9ae2cc44456ca52c7b2
Author: xiaoyu <54...@qq.com>
AuthorDate: Fri Dec 25 15:43:23 2020 +0800
agent add logging plugin (#8776)
---
.../shardingsphere-agent-binary-distribution.xml | 8 ++++
.../shardingsphere-agent-plugin-logging/pom.xml | 41 +++++++++++++++++++-
.../pom.xml | 17 +++++++-
.../base/advice/SchemaMetaDataLoaderAdvice.java | 39 +++++++++++++++++++
.../definition/BaseLoggingPluginDefinition.java | 45 ++++++++++++++++++++++
.../shardingsphere-agent-plugin-tracing/pom.xml | 2 +-
6 files changed, 148 insertions(+), 4 deletions(-)
diff --git a/shardingsphere-agent/shardingsphere-agent-distribution/src/main/assembly/shardingsphere-agent-binary-distribution.xml b/shardingsphere-agent/shardingsphere-agent-distribution/src/main/assembly/shardingsphere-agent-binary-distribution.xml
index 702788f..26959ef 100644
--- a/shardingsphere-agent/shardingsphere-agent-distribution/src/main/assembly/shardingsphere-agent-binary-distribution.xml
+++ b/shardingsphere-agent/shardingsphere-agent-distribution/src/main/assembly/shardingsphere-agent-binary-distribution.xml
@@ -41,6 +41,14 @@
</fileSet>
<fileSet>
+ <directory>${project.basedir}/../shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/target/plugins</directory>
+ <outputDirectory>./plugins</outputDirectory>
+ <includes>
+ <include>**.jar</include>
+ </includes>
+ </fileSet>
+
+ <fileSet>
<directory>${project.basedir}/../shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/target/plugins</directory>
<outputDirectory>./plugins</outputDirectory>
<includes>
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 e7e5781..a5d45e7 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
@@ -25,7 +25,46 @@
<artifactId>shardingsphere-agent-plugins</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <name>${project.artifactId}</name>
<artifactId>shardingsphere-agent-plugin-logging</artifactId>
+ <packaging>pom</packaging>
+ <name>${project.artifactId}</name>
+
+ <modules>
+ <module>shardingsphere-agent-logging-base</module>
+ </modules>
+
+ <properties>
+ <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>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Entrypoint>${entrypoint.class}</Entrypoint>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <outputFile>${logging.target.directory}/${project.build.finalName}</outputFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ 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/shardingsphere-agent-logging-base/pom.xml
similarity index 67%
copy from shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/pom.xml
copy to shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/pom.xml
index e7e5781..0479ae1 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/pom.xml
@@ -22,10 +22,23 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-agent-plugins</artifactId>
+ <artifactId>shardingsphere-agent-plugin-logging</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
+ <artifactId>shardingsphere-agent-logging-base</artifactId>
+ <packaging>jar</packaging>
<name>${project.artifactId}</name>
- <artifactId>shardingsphere-agent-plugin-logging</artifactId>
+ <properties>
+ <entrypoint.class>org.apache.shardingsphere.agent.plugin.logging.base.definition.BaseLoggingPluginDefinition</entrypoint.class>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-common</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/advice/SchemaMetaDataLoaderAdvice.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/advice/SchemaMetaDataLoaderAdvice.java
new file mode 100644
index 0000000..3d13bb5
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/advice/SchemaMetaDataLoaderAdvice.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.logging.base.advice;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodAroundAdvice;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodInvocationResult;
+import org.apache.shardingsphere.agent.core.plugin.advice.TargetObject;
+
+/**
+ * Schema meta data loader advice.
+ */
+@Slf4j
+public final class SchemaMetaDataLoaderAdvice implements MethodAroundAdvice {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void afterMethod(final TargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
+ Collection<String> results = (Collection<String>) result.getResult();
+ log.info("Loading {} tables' meta data for unconfigured tables.", results.size());
+ }
+}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/definition/BaseLoggingPluginDefinition.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/definition/BaseLoggingPluginDefinition.java
new file mode 100644
index 0000000..307bda7
--- /dev/null
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-logging/shardingsphere-agent-logging-base/src/main/java/org/apache/shardingsphere/agent/plugin/logging/base/definition/BaseLoggingPluginDefinition.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.agent.plugin.logging.base.definition;
+
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.definition.PluginDefinition;
+
+/**
+ * Base logging plugin definition.
+ */
+public final class BaseLoggingPluginDefinition extends PluginDefinition {
+
+ private static final String SCHEMA_METADATA_LOADER_CLASS = "org.apache.shardingsphere.infra.metadata.schema.builder.loader.SchemaMetaDataLoader";
+
+ private static final String SCHEMA_METADATA_LOADER_METHOD_NAME = "loadAllTableNames";
+
+ private static final String SCHEMA_METADATA_LOADER_ADVICE_CLASS = "org.apache.shardingsphere.agent.plugin.logging.base.advice.SchemaMetaDataLoaderAdvice";
+
+ public BaseLoggingPluginDefinition() {
+ super("base-logging");
+ }
+
+ @Override
+ protected void define() {
+ intercept(SCHEMA_METADATA_LOADER_CLASS)
+ .aroundInstanceMethod(ElementMatchers.named(SCHEMA_METADATA_LOADER_METHOD_NAME))
+ .implement(SCHEMA_METADATA_LOADER_ADVICE_CLASS)
+ .build();
+ }
+}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/pom.xml b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/pom.xml
index 943df88..e3ac2c3 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/pom.xml
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/pom.xml
@@ -19,12 +19,12 @@
<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>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-agent-plugins</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <modelVersion>4.0.0</modelVersion>
<artifactId>shardingsphere-agent-plugin-tracing</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>