Class SchemaShardingManager

    • Method Detail

      • publishShard

         final Unit publishShard(String table, Integer number)

        Check and shard table with table_0 to table_${NUMBER - 1}, total NUMBER tables. A warning is displayed if the footer is not consecutive or if the total is greater than the NUMBER. If shard table already exist, but none of them have records, delete them all and recreate. If none exist, create new ones. Otherwise, an error will throw. Manual intervention is required

        Parameters:
        table - plain table
        number - count of sharding, 0 means no sharding.
      • shardingData

         final Unit shardingData(String table, Boolean stopOnError)

        Migrate small size data from the plain table to the shard datasource, it is not recommended to use it for more than one million data. When migrating data, it is recommended to disable triggers to avoid generating a lot of useless data. The execution process uses 3 threads: select, insert and delete. 2 blocking queue: insert, delete. default size 1024. Execute without transaction. If the target data is successfully inserted, then the source data is deleted. If it fails, there may be dirty data, you need to insert manually, according to the log processing

        Parameters:
        table - plain table
        stopOnError - Whether to stop when insertion or deletion fails, the default is not to stop, only record error.