-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent registration of unsupported Cassandra versions in the cluster
- Loading branch information
Showing
4 changed files
with
95 additions
and
16 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
cassdio-core/src/main/java/kr/hakdang/cassdio/core/domain/cluster/CassdioVersionChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package kr.hakdang.cassdio.core.domain.cluster; | ||
|
||
import com.datastax.oss.driver.api.core.CqlSession; | ||
import com.datastax.oss.driver.api.core.Version; | ||
import kr.hakdang.cassdio.common.error.NotSupportedCassandraVersionException; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* CassdioVersionChecker | ||
* | ||
* @author seungh0 | ||
* @since 2024-07-31 | ||
*/ | ||
@Service | ||
public class CassdioVersionChecker { | ||
|
||
private static final Version MIN_SUPPORT_VERSION = Version.V3_0_0; | ||
|
||
private final ClusterVersionEvaluator clusterVersionEvaluator; | ||
private final ClusterConnector clusterConnector; | ||
|
||
public CassdioVersionChecker(ClusterVersionEvaluator clusterVersionEvaluator, ClusterConnector clusterConnector) { | ||
this.clusterVersionEvaluator = clusterVersionEvaluator; | ||
this.clusterConnector = clusterConnector; | ||
} | ||
|
||
public void verifyCompatibilityCassandraVersion(ClusterConnection connection) { | ||
try (CqlSession session = clusterConnector.makeSession(connection)) { | ||
if (clusterVersionEvaluator.isLessThan(session, MIN_SUPPORT_VERSION)) { | ||
throw new NotSupportedCassandraVersionException("Not supported cassandra with cluster version"); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters