Skip to content

Commit

Permalink
refactor(demo): Simplified configuration and docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Ruaux committed Feb 9, 2023
1 parent 15a0378 commit a2879bd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
Binary file modified demo/redis-smart-cache-demo/grafana/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion demo/redis-smart-cache-demo/redis-smart-cache-demo.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ dependencies {
runtimeOnly group: 'com.ibm.db2', name: 'jcc', version: db2Version
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
}

tasks.bootJar.dependsOn ':redis-smart-cache-jdbc:shadowJar'
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ private void load(Connection connection, String table, String[] columns, RowProv
for (int index = start; index < end; index++) {
rowProvider.set(preparedStatement, config.getDemo(), index);
preparedStatement.addBatch();
if (index > 0 && index % config.getDemo().getBatchSize() == 0) {
if (index > 0 && index % config.getDemo().getBatch() == 0) {
preparedStatement.executeBatch();
connection.commit();
preparedStatement.close();
preparedStatement = preparedStatement.getConnection().prepareStatement(insertSQL);
progressBar.stepBy(config.getDemo().getBatchSize());
progressBar.stepBy(config.getDemo().getBatch());
}
}
preparedStatement.executeBatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public void setDemo(DataConfig demo) {
public static class DataConfig {

private boolean flush;
private int queryThreads;
private int batchSize;
private int threads;
private int batch;
private int customers;
private int products;
private int orders;
Expand Down Expand Up @@ -70,20 +70,20 @@ public void setOrderdetails(int orderdetails) {
this.orderdetails = orderdetails;
}

public int getBatchSize() {
return batchSize;
public int getBatch() {
return batch;
}

public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
public void setBatch(int size) {
this.batch = size;
}

public int getQueryThreads() {
return queryThreads;
public int getThreads() {
return threads;
}

public void setQueryThreads(int queryThreads) {
this.queryThreads = queryThreads;
public void setThreads(int threads) {
this.threads = threads;
}

public boolean isFlush() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ public void execute() throws InterruptedException, ExecutionException, IOExcepti
hikariConfig.setPassword(dataSourceProperties.determinePassword());
try (HikariDataSource dataSource = new HikariDataSource(hikariConfig)) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(config.getDemo().getQueryThreads());
executor.setMaxPoolSize(config.getDemo().getQueryThreads());
executor.setCorePoolSize(config.getDemo().getThreads());
executor.setMaxPoolSize(config.getDemo().getThreads());
executor.setThreadNamePrefix("query-task");
executor.initialize();
ProgressBarBuilder progressBarBuilder = new ProgressBarBuilder();
progressBarBuilder.setTaskName("Querying");
progressBarBuilder.showSpeed();
progressBar = progressBarBuilder.build();
List<Future<Integer>> futures = new ArrayList<>();
for (int index = 0; index < config.getDemo().getQueryThreads(); index++) {
for (int index = 0; index < config.getDemo().getThreads(); index++) {
QueryTask task = new QueryTask(dataSource, config.getDemo().getOrders(), progressBar);
tasks.add(task);
futures.add(executor.submit(task));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ logging.level.org.springframework=INFO
# logging.level.org.springframework.web=DEBUG
# logging.level.org.springframework.context.annotation=TRACE

demo.batch-size=1000
demo.batch=1000
demo.customers=1000
demo.products=1000
demo.orders=100
demo.orderdetails=500
demo.query-threads=8
demo.threads=8
smartcache.metrics-step=5s
smartcache.config-step=1s
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
mysql:
image: mysql:latest
hostname: mysql
container_name: mysql
ports:
- 3306:3306
environment:
Expand All @@ -18,6 +19,7 @@ services:
grafana:
image: grafana/grafana
hostname: grafana
container_name: grafana
ports:
- 3000:3000
environment:
Expand All @@ -26,12 +28,14 @@ services:
redis:
image: redis/redis-stack-server
hostname: redis
container_name: redis
ports:
- 6379:6379

redis-smart-cache-demo:
demo:
image: fieldengineering/redis-demo-smart-cache
hostname: smartcache
container_name: smart-cache-demo
build: .
restart: on-failure
depends_on:
Expand Down

0 comments on commit a2879bd

Please sign in to comment.