Merge pull request #9 from taojintianxia/add-mvnw

Add : add mvnw to plugin repository
tree: 4b2d07905b16ec60cd1ced490007ffb628af73b4
  1. .idea/
  2. .mvn/
  3. features/
  4. infra/
  5. jdbc/
  6. mode/
  7. .asf.yaml
  8. .gitignore
  9. .licenserc.yaml
  10. LICENSE
  11. mvnw
  12. mvnw.cmd
  13. pom.xml
  14. README.md
  15. README_ZH.md
README.md

Table of Contents

OVERVIEW

ShardingSphere Plugin is designed to provide a plug-in implementation for ShardingSphere pluggable architecture. You can refer to ShardingSphere Dev Manual to extend the SPI. Developers are welcome to contribute to the implementation of plug-ins and build a distributed database ecosystem of ShardingSphere.

EN doc CN doc

Instruction

These plugins can be found in ShardingSphere Plugins repository. Plugins in ShardingSphere Plugin repository would remain the same release plan with ShardingSphere, they can be retrieved at https://central.sonatype.com/, and install into ShardingSphere. When using ShardingSphere-JDBC, users only need to add maven dependencies to the project to complete the plug-in installation. When using ShardingSphere-Proxy, they need to download the plug-in jar package and the jar packages that the plug-in may depend on, and then copy them to ShardingSphere-Proxy ext-lib directory.

When developers contribute new plug-ins, they need to refer to Contributor Guide and first execute ./mvnw clean install -DskipITs -DskipTests -Prelease to package ShardingSphere basic SPI and test components, and then create a new module for plug-in development. Newly developed plug-in code needs to follow ShardingSphere Code of Conduct.

Plug-in Implementation

Feature Plug-in

Encrypt Feature Plug-in

Like Encrypt Algorithm

  • CharDigestLike Encrypt Algorithm

Type:CHAR_DIGEST_LIKE

Attributes:

NameDataTypeDescription
deltaintCharacter Unicode offset(decimal number)
maskintCharacter encryption mask(decimal number)
startintCiphertext Unicode initial code(decimal number)
dictStringCommon words

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-encrypt-like</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>

Standard Encrypt Algorithm

  • RC4 Encrypt Algorithm

Type: RC4

Attributes:

NameDataTypeDescription
rc4-key-valueStringRC4 KEY

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-encrypt-rc4</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>
  • SM3 Encrypt Algorithm

Type: SM3

Attributes:

NameDataTypeDescription
sm3-saltStringSM3 SALT (should be blank or 8 bytes long)

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-encrypt-sm</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>
  • SM4 Encrypt Algorithm

Type: SM4

Attributes:

NameDataTypeDescription
sm4-keyStringSM4 KEY (should be 16 bytes)
sm4-modeStringSM4 MODE (should be CBC or ECB)
sm4-ivStringSM4 IV (should be specified on CBC, 16 bytes long)
sm4-paddingStringSM4 PADDING (should be PKCS5Padding or PKCS7Padding, NoPadding excepted)

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-encrypt-sm</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>

Sharding Feature Plug-in

Distributed Key Generator

  • Nano ID

Type:NANOID

Configurable Property:none

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-sharding-nanoid</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>
  • CosId

Type: COSID

Attributes:

NameDataTypeDescriptionDefault Value
id-nameStringID generator name__share__
as-stringboolWhether to generate a string type ID: Convert long type ID to Base-62 String type (Long.MAX_VALUE maximum string length is 11 digits), and ensure the ordering of string IDsfalse

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>
  • CosId-Snowflake

Type: COSID_SNOWFLAKE

Attributes:

NameDataTypeDescriptionDefault Value
epochStringEPOCH of Snowflake ID Algorithm1477929600000
as-stringboolWhether to generate a string type ID: Convert long type ID to Base-62 String type (Long.MAX_VALUE maximum string length is 11 digits), and ensure the ordering of string IDsfalse

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>

Sharding Algorithm

  • Fixed interval sharding algorithm provided by CosId

A fixed time range sharding algorithm implemented by the tool class based on me.ahoo.cosid:cosid-core. When the sharding key is a JSR-310 containing class or a time-related class, it will be converted to java.time.LocalDateTime before the next sharding. See the discussion at https://github.com/apache/shardingsphere/issues/14047.

Type:COSID_INTERVAL

Attributes:

NameDataTypeDescriptionDefault Value
zone-idStringTime zone, which must follow the contained value of java.time.ZoneId. For example: Asia/Shanghai
logic-name-prefixStringPrefix pattern of sharding data sources or tables
datetime-lowerStringDatetime sharding lower boundary, pattern is consistent with the timestamp format of yyyy-MM-dd HH:mm:ss
datetime-upperStringDatetime sharding upper boundary, pattern is consistent with the timestamp format of yyyy-MM-dd HH:mm:ss
sharding-suffix-patternStringSuffix pattern of sharding data sources or tables, must can be transformed to Java LocalDateTime, must be consistent with datetime-interval-unit. For example: yyyyMM
datetime-interval-unitStringUnit of sharding value interval, must can be transformed to Java ChronoUnit's Enum value. For example: MONTHS
datetime-interval-amountintInterval of sharding value, after which the next shard will be entered

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>
  • Snowflake key-based fixed interval sharding algorithm provided by CosId

Snowflake ID sharding algorithm with fixed time range implemented by tool class based on me.ahoo.cosid:cosid-core. When the sharding key is a JSR-310 containing class or a time-related class, it will be converted to java.time.LocalDateTime before the next sharding. See the discussion at https://github.com/apache/shardingsphere/issues/14047.

Type:COSID_INTERVAL_SNOWFLAKE

Attributes:

NameDataTypeDescriptionDefault Value
zone-idStringTime zone, which must follow the contained value of java.time.ZoneId. For example: Asia/Shanghai
logic-name-prefixStringPrefix pattern of sharding data sources or tables
datetime-lowerStringDatetime sharding lower boundary, pattern is consistent with the timestamp format of yyyy-MM-dd HH:mm:ss
datetime-upperStringDatetime sharding upper boundary, pattern is consistent with the timestamp format of yyyy-MM-dd HH:mm:ss
sharding-suffix-patternStringSuffix pattern of sharding data sources or tables, must can be transformed to Java LocalDateTime, must be consistent with datetime-interval-unit. For example: yyyyMM
datetime-interval-unitStringUnit of sharding value interval, must can be transformed to Java ChronoUnit's Enum value. For example: MONTHS
datetime-interval-amountintInterval of sharding value, after which the next shard will be entered

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>
  • Modulo sharding algorithm provided by CosId

Modulo sharding algorithm implemented by the tool class based on me.ahoo.cosid:cosid-core. See the discussion at https://github.com/apache/shardingsphere/issues/14047 .

Type: COSID_MOD

Attributes:

NameDataTypeDescription
modintSharding count
logic-name-prefixStringPrefix pattern of sharding data sources or tables

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>

Infra Plug-in

Connection Pool Plug-in

ShardingSphere-Proxy supports common data source connection pools: HikariCP, C3P0, DBCP.

The connection pool can be specified through the parameter dataSourceClassName. When not specified, the default data source connection pool is HikariCP.

  • C3P0 Connection Pool

Sample:

dataSources:
  ds_0:
    dataSourceClassName: com.mchange.v2.c3p0.ComboPooledDataSource
    url: jdbc:mysql://localhost:3306/ds_2
    username: root
    password:

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-infra-data-source-pool-c3p0</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>
  • DBCP Connection Pool

Sample:

dataSources:
  ds_0:
    dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource
    url: jdbc:mysql://localhost:3306/ds_3
    username: root
    password:
<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-infra-data-source-pool-dbcp</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>

JDBC Adaptor Plug-in

JDBC Driver Config Plug-in

ShardingSphere-JDBC provides a JDBC Driver, which can be used only through configuration changes without rewriting the code.

  • Apollo Driver Config

Load JDBC URL of the yaml configuration file in the specified namespace of apollo:

jdbc:shardingsphere:apollo:TEST.test_namespace

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-jdbc-driver-apollo</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>

Mode Plug-in

Mode Cluster Repository Plug-in

  • Nacos Repository

Type: Nacos

Mode: Cluster

Attributes:

NameTypeDescriptionDefault Value
clusterIpStringUnique identifier in clusterHost IP
retryIntervalMillisecondslongMilliseconds of retry interval500
maxRetriesintMax retries for client to check data availability3
timeToLiveSecondsintSeconds of ephemeral instance live30

Maven dependency:

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-plugin-mode-cluster-repository-nacos</artifactId>
    <version>${RELEASE.VERSION}</version>
</dependency>