You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/04/23 04:28:36 UTC

[shardingsphere] branch master updated: Add GlobalHighlyAvailableStatus and RoleSeparatedHighlyAvailableStatus (#17028)

This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 623e7c0a20d Add GlobalHighlyAvailableStatus and RoleSeparatedHighlyAvailableStatus (#17028)
623e7c0a20d is described below

commit 623e7c0a20d01265348c09a1662e652e01010efe
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Apr 23 12:28:31 2022 +0800

    Add GlobalHighlyAvailableStatus and RoleSeparatedHighlyAvailableStatus (#17028)
---
 .../dbdiscovery/spi/DatabaseDiscoveryType.java     |  1 +
 .../spi/status/GlobalHighlyAvailableStatus.java}   | 18 +++-----------
 .../spi/{ => status}/HighlyAvailableStatus.java    |  2 +-
 .../RoleSeparatedHighlyAvailableStatus.java}       | 23 +++++++----------
 .../algorithm/DatabaseDiscoveryEngine.java         | 29 +++++++++++++++++++---
 .../fixture/CoreFixtureDatabaseDiscoveryType.java  |  2 +-
 .../DistSQLFixtureDatabaseDiscoveryType.java       |  2 +-
 .../MasterSlaveHighlyAvailableStatus.java          |  4 +--
 .../mysql/type/mgr/MGRHighlyAvailableStatus.java   |  4 +--
 .../opengauss/OpenGaussDatabaseDiscoveryType.java  |  9 ++++---
 .../opengauss/OpenGaussHighlyAvailableStatus.java  | 10 ++++++--
 11 files changed, 60 insertions(+), 44 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/DatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/DatabaseDiscoveryType.java
index 3f0cb68dcbd..a786b5f48ca 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/DatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/DatabaseDiscoveryType.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.dbdiscovery.spi;
 
+import org.apache.shardingsphere.dbdiscovery.spi.status.HighlyAvailableStatus;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
 
 import javax.sql.DataSource;
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/GlobalHighlyAvailableStatus.java
similarity index 59%
copy from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java
copy to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/GlobalHighlyAvailableStatus.java
index 70f8256d2ef..1ef54ab621f 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/GlobalHighlyAvailableStatus.java
@@ -15,22 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.dbdiscovery.opengauss;
-
-import lombok.EqualsAndHashCode;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
-
-import javax.sql.DataSource;
-import java.util.Map;
-import java.util.Properties;
+package org.apache.shardingsphere.dbdiscovery.spi.status;
 
 /**
- * Highly available status of openGauss cluster.
+ * Global highly available status for database cluster.
  */
-@EqualsAndHashCode
-public final class OpenGaussHighlyAvailableStatus implements HighlyAvailableStatus {
-    
-    @Override
-    public void validate(final String databaseName, final Map<String, DataSource> dataSourceMap, final Properties props) {
-    }
+public interface GlobalHighlyAvailableStatus extends HighlyAvailableStatus {
 }
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/HighlyAvailableStatus.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/HighlyAvailableStatus.java
similarity index 95%
rename from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/HighlyAvailableStatus.java
rename to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/HighlyAvailableStatus.java
index 58755a0f4df..0545ca935e2 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/HighlyAvailableStatus.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/HighlyAvailableStatus.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.dbdiscovery.spi;
+package org.apache.shardingsphere.dbdiscovery.spi.status;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/RoleSeparatedHighlyAvailableStatus.java
similarity index 60%
copy from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java
copy to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/RoleSeparatedHighlyAvailableStatus.java
index 70f8256d2ef..ed0f91d035c 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/spi/status/RoleSeparatedHighlyAvailableStatus.java
@@ -15,22 +15,17 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.dbdiscovery.opengauss;
-
-import lombok.EqualsAndHashCode;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
-
-import javax.sql.DataSource;
-import java.util.Map;
-import java.util.Properties;
+package org.apache.shardingsphere.dbdiscovery.spi.status;
 
 /**
- * Highly available status of openGauss cluster.
+ * Role separated highly available status for database cluster.
  */
-@EqualsAndHashCode
-public final class OpenGaussHighlyAvailableStatus implements HighlyAvailableStatus {
+public interface RoleSeparatedHighlyAvailableStatus extends HighlyAvailableStatus {
     
-    @Override
-    public void validate(final String databaseName, final Map<String, DataSource> dataSourceMap, final Properties props) {
-    }
+    /**
+     * Is primary database instance.
+     * 
+     * @return primary database instance or not
+     */
+    boolean isPrimary();
 }
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
index a1904fe4d86..1964f9de6c5 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/DatabaseDiscoveryEngine.java
@@ -20,7 +20,9 @@ package org.apache.shardingsphere.dbdiscovery.algorithm;
 import com.google.common.base.Preconditions;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
+import org.apache.shardingsphere.dbdiscovery.spi.status.GlobalHighlyAvailableStatus;
+import org.apache.shardingsphere.dbdiscovery.spi.status.HighlyAvailableStatus;
+import org.apache.shardingsphere.dbdiscovery.spi.status.RoleSeparatedHighlyAvailableStatus;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.metadata.schema.QualifiedDatabase;
 import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceChangedEvent;
@@ -50,15 +52,36 @@ public final class DatabaseDiscoveryEngine {
      * @throws SQLException SQL exception
      */
     public void checkHighlyAvailableStatus(final String databaseName, final Map<String, DataSource> dataSourceMap) throws SQLException {
-        Collection<HighlyAvailableStatus> statuses = new HashSet<>();
+        Collection<HighlyAvailableStatus> statuses = loadHighlyAvailableStatuses(dataSourceMap);
+        Preconditions.checkState(!statuses.isEmpty(), "No database instance in database cluster `%s`.", databaseName);
+        HighlyAvailableStatus sample = statuses.iterator().next();
+        if (sample instanceof GlobalHighlyAvailableStatus) {
+            checkGlobalHighlyAvailableStatus(databaseName, dataSourceMap, statuses);
+        } else if (sample instanceof RoleSeparatedHighlyAvailableStatus) {
+            checkRoleSeparatedHighlyAvailableStatus(databaseName, dataSourceMap, statuses);
+        }
+    }
+    
+    private Collection<HighlyAvailableStatus> loadHighlyAvailableStatuses(final Map<String, DataSource> dataSourceMap) throws SQLException {
+        Collection<HighlyAvailableStatus> result = new HashSet<>();
         for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
             // TODO query with multiple threads
-            statuses.add(databaseDiscoveryType.loadHighlyAvailableStatus(entry.getValue()));
+            result.add(databaseDiscoveryType.loadHighlyAvailableStatus(entry.getValue()));
         }
+        return result;
+    }
+    
+    private void checkGlobalHighlyAvailableStatus(final String databaseName, final Map<String, DataSource> dataSourceMap, final Collection<HighlyAvailableStatus> statuses) throws SQLException {
         Preconditions.checkState(1 == statuses.size(), "Different status in highly available cluster in database `%s`.", databaseName);
         statuses.iterator().next().validate(databaseName, dataSourceMap, databaseDiscoveryType.getProps());
     }
     
+    private void checkRoleSeparatedHighlyAvailableStatus(final String databaseName, final Map<String, DataSource> dataSourceMap, final Collection<HighlyAvailableStatus> statuses) throws SQLException {
+        for (HighlyAvailableStatus each : statuses) {
+            each.validate(databaseName, dataSourceMap, databaseDiscoveryType.getProps());
+        }
+    }
+    
     /**
      * Update primary data source.
      *
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreFixtureDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreFixtureDatabaseDiscoveryType.java
index 20ee5ae091c..85b7217a655 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreFixtureDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/fixture/CoreFixtureDatabaseDiscoveryType.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.dbdiscovery.fixture;
 
 import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
+import org.apache.shardingsphere.dbdiscovery.spi.status.HighlyAvailableStatus;
 
 import javax.sql.DataSource;
 import java.util.Map;
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLFixtureDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLFixtureDatabas [...]
index fe9a00ce9ae..8f960c2007d 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLFixtureDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/fixture/DistSQLFixtureDatabaseDiscoveryType.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.dbdiscovery.distsql.handler.fixture;
 
 import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
+import org.apache.shardingsphere.dbdiscovery.spi.status.HighlyAvailableStatus;
 
 import javax.sql.DataSource;
 import java.util.Map;
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveHighlyAvailableStatus.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveHighlyAvailableStatus.java
index 8c3a4e8bbc6..bec3769573e 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveHighlyAvailableStatus.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/masterslave/MasterSlaveHighlyAvailableStatus.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
+import org.apache.shardingsphere.dbdiscovery.spi.status.GlobalHighlyAvailableStatus;
 
 import javax.sql.DataSource;
 import java.util.Map;
@@ -33,7 +33,7 @@ import java.util.Properties;
 @RequiredArgsConstructor
 @Getter
 @EqualsAndHashCode
-public final class MasterSlaveHighlyAvailableStatus implements HighlyAvailableStatus {
+public final class MasterSlaveHighlyAvailableStatus implements GlobalHighlyAvailableStatus {
     
     private final String primaryInstanceURL;
     
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRHighlyAvailableStatus.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRHighlyAvailableStatus.java
index 0b6e976d4d8..7c2a23f6e20 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRHighlyAvailableStatus.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mysql/src/main/java/org/apache/shardingsphere/dbdiscovery/mysql/type/mgr/MGRHighlyAvailableStatus.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
+import org.apache.shardingsphere.dbdiscovery.spi.status.GlobalHighlyAvailableStatus;
 import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
 
 import javax.sql.DataSource;
@@ -38,7 +38,7 @@ import java.util.Properties;
 @RequiredArgsConstructor
 @Getter
 @EqualsAndHashCode
-public final class MGRHighlyAvailableStatus implements HighlyAvailableStatus {
+public final class MGRHighlyAvailableStatus implements GlobalHighlyAvailableStatus {
     
     private final boolean pluginActive;
     
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
index 2d95c1acc1e..0982cafa2f9 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
@@ -52,9 +52,12 @@ public final class OpenGaussDatabaseDiscoveryType implements DatabaseDiscoveryTy
     private Properties props = new Properties();
     
     @Override
-    public OpenGaussHighlyAvailableStatus loadHighlyAvailableStatus(final DataSource dataSource) {
-        // TODO Load OpenGaussHighlyAvailableStatus
-        return new OpenGaussHighlyAvailableStatus();
+    public OpenGaussHighlyAvailableStatus loadHighlyAvailableStatus(final DataSource dataSource) throws SQLException {
+        try (Connection connection = dataSource.getConnection();
+             Statement statement = connection.createStatement();
+             ResultSet resultSet = statement.executeQuery(DB_ROLE)) {
+            return new OpenGaussHighlyAvailableStatus(resultSet.next() && resultSet.getString("local_role").equals("Primary"));
+        }
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java
index 70f8256d2ef..19498b33004 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussHighlyAvailableStatus.java
@@ -18,7 +18,9 @@
 package org.apache.shardingsphere.dbdiscovery.opengauss;
 
 import lombok.EqualsAndHashCode;
-import org.apache.shardingsphere.dbdiscovery.spi.HighlyAvailableStatus;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.dbdiscovery.spi.status.RoleSeparatedHighlyAvailableStatus;
 
 import javax.sql.DataSource;
 import java.util.Map;
@@ -27,8 +29,12 @@ import java.util.Properties;
 /**
  * Highly available status of openGauss cluster.
  */
+@RequiredArgsConstructor
+@Getter
 @EqualsAndHashCode
-public final class OpenGaussHighlyAvailableStatus implements HighlyAvailableStatus {
+public final class OpenGaussHighlyAvailableStatus implements RoleSeparatedHighlyAvailableStatus {
+    
+    private final boolean primary;
     
     @Override
     public void validate(final String databaseName, final Map<String, DataSource> dataSourceMap, final Properties props) {