getAllCacheStatic();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/DistributeLock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster;
7 |
8 | public abstract class DistributeLock {
9 |
10 | protected String path;
11 | protected String value;
12 |
13 | public abstract boolean acquire();
14 |
15 | public abstract void release();
16 |
17 | public String getPath() {
18 | return path;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/general/bean/SubscribeRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.general.bean;
7 |
8 | /**
9 | * Created by szf on 2019/3/12.
10 | */
11 | public class SubscribeRequest {
12 | private long index;
13 | private int duration;
14 | private String path;
15 |
16 |
17 | public long getIndex() {
18 | return index;
19 | }
20 |
21 | public void setIndex(long index) {
22 | this.index = index;
23 | }
24 |
25 | public int getDuration() {
26 | return duration;
27 | }
28 |
29 | public void setDuration(int duration) {
30 | this.duration = duration;
31 | }
32 |
33 | public String getPath() {
34 | return path;
35 | }
36 |
37 | public void setPath(String path) {
38 | this.path = path;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/general/response/ClusterXmlLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.general.response;
7 |
8 | import com.actiontech.dble.cluster.values.OriginClusterEvent;
9 |
10 | /**
11 | * Created by szf on 2018/1/26.
12 | */
13 | public interface ClusterXmlLoader {
14 |
15 | void notifyProcess(OriginClusterEvent> changeEvent, boolean ignoreTheGrandChild) throws Exception;
16 |
17 | void notifyCluster() throws Exception;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/logic/ClusterOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.logic;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-03-17
12 | */
13 | public enum ClusterOperation {
14 | PAUSE_RESUME(1),
15 | VIEW(1),
16 |
17 |
18 | HA(1),
19 | CONFIG(1),
20 |
21 | META(1),
22 | DDL(1),
23 | UNKNOWN(1),
24 | BINGLOG(1),
25 | ONLINE(1),
26 | ;
27 |
28 | private int apiVersion;
29 |
30 | ClusterOperation(int apiVersion) {
31 | this.apiVersion = apiVersion;
32 | }
33 |
34 | public int getApiVersion() {
35 | return apiVersion;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/logic/CommonClusterLogic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.logic;
8 |
9 | import org.apache.logging.log4j.LogManager;
10 | import org.apache.logging.log4j.Logger;
11 |
12 | /**
13 | * @author dcy
14 | * Create Date: 2021-04-30
15 | */
16 | public class CommonClusterLogic extends AbstractClusterLogic {
17 | private static final Logger LOGGER = LogManager.getLogger(CommonClusterLogic.class);
18 |
19 | CommonClusterLogic(ClusterOperation operation) {
20 | super(operation);
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/logic/MetaClusterLogic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.logic;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-04-30
12 | */
13 | class MetaClusterLogic extends AbstractClusterLogic {
14 |
15 | MetaClusterLogic() {
16 | super(ClusterOperation.META);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/logic/OnlineClusterLogic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.logic;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-04-30
12 | */
13 | public class OnlineClusterLogic extends AbstractClusterLogic {
14 |
15 | OnlineClusterLogic() {
16 | super(ClusterOperation.ONLINE);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/AnyType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-04-07
12 | *
13 | * if use this ,you must specify the class before read.
14 | */
15 | public class AnyType {
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/ChangeType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-03-30
12 | */
13 | public enum ChangeType {
14 | /**
15 | * cluster event type
16 | */
17 | ADDED,
18 | /*
19 | * UPDATED event is discarded in order to prevent event merge.
20 | * This UPDATED event are split into two event, remove the old and add the new.
21 | */
22 | // @Deprecated UPDATED,
23 | /**
24 | * cluster event type
25 | */
26 | REMOVED;
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/ClusterEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | import javax.annotation.Nonnull;
10 |
11 | /**
12 | * @author dcy
13 | * Create Date: 2021-03-30
14 | */
15 | public class ClusterEntry {
16 | private String key;
17 | private ClusterValue value;
18 |
19 | public ClusterEntry(String key, ClusterValue value) {
20 | this.key = key;
21 | this.value = value;
22 | }
23 |
24 | @Nonnull
25 | public String getKey() {
26 | return key;
27 | }
28 |
29 | @Nonnull
30 | public ClusterValue getValue() {
31 | return value;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/ClusterTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-04-06
12 | */
13 | public class ClusterTime {
14 |
15 | String time;
16 |
17 | public ClusterTime() {
18 | }
19 |
20 | public ClusterTime(String time) {
21 | this.time = time;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/ClusterValueForRawWrite.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | import com.google.gson.JsonElement;
10 |
11 | /**
12 | * @author dcy
13 | * Create Date: 2021-03-17
14 | */
15 | public class ClusterValueForRawWrite extends ClusterValueForBaseWrite {
16 |
17 |
18 | public ClusterValueForRawWrite(JsonElement data, int apiVersion) {
19 | super(data, apiVersion);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/ClusterValueForWrite.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-03-17
12 | */
13 | public class ClusterValueForWrite extends ClusterValueForBaseWrite {
14 |
15 |
16 | public ClusterValueForWrite(T data, int apiVersion) {
17 | super(data, apiVersion);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/DbInstanceStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.values;
7 |
8 | /**
9 | * Created by szf on 2019/10/29.
10 | */
11 | public class DbInstanceStatus {
12 | private String name;
13 | private boolean disable;
14 | private boolean primary;
15 |
16 | public DbInstanceStatus(String name, boolean disable, boolean primary) {
17 | this.name = name;
18 | this.disable = disable;
19 | this.primary = primary;
20 | }
21 |
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | public boolean isDisable() {
27 | return disable;
28 | }
29 |
30 | public boolean isPrimary() {
31 | return primary;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/Empty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-04-02
12 | */
13 | public final class Empty {
14 |
15 | public Empty() {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/OriginChangeType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-03-30
12 | */
13 | public enum OriginChangeType {
14 | /**
15 | * cluster event type
16 | */
17 | ADDED,
18 | /**
19 | * cluster event type
20 | */
21 | UPDATE,
22 | /**
23 | * cluster event type
24 | */
25 | REMOVED;
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/values/SelfSerialize.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.cluster.values;
8 |
9 | import com.google.gson.JsonElement;
10 | import com.google.gson.JsonObject;
11 |
12 | /**
13 | * @author dcy
14 | * Create Date: 2021-04-02
15 | */
16 | public interface SelfSerialize {
17 | JsonObject serialize();
18 |
19 | T deserialize(JsonElement object);
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/comm/NotifyService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.comm;
7 |
8 | /**
9 | * @author liujun
10 | * @date 2015/2/4
11 | * @vsersion 0.0.1
12 | */
13 | public interface NotifyService {
14 |
15 | /**
16 | * notify interface
17 | *
18 | * @return true for success ,false for failed
19 | * @throws Exception
20 | */
21 | void notifyProcess() throws Exception;
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/console/ParseParamEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.console;
7 |
8 | /**
9 | * ParseParamEnum
10 | *
11 | *
12 | * author:liujun
13 | * Created:2016/9/18
14 | */
15 | public enum ParseParamEnum {
16 |
17 | /**
18 | * mapfile for rule
19 | */
20 | ZK_PATH_RULE_MAPFILE_NAME("mapFile"),
21 | ;
22 |
23 | private String key;
24 |
25 | ParseParamEnum(String key) {
26 | this.key = key;
27 | }
28 |
29 | public String getKey() {
30 | return key;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/entity/Named.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.entity;
7 |
8 | /**
9 | * presentation a object have a filed name.
10 | */
11 | public interface Named {
12 | /**
13 | * @return
14 | * @Created 2016/9/15
15 | */
16 | String getName();
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/entity/Propertied.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.entity;
7 |
8 | /**
9 | * Created by lion on 12/8/15.
10 | */
11 | public interface Propertied {
12 | void addProperty(Property property);
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | @XmlSchema(xmlns = @XmlNs(prefix = Versions.ROOT_PREFIX, namespaceURI = Versions.DOMAIN), elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
7 |
8 | package com.actiontech.dble.cluster.zkprocess.entity;
9 |
10 | import com.actiontech.dble.config.Versions;
11 |
12 | import javax.xml.bind.annotation.XmlNs;
13 | import javax.xml.bind.annotation.XmlSchema;
14 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/entity/sharding/schema/SingleTable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.entity.sharding.schema;
7 |
8 | import javax.xml.bind.annotation.XmlAccessType;
9 | import javax.xml.bind.annotation.XmlAccessorType;
10 | import javax.xml.bind.annotation.XmlRootElement;
11 | import javax.xml.bind.annotation.XmlType;
12 |
13 | @XmlAccessorType(XmlAccessType.FIELD)
14 | @XmlType(name = "singleTable")
15 | @XmlRootElement
16 | public class SingleTable extends Table {
17 | @Override
18 | public String toString() {
19 | return "singleTable [" + super.toString() + "]";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/entity/user/HybridTAUser.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.cluster.zkprocess.entity.user;
2 |
3 | import javax.xml.bind.annotation.*;
4 |
5 | @XmlAccessorType(XmlAccessType.FIELD)
6 | @XmlType(name = "hybridTAUser")
7 | @XmlRootElement
8 | public class HybridTAUser extends ShardingUser {
9 |
10 | @Override
11 | public String toString() {
12 | StringBuilder sb = new StringBuilder();
13 | sb.append("HybridTAUser{").append(super.toString());
14 | sb.append(", schemas=").append(schemas);
15 | sb.append(", tenant=").append(tenant);
16 | sb.append(", readOnly=").append(readOnly);
17 | sb.append(", blacklist=").append(blacklist);
18 |
19 | if (privileges != null) {
20 | sb.append(", privileges=").append(privileges);
21 | }
22 | sb.append('}');
23 | return sb.toString();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/entity/user/ManagerUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.entity.user;
7 |
8 | import javax.xml.bind.annotation.*;
9 |
10 | @XmlAccessorType(XmlAccessType.FIELD)
11 | @XmlType(name = "managerUser")
12 | @XmlRootElement
13 | public class ManagerUser extends User {
14 | @XmlAttribute
15 | protected Boolean readOnly;
16 |
17 |
18 | public Boolean getReadOnly() {
19 | return readOnly;
20 | }
21 |
22 | public void setReadOnly(Boolean readOnly) {
23 | this.readOnly = readOnly;
24 | }
25 |
26 | @Override
27 | public String toString() {
28 | String sb = "managerUser{" + super.toString() +
29 | ", readOnly=" + readOnly +
30 | '}';
31 | return sb;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/xmltozk/listen/DbXmlToZkLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.xmltozk.listen;
7 |
8 |
9 | import com.actiontech.dble.cluster.logic.ClusterLogic;
10 | import com.actiontech.dble.cluster.zkprocess.comm.NotifyService;
11 | import com.actiontech.dble.cluster.zkprocess.comm.ZookeeperProcessListen;
12 |
13 | public class DbXmlToZkLoader implements NotifyService {
14 |
15 | public DbXmlToZkLoader(ZookeeperProcessListen zookeeperListen) {
16 | zookeeperListen.addToInit(this);
17 | }
18 |
19 | @Override
20 | public void notifyProcess() throws Exception {
21 | ClusterLogic.forConfig().syncDbXmlToCluster();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/xmltozk/listen/SequenceToZkLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.xmltozk.listen;
7 |
8 | import com.actiontech.dble.cluster.logic.ClusterLogic;
9 | import com.actiontech.dble.cluster.zkprocess.comm.NotifyService;
10 | import com.actiontech.dble.cluster.zkprocess.comm.ZookeeperProcessListen;
11 |
12 | public class SequenceToZkLoader implements NotifyService {
13 | public SequenceToZkLoader(ZookeeperProcessListen zookeeperListen) {
14 | zookeeperListen.addToInit(this);
15 | }
16 |
17 | @Override
18 | public void notifyProcess() throws Exception {
19 | ClusterLogic.forConfig().syncSequencePropsToCluster();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/xmltozk/listen/ShardingXmlToZKLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.xmltozk.listen;
7 |
8 | import com.actiontech.dble.cluster.logic.ClusterLogic;
9 | import com.actiontech.dble.cluster.zkprocess.comm.NotifyService;
10 | import com.actiontech.dble.cluster.zkprocess.comm.ZookeeperProcessListen;
11 |
12 | public class ShardingXmlToZKLoader implements NotifyService {
13 | public ShardingXmlToZKLoader(ZookeeperProcessListen zookeeperListen) {
14 | zookeeperListen.addToInit(this);
15 | }
16 |
17 | @Override
18 | public void notifyProcess() throws Exception {
19 | ClusterLogic.forConfig().syncShardingXmlToCluster();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/cluster/zkprocess/xmltozk/listen/UserXmlToZkLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.cluster.zkprocess.xmltozk.listen;
7 |
8 |
9 | import com.actiontech.dble.cluster.logic.ClusterLogic;
10 | import com.actiontech.dble.cluster.zkprocess.comm.NotifyService;
11 | import com.actiontech.dble.cluster.zkprocess.comm.ZookeeperProcessListen;
12 |
13 | public class UserXmlToZkLoader implements NotifyService {
14 |
15 | public UserXmlToZkLoader(ZookeeperProcessListen zookeeperListen) {
16 | zookeeperListen.addToInit(this);
17 | }
18 |
19 | @Override
20 | public void notifyProcess() throws Exception {
21 | ClusterLogic.forConfig().syncUserXmlToCluster();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/ConfigFileName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | public final class ConfigFileName {
9 | private ConfigFileName() {
10 | }
11 |
12 | public static final String DB_XML = "db.xml";
13 | public static final String DB_XSD = "db.xsd";
14 | public static final String USER_XML = "user.xml";
15 | public static final String USER_XSD = "user.xsd";
16 | public static final String SHARDING_XML = "sharding.xml";
17 | public static final String SHARDING_XSD = "sharding.xsd";
18 | public static final String SEQUENCE_DB_FILE_NAME = "sequence_db_conf.properties";
19 | public static final String SEQUENCE_FILE_NAME = "sequence_conf.properties";
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/FlowControllerConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | public class FlowControllerConfig {
9 |
10 | private final boolean enableFlowControl;
11 | private final int highWaterLevel;
12 | private final int lowWaterLevel;
13 |
14 | public FlowControllerConfig(boolean enableFlowControl, int highWaterLevel, int lowWaterLevel) {
15 | this.enableFlowControl = enableFlowControl;
16 | this.highWaterLevel = highWaterLevel;
17 | this.lowWaterLevel = lowWaterLevel;
18 | }
19 |
20 | public boolean isEnableFlowControl() {
21 | return enableFlowControl;
22 | }
23 |
24 | public int getHighWaterLevel() {
25 | return highWaterLevel;
26 | }
27 |
28 | public int getLowWaterLevel() {
29 | return lowWaterLevel;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/ProblemReporter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | public interface ProblemReporter {
9 | void error(String problem);
10 |
11 | void warn(String problem);
12 |
13 | void notice(String problem);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/helper/TestTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config.helper;
7 |
8 | import com.actiontech.dble.backend.datasource.PhysicalDbInstance;
9 | import com.actiontech.dble.plan.common.ptr.BoolPtr;
10 |
11 | import java.io.IOException;
12 |
13 | public class TestTask extends Thread {
14 | private PhysicalDbInstance ds;
15 | private BoolPtr boolPtr;
16 |
17 | public TestTask(PhysicalDbInstance ds, BoolPtr boolPtr) {
18 | this.ds = ds;
19 | this.boolPtr = boolPtr;
20 | }
21 |
22 | @Override
23 | public void run() {
24 | try {
25 | boolean isConnected = ds.testConnection();
26 | boolPtr.set(isConnected);
27 | } catch (IOException e) {
28 | boolPtr.set(false);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/ParamInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config.model;
7 |
8 | public class ParamInfo {
9 | private final String name;
10 | private final String value;
11 | private final String comment;
12 |
13 | public ParamInfo(String name, String value, String comment) {
14 | this.name = name;
15 | this.value = value;
16 | this.comment = comment;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public String getValue() {
24 | return value;
25 | }
26 |
27 | public String getComment() {
28 | return comment;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/db/type/DataBaseType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config.model.db.type;
7 |
8 | public enum DataBaseType {
9 | MYSQL, CLICKHOUSE;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/rule/RuleAlgorithm.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.config.model.rule;
7 |
8 | import java.util.Map;
9 |
10 | /**
11 | * @author mycat
12 | */
13 | public interface RuleAlgorithm {
14 |
15 | void init();
16 |
17 | /**
18 | * return sharding nodes's index
19 | *
20 | * @return never null
21 | */
22 | Integer calculate(String columnValue);
23 |
24 | /**
25 | * return the index of node
26 | * return an empty array means router to all node
27 | * return null if no node matches
28 | * only support long and Date
29 | */
30 | Integer[] calculateRange(String beginValue, String endValue);
31 |
32 | Map getAllProperties();
33 |
34 | void selfCheck();
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/sharding/ApNodeConfig.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.config.model.sharding;
2 |
3 | public class ApNodeConfig extends ShardingNodeConfig {
4 |
5 | public ApNodeConfig(String name, String database, String dbGroupName) {
6 | super(name, database, dbGroupName);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/sharding/ShardingNodeConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 | package com.actiontech.dble.config.model.sharding;
6 |
7 | public class ShardingNodeConfig {
8 |
9 | private final String name;
10 | private final String database;
11 | private final String dbGroupName;
12 |
13 | public ShardingNodeConfig(String name, String database, String dbGroupName) {
14 | super();
15 | this.name = name;
16 | this.database = database;
17 | this.dbGroupName = dbGroupName;
18 | }
19 |
20 | public String getName() {
21 | return name;
22 | }
23 |
24 | public String getDatabase() {
25 | return database;
26 | }
27 |
28 | public String getDbGroupName() {
29 | return dbGroupName;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/sharding/table/ShardingTableFakeConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config.model.sharding.table;
7 |
8 | import com.actiontech.dble.meta.table.MetaHelper;
9 | import com.actiontech.dble.route.function.AbstractPartitionAlgorithm;
10 |
11 | import java.util.List;
12 |
13 | public class ShardingTableFakeConfig extends ShardingTableConfig {
14 |
15 | public ShardingTableFakeConfig(String name, int maxLimit, List shardingNodes, AbstractPartitionAlgorithm function, String createSql) {
16 | super(name, maxLimit, shardingNodes, null, function,
17 | MetaHelper.electionShardingColumn(createSql).toUpperCase(), false, false);
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/sharding/table/SingleTableConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config.model.sharding.table;
7 |
8 | import java.util.List;
9 |
10 | public final class SingleTableConfig extends BaseTableConfig {
11 |
12 | public SingleTableConfig(String name, int maxLimit, List shardingNodes, boolean specifyCharset) {
13 | super(name, maxLimit, shardingNodes, specifyCharset);
14 | }
15 |
16 | @Override
17 | public BaseTableConfig lowerCaseCopy(BaseTableConfig parent) {
18 | SingleTableConfig config = new SingleTableConfig(this.name.toLowerCase(), this.maxLimit, this.shardingNodes, this.specifyCharset);
19 | config.setId(getId());
20 | return config;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/user/HybridTAUserConfig.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.config.model.user;
2 |
3 | import com.alibaba.druid.wall.WallProvider;
4 |
5 | import java.util.Set;
6 |
7 | public class HybridTAUserConfig extends ShardingUserConfig {
8 |
9 | public HybridTAUserConfig(UserConfig user, String tenant, WallProvider blacklist, boolean readOnly, Set schemas, UserPrivilegesConfig privilegesConfig) {
10 | super(user, tenant, blacklist, readOnly, schemas, privilegesConfig);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/model/user/SingleDbGroupUserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config.model.user;
7 |
8 | import com.alibaba.druid.wall.WallProvider;
9 |
10 | public class SingleDbGroupUserConfig extends ServerUserConfig {
11 | protected final String dbGroup;
12 |
13 | SingleDbGroupUserConfig(UserConfig user, String tenant, WallProvider blacklist, String dbGroup) {
14 | super(user, tenant, blacklist);
15 | this.dbGroup = dbGroup;
16 | }
17 |
18 | public String getDbGroup() {
19 | return dbGroup;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/config/util/ConfigException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.config.util;
7 |
8 | /**
9 | * @author mycat
10 | */
11 | public class ConfigException extends RuntimeException {
12 | private static final long serialVersionUID = -180146385688342818L;
13 |
14 | public ConfigException() {
15 | super();
16 | }
17 |
18 | public ConfigException(String message, Throwable cause) {
19 | super(message, cause);
20 | }
21 |
22 | public ConfigException(String message) {
23 | super(message);
24 | }
25 |
26 | public ConfigException(Throwable cause) {
27 | super(cause);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/log/general/LogEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.log.general;
7 |
8 | public class LogEntry {
9 |
10 | protected long time;
11 |
12 | public long getTime() {
13 | return time;
14 | }
15 |
16 | public void setTime(long time) {
17 | this.time = time;
18 | }
19 |
20 | public LogEntry() {
21 | this.time = System.currentTimeMillis();
22 | }
23 |
24 | public String toLog() {
25 | return "";
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/meta/ReloadException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.meta;
7 |
8 | import com.actiontech.dble.config.ErrorCode;
9 |
10 | public final class ReloadException extends RuntimeException {
11 |
12 | private final int errorCode;
13 |
14 | public ReloadException() {
15 | super();
16 | errorCode = ErrorCode.ER_YES;
17 | }
18 |
19 | public ReloadException(int errorCode, String message) {
20 | super(message);
21 | this.errorCode = errorCode;
22 | }
23 |
24 |
25 | public int getErrorCode() {
26 | return errorCode;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/ClosableConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net;
7 |
8 | import com.actiontech.dble.net.mysql.CharsetNames;
9 |
10 | public interface ClosableConnection {
11 | CharsetNames getCharset();
12 |
13 | /**
14 | * close connection
15 | */
16 | void close(String reason);
17 |
18 | boolean isClosed();
19 |
20 | long getStartupTime();
21 |
22 | String getHost();
23 |
24 | int getPort();
25 |
26 | int getLocalPort();
27 |
28 | long getNetInBytes();
29 |
30 | long getNetOutBytes();
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/ConnectionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net;
7 |
8 | public class ConnectionException extends RuntimeException {
9 | /**
10 | *
11 | */
12 | private static final long serialVersionUID = 1L;
13 | private final int code;
14 | private final String msg;
15 |
16 | public ConnectionException(int code, String msg) {
17 | super(msg);
18 | this.code = code;
19 | this.msg = msg;
20 | }
21 |
22 | @Override
23 | public String toString() {
24 | return "ConnectionException [code=" + code + ", msg=" + msg + "]";
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/NIOConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net;
7 |
8 | import java.io.IOException;
9 | import java.nio.ByteBuffer;
10 |
11 | /**
12 | * @author mycat
13 | */
14 | public interface NIOConnection extends ClosableConnection {
15 |
16 | /**
17 | * connected
18 | */
19 | void register() throws IOException;
20 |
21 | /**
22 | * execute
23 | */
24 | void handle(byte[] data);
25 |
26 | /**
27 | * writeDirectly from buffer
28 | */
29 | void write(ByteBuffer buffer);
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/NIOHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net;
7 |
8 | /**
9 | * @author mycat
10 | */
11 | public interface NIOHandler {
12 |
13 | void handle(byte[] data);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/SocketAcceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net;
7 |
8 | public interface SocketAcceptor {
9 |
10 | void start();
11 |
12 | String getName();
13 |
14 | int getPort();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/SocketConnector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net;
7 |
8 | public interface SocketConnector {
9 |
10 | void start();
11 |
12 | void postConnect(com.actiontech.dble.net.connection.AbstractConnection c);
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/WriteOutTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net;
7 |
8 | import java.nio.ByteBuffer;
9 |
10 | /**
11 | * Created by szf on 2020/7/7.
12 | */
13 | public class WriteOutTask {
14 |
15 | private final ByteBuffer buffer;
16 | private final boolean closeFlag;
17 |
18 | public WriteOutTask(ByteBuffer buffer, boolean closeFlag) {
19 | this.buffer = buffer;
20 | this.closeFlag = closeFlag;
21 | }
22 |
23 | public ByteBuffer getBuffer() {
24 | return buffer;
25 | }
26 |
27 | public boolean closeFlag() {
28 | return closeFlag;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/connection/Connection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.connection;
7 |
8 |
9 | import javax.annotation.Nonnull;
10 |
11 | /**
12 | * Created by szf on 2020/6/15.
13 | */
14 | public interface Connection {
15 |
16 |
17 | void closeGracefully(@Nonnull String reason);
18 |
19 | void closeImmediately(String reason);
20 |
21 | /**
22 | * Connection forced to close function
23 | * would be called by IO error .....
24 | * the service would get the error message and resoponse to it
25 | *
26 | * @param reason
27 | */
28 | void close(String reason);
29 |
30 |
31 | /**
32 | * businessReasonClose the connection
33 | * service not response to the event because the service should already know about the event
34 | */
35 | void businessClose(String reason);
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/executor/BackendRunnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.executor;
7 |
8 |
9 | /**
10 | * Created by szf on 2020/6/18.
11 | */
12 | public interface BackendRunnable extends Runnable {
13 | ThreadContextView getThreadContext();
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/executor/FrontendRunnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.executor;
7 |
8 |
9 | /**
10 | * Created by szf on 2020/6/18.
11 | */
12 | public interface FrontendRunnable extends Runnable {
13 | ThreadContextView getThreadContext();
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/executor/ThreadContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.executor;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-08-25
12 | */
13 | public class ThreadContext implements ThreadContextView {
14 | private volatile boolean doingTask = false;
15 |
16 |
17 | @Override
18 | public boolean isDoingTask() {
19 | return doingTask;
20 | }
21 |
22 | public void setDoingTask(boolean doingTaskTmp) {
23 | doingTask = doingTaskTmp;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/executor/ThreadContextView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.executor;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-08-25
12 | */
13 | public interface ThreadContextView {
14 |
15 |
16 | boolean isDoingTask();
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/factory/TrustAllManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.factory;
7 |
8 | import javax.net.ssl.X509TrustManager;
9 | import java.security.cert.X509Certificate;
10 |
11 | public class TrustAllManager implements X509TrustManager {
12 | private X509Certificate[] issuers;
13 |
14 | public TrustAllManager() {
15 | this.issuers = new X509Certificate[0];
16 | }
17 |
18 | public X509Certificate[] getAcceptedIssuers() {
19 | return issuers;
20 | }
21 |
22 | public void checkClientTrusted(X509Certificate[] chain, String authType) {
23 | }
24 |
25 | public void checkServerTrusted(X509Certificate[] chain, String authType) {
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/handler/BackEndCleaner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.handler;
7 |
8 | /**
9 | * Created by szf on 2018/11/6.
10 | */
11 | public interface BackEndCleaner {
12 |
13 | void signal();
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/handler/FrontendPrepareHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net.handler;
7 |
8 | /**
9 | * FrontendPrepareHandler
10 | *
11 | * @author mycat, CrazyPig
12 | */
13 | public interface FrontendPrepareHandler {
14 |
15 | void prepare(String sql);
16 |
17 | void sendLongData(byte[] data);
18 |
19 | void reset(byte[] data);
20 |
21 | void execute(byte[] data);
22 |
23 | void close(byte[] data);
24 |
25 | void clear();
26 |
27 | void fetch(byte[] data);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/handler/FrontendQueryHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net.handler;
7 |
8 | /**
9 | * FrontendQueryHandler
10 | *
11 | * @author mycat
12 | */
13 | public interface FrontendQueryHandler {
14 |
15 | void query(String sql);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/handler/LoadDataInfileHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net.handler;
7 |
8 | /**
9 | * load data infile
10 | *
11 | * @author magicdoom
12 | */
13 | public interface LoadDataInfileHandler {
14 |
15 | void start(String sql);
16 |
17 | void handle(byte[] data);
18 |
19 | void end(byte packetId);
20 |
21 | void clear();
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/mysql/CursorTypeFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.mysql;
7 |
8 | public final class CursorTypeFlags {
9 | private CursorTypeFlags() {
10 | }
11 |
12 |
13 | public static final int CURSOR_TYPE_NO_CURSOR = 0;
14 | public static final int CURSOR_TYPE_READ_ONLY = 1;
15 | public static final int CURSOR_TYPE_FOR_UPDATE = 2;
16 | public static final int CURSOR_TYPE_SCROLLABLE = 4;
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/mysql/EOFRowPacket.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.mysql;
7 |
8 | import com.actiontech.dble.net.service.AbstractService;
9 | import com.actiontech.dble.net.service.ResultFlag;
10 |
11 | import java.nio.ByteBuffer;
12 |
13 | /**
14 | * Created by szf on 2020/7/8.
15 | */
16 | public class EOFRowPacket extends EOFPacket {
17 |
18 |
19 | public void write(ByteBuffer buffer, AbstractService service) {
20 | service.writeWithBuffer(this, buffer);
21 | }
22 |
23 | @Override
24 | public boolean isEndOfQuery() {
25 | return true;
26 | }
27 |
28 | @Override
29 | public ResultFlag getResultFlag() {
30 | return ResultFlag.EOF_ROW;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/mysql/PingPacket.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net.mysql;
7 |
8 | import com.actiontech.dble.net.service.AbstractService;
9 |
10 | /**
11 | * @author mycat
12 | */
13 | public class PingPacket extends MySQLPacket {
14 | public static final byte[] PING = new byte[]{1, 0, 0, 0, 14};
15 |
16 |
17 | @Override
18 | public int calcPacketSize() {
19 | return 1;
20 | }
21 |
22 | @Override
23 | protected String getPacketInfo() {
24 | return "MySQL Ping Packet";
25 | }
26 |
27 |
28 | public static void response(AbstractService service) {
29 | service.write(OkPacket.getDefault());
30 | }
31 |
32 | @Override
33 | public boolean isEndOfQuery() {
34 | return true;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/mysql/QuitPacket.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.net.mysql;
7 |
8 | /**
9 | * @author mycat
10 | */
11 | public class QuitPacket extends MySQLPacket {
12 | public static final byte[] QUIT = new byte[]{1, 0, 0, 0, 1};
13 |
14 |
15 | @Override
16 | public int calcPacketSize() {
17 | return 1;
18 | }
19 |
20 | @Override
21 | protected String getPacketInfo() {
22 | return "MySQL Quit Packet";
23 | }
24 |
25 | @Override
26 | public boolean isEndOfQuery() {
27 | return true;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/mysql/ResetConnectionPacket.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.mysql;
7 |
8 | public class ResetConnectionPacket extends MySQLPacket {
9 | public static final byte[] RESET = new byte[]{1, 0, 0, 0, 31};
10 |
11 |
12 | @Override
13 | public int calcPacketSize() {
14 | return 1;
15 | }
16 |
17 | @Override
18 | protected String getPacketInfo() {
19 | return "MySQL Reset Connection Packet";
20 | }
21 |
22 | @Override
23 | public boolean isEndOfQuery() {
24 | return true;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/response/CustomDataResponseHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2021 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.response;
8 |
9 | import com.actiontech.dble.services.mysqlsharding.MySQLResponseService;
10 |
11 | /**
12 | * use it when need override data func
13 | *
14 | * @author dcy
15 | * Create Date: 2022-08-18
16 | */
17 | public abstract class CustomDataResponseHandler extends DefaultResponseHandler {
18 | public CustomDataResponseHandler(MySQLResponseService service) {
19 | super(service);
20 | }
21 |
22 |
23 | @Override
24 | protected void beforeError() {
25 | //doesn't setRowDataFlowing. just do nothing.
26 | }
27 |
28 |
29 | @Override
30 | public abstract void data(byte[] data);
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/response/ProtocolResponseHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.response;
7 |
8 | public interface ProtocolResponseHandler {
9 |
10 | int INITIAL = -1;
11 |
12 | int FIELD = 1;
13 | int ROW = 2;
14 |
15 | int PREPARED_PARAM = 3;
16 | int PREPARED_FIELD = 4;
17 |
18 | void ok(byte[] data);
19 |
20 | void error(byte[] data);
21 |
22 | void eof(byte[] data);
23 |
24 | void data(byte[] data);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/AuthService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.service;
7 |
8 | import java.io.IOException;
9 |
10 | public interface AuthService {
11 |
12 | void register() throws IOException;
13 |
14 | default void onConnectFailed(Throwable e) {
15 | }
16 |
17 |
18 | boolean haveNotReceivedMessage();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/CloseType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.service;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-08-03
12 | */
13 | public enum CloseType {
14 | READ,
15 | WRITE;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/DelayedServiceTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.service;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-08-27
12 | */
13 | public class DelayedServiceTask extends InnerServiceTask {
14 | private ServiceTask originTask;
15 |
16 | @Override
17 | public ServiceTaskType getType() {
18 | return ServiceTaskType.DELAYED;
19 | }
20 |
21 | public DelayedServiceTask(ServiceTask task) {
22 | super(task.getService());
23 | this.originTask = task;
24 | this.setTaskId(originTask.getTaskId());
25 | }
26 |
27 |
28 | public ServiceTask getOriginTask() {
29 | return originTask;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/InnerServiceTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.service;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-05-11
12 | */
13 | public abstract class InnerServiceTask extends ServiceTask {
14 | public InnerServiceTask(Service service) {
15 | super(service);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/NotificationServiceTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.service;
8 |
9 | import javax.annotation.Nonnull;
10 |
11 | /**
12 | * @author dcy
13 | * Create Date: 2021-04-16
14 | */
15 | public class NotificationServiceTask extends InnerServiceTask {
16 | public NotificationServiceTask(Service service) {
17 | super(service);
18 | }
19 |
20 | @Nonnull
21 | @Override
22 | public ServiceTaskType getType() {
23 | return ServiceTaskType.NOTIFICATION;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/ResultFlag.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.service;
7 |
8 | /**
9 | * response to the results of front connection
10 | */
11 | public enum ResultFlag {
12 | OK,
13 | EOF_ROW,
14 | ERROR,
15 | OTHER // Default
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/SSLProtoServerTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.service;
7 |
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import javax.annotation.Nonnull;
11 |
12 | public class SSLProtoServerTask extends ServiceTask {
13 |
14 | @Nonnull
15 | private final byte[] orgData;
16 |
17 | public SSLProtoServerTask(@Nonnull byte[] orgData, Service service) {
18 | super(service);
19 | this.orgData = orgData;
20 | }
21 |
22 | @NotNull
23 | @Override
24 | public ServiceTaskType getType() {
25 | return ServiceTaskType.SSL;
26 | }
27 |
28 | @Nonnull
29 | public byte[] getOrgData() {
30 | return orgData;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/Service.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.net.service;
7 |
8 | import com.actiontech.dble.net.executor.ThreadContext;
9 |
10 | /**
11 | * Created by szf on 2020/6/15.
12 | */
13 | public interface Service {
14 |
15 | void handle(ServiceTask task);
16 |
17 | void execute(ServiceTask task, ThreadContext threadContext);
18 |
19 | void cleanup();
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/ServiceTaskType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.service;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-04-16
12 | */
13 | public enum ServiceTaskType {
14 | NORMAL,
15 | NOTIFICATION,
16 | CLOSE,
17 | DELAYED,
18 | SSL;
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/net/service/WriteFlag.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.net.service;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-05-19
12 | */
13 | public enum WriteFlag {
14 | END_OF_QUERY,
15 | END_OF_SESSION,
16 | PARK_OF_MULTI_QUERY,
17 |
18 | //useless
19 | FLUSH;
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/CastTarget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common;
7 |
8 | public enum CastTarget {
9 | ITEM_CAST_BINARY,
10 | ITEM_CAST_CHAR,
11 | ITEM_CAST_DATE,
12 | ITEM_CAST_DATETIME,
13 | ITEM_CAST_DECIMAL,
14 | //JSON
15 | ITEM_CAST_NCHAR,
16 | ITEM_CAST_SIGNED_INT,
17 | ITEM_CAST_TIME,
18 | ITEM_CAST_UNSIGNED_INT
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/CastType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | /**
7 | *
8 | */
9 | package com.actiontech.dble.plan.common;
10 |
11 | public class CastType {
12 | private CastTarget target;
13 | private int length = -1;
14 | private int dec = -1;
15 |
16 |
17 | public CastTarget getTarget() {
18 | return target;
19 | }
20 |
21 | public void setTarget(CastTarget target) {
22 | this.target = target;
23 | }
24 |
25 | public int getLength() {
26 | return length;
27 | }
28 |
29 | public void setLength(int length) {
30 | this.length = length;
31 | }
32 |
33 | public int getDec() {
34 | return dec;
35 | }
36 |
37 | public void setDec(int dec) {
38 | this.dec = dec;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/context/ReferContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.context;
7 |
8 | import com.actiontech.dble.plan.node.PlanNode;
9 |
10 | public class ReferContext {
11 |
12 | private PlanNode planNode;
13 | private boolean isPushDownNode;
14 |
15 | public ReferContext() {
16 | this.planNode = null;
17 | this.isPushDownNode = false;
18 | }
19 |
20 | public PlanNode getPlanNode() {
21 | return planNode;
22 | }
23 |
24 | public void setPlanNode(PlanNode planNode) {
25 | this.planNode = planNode;
26 | }
27 |
28 | public boolean isPushDownNode() {
29 | return isPushDownNode;
30 | }
31 |
32 | public void setPushDownNode(boolean pushDownNode) {
33 | this.isPushDownNode = pushDownNode;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/exception/TempTableException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.exception;
7 |
8 | public class TempTableException extends RuntimeException {
9 |
10 | private static final long serialVersionUID = 2869994979718401423L;
11 |
12 | public TempTableException(String message, Throwable cause) {
13 | super(message, cause);
14 | }
15 |
16 | public TempTableException(String message) {
17 | super(message);
18 | }
19 |
20 | public TempTableException(Throwable cause) {
21 | super(cause);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/external/ResultStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.external;
7 |
8 | import com.actiontech.dble.net.mysql.RowDataPacket;
9 |
10 | public interface ResultStore {
11 | /* add a new row */
12 | void add(RowDataPacket row);
13 |
14 | /* all rows added */
15 | void done();
16 |
17 | /* visit all rows in the store */
18 | RowDataPacket next();
19 |
20 | int getRowCount();
21 |
22 | /* close result */
23 | void close();
24 |
25 | /* clear data */
26 | void clear();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/num/FieldDecimal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.num;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | /**
11 | * decimal(%d,%d) |unsigned |zerofilled
12 | *
13 | * @author ActionTech
14 | */
15 | public class FieldDecimal extends FieldReal {
16 |
17 | public FieldDecimal(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
18 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
19 | }
20 |
21 | @Override
22 | public FieldTypes fieldType() {
23 | return FieldTypes.MYSQL_TYPE_DECIMAL;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/num/FieldDouble.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.num;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | /**
11 | * bigint(%d) |unsigned |zerofilled
12 | *
13 | * @author ActionTech
14 | */
15 | public class FieldDouble extends FieldReal {
16 |
17 | public FieldDouble(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
18 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
19 | }
20 |
21 | @Override
22 | public FieldTypes fieldType() {
23 | return FieldTypes.MYSQL_TYPE_DOUBLE;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/num/FieldFloat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.num;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | /**
11 | * bigint(%d) |unsigned |zerofilled
12 | *
13 | * @author ActionTech
14 | */
15 | public class FieldFloat extends FieldReal {
16 |
17 | public FieldFloat(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
18 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
19 | }
20 |
21 | @Override
22 | public FieldTypes fieldType() {
23 | return FieldTypes.MYSQL_TYPE_FLOAT;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldBlob.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | /**
11 | * blob,enum is not support calc now
12 | *
13 | * @author ActionTech
14 | */
15 | public class FieldBlob extends FieldLongstr {
16 |
17 | public FieldBlob(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
18 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
19 | }
20 |
21 | @Override
22 | public FieldTypes fieldType() {
23 | return FieldTypes.MYSQL_TYPE_BLOB;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | public class FieldEnum extends FieldStr {
11 |
12 | public FieldEnum(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
13 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
14 | }
15 |
16 | @Override
17 | public FieldTypes fieldType() {
18 | return FieldTypes.MYSQL_TYPE_STRING;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldJson.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | public class FieldJson extends FieldLongstr {
11 |
12 | public FieldJson(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
13 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
14 | }
15 |
16 | @Override
17 | public FieldTypes fieldType() {
18 | return FieldTypes.MYSQL_TYPE_JSON;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldLongstr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | /**
9 | * base class for Field_string, Field_varstring and Field_blob
10 | *
11 | * @author ActionTech
12 | */
13 | public abstract class FieldLongstr extends FieldStr {
14 |
15 | public FieldLongstr(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
16 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | public class FieldSet extends FieldEnum {
11 |
12 | public FieldSet(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
13 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
14 | }
15 |
16 | @Override
17 | public FieldTypes fieldType() {
18 | return FieldTypes.MYSQL_TYPE_SET;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldString.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | /**
11 | * char\binary
12 | *
13 | * @author ActionTech
14 | */
15 | public class FieldString extends FieldLongstr {
16 | public FieldString(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
17 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
18 | }
19 |
20 | @Override
21 | public FieldTypes fieldType() {
22 | return FieldTypes.MYSQL_TYPE_STRING;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldVarchar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | public class FieldVarchar extends FieldString {
11 | public FieldVarchar(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
12 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
13 | }
14 |
15 | @Override
16 | public FieldTypes fieldType() {
17 | return FieldTypes.MYSQL_TYPE_VARCHAR;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/string/FieldVarstring.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.string;
7 |
8 | import com.actiontech.dble.plan.common.item.FieldTypes;
9 |
10 | public class FieldVarstring extends FieldString {
11 | public FieldVarstring(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
12 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
13 | }
14 |
15 | @Override
16 | public FieldTypes fieldType() {
17 | return FieldTypes.MYSQL_TYPE_VAR_STRING;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/temporal/FieldTemporalWithDateAndTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.temporal;
7 |
8 | public abstract class FieldTemporalWithDateAndTime extends FieldTemporaWithDate {
9 |
10 | public FieldTemporalWithDateAndTime(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength,
11 | int decimals, long flags) {
12 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/field/temporal/FieldYear.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.field.temporal;
7 |
8 | import com.actiontech.dble.plan.common.field.num.FieldTiny;
9 | import com.actiontech.dble.plan.common.item.FieldTypes;
10 |
11 | /**
12 | * @author ActionTech
13 | */
14 | public class FieldYear extends FieldTiny {
15 |
16 | public FieldYear(String name, String dbName, String table, String orgTable, int charsetIndex, int fieldLength, int decimals, long flags) {
17 | super(name, dbName, table, orgTable, charsetIndex, fieldLength, decimals, flags);
18 | }
19 |
20 | @Override
21 | public FieldTypes fieldType() {
22 | return FieldTypes.MYSQL_TYPE_YEAR;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/ItemResultField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item;
7 |
8 | public abstract class ItemResultField extends Item {
9 |
10 | protected ItemResultField() {
11 | this.withUnValAble = true;
12 | }
13 |
14 |
15 | public void cleanup() {
16 |
17 | }
18 |
19 | public abstract void fixLengthAndDec();
20 |
21 | public abstract String funcName();
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/ItemFuncKeyWord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function;
7 |
8 | public final class ItemFuncKeyWord {
9 | private ItemFuncKeyWord() {
10 | }
11 |
12 | public static final String USING = "USING";
13 | public static final String ORDER_BY = "ORDER BY";
14 | public static final String SEPARATOR = "SEPARATOR";
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/mathsfunc/ItemFuncRound.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.mathsfunc;
7 |
8 | import com.actiontech.dble.plan.common.item.Item;
9 | import com.actiontech.dble.plan.common.item.ItemInt;
10 | import com.actiontech.dble.plan.common.item.function.ItemFunc;
11 |
12 | import java.util.List;
13 |
14 |
15 | public class ItemFuncRound extends ItemFuncRoundOrTruncate {
16 |
17 | public ItemFuncRound(List- args, int charsetIndex) {
18 | super(args, false, charsetIndex);
19 | }
20 |
21 | @Override
22 | public ItemFunc nativeConstruct(List
- realArgs) {
23 | if (realArgs != null && realArgs.size() == 1) {
24 | realArgs.add(new ItemInt(0));
25 | }
26 | return new ItemFuncRound(realArgs, charsetIndex);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/mathsfunc/ItemFuncTruncate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.mathsfunc;
7 |
8 | import com.actiontech.dble.plan.common.item.Item;
9 | import com.actiontech.dble.plan.common.item.function.ItemFunc;
10 |
11 | import java.util.List;
12 |
13 | public class ItemFuncTruncate extends ItemFuncRoundOrTruncate {
14 |
15 | public ItemFuncTruncate(List
- args, int charsetIndex) {
16 | super(args, true, charsetIndex);
17 | }
18 |
19 | @Override
20 | public ItemFunc nativeConstruct(List
- realArgs) {
21 | return new ItemFuncTruncate(realArgs, charsetIndex);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/operator/cmpfunc/util/GetTimeValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.operator.cmpfunc.util;
7 |
8 | import com.actiontech.dble.plan.common.item.Item;
9 | import com.actiontech.dble.plan.common.ptr.BoolPtr;
10 |
11 | public class GetTimeValue implements GetValueFunc {
12 |
13 | @Override
14 | public long get(Item item, Item warn, BoolPtr isNull) {
15 | long value = item.valTimeTemporal();
16 | isNull.set(item.isNullValue());
17 | return value;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/operator/cmpfunc/util/GetValueFunc.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.operator.cmpfunc.util;
7 |
8 | import com.actiontech.dble.plan.common.item.Item;
9 | import com.actiontech.dble.plan.common.ptr.BoolPtr;
10 |
11 | public interface GetValueFunc {
12 | long get(Item arg, Item warnitem, BoolPtr isNull);
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/primary/ItemDecFunc.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.primary;
7 |
8 | import com.actiontech.dble.plan.common.item.Item;
9 |
10 | import java.util.List;
11 |
12 |
13 | public abstract class ItemDecFunc extends ItemRealFunc {
14 |
15 | public ItemDecFunc(List
- args, int charsetIndex) {
16 | super(args, charsetIndex);
17 | }
18 |
19 | @Override
20 | public void fixLengthAndDec() {
21 | decimals = NOT_FIXED_DEC;
22 | maxLength = floatLength(decimals);
23 | maybeNull = true;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/primary/ItemFuncAdditiveOp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.primary;
7 |
8 | import com.actiontech.dble.plan.common.item.Item;
9 |
10 | public abstract class ItemFuncAdditiveOp extends ItemNumOp {
11 |
12 | public ItemFuncAdditiveOp(Item a, Item b, int charsetIndex) {
13 | super(a, b, charsetIndex);
14 | }
15 |
16 | @Override
17 | public void resultPrecision() {
18 | decimals = Math.max(args.get(0).getDecimals(), args.get(1).getDecimals());
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/primary/ItemFuncBit.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.primary;
7 |
8 | import com.actiontech.dble.plan.common.item.Item;
9 |
10 | public abstract class ItemFuncBit extends ItemIntFunc {
11 |
12 | public ItemFuncBit(Item a, int charsetIndex) {
13 | super(a, charsetIndex);
14 | }
15 |
16 | public ItemFuncBit(Item a, Item b, int charsetIndex) {
17 | super(a, b, charsetIndex);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/strfunc/ItemFuncInstr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | /**
7 | *
8 | */
9 | package com.actiontech.dble.plan.common.item.function.strfunc;
10 |
11 | import com.actiontech.dble.plan.common.item.Item;
12 | import com.actiontech.dble.plan.common.item.function.ItemFunc;
13 |
14 | import java.util.List;
15 |
16 | public class ItemFuncInstr extends ItemFuncLocate {
17 |
18 | /**
19 | * @param args
20 | */
21 | public ItemFuncInstr(List
- args, int charsetIndex) {
22 | super(args, charsetIndex);
23 | }
24 |
25 | @Override
26 | public final String funcName() {
27 | return "instr";
28 | }
29 |
30 | @Override
31 | public ItemFunc nativeConstruct(List
- realArgs) {
32 | return new ItemFuncInstr(realArgs, charsetIndex);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/function/strfunc/ItemFuncUuid.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.function.strfunc;
7 |
8 |
9 | import java.util.UUID;
10 |
11 | public class ItemFuncUuid extends ItemStrFunc {
12 |
13 | public ItemFuncUuid(int charsetIndex) {
14 | super(charsetIndex);
15 | }
16 |
17 | @Override
18 | public String funcName() {
19 | return "uuid";
20 | }
21 |
22 | @Override
23 | public String valStr() {
24 | return UUID.randomUUID().toString();
25 | }
26 |
27 | @Override
28 | public void fixLengthAndDec() {
29 | fixCharLength(36);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/item/num/ItemNum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.item.num;
7 |
8 | import com.actiontech.dble.plan.common.item.ItemBasicConstant;
9 |
10 | public abstract class ItemNum extends ItemBasicConstant {
11 |
12 | public ItemNum() {
13 | // my_charset_numeric
14 | charsetIndex = 8;
15 | }
16 |
17 | public abstract ItemNum neg();
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/locale/MyLocaleErrMsgs.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.locale;
7 |
8 | public class MyLocaleErrMsgs {
9 |
10 | private String language;
11 | private String errMsgs;
12 |
13 | public MyLocaleErrMsgs(String language, String errMsgs) {
14 | this.language = language;
15 | this.errMsgs = errMsgs;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/BoolPtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | public class BoolPtr {
9 | private volatile boolean b;
10 |
11 | public BoolPtr(boolean b) {
12 | this.b = b;
13 | }
14 |
15 | public boolean get() {
16 | return b;
17 | }
18 |
19 | public void set(boolean bool) {
20 | this.b = bool;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/BytePtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | public class BytePtr {
9 | private byte l;
10 |
11 | public BytePtr(byte l) {
12 | this.l = l;
13 | }
14 |
15 | public byte get() {
16 | return l;
17 | }
18 |
19 | public void set(byte v) {
20 | this.l = v;
21 | }
22 |
23 | public long decre() {
24 | return l--;
25 | }
26 |
27 | public long incre() {
28 | return l++;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/DecimalPtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | import java.math.BigDecimal;
9 |
10 | public class DecimalPtr {
11 | private BigDecimal bd;
12 |
13 | public DecimalPtr(BigDecimal bd) {
14 | this.bd = bd;
15 | }
16 |
17 | public BigDecimal get() {
18 | return bd;
19 | }
20 |
21 | public void set(BigDecimal bigDecimal) {
22 | this.bd = bigDecimal;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/DoublePtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | public class DoublePtr {
9 | private double db;
10 |
11 | public DoublePtr(double db) {
12 | this.db = db;
13 | }
14 |
15 | public double get() {
16 | return db;
17 | }
18 |
19 | public void set(double v) {
20 | this.db = v;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/GenericPtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | public class GenericPtr {
9 | private T value;
10 |
11 | public GenericPtr(T initValue) {
12 | this.value = initValue;
13 | }
14 |
15 | public T get() {
16 | return value;
17 | }
18 |
19 | public void set(T t) {
20 | this.value = t;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/ItemResultPtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | import com.actiontech.dble.plan.common.item.Item.ItemResult;
9 |
10 | public class ItemResultPtr {
11 | private ItemResult itemResult;
12 |
13 | public ItemResultPtr(ItemResult itemResult) {
14 | this.itemResult = itemResult;
15 | }
16 |
17 | public ItemResult get() {
18 | return itemResult;
19 | }
20 |
21 | public void set(ItemResult result) {
22 | this.itemResult = result;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/LongPtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | public class LongPtr {
9 | private long l;
10 |
11 | public LongPtr(long l) {
12 | this.l = l;
13 | }
14 |
15 | public long get() {
16 | return l;
17 | }
18 |
19 | public void set(long v) {
20 | this.l = v;
21 | }
22 |
23 | public long decre() {
24 | return l--;
25 | }
26 |
27 | public long incre() {
28 | return l++;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/ptr/StringPtr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.ptr;
7 |
8 | public class StringPtr {
9 | private String s;
10 |
11 | public StringPtr(String s) {
12 | this.s = s;
13 | }
14 |
15 | public String get() {
16 | return s;
17 | }
18 |
19 | public void set(String str) {
20 | this.s = str;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/time/DateTimeFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.time;
7 |
8 | public class DateTimeFormat {
9 | //public char time_separator; /* Separator between hour and minute */
10 | //public int flag; /* For future */
11 | private String format;
12 |
13 | public DateTimeFormat() {
14 |
15 | }
16 |
17 | //public DateTimeFormat(char time_separator, int flag, String format) {
18 | // this.time_separator = time_separator;
19 | // this.flag = flag;
20 | // this.format = format;
21 | //}
22 | public DateTimeFormat(String format) {
23 | this.format = format;
24 | }
25 |
26 | public String getFormat() {
27 | return format;
28 | }
29 |
30 | public void setFormat(String format) {
31 | this.format = format;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/time/DateTimeUnit.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.time;
7 |
8 | public enum DateTimeUnit {
9 | MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, SECOND_MICROSECOND, MINUTE_MICROSECOND, MINUTE_SECOND, HOUR_MICROSECOND, HOUR_SECOND, HOUR_MINUTE, DAY_MICROSECOND, DAY_SECOND, DAY_MINUTE, DAY_HOUR, YEAR_MONTH,
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/time/LLDivT.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | /**
7 | *
8 | */
9 | package com.actiontech.dble.plan.common.time;
10 |
11 | public class LLDivT {
12 | private long quot;
13 | private long rem;
14 |
15 | public long getQuot() {
16 | return quot;
17 | }
18 |
19 | public void setQuot(long quot) {
20 | this.quot = quot;
21 | }
22 |
23 | public long getRem() {
24 | return rem;
25 | }
26 |
27 | public void setRem(long rem) {
28 | this.rem = rem;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/common/time/MySQLTimestampType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.plan.common.time;
7 |
8 | public enum MySQLTimestampType {
9 |
10 | MYSQL_TIMESTAMP_NONE(-2), MYSQL_TIMESTAMP_ERROR(-1), MYSQL_TIMESTAMP_DATE(0), MYSQL_TIMESTAMP_DATETIME(
11 | 1), MYSQL_TIMESTAMP_TIME(2);
12 | private int i;
13 |
14 | MySQLTimestampType(int i) {
15 | this.i = i;
16 | }
17 |
18 | public static MySQLTimestampType valueOf(int i) {
19 | if (i < 0 || i >= values().length) {
20 | throw new IndexOutOfBoundsException("Invalid ordinal");
21 | }
22 | return values()[i];
23 | }
24 |
25 | public String toString() {
26 | return String.valueOf(i);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/plan/optimizer/HintPlanNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.plan.optimizer;
7 |
8 | /**
9 | * @author collapsar
10 | */
11 | public final class HintPlanNode {
12 |
13 | String name;
14 |
15 | private HintPlanNode(String name) {
16 | this.name = name;
17 | }
18 |
19 | public static HintPlanNode of(String name) {
20 | return new HintPlanNode(name);
21 | }
22 |
23 | public String getName() {
24 | return name;
25 | }
26 |
27 |
28 | @Override
29 | public String toString() {
30 | return "nodeName='" + name + "'";
31 | }
32 |
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/route/RouteStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.route;
7 |
8 | import com.actiontech.dble.config.model.sharding.SchemaConfig;
9 | import com.actiontech.dble.services.mysqlsharding.ShardingService;
10 |
11 | import java.sql.SQLException;
12 |
13 | /**
14 | * RouteStrategy
15 | *
16 | * @author wang.dw
17 | */
18 | public interface RouteStrategy {
19 |
20 | RouteResultset route(SchemaConfig schema, int sqlType, String origSQL, ShardingService service)
21 | throws SQLException;
22 |
23 | RouteResultset route(SchemaConfig schema, int sqlType, String origSQL, ShardingService service, boolean isExplain)
24 | throws SQLException;
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/route/factory/RouteStrategyFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.route.factory;
7 |
8 | import com.actiontech.dble.route.RouteStrategy;
9 | import com.actiontech.dble.route.impl.DefaultRouteStrategy;
10 |
11 | /**
12 | * RouteStrategyFactory
13 | *
14 | * @author wang.dw
15 | */
16 | public final class RouteStrategyFactory {
17 | private static RouteStrategy defaultStrategy = new DefaultRouteStrategy();
18 |
19 | private RouteStrategyFactory() {
20 |
21 | }
22 |
23 |
24 | public static RouteStrategy getRouteStrategy() {
25 | return defaultStrategy;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/handler/BeginHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.server.handler;
7 |
8 | import com.actiontech.dble.services.mysqlsharding.ShardingService;
9 |
10 | public final class BeginHandler {
11 | private BeginHandler() {
12 | }
13 |
14 | public static void handle(String stmt, ShardingService service) {
15 | service.begin(stmt);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/handler/CommitHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.server.handler;
7 |
8 | import com.actiontech.dble.services.mysqlsharding.ShardingService;
9 |
10 | public final class CommitHandler {
11 | private CommitHandler() {
12 | }
13 |
14 | public static void handle(String stmt, ShardingService service) {
15 | service.commit(stmt);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/handler/RollBackHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.server.handler;
7 |
8 | import com.actiontech.dble.services.mysqlsharding.ShardingService;
9 |
10 | public final class RollBackHandler {
11 | private RollBackHandler() {
12 | }
13 |
14 | public static void handle(String stmt, ShardingService service) {
15 | service.rollback(stmt);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/parser/ServerParseFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.server.parser;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-01-12
12 | */
13 | public final class ServerParseFactory {
14 | private ServerParseFactory() {
15 | }
16 |
17 |
18 | public static ShardingServerParse getShardingParser() {
19 | return new ShardingServerParse();
20 | }
21 |
22 | public static RwSplitServerParse getRwSplitParser() {
23 | return new RwSplitServerParse();
24 | }
25 |
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/parser/TableAliasVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.server.parser;
7 |
8 | import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
9 | import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class TableAliasVisitor extends MySqlASTVisitorAdapter {
15 |
16 | private List tableAlias = new ArrayList<>(5);
17 |
18 | public boolean visit(SQLExprTableSource x) {
19 | String alias = x.getAlias();
20 | tableAlias.add(alias);
21 | return true;
22 | }
23 |
24 | public List getAlias() {
25 | return tableAlias;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/response/InnerFuncResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.server.response;
7 |
8 | import com.actiontech.dble.net.mysql.FieldPacket;
9 | import com.actiontech.dble.net.mysql.RowDataPacket;
10 |
11 | import com.actiontech.dble.services.mysqlsharding.ShardingService;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * Created by szf on 2019/5/30.
17 | */
18 | public interface InnerFuncResponse {
19 |
20 | List getField();
21 |
22 | List getRows(ShardingService service);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/response/PackageBufINf.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.server.response;
7 |
8 | import java.nio.ByteBuffer;
9 |
10 | public class PackageBufINf {
11 | private byte packetId;
12 | private ByteBuffer buffer;
13 |
14 | public byte getPacketId() {
15 | return packetId;
16 | }
17 |
18 | public void setPacketId(byte packetId) {
19 | this.packetId = packetId;
20 | }
21 |
22 | public ByteBuffer getBuffer() {
23 | return buffer;
24 | }
25 |
26 | public void setBuffer(ByteBuffer buffer) {
27 | this.buffer = buffer;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/response/SptDrop.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.server.response;
7 |
8 | import com.actiontech.dble.config.ErrorCode;
9 | import com.actiontech.dble.services.mysqlsharding.ShardingService;
10 |
11 | public final class SptDrop {
12 | private SptDrop() {
13 | }
14 |
15 | public static void response(ShardingService service) {
16 | String name = service.getSptPrepare().getName();
17 | if (service.getSptPrepare().delPrepare(name)) {
18 | service.writeOkPacket();
19 | } else {
20 | service.writeErrMessage(ErrorCode.ER_UNKNOWN_STMT_HANDLER, "Unknown prepared statement handler" + name + " given to DEALLOCATE PREPARE");
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/variables/OutputStateEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.server.variables;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2020-12-24
12 | */
13 | public enum OutputStateEnum {
14 | /**
15 | *
16 | */
17 | NORMAL_QUERY,
18 | /**
19 | * used for prepare
20 | */
21 | PREPARE,
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/server/variables/VariableType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.server.variables;
7 |
8 | public enum VariableType {
9 | SYNTAX_ERROR,
10 | XA,
11 | AUTOCOMMIT,
12 | NAMES,
13 | CHARSET,
14 | CHARACTER_SET_CLIENT,
15 | CHARACTER_SET_CONNECTION,
16 | CHARACTER_SET_RESULTS,
17 | COLLATION_CONNECTION,
18 | SYSTEM_VARIABLES,
19 | USER_VARIABLES,
20 | TX_READ_ONLY,
21 | TX_ISOLATION,
22 | TRACE
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/FakeService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.services;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-05-27
12 | */
13 | public interface FakeService {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/TransactionOperate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services;
7 |
8 | public enum TransactionOperate {
9 | AUTOCOMMIT,
10 | UNAUTOCOMMIT,
11 | BEGIN,
12 | END, // commit、rollback
13 | IMPLICITLY_COMMIT, // == END
14 | QUERY,
15 | QUIT
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/dump/DumpException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.dump;
7 |
8 | public class DumpException extends RuntimeException {
9 |
10 | public DumpException() {
11 | super();
12 | }
13 |
14 | public DumpException(String message, Throwable cause) {
15 | super(message, cause);
16 | }
17 |
18 | public DumpException(String message) {
19 | super(message);
20 | }
21 |
22 | public DumpException(Throwable cause) {
23 | super(cause);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/dump/ErrorMsg.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.dump;
7 |
8 | public class ErrorMsg {
9 | private String target;
10 | private String errorMeg;
11 |
12 | public ErrorMsg(String target, String errorMeg) {
13 | this.target = target;
14 | this.errorMeg = errorMeg;
15 | }
16 |
17 | public String getTarget() {
18 | return target;
19 | }
20 |
21 | public void setTarget(String target) {
22 | this.target = target;
23 | }
24 |
25 | public String getErrorMeg() {
26 | return errorMeg;
27 | }
28 |
29 | public void setErrorMeg(String errorMeg) {
30 | this.errorMeg = errorMeg;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/dump/handler/StatementHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.dump.handler;
7 |
8 | import com.actiontech.dble.services.manager.dump.DumpException;
9 | import com.actiontech.dble.services.manager.dump.DumpFileContext;
10 | import com.alibaba.druid.sql.ast.SQLStatement;
11 |
12 | import java.sql.SQLNonTransientException;
13 |
14 | public interface StatementHandler {
15 |
16 | SQLStatement preHandle(DumpFileContext context, String stmt) throws DumpException, InterruptedException, SQLNonTransientException;
17 |
18 | void handle(DumpFileContext context, SQLStatement statement) throws DumpException, InterruptedException;
19 |
20 | void handle(DumpFileContext context, String stmt) throws DumpException, InterruptedException;
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/dump/parse/InsertLexer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.dump.parse;
7 |
8 | import com.alibaba.druid.sql.parser.Lexer;
9 |
10 | class InsertLexer extends Lexer {
11 |
12 | InsertLexer(String input) {
13 | super(input);
14 | }
15 |
16 | public int getStartPos() {
17 | return startPos;
18 | }
19 |
20 | public int getPos() {
21 | return pos;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/handler/PackageBufINf.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.handler;
7 |
8 | import java.nio.ByteBuffer;
9 |
10 | public class PackageBufINf {
11 | private byte packetId;
12 | private ByteBuffer buffer;
13 |
14 | public byte getPacketId() {
15 | return packetId;
16 | }
17 |
18 | public void setPacketId(byte packetId) {
19 | this.packetId = packetId;
20 | }
21 |
22 | public ByteBuffer getBuffer() {
23 | return buffer;
24 | }
25 |
26 | public void setBuffer(ByteBuffer buffer) {
27 | this.buffer = buffer;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/response/ChangeItemType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.response;
7 |
8 | public enum ChangeItemType {
9 | PHYSICAL_DB_GROUP(), PHYSICAL_DB_INSTANCE(), SHARDING_NODE(), AP_NODE(), USERNAME();
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/response/ChangeType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.response;
7 |
8 | public enum ChangeType {
9 | ADD(), UPDATE(), DELETE();
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/response/Offline.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.services.manager.response;
7 |
8 | import com.actiontech.dble.DbleServer;
9 | import com.actiontech.dble.services.manager.ManagerService;
10 | import com.actiontech.dble.net.mysql.OkPacket;
11 |
12 | /**
13 | * @author mycat
14 | */
15 | public final class Offline {
16 | private Offline() {
17 | }
18 |
19 | private static final OkPacket OK = new OkPacket();
20 |
21 | static {
22 | OK.setPacketId(1);
23 | OK.setAffectedRows(1);
24 | OK.setServerStatus(2);
25 | }
26 |
27 | public static void execute(ManagerService service) {
28 | DbleServer.getInstance().offline();
29 | OK.write(service.getConnection());
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/response/Online.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.services.manager.response;
7 |
8 | import com.actiontech.dble.DbleServer;
9 | import com.actiontech.dble.services.manager.ManagerService;
10 | import com.actiontech.dble.net.mysql.OkPacket;
11 |
12 | /**
13 | * @author mycat
14 | */
15 | public final class Online {
16 | private Online() {
17 | }
18 |
19 | private static final OkPacket OK = new OkPacket();
20 |
21 | static {
22 | OK.setPacketId(1);
23 | OK.setAffectedRows(1);
24 | OK.setServerStatus(2);
25 | }
26 |
27 | public static void execute(ManagerService service) {
28 | DbleServer.getInstance().online();
29 | OK.write(service.getConnection());
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/response/ShowSQL.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.services.manager.response;
7 |
8 | import com.actiontech.dble.services.manager.ManagerService;
9 |
10 |
11 | /**
12 | * Show Last SQL
13 | *
14 | * @author mycat
15 | * @author zhuam
16 | */
17 | public final class ShowSQL {
18 | private ShowSQL() {
19 | }
20 |
21 | public static void execute(ManagerService service) {
22 | String sql = "select sql_id as ID, user as USER, start_time as START_TIME, duration as EXECUTE_TIME, sql_stmt as SQL from dble_information.sql_log order by start_time desc";
23 | (new ManagerSelectHandler()).execute(service, sql);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/response/ShowSQLHigh.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.response;
7 |
8 | import com.actiontech.dble.services.manager.ManagerService;
9 |
10 | /**
11 | * ShowSQLHigh
12 | *
13 | * @author zhuam
14 | */
15 | public final class ShowSQLHigh {
16 | private ShowSQLHigh() {
17 | }
18 |
19 | public static void execute(ManagerService service) {
20 | String sql = "select sql_id as ID, user as USER, count(0) as FREQUENCY, avg(duration) AVG_TIME, max(duration) as MAX_TIME, min(duration) as MIN_TIME, duration as EXECUTE_TIME, start_time as LAST_TIME, sql_digest as SQL from dble_information.sql_log group by sql_digest,user order by start_time";
21 | (new ManagerSelectHandler()).execute(service, sql);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/manager/response/ShowSQLLarge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.manager.response;
7 |
8 | import com.actiontech.dble.services.manager.ManagerService;
9 |
10 | /**
11 | * ShowSQLLarge
12 | *
13 | * @author zhuam
14 | */
15 | public final class ShowSQLLarge {
16 | private ShowSQLLarge() {
17 | }
18 |
19 | public static void execute(ManagerService service) {
20 | String sql = "select user as USER, rows as ROWS, start_time as START_TIME, duration as EXECUTE_TIME, sql_stmt as SQL from dble_information.sql_log where sql_type='Select' and rows > 10000;";
21 | (new ManagerSelectHandler()).execute(service, sql);
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/mysqlauthenticate/PluginName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.mysqlauthenticate;
7 |
8 | /**
9 | * Created by szf on 2020/6/22.
10 | */
11 | public enum PluginName {
12 | caching_sha2_password,
13 | mysql_native_password,
14 | unsupport_plugin
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/rwsplit/Callback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.rwsplit;
7 |
8 | public interface Callback {
9 |
10 | void callback(boolean isSuccess, byte[] response, RWSplitService rwSplitService);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/rwsplit/ShowFieldsHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.rwsplit;
7 |
8 | import com.actiontech.dble.net.service.AbstractService;
9 |
10 | import javax.annotation.Nonnull;
11 | import java.util.List;
12 |
13 | public interface ShowFieldsHandler {
14 |
15 | void fieldsEof(byte[] header, List fields, byte[] eof, @Nonnull AbstractService service);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/services/rwsplit/StatisticsHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.services.rwsplit;
7 |
8 | import com.actiontech.dble.net.service.AbstractService;
9 |
10 | import javax.annotation.Nonnull;
11 |
12 | public interface StatisticsHandler {
13 |
14 | void stringEof(byte[] data, @Nonnull AbstractService service);
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/singleton/TransactionCounter.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.singleton;
2 |
3 | import java.util.concurrent.atomic.AtomicLong;
4 |
5 | public final class TransactionCounter {
6 | private static final AtomicLong TX_ID = new AtomicLong(0);
7 |
8 | private TransactionCounter() {
9 | }
10 |
11 | public static long txIdGlobalCount() {
12 | return TX_ID.incrementAndGet();
13 | }
14 |
15 | public static long getCurrentTransactionCount() {
16 | return TX_ID.get();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/sqlengine/SQLJobHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.sqlengine;
7 |
8 | import java.util.List;
9 |
10 | public interface SQLJobHandler {
11 |
12 | void onHeader(List fields);
13 |
14 | void onRowData(byte[] rowData);
15 |
16 | void finished(String shardingNode, boolean failed);
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/sqlengine/SQLQueryResultListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.sqlengine;
7 |
8 |
9 | public interface SQLQueryResultListener {
10 |
11 | void onResult(T result);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/sqlengine/mpp/IsValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.sqlengine.mpp;
7 |
8 | /**
9 | * Created by szf on 2018/8/17.
10 | */
11 | public class IsValue {
12 |
13 |
14 | private final Object value;
15 |
16 |
17 | public IsValue(Object value) {
18 | this.value = value;
19 | }
20 |
21 |
22 | public Object getValue() {
23 | return value;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/statistic/sql/StatisticEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.statistic.sql;
7 |
8 | import com.actiontech.dble.statistic.sql.entry.StatisticEntry;
9 |
10 | public class StatisticEvent {
11 |
12 | private StatisticEntry entry;
13 |
14 | public void setEntry(StatisticEntry entry) {
15 | this.entry = entry;
16 | }
17 |
18 | public StatisticEntry getEntry() {
19 | return entry;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/statistic/sql/UsageData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.statistic.sql;
7 |
8 | public class UsageData {
9 |
10 | private String dataTime;
11 | private String usage;
12 |
13 | public UsageData(String dataTime, String usage) {
14 | this.dataTime = dataTime;
15 | this.usage = usage;
16 | }
17 |
18 | public String getDataTime() {
19 | return dataTime;
20 | }
21 |
22 | public String getUsage() {
23 | return usage;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/statistic/sql/UsageDataBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.statistic.sql;
7 |
8 | import java.lang.ref.SoftReference;
9 |
10 | public class UsageDataBlock extends SoftReference {
11 |
12 | public UsageDataBlock(String key, String value) {
13 | super(new UsageData(key, value));
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/statistic/sql/analyzer/AbstractAnalyzer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.statistic.sql.analyzer;
7 |
8 | import com.actiontech.dble.statistic.sql.entry.StatisticFrontendSqlEntry;
9 |
10 | public interface AbstractAnalyzer {
11 |
12 | void toAnalyzing(StatisticFrontendSqlEntry fEntry);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/statistic/sql/entry/BackendInfo.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.statistic.sql.entry;
2 |
3 | import com.actiontech.dble.backend.mysql.nio.MySQLInstance;
4 | import com.actiontech.dble.net.connection.BackendConnection;
5 |
6 | public class BackendInfo {
7 | String name; // db_instance
8 | String host;
9 | int port;
10 |
11 | public BackendInfo(BackendConnection bConn) {
12 | this.name = ((MySQLInstance) bConn.getInstance()).getName();
13 | this.host = bConn.getHost();
14 | this.port = bConn.getPort();
15 | }
16 |
17 | public String getName() {
18 | return name;
19 | }
20 |
21 | public String getHost() {
22 | return host;
23 | }
24 |
25 | public int getPort() {
26 | return port;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/statistic/sql/handler/StatisticDataHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.statistic.sql.handler;
7 |
8 | import com.actiontech.dble.statistic.sql.StatisticEvent;
9 | import com.lmax.disruptor.EventHandler;
10 |
11 | public interface StatisticDataHandler extends EventHandler {
12 |
13 | @Override
14 | void onEvent(StatisticEvent statisticEvent, long l, boolean b) throws Exception;
15 |
16 | Object getList();
17 |
18 | void clear();
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/BooleanUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.util;
7 |
8 | public final class BooleanUtil {
9 | private static final String TRUE = "true";
10 | private static final String FALSE = "false";
11 | private BooleanUtil() {
12 | }
13 |
14 | public static boolean parseBoolean(String val) {
15 | if (TRUE.equalsIgnoreCase(val)) {
16 | return true;
17 | } else if (FALSE.equalsIgnoreCase(val)) {
18 | return false;
19 | } else {
20 | throw new NumberFormatException("value " + val + " is not boolean value");
21 | }
22 | }
23 |
24 | public static boolean isBoolean(String val) {
25 | return TRUE.equalsIgnoreCase(val) || FALSE.equalsIgnoreCase(val);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/CharsetContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.util;
7 |
8 | import java.util.Objects;
9 |
10 | public final class CharsetContext {
11 | private CharsetContext() {
12 | }
13 |
14 | private static final ThreadLocal CHARSET_CTX = new ThreadLocal<>();
15 |
16 | public static void put(String value) {
17 | CHARSET_CTX.set(value);
18 | }
19 |
20 | public static String get() {
21 | return CHARSET_CTX.get();
22 | }
23 |
24 | public static String remove() {
25 | String value = get();
26 | if (Objects.nonNull(value)) {
27 | CHARSET_CTX.remove();
28 | }
29 | return value;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/IOUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.util;
7 |
8 | import org.apache.logging.log4j.core.util.IOUtils;
9 |
10 | import java.io.IOException;
11 | import java.io.InputStream;
12 | import java.io.InputStreamReader;
13 | import java.nio.charset.Charset;
14 |
15 | public final class IOUtil {
16 | private IOUtil() {
17 | }
18 |
19 | public static String convertStreamToString(InputStream is, Charset ecoding) throws IOException {
20 | try {
21 | InputStreamReader reader = new InputStreamReader(is, ecoding);
22 | return IOUtils.toString(reader);
23 | } finally {
24 | is.close();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/MinHeap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.util;
7 |
8 | import java.util.Collection;
9 |
10 | public interface MinHeap extends Collection {
11 |
12 | E poll();
13 |
14 | E peak();
15 |
16 | void replaceTop(E e);
17 |
18 | E find(E e);
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/TimeUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.util;
7 |
8 | /**
9 | * weak accuracy timer for performance.
10 | *
11 | * @author mycat
12 | */
13 | public final class TimeUtil {
14 | private TimeUtil() {
15 | }
16 |
17 | private static volatile long currentTime = System.currentTimeMillis();
18 |
19 | public static long currentTimeMillis() {
20 | return currentTime;
21 | }
22 |
23 | public static long currentTimeNanos() {
24 | return System.nanoTime();
25 | }
26 |
27 | public static void update() {
28 | currentTime = System.currentTimeMillis();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/exception/DetachedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.util.exception;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-08-31
12 | */
13 | public class DetachedException extends RuntimeException {
14 | public DetachedException(String message) {
15 | super(message);
16 | }
17 |
18 | public DetachedException(String message, Throwable cause) {
19 | super(message, cause);
20 | }
21 |
22 | public DetachedException(Throwable cause) {
23 | super(cause);
24 | }
25 |
26 | public DetachedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
27 | super(message, cause, enableSuppression, writableStackTrace);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/exception/DirectPrintException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 |
7 | package com.actiontech.dble.util.exception;
8 |
9 | /**
10 | * @author dcy
11 | * Create Date: 2021-08-31
12 | */
13 | public class DirectPrintException extends RuntimeException {
14 | public DirectPrintException(String message) {
15 | super(message);
16 | }
17 |
18 | public DirectPrintException(String message, Throwable cause) {
19 | super(message, cause);
20 | }
21 |
22 | public DirectPrintException(Throwable cause) {
23 | super(cause);
24 | }
25 |
26 | public DirectPrintException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
27 | super(message, cause, enableSuppression, writableStackTrace);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/exception/NotSslRecordException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.util.exception;
7 |
8 | import javax.net.ssl.SSLException;
9 |
10 | public class NotSslRecordException extends SSLException {
11 |
12 | private static final long serialVersionUID = -4316784434770656841L;
13 |
14 | public NotSslRecordException() {
15 | super("");
16 | }
17 |
18 | public NotSslRecordException(String message) {
19 | super(message);
20 | }
21 |
22 | public NotSslRecordException(Throwable cause) {
23 | super(cause);
24 | }
25 |
26 | public NotSslRecordException(String message, Throwable cause) {
27 | super(message, cause);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/exception/UnknownTxIsolationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.util.exception;
7 |
8 | /**
9 | * UnknownTxIsolationException
10 | *
11 | * @author mycat
12 | */
13 | public class UnknownTxIsolationException extends RuntimeException {
14 | private static final long serialVersionUID = -3911059999308980358L;
15 |
16 | public UnknownTxIsolationException() {
17 | super();
18 | }
19 |
20 | public UnknownTxIsolationException(String message, Throwable cause) {
21 | super(message, cause);
22 | }
23 |
24 | public UnknownTxIsolationException(String message) {
25 | super(message);
26 | }
27 |
28 | public UnknownTxIsolationException(Throwable cause) {
29 | super(cause);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/actiontech/dble/util/exception/res/_messages_en.prop:
--------------------------------------------------------------------------------
1 | 5301=Could not open file {0}
2 | 5302=Could not force file {0}
3 | 5303=Could not sync file {0}
4 | 5304=Reading from {0} failed
5 | 5305=Writing to {0} failed
6 | 5306=Error while renaming file {0} to {1}
7 | 5307=Cannot delete file {0}
8 | 5308=IO Exception: {0}
9 | 5309=Reading from {0} failed,index out of bounds
10 | 5310=Hex a decimal string with odd number of characters: {0}
11 | 5311=Hex a decimal string contains non-hex character: {0}
12 | 5312=Invalid value {0} for parameter {1}
13 | 5313=Error while creating file {0}
--------------------------------------------------------------------------------
/src/main/resources/bootstrap.dynamic.cnf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/actiontech/dble/61c7d4753091d359d809fc6913a3dbe4407327fc/src/main/resources/bootstrap.dynamic.cnf
--------------------------------------------------------------------------------
/src/main/resources/cacheservice.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2016-2023 ActionTech.
3 | # License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | #
5 | #used for cache service conf
6 | factory.encache=ehcache
7 | #key is pool name ,value is type,max size, expire seconds
8 | pool.SQLRouteCache=encache,10000,1800
9 | pool.ER_SQL2PARENTID=encache,1000,1800
10 |
--------------------------------------------------------------------------------
/src/main/resources/cluster_template.cnf:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2016-2023 ActionTech.
3 | # License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | #
5 |
6 |
7 | clusterEnable=false
8 | # cluster ucore/zk
9 | clusterMode=zk
10 | # zk: clusterIP=10.186.19.aa:2281,10.186.60.bb:2281
11 | clusterIP=10.186.61.132:2181
12 | # zk not need cluster.port
13 | clusterPort=5700
14 | rootPath=/dble
15 | #cluster namespace, please use the same one in one cluster
16 | clusterId=cluster-1
17 | # if HA need sync by cluster, only useful when useOuterHa=true
18 | needSyncHa=false
19 | # unit is millisecond
20 | showBinlogStatusTimeout=60000
21 | sequenceHandlerType=2
22 | # valid for sequenceHandlerType=2 or 3
23 | #sequenceStartTime=2010-11-04 09:42:54
24 | # valid for sequenceHandlerType=3 and clusterMode is zk, default true
25 | #sequenceInstanceByZk=true
26 | grpcTimeout=10
27 |
--------------------------------------------------------------------------------
/src/main/resources/db.xsd:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/resources/ehcache.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
13 |
--------------------------------------------------------------------------------
/src/main/resources/log4j2.component.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2016-2023 ActionTech.
3 | # License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | #
5 | #AsyncLoggerConfig.RingBufferSize=262144
6 |
--------------------------------------------------------------------------------
/src/main/resources/partition-enum.txt:
--------------------------------------------------------------------------------
1 | 10000=0
2 | 10010=1
--------------------------------------------------------------------------------
/src/main/resources/partition-number-range.txt:
--------------------------------------------------------------------------------
1 | # range start-end ,data node index
2 | # K=1000,M=10000.
3 | 0-500M=0
4 | 500M-1000M=1
5 | 1000M-1500M=2
--------------------------------------------------------------------------------
/src/main/resources/partition-pattern.txt:
--------------------------------------------------------------------------------
1 | //this is comment
2 | # this is comment too
3 | # use closed interval
4 |
5 | #begin - end = nodeid
6 | 0 - 10 = 0
7 | 11 - 20 = 1
8 |
--------------------------------------------------------------------------------
/src/main/resources/sequence_conf.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2016-2023 ActionTech.
3 | # License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | #
5 | #default global sequence
6 | `testdb`.`GLOBAL`.MINID=10001
7 | `testdb`.`GLOBAL`.MAXID=20000
8 | `testdb`.`GLOBAL`.CURID=10000
9 | # self define sequence
10 | `testdb`.`COMPANY`.MINID=1001
11 | `testdb`.`COMPANY`.MAXID=2000
12 | `testdb`.`COMPANY`.CURID=1000
13 | `testdb`.`CUSTOMER`.MINID=1001
14 | `testdb`.`CUSTOMER`.MAXID=2000
15 | `testdb`.`CUSTOMER`.CURID=1000
16 | `testdb`.`ORDER`.MINID=11
17 | `testdb`.`ORDER`.MAXID=20
18 | `testdb`.`ORDER`.CURID=10
19 | `testdb`.`HOTNEWS`.MINID=1001
20 | `testdb`.`HOTNEWS`.MAXID=2000
21 | `testdb`.`HOTNEWS`.CURID=1000
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/resources/sequence_db_conf.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2016-2023 ActionTech.
3 | # License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | #
5 | #sequence stored in shardingnode
6 | `TESTDB`.`GLOBAL`=dn1
7 | `TESTDB`.`COMPANY`=dn1
8 | `TESTDB`.`CUSTOMER`=dn1
9 | `TESTDB`.`ORDERS`=dn1
10 | `TESTDB`.`myauto_test`=dn1
11 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/ConfigInitializerTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble;
7 |
8 | import com.actiontech.dble.config.ConfigInitializer;
9 | import org.junit.Test;
10 |
11 | /**
12 | * @author mycat
13 | */
14 | public class ConfigInitializerTest {
15 | @Test
16 | public void testConfigLoader() {
17 | new ConfigInitializer();
18 | }
19 | }
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/AnalysisUserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | /**
9 | * requires attention:
10 | * New fields need to consider equals and copyBaseInfo methods
11 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
12 | */
13 |
14 | public class AnalysisUserConfig extends SingleDbGroupUserConfig {
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/DataBaseType.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.config;
2 |
3 | /**
4 | * requires attention:
5 | * New fields need to consider equals and copyBaseInfo methods
6 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
7 | */
8 | public enum DataBaseType {
9 | MYSQL, CLICKHOUSE;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/ManagerUserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | /**
9 | * requires attention:
10 | * New fields need to consider equals and copyBaseInfo methods
11 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
12 | */
13 | public class ManagerUserConfig extends UserConfig {
14 | private boolean readOnly;
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/RwSplitUserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | /**
9 | * requires attention:
10 | * New fields need to consider equals and copyBaseInfo methods
11 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
12 | */
13 | public class RwSplitUserConfig extends SingleDbGroupUserConfig {
14 | private String dbGroup;
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/ServerUserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | import com.alibaba.druid.wall.WallProvider;
9 |
10 | /**
11 | * requires attention:
12 | * New fields need to consider equals and copyBaseInfo methods
13 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
14 | */
15 | public abstract class ServerUserConfig extends UserConfig {
16 | private String tenant;
17 | private WallProvider blacklist;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/ShardingNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.config;
7 |
8 | import org.slf4j.Logger;
9 | import org.slf4j.LoggerFactory;
10 |
11 | /**
12 | * requires attention:
13 | * New fields need to consider equals and copyBaseInfo methods
14 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
15 | */
16 | public class ShardingNode {
17 | protected static final Logger LOGGER = LoggerFactory.getLogger(ShardingNode.class);
18 |
19 | protected String name;
20 | private String dbGroupName;
21 | protected String database;
22 | protected volatile PhysicalDbGroup dbGroup;
23 | private volatile boolean isSchemaExists = false;
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/ShardingUserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | import com.actiontech.dble.config.model.user.UserPrivilegesConfig;
9 |
10 | import java.util.Set;
11 |
12 | /**
13 | * requires attention:
14 | * New fields need to consider equals and copyBaseInfo methods
15 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
16 | */
17 | public class ShardingUserConfig extends ServerUserConfig {
18 | private boolean readOnly;
19 | private Set schemas;
20 | private UserPrivilegesConfig privilegesConfig;
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/SingleDbGroupUserConfig.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.config;
2 |
3 | /**
4 | * requires attention:
5 | * New fields need to consider equals and copyBaseInfo methods
6 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
7 | */
8 | public class SingleDbGroupUserConfig extends ServerUserConfig {
9 | protected String dbGroup;
10 | }
11 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/UserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | import java.util.Set;
9 |
10 | /**
11 | * requires attention:
12 | * New fields need to consider equals and copyBaseInfo methods
13 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
14 | */
15 | public class UserConfig {
16 | private int id;
17 | protected String name;
18 | protected String password;
19 | protected boolean isEncrypt;
20 | protected Set whiteIPs;
21 | protected int maxCon;
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/config/UserName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.config;
7 |
8 | /**
9 | * requires attention:
10 | * New fields need to consider equals and copyBaseInfo methods
11 | * http://10.186.18.11/jira/browse/DBLE0REQ-1793?focusedCommentId=99601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-99601
12 | */
13 | public class UserName {
14 | private String name;
15 | private String tenant;
16 | private int hashCode = -1;
17 | private static final int HASH_CONST = 37;
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/sqlexecute/RollbackTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.sqlexecute;
7 |
8 | import java.sql.Connection;
9 | import java.sql.DriverManager;
10 | import java.sql.SQLException;
11 |
12 | public class RollbackTest {
13 | private static Connection getCon(String url, String user, String passwd)
14 | throws SQLException {
15 | Connection theCon = DriverManager.getConnection(url, user, passwd);
16 | return theCon;
17 | }
18 |
19 | public static void main(String[] args) {
20 |
21 |
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/util/BitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.util;
7 |
8 | import org.junit.Test;
9 |
10 | /**
11 | * @author mycat
12 | */
13 | public class BitTest {
14 | @Test
15 | public void testNoop() {
16 | }
17 |
18 | public static void main(String[] args) {
19 | System.out.println(0xffff0001 & 0xffff);// low 16 bits
20 | System.out.println(0x0002ffff >>> 16);// high 16 bits
21 | }
22 | }
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/util/DateUtilTest.java:
--------------------------------------------------------------------------------
1 | package com.actiontech.dble.util;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import java.util.Calendar;
7 |
8 |
9 | public class DateUtilTest {
10 |
11 | @Test
12 | public void testDiffDays() {
13 | Calendar cal1 = Calendar.getInstance();
14 | Calendar cal2 = Calendar.getInstance();
15 | cal1.set(2021, 1, 1);
16 | cal2.set(2020, 1, 1);
17 | long diffDays = DateUtil.diffDays(cal1, cal2);
18 | Assert.assertEquals(366, diffDays);
19 | cal1.set(2021, 3, 1);
20 | cal2.set(2020, 3, 1);
21 | long diffDays2 = DateUtil.diffDays(cal1, cal2);
22 | Assert.assertEquals(365, diffDays2);
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/util/HexFormatUtilTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | */
5 |
6 | package com.actiontech.dble.util;
7 |
8 | import org.junit.Assert;
9 | import org.junit.Test;
10 |
11 | /**
12 | * @author CrazyPig
13 | * @since 2016-09-09
14 | */
15 | public class HexFormatUtilTest {
16 |
17 | @Test
18 | public void testBytesToString() {
19 | byte[] bytes = new byte[]{
20 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
21 | };
22 | String hexString = HexFormatUtil.bytesToHexString(bytes);
23 | String expected = "0102030405060708090A0B0C0D0E0F1011121314";
24 | Assert.assertEquals(expected, hexString);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/com/actiontech/dble/util/StringHashPerfMain.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016-2023 ActionTech.
3 | * based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
4 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
5 | */
6 | package com.actiontech.dble.util;
7 |
8 | /**
9 | * @author mycat
10 | */
11 | public class StringHashPerfMain {
12 |
13 | public static void main(String[] args) {
14 | String s = "abcdejdsalfp";
15 | int end = s.length();
16 | for (int i = 0; i < 10; i++) {
17 | StringUtil.hash(s, 0, end);
18 | }
19 | long loop = 10000 * 10000;
20 | long t1 = System.currentTimeMillis();
21 | t1 = System.currentTimeMillis();
22 | for (long i = 0; i < loop; ++i) {
23 | StringUtil.hash(s, 0, end);
24 | }
25 | long t2 = System.currentTimeMillis();
26 | System.out.println((((t2 - t1) * 1000 * 1000) / loop) + " ns.");
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/src/test/resources/autopartition-long.txt:
--------------------------------------------------------------------------------
1 | # range start-end ,data node index
2 | 0-200M=0
3 | 200M1-400M=1
4 | 400M1-600M=2
5 | #600M1-800M=3
6 | #800M1-1000M=4
7 |
--------------------------------------------------------------------------------
/src/test/resources/autopartition-long2.txt:
--------------------------------------------------------------------------------
1 | # range start-end ,data node index
2 | 0-200M=0
3 | 200M1-400M=1
4 | #400M1-600M=2
5 | #600M1-800M=3
6 | #800M1-1000M=4
7 |
--------------------------------------------------------------------------------
/src/test/resources/blob/image0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/actiontech/dble/61c7d4753091d359d809fc6913a3dbe4407327fc/src/test/resources/blob/image0.jpg
--------------------------------------------------------------------------------
/src/test/resources/blob/image1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/actiontech/dble/61c7d4753091d359d809fc6913a3dbe4407327fc/src/test/resources/blob/image1.png
--------------------------------------------------------------------------------
/src/test/resources/blob/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/actiontech/dble/61c7d4753091d359d809fc6913a3dbe4407327fc/src/test/resources/blob/image2.png
--------------------------------------------------------------------------------
/src/test/resources/blob/image3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/actiontech/dble/61c7d4753091d359d809fc6913a3dbe4407327fc/src/test/resources/blob/image3.png
--------------------------------------------------------------------------------
/src/test/resources/cluster.cnf:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2016-2023 ActionTech.
3 | # License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
4 | #
5 |
6 |
7 | clusterEnable=true
8 | clusterMode=ucore
9 | clusterIP=127.0.0.1
10 | clusterPort=25700
11 | rootPath=universe/dble
12 | clusterId=cluster-1
13 | needSyncHa=true
14 | showBinlogStatusTimeout=60000
15 | sequenceHandlerType=2
16 | # valid for sequenceHandlerType=2 or 3
17 | #sequenceStartTime=2010-11-04 09:42:54
18 | # valid for sequenceHandlerType=3 and clusterMode is zk, default true
19 | sequenceInstanceByZk=true
20 | grpcTimeout=10
21 |
--------------------------------------------------------------------------------
/src/test/resources/ehcache.xml:
--------------------------------------------------------------------------------
1 |
4 |
8 |
--------------------------------------------------------------------------------
/src/test/resources/partition-hash-int.txt:
--------------------------------------------------------------------------------
1 | 10000=0
2 | 10010=1
--------------------------------------------------------------------------------
/src/test/resources/partition-hash-int2.txt:
--------------------------------------------------------------------------------
1 | A=0
2 | B=1
--------------------------------------------------------------------------------
/src/test/resources/partition-pattern-test.txt:
--------------------------------------------------------------------------------
1 | # id partition range start-end ,data node index
2 | ###### first host configuration
3 | 1-32=0
4 | 33-64=1
5 | 65-96=2
6 | 97-128=3
7 | ######## second host configuration
8 | 129-160=4
9 | 161-192=5
10 | 193-224=6
11 | 225-256=7
12 | 0-0=7
--------------------------------------------------------------------------------
/src/test/resources/partition-range-mod.txt:
--------------------------------------------------------------------------------
1 | # range start-end ,data node group size
2 | 0-200M=5
3 | 200M1-400M=1
4 | 400M1-600M=4
5 | 600M1-800M=4
6 | 800M1-1000M=6
7 |
--------------------------------------------------------------------------------
/src/test/resources/partition_prefix_pattern.txt:
--------------------------------------------------------------------------------
1 | # range start-end ,data node index
2 | # ASCII编码:主要划分出10个数字,小字母26,一共36个字母进行分片
3 | # 48-57=0-9阿拉伯数字
4 | # 64、65-90=@、A-Z
5 | # 97-122=a-z
6 | ###### first host configuration
7 | 1-4=0
8 | 5-8=1
9 | 9-12=2
10 | 13-16=3
11 | ###### second host configuration
12 | 17-20=4
13 | 21-24=5
14 | 25-28=6
15 | 29-32=7
16 | 0-0=7
17 |
--------------------------------------------------------------------------------
/src/test/resources/sequence_conf.properties:
--------------------------------------------------------------------------------
1 | GLOBAL.HISIDS=
2 | GLOBAL.MINID=1
3 | GLOBAL.MAXID=10
4 | GLOBAL.CURID=1
5 | MY1.HISIDS=
6 | MY1.MINID=1001
7 | MY1.MAXID=2000
8 | MY1.CURID=1000
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/sequence_time_conf.properties:
--------------------------------------------------------------------------------
1 | #sequence depend on TIME
2 | WORKID=01
3 | DATAACENTERID=01
4 |
--------------------------------------------------------------------------------
/src/test/resources/sharding.txt:
--------------------------------------------------------------------------------
1 | 10000=0
2 | 10010=1
--------------------------------------------------------------------------------