Skip to content

Commit

Permalink
Develop (0.1.0) (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
akageun authored Aug 5, 2024
2 parents 6d48be9 + d32eb41 commit b4a277a
Show file tree
Hide file tree
Showing 135 changed files with 13,130 additions and 35,803 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @akageun
* @seungh0
30 changes: 20 additions & 10 deletions .github/workflows/ci-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ on:
pull_request:
branches:
- main
- develop
types:
- opened
- synchronize
- reopened
push:
branches:
- main
- develop
workflow_dispatch:

env:
Expand All @@ -31,22 +33,30 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache yarn cache
id: cache-yarn
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
${{ runner.os }}-node_modules-
- name: Install and Build
run: |
npm install
npm run build
yarn install --frozen-lockfile
yarn run build
working-directory: cassdio-web/src/main/webapp
16 changes: 16 additions & 0 deletions .github/workflows/ci-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on:
pull_request:
branches:
- main
- develop
types:
- opened
- synchronize
- reopened
push:
branches:
- main
- develop
workflow_dispatch:

jobs:
Expand All @@ -29,9 +31,23 @@ jobs:
cache: gradle
timeout-minutes: 3

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Test
run: ./gradlew unitTest

- name: Sonarqube analyze
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./gradlew sonar
integration-test:
name: Build on Cassandra
runs-on: ubuntu-latest
Expand Down
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# Cassdio (`Cass`andra Stu`dio`)

Cassdio is centralized web management system for managing [Apache Cassandra](https://cassandra.apache.org/_/index.html)!

Cassdio provide powerful tools to efficiently manage and monitor Apache Cassandra databases. You can monitor the real-time status of your database clusters and perform various tasks intuitively through a user-friendly interface.
Cassdio provide powerful tools to efficiently manage and monitor Apache Cassandra databases. You can monitor the
real-time status of your database clusters and perform various tasks intuitively through a user-friendly interface.

This management system helps simplify system operations and enhance stability. It's an essential tool for managing Apache Cassandra databases, offering excellent functionality and user convenience.
This management system helps simplify system operations and enhance stability. It's an essential tool for managing
Apache Cassandra databases, offering excellent functionality and user convenience.

[![latest-tag](https://badgen.net/github/release/hakdang/cassdio)](https://github.com/hakdang/cassdio/releases)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=hakdang_cassdio&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=hakdang_cassdio)

## Demo

![intro_screenshot](./docs/screenshot/intro_s1.gif)

## Features

- `Multi Cassandra Cluster(With AuthCredentials)`
- Node Monitoring
- `View Keysapce`
Expand All @@ -22,16 +28,17 @@ This management system helps simplify system operations and enhance stability. I
- CQL Query

## Requirements

- JDK 21

### Support Versions
### Support Cassandra Versions

Version | Supported | Cassandra Docs
-- | -- | --
3.11 | O | [Link](https://cassandra.apache.org/doc/3.11/index.html)
4.0 | O | [Link](https://cassandra.apache.org/doc/4.0/index.html)
4.1 | O | [Link](https://cassandra.apache.org/doc/4.1/index.html)
5.0 | O | [Link](https://cassandra.apache.org/doc/5.0/index.html)
Version | Supported | Cassandra Docs
---------|-----------|----------------------------------------------------------
3.11 | O | [Link](https://cassandra.apache.org/doc/3.11/index.html)
4.0 | O | [Link](https://cassandra.apache.org/doc/4.0/index.html)
4.1 | O | [Link](https://cassandra.apache.org/doc/4.1/index.html)
5.0 | O | [Link](https://cassandra.apache.org/doc/5.0/index.html)

## Getting Started

Expand All @@ -45,7 +52,7 @@ java -jar ./cassdio-0.0.2.jar

### Browser

> http://locahost:20000
> http://localhost:20000
### Jar Build Command

Expand All @@ -54,6 +61,7 @@ java -jar ./cassdio-0.0.2.jar
[//]: # (## Environment)

[//]: # ()

[//]: # (env name | description | env value | default value)

[//]: # (-- | -- | -- | --)
Expand All @@ -62,3 +70,7 @@ java -jar ./cassdio-0.0.2.jar

[//]: # ()

## License

Cassdio is Open Source software released under
the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.html).
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.6'
id 'com.github.node-gradle.node' version '7.0.2'
id "org.sonarqube" version "5.1.0.4882"
}

allprojects {
Expand Down Expand Up @@ -77,3 +78,11 @@ subprojects {
}
}
}

sonar {
properties {
property "sonar.projectKey", "hakdang_cassdio"
property "sonar.organization", "hakdang"
property "sonar.host.url", "https://sonarcloud.io"
}
}
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

echo "Cassdio Build!! Start!!!!"

./gradlew :cassdio-web:clean :cassdio-web:build -Pfrontend=true

echo "Cassdio Build!! Complete!!!"
7 changes: 3 additions & 4 deletions cassdio-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ dependencies {
// Spring Boot
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.mapdb:mapdb:3.1.0")
//TODO ClusterFactory 만들어지면 변경
api("com.datastax.oss:java-driver-core:${datastaxJavaDriverVersion}")
api("com.datastax.oss:java-driver-query-builder:${datastaxJavaDriverVersion}")
api("com.datastax.oss:java-driver-mapper-runtime:${datastaxJavaDriverVersion}")
implementation("com.datastax.oss:java-driver-core:${datastaxJavaDriverVersion}")
implementation("com.datastax.oss:java-driver-query-builder:${datastaxJavaDriverVersion}")
implementation("com.datastax.oss:java-driver-mapper-runtime:${datastaxJavaDriverVersion}")
// implementation("com.datastax.oss:java-driver-core:${datastaxJavaDriverVersion}")
// implementation("com.datastax.oss:java-driver-query-builder:${datastaxJavaDriverVersion}")
// implementation("com.datastax.oss:java-driver-mapper-runtime:${datastaxJavaDriverVersion}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package kr.hakdang.cassdio.common.utils;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.UUID;
import java.util.zip.CRC32;

Expand All @@ -9,7 +12,8 @@
* @author akageun
* @since 2024-07-17
*/
public abstract class IdGenerator {
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class IdGenerator {

public static String makeId() {
String uuid = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package kr.hakdang.cassdio.core.domain;

import kr.hakdang.cassdio.core.domain.cluster.CassdioConsistencyLevel;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
* BootstrapProvider
*
* @author akageun
* @since 2024-07-30
*/
@Slf4j
@Service
public class BootstrapProvider {

public Map<String, Object> consistencyLevels() {
Map<String, Object> result = new HashMap<>();
result.put("consistencyLevels", CassdioConsistencyLevel.makeList(DefaultConsistencyLevel.values()));
result.put("defaultConsistencyLevel", CassdioConsistencyLevel.make(DefaultConsistencyLevel.LOCAL_ONE)); //TODO : System Config

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.datastax.oss.driver.internal.core.util.Strings;
import kr.hakdang.cassdio.common.utils.Jsons;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
Expand All @@ -28,6 +29,9 @@
@Slf4j
public abstract class BaseClusterCommander {

@Autowired
protected CqlSessionFactory cqlSessionFactory;

protected List<Map<String, Object>> convertRows(CqlSession session, ResultSet resultSet) {
ColumnDefinitions definitions = resultSet.getColumnDefinitions();
CodecRegistry codecRegistry = session.getContext().getCodecRegistry();
Expand All @@ -47,40 +51,44 @@ protected Map<String, Object> convertRow(CodecRegistry codecRegistry, ColumnDefi
TypeCodec<Object> codec = codecRegistry.codecFor(definition.getType());
Object value = codec.decode(row.getBytesUnsafe(i), row.protocolVersion());

String formatedValue;
if (codec instanceof MapCodec) {
DataType cqlType = codec.getCqlType();
DataType keyType = ((MapType) cqlType).getKeyType();
DataType valueType = ((MapType) cqlType).getValueType();
TypeCodec<Object> keyCodec = codecRegistry.codecFor(keyType);
TypeCodec<Object> valueCodec = codecRegistry.codecFor(valueType);
Map<Object, Object> valueMap = (Map<Object, Object>) value;
Map<String, String> convertedMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : valueMap.entrySet()) {
String key = keyCodec.format(entry.getKey());
if (Strings.isQuoted(key)) {
key = Strings.unquote(key);
}

String entryValue = valueCodec.format(entry.getValue());
if (Strings.isQuoted(entryValue)) {
entryValue = Strings.unquote(entryValue);
}

convertedMap.put(key, entryValue);
String formatedValue = makeFormatedValue(codecRegistry, codec, value);

result.put(name, formatedValue);
}

return result;
}

private static String makeFormatedValue(CodecRegistry codecRegistry, TypeCodec<Object> codec, Object value) {
if (codec instanceof MapCodec) {
DataType cqlType = codec.getCqlType();
DataType keyType = ((MapType) cqlType).getKeyType();
DataType valueType = ((MapType) cqlType).getValueType();
TypeCodec<Object> keyCodec = codecRegistry.codecFor(keyType);
TypeCodec<Object> valueCodec = codecRegistry.codecFor(valueType);
Map<Object, Object> valueMap = (Map<Object, Object>) value;
Map<String, String> convertedMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : valueMap.entrySet()) {
String key = keyCodec.format(entry.getKey());
if (Strings.isQuoted(key)) {
key = Strings.unquote(key);
}

formatedValue = Jsons.toJson(convertedMap);
} else {
formatedValue = codec.format(value);
if (Strings.isQuoted(formatedValue)) {
formatedValue = Strings.unquote(formatedValue);
String entryValue = valueCodec.format(entry.getValue());
if (Strings.isQuoted(entryValue)) {
entryValue = Strings.unquote(entryValue);
}

convertedMap.put(key, entryValue);
}

result.put(name, formatedValue);
return Jsons.toJson(convertedMap);
}

return result;
String formatedValue = codec.format(value);
if (Strings.isQuoted(formatedValue)) {
formatedValue = Strings.unquote(formatedValue);
}
return formatedValue;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.hakdang.cassdio.web.common.dto.response;
package kr.hakdang.cassdio.core.domain.cluster;

import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import lombok.AccessLevel;
Expand Down
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");
}
}
}

}
Loading

0 comments on commit b4a277a

Please sign in to comment.