-
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.
- Loading branch information
Showing
24 changed files
with
484 additions
and
127 deletions.
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/TempClusterConnector.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,62 @@ | ||
package kr.hakdang.cadio.core.domain.cluster; | ||
|
||
import com.datastax.oss.driver.api.core.CqlSession; | ||
import com.datastax.oss.driver.api.core.CqlSessionBuilder; | ||
import kr.hakdang.cadio.core.domain.cluster.info.ClusterInfo; | ||
import kr.hakdang.cadio.core.domain.cluster.info.ClusterInfoProvider; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* TempClusterConnector | ||
* - 임시 목적으로 사용할 connector | ||
* | ||
* @author akageun | ||
* @since 2024-07-03 | ||
*/ | ||
@Slf4j | ||
@Service | ||
public class TempClusterConnector { | ||
|
||
private final ClusterInfoProvider clusterInfoProvider; | ||
|
||
public TempClusterConnector( | ||
ClusterInfoProvider clusterInfoProvider | ||
) { | ||
this.clusterInfoProvider = clusterInfoProvider; | ||
} | ||
|
||
public List<InetSocketAddress> makeContactPoint(String contactPoints, int port) { | ||
String[] contactPointArr = StringUtils.split(contactPoints, ","); | ||
|
||
List<InetSocketAddress> result = new ArrayList<>(); | ||
for (String contactPoint : contactPointArr) { | ||
result.add(new InetSocketAddress(contactPoint, port)); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public CqlSession makeSession(ClusterConnection clusterConnection) { | ||
CqlSessionBuilder builder = CqlSession.builder() | ||
.addContactPoints(makeContactPoint(clusterConnection.getContactPoints(), clusterConnection.getPort())) | ||
.withLocalDatacenter(clusterConnection.getLocalDatacenter()); | ||
|
||
if (clusterConnection.isAuthCredentials()) { | ||
builder.withAuthCredentials(clusterConnection.getUsername(), clusterConnection.getPassword()); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
|
||
public CqlSession makeSession(String clusterId) { | ||
ClusterInfo info = clusterInfoProvider.findClusterInfo(clusterId); | ||
return makeSession(info.makeClusterConnector()); | ||
} | ||
} |
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
54 changes: 54 additions & 0 deletions
54
cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/info/ClusterInfo.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,54 @@ | ||
package kr.hakdang.cadio.core.domain.cluster.info; | ||
|
||
import kr.hakdang.cadio.core.domain.cluster.ClusterConnection; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* ClusterInfo | ||
* | ||
* @author akageun | ||
* @since 2024-07-03 | ||
*/ | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class ClusterInfo { | ||
private String clusterId; | ||
private String clusterName; | ||
private String contactPoints; | ||
private int port; | ||
private String localDatacenter; | ||
private String username; | ||
private String password; | ||
|
||
@Builder(toBuilder = true) | ||
public ClusterInfo( | ||
String clusterId, | ||
String clusterName, | ||
String contactPoints, | ||
int port, | ||
String localDatacenter, | ||
String username, | ||
String password | ||
) { | ||
this.clusterId = clusterId; | ||
this.clusterName = clusterName; | ||
this.contactPoints = contactPoints; | ||
this.port = port; | ||
this.localDatacenter = localDatacenter; | ||
this.username = username; | ||
this.password = password; | ||
} | ||
|
||
public ClusterConnection makeClusterConnector() { | ||
return ClusterConnection.builder() | ||
.contactPoints(contactPoints) | ||
.port(port) | ||
.localDatacenter(localDatacenter) | ||
.username(username) | ||
.password(password) | ||
.build(); | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
...core/src/main/java/kr/hakdang/cadio/core/domain/cluster/info/ClusterInfoRegisterArgs.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,49 @@ | ||
package kr.hakdang.cadio.core.domain.cluster.info; | ||
|
||
import kr.hakdang.cadio.core.domain.cluster.ClusterConnection; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* ClusterInfoRegisterArgs | ||
* | ||
* @author akageun | ||
* @since 2024-07-03 | ||
*/ | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class ClusterInfoRegisterArgs { | ||
private String clusterName; | ||
private String contactPoints; | ||
private int port; | ||
private String localDatacenter; | ||
private String username; | ||
private String password; | ||
|
||
//Append | ||
|
||
@Builder | ||
public ClusterInfoRegisterArgs(String clusterName, String contactPoints, int port, String localDatacenter, String username, String password) { | ||
this.clusterName = clusterName; | ||
this.contactPoints = contactPoints; | ||
this.port = port; | ||
this.localDatacenter = localDatacenter; | ||
this.username = username; | ||
this.password = password; | ||
} | ||
|
||
public ClusterInfo makeClusterInfo(String clusterId) { | ||
return ClusterInfo.builder() | ||
.clusterId(clusterId) | ||
.clusterName(clusterName) | ||
.contactPoints(contactPoints) | ||
.port(port) | ||
.localDatacenter(localDatacenter) | ||
.username(username) | ||
.password(password) | ||
.build(); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...core/src/main/java/kr/hakdang/cadio/core/domain/cluster/info/ClusterInfoValidateArgs.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,10 @@ | ||
package kr.hakdang.cadio.core.domain.cluster.info; | ||
|
||
/** | ||
* ClusterInfoValidateArgs | ||
* | ||
* @author akageun | ||
* @since 2024-07-03 | ||
*/ | ||
public class ClusterInfoValidateArgs { | ||
} |
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
Oops, something went wrong.