Skip to content

Commit

Permalink
미사용 코드들 제거 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
seungh0 authored Jul 7, 2024
1 parent bf24ab3 commit 8874d64
Show file tree
Hide file tree
Showing 22 changed files with 37 additions and 153 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# CassDio

- `Cass`andra Stu`dio`

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package kr.hakdang.cassdio.core.domain.bootstrap;

import kr.hakdang.cassdio.core.domain.cluster.info.ClusterInfoProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.TraceEvent;
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry;
import com.datastax.oss.protocol.internal.util.Bytes;
import io.micrometer.common.util.StringUtils;
Expand All @@ -18,7 +17,6 @@
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import kr.hakdang.cassdio.common.Jsons;
import kr.hakdang.cassdio.core.domain.bootstrap.BootstrapProvider;
import kr.hakdang.cassdio.core.domain.cluster.ClusterUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -21,18 +20,6 @@
@Service
public class ClusterInfoManager extends BaseClusterInfo {

private final BootstrapProvider bootstrapProvider;

private final ClusterInfoProvider clusterInfoProvider;

public ClusterInfoManager(
BootstrapProvider bootstrapProvider,
ClusterInfoProvider clusterInfoProvider
) {
this.bootstrapProvider = bootstrapProvider;
this.clusterInfoProvider = clusterInfoProvider;
}

public void register(ClusterInfoRegisterArgs args) {
ObjectMapper om = Jsons.OBJECT_MAPPER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,25 @@ private ClusterTableListArgs(String keyspace, int limit, String nextPageState) {

}

@ToString
@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class ClusterTablePureSelectArgs {

private String keyspace;
private String table;

private int pageSize; //TODO : max check

private String cursor;

@Builder
public ClusterTablePureSelectArgs(String keyspace, String table, int pageSize, String cursor) {
this.keyspace = keyspace;
this.table = table;
this.pageSize = pageSize;
this.cursor = cursor;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import kr.hakdang.cassdio.core.domain.cluster.BaseClusterCommander;
import kr.hakdang.cassdio.core.domain.cluster.ClusterUtils;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.CassandraSystemKeyspace;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableArgs.ClusterTablePureSelectArgs;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.column.CassandraSystemTablesColumn;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.datastax.oss.protocol.internal.util.Bytes;
import io.micrometer.common.util.StringUtils;
import kr.hakdang.cassdio.core.domain.cluster.BaseClusterCommander;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableArgs.ClusterTableListArgs;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.CassandraSystemKeyspace;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableArgs.ClusterTableListArgs;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.column.CassandraSystemTablesColumn;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -37,16 +37,6 @@ public ClusterTableListResult listTables(CqlSession session, ClusterTableListArg
.build(args.getKeyspace())
.setPagingState(StringUtils.isBlank(args.getNextPageState()) ? null : Bytes.fromHexString(args.getNextPageState()));

// for (Map.Entry<CqlIdentifier, TableMetadata> entry : session.getMetadata().getKeyspace(args.getKeyspace())
// .orElseThrow().getTables().entrySet()) {
// log.info("key : {}, value : {}", entry.getKey(), entry.getValue());
// }

// ResultSet rs2 = session.execute("DESC " + args.getKeyspace());
// for (Row row : rs2.all()) {
// log.info("222row : {}", row.getFormattedContents());
// }

ResultSet rs = session.execute(statement);

List<ClusterTable> tables = rs.all().stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
package kr.hakdang.cassdio.core.domain.cluster.keyspace.table;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* ClusterTablePureSelectArgs
*
* @author akageun
* @since 2024-06-30
*/
@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ClusterTablePureSelectArgs {

private String keyspace;
private String table;

private int pageSize; //TODO : max check

private String cursor;

@Builder
public ClusterTablePureSelectArgs(String keyspace, String table, int pageSize, String cursor) {
this.keyspace = keyspace;
this.table = table;
this.pageSize = pageSize;
this.cursor = cursor;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.hakdang.cassdio.core.domain.cluster.keyspace.table;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
@Getter
public enum CacheType {

// TODO: 만료시간은 5분으로 가져가돼, N분마다 api를 쏴서 클러스터에 대한 정보를 갱신하는 것도 좋을듯
CLUSTER_LIST(CacheTypeNames.CLUSTER_LIST, Duration.ofMinutes(5)),
CLUSTER(CacheTypeNames.CLUSTER, Duration.ofMinutes(5)),
TABLE_LIST(CacheTypeNames.TABLE_LIST, Duration.ofMinutes(5)),
TABLE(CacheTypeNames.TABLE, Duration.ofMinutes(5)),
;

private final String key;
Expand All @@ -34,9 +30,6 @@ public enum CacheType {
public static class CacheTypeNames {

public static final String CLUSTER_LIST = "clusterList";
public static final String CLUSTER = "cluster";
public static final String TABLE_LIST = "tableList";
public static final String TABLE = "table";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class InitConfig implements InitializingBean {
private ClusterInfoProvider clusterInfoProvider;

@Override
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
bootstrapProvider.updateMinClusterCountCheck(clusterInfoProvider.checkMinClusterCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ public ApiResponse<Map<String, Object>> getCassandraClusterDetail(
public ApiResponse<Map<String, Object>> clusterRegister(
@Valid @RequestBody ClusterRegisterRequest request
) {
try (
CqlSession session = tempClusterConnector.makeSession(request.makeClusterConnector());
) {
try (CqlSession session = tempClusterConnector.makeSession(request.makeClusterConnector())) {
String clusterName = session.getMetadata().getClusterName()
.orElse(UUID.randomUUID().toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.internal.core.metadata.schema.queries.KeyspaceFilter;
import kr.hakdang.cassdio.core.domain.cluster.ClusterUtils;
import kr.hakdang.cassdio.core.domain.cluster.TempClusterConnector;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.ClusterKeyspaceCommander;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.ClusterKeyspaceListResult;
import kr.hakdang.cassdio.core.support.cache.CacheType;
import kr.hakdang.cassdio.core.domain.cluster.ClusterUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
Expand Down Expand Up @@ -71,15 +71,4 @@ public void refreshKeyspaceCache(String clusterId) {
log.info("ClusterList ({}) is evicted", clusterId);
}

// @Cacheable(value = CacheType.CacheTypeNames.CLUSTER_LIST)
// public String getKeyspace(String clusterId, String keyspace) {
// try (CqlSession session = tempClusterConnector.makeSession(clusterId)) {
// return clusterKeyspaceCommander.describe(session, ClusterKeyspaceDescribeArgs.builder()
// .keyspace(keyspace)
// .withChildren(false)
// .pretty(true)
// .build());
// }
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import kr.hakdang.cassdio.core.domain.cluster.TempClusterConnector;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTable;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableArgs;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableArgs.ClusterTableListArgs;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableCommander;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableGetCommander;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableGetResult2;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableListCommander;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableListResult;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.column.ClusterTableColumnCommander;
import kr.hakdang.cassdio.web.common.dto.request.CursorRequest;
import kr.hakdang.cassdio.web.common.dto.response.CursorResponse;
import kr.hakdang.cassdio.web.common.dto.response.ItemListWithCursorResponse;
Expand All @@ -26,28 +25,21 @@ public class ClusterTableReader {

private final TempClusterConnector tempClusterConnector;
private final ClusterTableListCommander clusterTableListCommander;
private final ClusterTableGetCommander clusterTableGetCommander;
private final ClusterTableCommander clusterTableCommander;
private final ClusterTableColumnCommander clusterTableColumnCommander;

public ClusterTableReader(
TempClusterConnector tempClusterConnector,
ClusterTableListCommander clusterTableListCommander,
ClusterTableGetCommander clusterTableGetCommander,
ClusterTableCommander clusterTableCommander,
ClusterTableColumnCommander clusterTableColumnCommander
ClusterTableCommander clusterTableCommander
) {
this.tempClusterConnector = tempClusterConnector;
this.clusterTableListCommander = clusterTableListCommander;
this.clusterTableGetCommander = clusterTableGetCommander;
this.clusterTableCommander = clusterTableCommander;
this.clusterTableColumnCommander = clusterTableColumnCommander;
}

//@Cacheable(value = CacheType.CacheTypeNames.TABLE_LIST, condition = "#cursorRequest.cursor == null")
public ItemListWithCursorResponse<ClusterTable, String> listTables(String clusterId, String keyspace, CursorRequest cursorRequest) {
try (CqlSession session = tempClusterConnector.makeSession(clusterId, keyspace)) {
ClusterTableListResult result = clusterTableListCommander.listTables(session, ClusterTableArgs.ClusterTableListArgs.builder().build().builder()
ClusterTableListResult result = clusterTableListCommander.listTables(session, ClusterTableListArgs.builder()
.keyspace(keyspace)
.limit(cursorRequest.getSize())
.nextPageState(cursorRequest.getCursor())
Expand All @@ -57,12 +49,9 @@ public ItemListWithCursorResponse<ClusterTable, String> listTables(String cluste
}
}

//@Cacheable(value = CacheType.CacheTypeNames.TABLE)
public ClusterTableGetResult2 getTable(String clusterId, String keyspace, String table, boolean withTableDescribe) {
try (CqlSession session = tempClusterConnector.makeSession(clusterId)) {

clusterTableColumnCommander.columnList(session, keyspace, table);

return clusterTableCommander.tableDetail(session, ClusterTableArgs.ClusterTableGetArgs.builder()
.keyspace(keyspace)
.table(table)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.hakdang.cassdio.web.route.cluster.keyspace.table.pureselect;

import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTablePureSelectArgs;
import kr.hakdang.cassdio.core.domain.cluster.keyspace.table.ClusterTableArgs.ClusterTablePureSelectArgs;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ClusterQueryRequest {
private boolean trace = false;

private String nextCursor;

@Builder
public ClusterQueryRequest(String query, String cursor, int pageSize, int timeoutSeconds, boolean trace) {
this.query = query;
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-cassandra-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- cassdio_cassandra_data_1:/var/lib/cassandra
- ./conf/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
test: [ "CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 30s
timeout: 10s
retries: 10
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-cassandra-4.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- cassdio_cassandra_data_1:/var/lib/cassandra
- ./conf/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
test: [ "CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 30s
timeout: 10s
retries: 10
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-cassandra-4.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- cassdio_cassandra_data_1:/var/lib/cassandra
- ./conf/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
test: [ "CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 30s
timeout: 10s
retries: 10
Expand Down
Loading

0 comments on commit 8874d64

Please sign in to comment.