Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/master' into dev_27031
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangfengcdt committed Sep 18, 2023
2 parents 4ac2749 + 3cbd841 commit 1890c6b
Show file tree
Hide file tree
Showing 1,481 changed files with 20,236 additions and 15,713 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-sql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
matrix:
adapter: [ proxy, jdbc ]
mode: [ Standalone, Cluster ]
database: [ MySQL, PostgreSQL, openGauss ]
database: [ MySQL, PostgreSQL ]
# Fix me #25051
#scenario: [ dbtbl_with_readwrite_splitting, dbtbl_with_readwrite_splitting_and_encrypt, sharding_and_encrypt, encrypt_and_readwrite_splitting, encrypt_shadow, readwrite_splitting_and_shadow, sharding_and_shadow, sharding_encrypt_shadow, mask_encrypt, mask_sharding, mask_encrypt_sharding ]
scenario: [ empty_rules, rdl_empty_rules, passthrough, tbl, encrypt, readwrite_splitting, shadow, mask, dbtbl_with_readwrite_splitting_and_encrypt, sharding_and_encrypt, encrypt_and_readwrite_splitting, encrypt_shadow, readwrite_splitting_and_shadow, sharding_and_shadow, sharding_encrypt_shadow, mask_encrypt, mask_sharding, mask_encrypt_sharding ]
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,16 @@ jobs:
ref: ${{ inputs.commit-id }}
- uses: graalvm/setup-graalvm@v1
with:
version: '22.3.1'
java-version: '17'
components: 'espresso,native-image'
java-version: '17.0.8'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-${{ github.sha }}
restore-keys: |
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-cache-
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}-maven-third-party-
- uses: docker/login-action@v2
with:
registry: ${{ env.HUB }}
Expand Down Expand Up @@ -217,17 +222,17 @@ jobs:
- name: Build with Maven
run: ./mvnw -B -T1C -ntp clean install -DskipITs -DskipTests
- name: Generate Examples
run: ./mvnw -B clean install -f examples/shardingsphere-example-generator/pom.xml -Pexample-generator -Dproducts=${{ matrix.product }} -Dmodes=${{ matrix.mode }} -Dtransactions=${{ matrix.transaction }} -Dfeatures=${{ matrix.feature }} -Dframeworks=${{ matrix.framework }}
run: ./mvnw -B clean install -f examples/shardingsphere-jdbc-example-generator/pom.xml -Pexample-generator -Dproducts=${{ matrix.product }} -Dmodes=${{ matrix.mode }} -Dtransactions=${{ matrix.transaction }} -Dfeatures=${{ matrix.feature }} -Dframeworks=${{ matrix.framework }}
- name: Test Examples
run : ./mvnw -B test -f examples/shardingsphere-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}/pom.xml -Pexample-generator -Dexec.cleanupDaemonThreads=false
run : ./mvnw -B test -f examples/shardingsphere-jdbc-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}/pom.xml -Pexample-generator -Dexec.cleanupDaemonThreads=false
- name: Package Examples
run: |
cd examples/shardingsphere-example-generator/target/generated-sources/shardingsphere-jdbc-sample/
cd examples/shardingsphere-jdbc-example-generator/target/generated-sources/shardingsphere-jdbc-sample/
tar -czvf ${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}.tar.gz ${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}
- uses: burnett01/[email protected]
with:
switches: -avzr
path: examples/shardingsphere-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}.tar.gz
path: examples/shardingsphere-jdbc-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}.tar.gz
remote_path: ${{ secrets.NIGHTLIES_RSYNC_PATH }}/shardingsphere/examples
remote_host: ${{ secrets.NIGHTLIES_RSYNC_HOST }}
remote_port: ${{ secrets.NIGHTLIES_RSYNC_PORT }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
name: Check - CodeQL
needs: global-environment
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 100
permissions:
actions: read
contents: read
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ The concepts at the core of the project are `Connect`, `Enhance` and `Pluggable`
- `Enhance:` Capture database access entry to provide additional features transparently, such as: redirect (sharding, readwrite-splitting and shadow), transform (data encrypt and mask), authentication (security, audit and authority), governance (circuit breaker and access limitation and analyze, QoS and observability).
- `Pluggable:` Leveraging the micro kernel and 3 layers pluggable mode, features and database ecosystem can be embedded flexibly. Developers can customize their ShardingSphere just like building with LEGO blocks.

Virtually all databases are [supported](https://shardingsphere.apache.org/document/current/en/dev-manual/data-source/) including [MySQL](https://www.mysql.com), [PostgreSQL](https://www.postgresql.org), [SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads), [Oracle Database](https://www.oracle.com/database/), [MariaDB](https://mariadb.org) or any other SQL-92 database.

ShardingSphere became an [Apache](https://apache.org/index.html#projects-list) Top-Level Project on April 16, 2020.

So far, ShardingSphere has been used by over [10,000 projects on GitHub](https://github.com/search?l=Maven+POM&q=shardingsphere+language%3A%22Maven+POM%22&type=Code).
Expand All @@ -54,7 +52,7 @@ So far, ShardingSphere has been used by over [10,000 projects on GitHub](https:/

For full documentation & more details, visit: [Docs](https://shardingsphere.apache.org/document/current/en/overview/)

### CONTRIBUTION🚀🧑💻
### CONTRIBUTION🚀🧑💻

<hr>

Expand Down
2 changes: 1 addition & 1 deletion README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ShardingSphere 已于 2020 年 4 月 16 日成为 [Apache 软件基金会](https

更多信息请参考:[https://shardingsphere.apache.org/document/current/cn/overview/](https://shardingsphere.apache.org/document/current/cn/overview/)

### 参与贡献🚀🧑💻
### 参与贡献🚀🧑💻

<hr>

Expand Down
21 changes: 0 additions & 21 deletions agent/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -88,10 +83,6 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
<relocations>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>${shade.package}.com.google</shadedPattern>
</relocation>
<relocation>
<pattern>net.bytebuddy</pattern>
<shadedPattern>${shade.package}.net.bytebuddy</shadedPattern>
Expand All @@ -100,18 +91,6 @@
<pattern>org.yaml</pattern>
<shadedPattern>${shade.package}.org.yaml</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>${shade.package}.org.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>ch.qos.logback</pattern>
<shadedPattern>${shade.package}.ch.qos.logback</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.logging</pattern>
<shadedPattern>${shade.package}.org.apache.commons.logging</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.shardingsphere.agent.core.path;

import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.agent.core.util.AgentPreconditions;

import java.io.File;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -47,7 +47,7 @@ public static File getRootPath() {
private static File getJarFile(final String url) {
try {
File result = new File(new URL(url.substring(url.indexOf("file:"), url.indexOf('!'))).toURI());
Preconditions.checkState(result.exists(), "Can not locate agent jar file by URL `%s`.", url);
AgentPreconditions.checkState(result.exists(), String.format("Can not locate agent jar file by URL `%s`.", url));
return result;
} catch (final MalformedURLException | URISyntaxException ex) {
throw new IllegalStateException(String.format("Can not locate agent jar file by URL `%s`.", url), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.shardingsphere.agent.core.plugin.classloader;

import com.google.common.io.ByteStreams;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
Expand Down Expand Up @@ -94,10 +94,26 @@ private void definePackage(final String name, final Manifest manifest) {
}

private Class<?> defineClass(final String name, final JarFile extraJar, final ZipEntry entry) throws IOException {
byte[] data = ByteStreams.toByteArray(extraJar.getInputStream(entry));
byte[] data = toByteArray(extraJar.getInputStream(entry));
return defineClass(name, data, 0, data.length);
}

private static byte[] toByteArray(final InputStream inStream) throws IOException {
int buffSize = 2048;
ByteArrayOutputStream result = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[buffSize];
int len = -1;
while ((len = inStream.read(buffer)) != -1) {
result.write(buffer, 0, len);
}
} finally {
result.close();
inStream.close();
}
return result.toByteArray();
}

@Override
protected Enumeration<URL> findResources(final String name) {
Collection<URL> result = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -57,10 +58,11 @@ public static Map<String, PluginConfiguration> swap(final YamlAgentConfiguration
private static Map<String, PluginConfiguration> swap(final Map<String, YamlPluginConfiguration> yamlConfigs) {
return null == yamlConfigs
? Collections.emptyMap()
: yamlConfigs.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> swap(entry.getValue()), (key, value) -> value, LinkedHashMap::new));
: yamlConfigs.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> swap(entry.getValue()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}

private static PluginConfiguration swap(final YamlPluginConfiguration yamlConfig) {
return new PluginConfiguration(yamlConfig.getHost(), yamlConfig.getPort(), yamlConfig.getPassword(), yamlConfig.getProps());
return null == yamlConfig ? new PluginConfiguration(null, 0, null, new Properties())
: new PluginConfiguration(yamlConfig.getHost(), yamlConfig.getPort(), yamlConfig.getPassword(), yamlConfig.getProps());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.apache.shardingsphere.agent.core.spi;

import com.google.common.base.Preconditions;
import lombok.Getter;
import org.apache.shardingsphere.agent.core.util.AgentPreconditions;

import java.util.Collection;
import java.util.LinkedList;
Expand All @@ -44,8 +44,8 @@ private AgentServiceLoader(final Class<T> service) {
}

private void validate(final Class<T> service) {
Preconditions.checkNotNull(service, "SPI class is null.");
Preconditions.checkArgument(service.isInterface(), "SPI class `%s` is not interface.", service);
AgentPreconditions.checkNotNull(service, "SPI class is null.");
AgentPreconditions.checkArgument(service.isInterface(), String.format("SPI class `%s` is not interface.", service));
}

private Collection<T> load(final Class<T> service) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.core.util;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
* Agent preconditions.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class AgentPreconditions {

/**
* Check state.
*
* @param state state
* @param errorMessage error message
* @throws IllegalStateException illegal state exception
*/
public static void checkState(final boolean state, final String errorMessage) {
if (!state) {
throw new IllegalStateException(errorMessage);
}
}

/**
* Check not null.
*
* @param reference reference
* @param errorMessage error message
* @throws NullPointerException null pointer exception
*/
public static void checkNotNull(final Object reference, final String errorMessage) {
if (null == reference) {
throw new NullPointerException(errorMessage);
}
}

/**
* Check argument.
*
* @param condition condition
* @param errorMessage error message
* @throws IllegalArgumentException illegal argument exception
*/
public static void checkArgument(final boolean condition, final String errorMessage) {
if (!condition) {
throw new IllegalArgumentException(errorMessage);
}
}
}
Loading

0 comments on commit 1890c6b

Please sign in to comment.