diff --git a/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTableCommander.java b/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTableCommander.java index 2d1141bf..102fb433 100644 --- a/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTableCommander.java +++ b/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTableCommander.java @@ -35,7 +35,11 @@ public class ClusterTableCommander extends BaseClusterCommander { public ClusterTablePureSelectResult pureSelect(CqlSession session, ClusterTablePureSelectArgs args) { - SimpleStatement statement = QueryBuilder.selectFrom(args.getKeyspace(), args.getTable()).all().build().setPageSize(args.getLimit()).setTimeout(Duration.ofSeconds(3)) // 3s timeout + SimpleStatement statement = QueryBuilder.selectFrom(args.getKeyspace(), args.getTable()) + .all() + .build() + .setPageSize(args.getPageSize()) + .setTimeout(Duration.ofSeconds(3)) // 3s timeout .setPagingState(StringUtils.isNotBlank(args.getCursor()) ? Bytes.fromHexString(args.getCursor()) : null); ResultSet resultSet = session.execute(statement); @@ -47,7 +51,6 @@ public ClusterTablePureSelectResult pureSelect(CqlSession session, ClusterTableP rows.add(convertMap(definitions, page1Iter.next())); } - String previewCursor = args.getCursor(); String nextCursor = ""; ByteBuffer pagingState = resultSet.getExecutionInfo().getPagingState(); if (pagingState != null) { @@ -63,8 +66,7 @@ public ClusterTablePureSelectResult pureSelect(CqlSession session, ClusterTableP .wasApplied(resultSet.wasApplied()) .columnNames(columnNames) .rows(rows) - .nextToken(nextCursor) - .previewToken(previewCursor) + .nextCursor(nextCursor) .build(); } diff --git a/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectArgs.java b/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectArgs.java index 5b250c62..3133cd45 100644 --- a/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectArgs.java +++ b/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectArgs.java @@ -18,15 +18,15 @@ public class ClusterTablePureSelectArgs { private String keyspace; private String table; - private int limit; //TODO : max check + private int pageSize; //TODO : max check private String cursor; @Builder - public ClusterTablePureSelectArgs(String keyspace, String table, int limit, String cursor) { + public ClusterTablePureSelectArgs(String keyspace, String table, int pageSize, String cursor) { this.keyspace = keyspace; this.table = table; - this.limit = limit; + this.pageSize = pageSize; this.cursor = cursor; } } diff --git a/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectResult.java b/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectResult.java index 8b112e64..22bd2ed9 100644 --- a/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectResult.java +++ b/cadio-core/src/main/java/kr/hakdang/cadio/core/domain/cluster/keyspace/table/ClusterTablePureSelectResult.java @@ -20,15 +20,13 @@ public class ClusterTablePureSelectResult { private boolean wasApplied; private List columnNames; private List> rows; - private String previewToken; - private String nextToken; + private String nextCursor; @Builder - public ClusterTablePureSelectResult(boolean wasApplied, List columnNames, List> rows, String previewToken, String nextToken) { + public ClusterTablePureSelectResult(boolean wasApplied, List columnNames, List> rows, String nextCursor) { this.wasApplied = wasApplied; this.columnNames = columnNames; this.rows = rows; - this.previewToken = previewToken; - this.nextToken = nextToken; + this.nextCursor = nextCursor; } } diff --git a/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/query/ClusterQueryResponse.java b/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/query/ClusterQueryResponse.java index c4198344..6cc9ae09 100644 --- a/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/query/ClusterQueryResponse.java +++ b/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/query/ClusterQueryResponse.java @@ -9,6 +9,7 @@ /** * ClusterQueryResponse + * TODO : 변경필요 * * @author akageun * @since 2024-07-03 diff --git a/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/table/pureselect/ClusterTablePureSelectApi.java b/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/table/pureselect/ClusterTablePureSelectApi.java new file mode 100644 index 00000000..494d325e --- /dev/null +++ b/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/table/pureselect/ClusterTablePureSelectApi.java @@ -0,0 +1,57 @@ +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.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; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +/** + * ClusterTablePureSelectApi + * + * @author akageun + * @since 2024-07-03 + */ +@Slf4j +@RestController +@RequestMapping("/api/cassandra/cluster/{clusterId}/keyspace/{keyspace}") +public class ClusterTablePureSelectApi extends BaseSample { + + @Autowired + private ClusterTableCommander clusterTableCommander; + + @PostMapping("/table/{table}/query") + public ApiResponse> clusterQueryCommand( + @PathVariable String clusterId, + @PathVariable String keyspace, + @PathVariable String table, + @RequestBody ClusterTablePureSelectRequest request + ) { + Map map = new HashMap<>(); + try (CqlSession session = makeSession()) { //TODO : interface 작업할 때 facade layer 로 변경 예정 + ClusterTablePureSelectResult result1 = clusterTableCommander.pureSelect(session, request.makeArgs(keyspace, table)); + + map.put("wasApplied", result1.isWasApplied()); + map.put("nextCursor", result1.getNextCursor()); + map.put("rows", result1.getRows()); + map.put("columnNames", result1.getColumnNames()); + } catch (Exception e) { + log.error("error : {}", e.getMessage(), e); + throw e; + } + + return ApiResponse.ok(map); + } +} diff --git a/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/table/pureselect/ClusterTablePureSelectRequest.java b/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/table/pureselect/ClusterTablePureSelectRequest.java new file mode 100644 index 00000000..b5a4e9b8 --- /dev/null +++ b/cadio-web/src/main/java/kr/hakdang/cadio/web/route/cluster/table/pureselect/ClusterTablePureSelectRequest.java @@ -0,0 +1,35 @@ +package kr.hakdang.cadio.web.route.cluster.table.pureselect; + +import kr.hakdang.cadio.core.domain.cluster.keyspace.table.ClusterTablePureSelectArgs; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * ClusterTablePureSelectRequest + * + * @author akageun + * @since 2024-07-03 + */ +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class ClusterTablePureSelectRequest { + private String cursor; + private int pageSize; + + @Builder + public ClusterTablePureSelectRequest(String cursor, int pageSize) { + this.cursor = cursor; + this.pageSize = pageSize; + } + + public ClusterTablePureSelectArgs makeArgs(String keyspace, String table) { + return ClusterTablePureSelectArgs.builder() + .keyspace(keyspace) + .table(table) + .cursor(cursor) + .pageSize(pageSize) + .build(); + } +} diff --git a/cadio-web/src/main/webapp/src/App.js b/cadio-web/src/main/webapp/src/App.js index 74e38001..f40e82da 100644 --- a/cadio-web/src/main/webapp/src/App.js +++ b/cadio-web/src/main/webapp/src/App.js @@ -19,6 +19,10 @@ import {useCadioState} from "./pages/commons/context/cadioContext"; import InitializeView from "./pages/commons/initialize-view"; import NodesHome from "./pages/cluster/components/nodes-home"; import SystemView from "./pages/system/system-view"; +import TableRows from "./pages/cluster/components/keyspace/table/table-rows"; +import TableInformation from "./pages/cluster/components/keyspace/table/table-information"; +import TableImport from "./pages/cluster/components/keyspace/table/table-import"; +import TableExport from "./pages/cluster/components/keyspace/table/table-export"; function App() { const {doBootstrap} = useCadio(); @@ -68,8 +72,19 @@ function App() { }> }> - + element={ + }> + }> + }> + }> }> {/* 상단에 위치하는 라우트들의 규칙을 모두 확인, 일치하는 라우트가 없는경우 처리 */} diff --git a/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-export.js b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-export.js new file mode 100644 index 00000000..5d9f259a --- /dev/null +++ b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-export.js @@ -0,0 +1,10 @@ +const TableExport = () => { + + return ( + <> + Export + + ) +} + +export default TableExport; diff --git a/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-home.js b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-home.js index 74e01431..47f9ce7c 100644 --- a/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-home.js +++ b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-home.js @@ -2,8 +2,8 @@ import {Link, useParams} from "react-router-dom"; import {useClusterState} from "../../../context/clusterContext"; import {useEffect} from "react"; -const TableHome = () => { - +const TableHome = (props) => { + console.log("props : ", props.submenu); const routeParams = useParams(); //const {doGetKeyspaceList} = useCluster(); @@ -68,68 +68,52 @@ const TableHome = () => { -
- - - - - - - - - - - - { - new Array(1000).fill({ - t1: "test", - t2: "value", - t3: "tttt", - t4: "adfasdfasd" - }).map((info, infoIndex) => { - return ( - - - - - - - - ) - }) - } - - -
#HeaderHeaderHeaderHeader
{info.t1}{info.t2}{info.t3}{info.t4}
-
- - + {props.children} ) } diff --git a/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-import.js b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-import.js new file mode 100644 index 00000000..31716a49 --- /dev/null +++ b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-import.js @@ -0,0 +1,10 @@ +const TableImport = () => { + + return ( + <> + Infomation + + ) +} + +export default TableImport; diff --git a/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-information.js b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-information.js new file mode 100644 index 00000000..7fb93bbe --- /dev/null +++ b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-information.js @@ -0,0 +1,10 @@ +const TableInformation = () => { + + return ( + <> + Infomation + + ) +} + +export default TableInformation; diff --git a/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-rows.js b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-rows.js new file mode 100644 index 00000000..b7456963 --- /dev/null +++ b/cadio-web/src/main/webapp/src/pages/cluster/components/keyspace/table/table-rows.js @@ -0,0 +1,48 @@ +const TableRows = () => { + + return ( +
+
+
Rows
+ +
+ + + + + + + + + + + + { + new Array(1000).fill({ + t1: "test", + t2: "value", + t3: "tttt", + t4: "adfasdfasd" + }).map((info, infoIndex) => { + return ( + + + + + + + + ) + }) + } + + +
#HeaderHeaderHeaderHeader
{info.t1}{info.t2}{info.t3}{info.t4}
+
+
+ +
+ ) +} + +export default TableRows;