Skip to content

Commit

Permalink
누락분 적용 (#23)
Browse files Browse the repository at this point in the history
* Cluster Connector Draft

* Cluster Connector Draft

* Cluster Connector Draft

* Cluster Connector Draft
  • Loading branch information
akageun authored Jul 3, 2024
1 parent 3623142 commit f40580c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 53 deletions.
21 changes: 0 additions & 21 deletions cadio-web/src/main/java/kr/hakdang/cadio/web/route/BaseSample.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
import kr.hakdang.cadio.core.domain.cluster.info.ClusterInfoProvider;
import kr.hakdang.cadio.core.domain.cluster.info.ClusterInfoRegisterArgs;
import kr.hakdang.cadio.web.common.dto.response.ApiResponse;
import kr.hakdang.cadio.web.route.BaseSample;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -23,7 +18,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -40,7 +34,7 @@
@Slf4j
@RestController
@RequestMapping("/api/cassandra/cluster")
public class ClusterApi extends BaseSample {
public class ClusterApi {

private final BootstrapProvider bootstrapProvider;
private final ClusterInfoProvider clusterInfoProvider;
Expand Down Expand Up @@ -83,12 +77,7 @@ public ApiResponse<Map<String, Object>> getCassandraClusterDetail(
@PathVariable String clusterId
) {
Map<String, Object> result = new HashMap<>();
try (CqlSession session = makeSession()) { //TODO : interface 작업할 때 facade layer 로 변경 예정
//session.getMetadata().getNodes()
} catch (Exception e) {
log.error("error : {}", e.getMessage(), e);
throw e;
}

return ApiResponse.ok(emptyMap());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import kr.hakdang.cadio.core.domain.cluster.ClusterNode;
import kr.hakdang.cadio.core.domain.cluster.ClusterNodeGetCommander;
import kr.hakdang.cadio.core.domain.cluster.ClusterNodeListCommander;
import kr.hakdang.cadio.core.domain.cluster.TempClusterConnector;
import kr.hakdang.cadio.web.common.dto.response.ApiResponse;
import kr.hakdang.cadio.web.common.dto.response.ItemListWithCursorResponse;
import kr.hakdang.cadio.web.route.BaseSample;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -23,15 +23,18 @@
*/
@RestController
@RequestMapping("/api/cassandra/cluster/{clusterId}")
public class ClusterNodeApi extends BaseSample {
public class ClusterNodeApi {

private final TempClusterConnector tempClusterConnector;
private final ClusterNodeListCommander clusterNodeListCommander;
private final ClusterNodeGetCommander clusterNodeGetCommander;

public ClusterNodeApi(
TempClusterConnector tempClusterConnector,
ClusterNodeListCommander clusterNodeListCommander,
ClusterNodeGetCommander clusterNodeGetCommander
) {
this.tempClusterConnector = tempClusterConnector;
this.clusterNodeListCommander = clusterNodeListCommander;
this.clusterNodeGetCommander = clusterNodeGetCommander;
}
Expand All @@ -40,7 +43,7 @@ public ClusterNodeApi(
public ApiResponse<ItemListWithCursorResponse<ClusterNode, String>> nodeList(
@PathVariable String clusterId
) {
try (CqlSession session = makeSession()) {
try (CqlSession session = tempClusterConnector.makeSession(clusterId)) {
List<ClusterNode> nodes = clusterNodeListCommander.listNodes(session);
return ApiResponse.ok(ItemListWithCursorResponse.noMore(nodes));
}
Expand All @@ -51,7 +54,7 @@ public ApiResponse<ClusterNode> nodeDetail(
@PathVariable String clusterId,
@PathVariable UUID nodeId
) {
try (CqlSession session = makeSession()) {
try (CqlSession session = tempClusterConnector.makeSession(clusterId)) {
ClusterNode result = clusterNodeGetCommander.getNode(session, nodeId);
return ApiResponse.ok(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import kr.hakdang.cadio.core.domain.cluster.keyspace.ClusterKeyspaceDescribeArgs;
import kr.hakdang.cadio.core.domain.cluster.keyspace.ClusterKeyspaceListResult;
import kr.hakdang.cadio.web.common.dto.response.ApiResponse;
import kr.hakdang.cadio.web.route.BaseSample;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -25,7 +24,7 @@
@Slf4j
@RestController
@RequestMapping("/api/cassandra/cluster/{clusterId}")
public class ClusterKeyspaceApi extends BaseSample {
public class ClusterKeyspaceApi {

private final TempClusterConnector tempClusterConnector;
private final ClusterKeyspaceCommander clusterKeyspaceCommander;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import kr.hakdang.cadio.core.domain.cluster.ClusterQueryCommanderResult;
import kr.hakdang.cadio.core.domain.cluster.TempClusterConnector;
import kr.hakdang.cadio.web.common.dto.response.ApiResponse;
import kr.hakdang.cadio.web.route.BaseSample;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -25,7 +24,7 @@
@Slf4j
@RestController
@RequestMapping("/api/cassandra/cluster")
public class ClusterQueryApi extends BaseSample {
public class ClusterQueryApi {

private final TempClusterConnector tempClusterConnector;
private final ClusterQueryCommander clusterQueryCommander;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.datastax.oss.driver.api.core.CqlSession;
import jakarta.validation.Valid;
import kr.hakdang.cadio.core.domain.cluster.TempClusterConnector;
import kr.hakdang.cadio.core.domain.cluster.keyspace.table.ClusterTable;
import kr.hakdang.cadio.core.domain.cluster.keyspace.table.ClusterTableArgs;
import kr.hakdang.cadio.core.domain.cluster.keyspace.table.ClusterTableArgs.ClusterTableGetArgs;
Expand All @@ -13,7 +14,6 @@
import kr.hakdang.cadio.web.common.dto.response.ApiResponse;
import kr.hakdang.cadio.web.common.dto.response.CursorResponse;
import kr.hakdang.cadio.web.common.dto.response.ItemListWithCursorResponse;
import kr.hakdang.cadio.web.route.BaseSample;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -27,15 +27,18 @@
*/
@RestController
@RequestMapping("/api/cassandra/cluster/{clusterId}/keyspace/{keyspace}")
public class ClusterTableApi extends BaseSample {
public class ClusterTableApi {

private final TempClusterConnector tempClusterConnector;
private final ClusterTableListCommander clusterTableListCommander;
private final ClusterTableGetCommander clusterTableGetCommander;

public ClusterTableApi(
TempClusterConnector tempClusterConnector,
ClusterTableListCommander clusterTableListCommander,
ClusterTableGetCommander clusterTableGetCommander
) {
this.tempClusterConnector = tempClusterConnector;
this.clusterTableListCommander = clusterTableListCommander;
this.clusterTableGetCommander = clusterTableGetCommander;
}
Expand All @@ -46,7 +49,7 @@ public ApiResponse<ItemListWithCursorResponse<ClusterTable, String>> listTables(
@PathVariable String keyspace,
@Valid CursorRequest cursorRequest
) {
try (CqlSession session = makeSession()) {
try (CqlSession session = tempClusterConnector.makeSession(clusterId)) {
ClusterTableListResult result = clusterTableListCommander.listTables(session, ClusterTableArgs.ClusterTableListArgs.builder().build().builder()
.keyspace(keyspace)
.limit(cursorRequest.getSize())
Expand All @@ -62,7 +65,7 @@ public ApiResponse<ClusterTableGetResult> getTable(
@PathVariable String keyspace,
@PathVariable String table
) {
try (CqlSession session = makeSession()) {
try (CqlSession session = tempClusterConnector.makeSession(clusterId)) {
ClusterTableGetResult result = clusterTableGetCommander.getTable(session, ClusterTableGetArgs.builder()
.keyspace(keyspace)
.table(table)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package kr.hakdang.cadio.web.route.cluster.table.pureselect;

import com.datastax.oss.driver.api.core.CqlSession;
import kr.hakdang.cadio.core.domain.cluster.ClusterQueryCommanderResult;
import kr.hakdang.cadio.core.domain.cluster.TempClusterConnector;
import kr.hakdang.cadio.core.domain.cluster.keyspace.table.ClusterTableCommander;
import kr.hakdang.cadio.core.domain.cluster.keyspace.table.ClusterTablePureSelectResult;
import kr.hakdang.cadio.web.common.dto.response.ApiResponse;
import kr.hakdang.cadio.web.route.BaseSample;
import kr.hakdang.cadio.web.route.cluster.query.ClusterQueryRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -27,11 +25,14 @@
@Slf4j
@RestController
@RequestMapping("/api/cassandra/cluster/{clusterId}/keyspace/{keyspace}")
public class ClusterTablePureSelectApi extends BaseSample {
public class ClusterTablePureSelectApi {

@Autowired
private ClusterTableCommander clusterTableCommander;

@Autowired
private TempClusterConnector tempClusterConnector;

@PostMapping("/table/{table}/query")
public ApiResponse<Map<String, Object>> clusterQueryCommand(
@PathVariable String clusterId,
Expand All @@ -40,7 +41,7 @@ public ApiResponse<Map<String, Object>> clusterQueryCommand(
@RequestBody ClusterTablePureSelectRequest request
) {
Map<String, Object> map = new HashMap<>();
try (CqlSession session = makeSession()) { //TODO : interface 작업할 때 facade layer 로 변경 예정
try (CqlSession session = tempClusterConnector.makeSession(clusterId)) { //TODO : interface 작업할 때 facade layer 로 변경 예정
ClusterTablePureSelectResult result1 = clusterTableCommander.pureSelect(session, request.makeArgs(keyspace, table));

map.put("wasApplied", result1.isWasApplied());
Expand Down
4 changes: 2 additions & 2 deletions cadio-web/src/main/webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f40580c

Please sign in to comment.