-
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
4 changed files
with
113 additions
and
76 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
45 changes: 45 additions & 0 deletions
45
cassdio-core/src/main/java/kr/hakdang/cassdio/core/support/MapDBConfig.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,45 @@ | ||
package kr.hakdang.cassdio.core.support; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.mapdb.DB; | ||
import org.mapdb.DBMaker; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* MapDBConfig | ||
* | ||
* @author akageun | ||
* @since 2024-07-19 | ||
*/ | ||
@Slf4j | ||
@Configuration | ||
public class MapDBConfig { | ||
|
||
@Bean(name = "mapDb", destroyMethod = "close") | ||
public DB mapDb() { | ||
File file = new File(System.getProperty("user.home") + "/.cassdio"); | ||
if (!file.exists()) { | ||
file.mkdir(); | ||
} | ||
|
||
DBMaker.Maker maker = DBMaker | ||
//TODO : 추후 프로퍼티 받아서 주입할 수 있도록 변경 예정 | ||
.fileDB(System.getProperty("user.home") + "/.cassdio/cassdio_v1.db") | ||
.fileMmapEnable() // Always enable mmap | ||
.fileMmapEnableIfSupported() // Only enable mmap on supported platforms | ||
.fileMmapPreclearDisable() // Make mmap file faster | ||
.transactionEnable() | ||
.fileLockDisable() | ||
// Unmap (release resources) file when its closed. | ||
// That can cause JVM crash if file is accessed after it was unmapped | ||
// (there is possible race condition). | ||
.cleanerHackEnable(); | ||
|
||
return maker.make(); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
cassdio-core/src/test/java/kr/hakdang/cassdio/core/support/MapDBConfigTest.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,26 @@ | ||
package kr.hakdang.cassdio.core.support; | ||
|
||
import org.mapdb.DB; | ||
import org.mapdb.DBMaker; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
import java.io.File; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@TestConfiguration | ||
class MapDBConfigTest { | ||
|
||
|
||
@Bean(name = "mapDb") | ||
public DB mapDb() { | ||
DBMaker.Maker maker = DBMaker | ||
.memoryDB(); | ||
|
||
|
||
return maker.make(); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,34 +1,38 @@ | ||
apply plugin: "com.github.node-gradle.node" | ||
def frontend = project.findProperty('frontend') ?: false | ||
if (frontend.toBoolean()) { | ||
|
||
def projectDir = file("${project.rootDir}/cassdio-web/src/main/webapp") | ||
apply plugin: "com.github.node-gradle.node" | ||
|
||
node { | ||
version = '20.15.1' | ||
npmVersion = '9.8.0' | ||
download = true | ||
def projectDir = file("${project.rootDir}/cassdio-web/src/main/webapp") | ||
|
||
nodeProjectDir.set(projectDir) | ||
} | ||
node { | ||
version = '20.15.1' | ||
npmVersion = '9.8.0' | ||
download = true | ||
|
||
task npmInstall2(type: NpmTask) { | ||
args = ['install'] | ||
} | ||
nodeProjectDir.set(projectDir) | ||
} | ||
|
||
task npmBuild(type: NpmTask, dependsOn: npmInstall2) { | ||
args = ['run', 'build'] | ||
} | ||
task npmInstall2(type: NpmTask) { | ||
args = ['install'] | ||
} | ||
|
||
task copyDist(type: Copy, dependsOn: npmBuild) { | ||
from("${projectDir}/build") { | ||
include '**/*' | ||
task npmBuild(type: NpmTask, dependsOn: npmInstall2) { | ||
args = ['run', 'build'] | ||
} | ||
into "${project.rootDir}/cassdio-web/src/main/resources/static" | ||
includeEmptyDirs = true | ||
} | ||
|
||
task deleteDist(type: Delete, dependsOn: copyDist) { | ||
delete "${projectDir}/build" | ||
} | ||
task copyDist(type: Copy, dependsOn: npmBuild) { | ||
from("${projectDir}/build") { | ||
include '**/*' | ||
} | ||
into "${project.rootDir}/cassdio-web/src/main/resources/static" | ||
includeEmptyDirs = true | ||
} | ||
|
||
processResources { dependsOn "deleteDist" } | ||
task deleteDist(type: Delete, dependsOn: copyDist) { | ||
delete "${projectDir}/build" | ||
} | ||
|
||
processResources { dependsOn "deleteDist" } | ||
|
||
} |