From 80e9ccb4199b2f05c81c1c1b89fa496875265332 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 17 Nov 2023 12:04:58 +0800 Subject: [PATCH 1/3] break --- .../benchmark/mode/TestWithDefaultPathMode.java | 3 ++- .../iot/benchmark/mode/VerificationWriteMode.java | 3 ++- .../edu/tsinghua/iot/benchmark/tsdb/DBWrapper.java | 14 ++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java index 4e7c83b85..8d3b03df2 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java @@ -45,7 +45,8 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - return cleanUpData(dbConfigs, measurement) && registerSchema(measurement); + return cleanUpData(dbConfigs, measurement) + && (!config.isCREATE_SCHEMA() || registerSchema(measurement)); } @Override diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java index f56446179..60be64bff 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java @@ -40,7 +40,8 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - return cleanUpData(dbConfigs, measurement) && registerSchema(measurement); + return cleanUpData(dbConfigs, measurement) + && (!config.isCREATE_SCHEMA() || registerSchema(measurement)); } @Override diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBWrapper.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBWrapper.java index 11491eaed..efa398dbd 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBWrapper.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/tsdb/DBWrapper.java @@ -510,15 +510,13 @@ public Double registerSchema(List schemaList) throws TsdbException double createSchemaTimeInSecond = 0.0; LOGGER.info("Registering schema..."); try { - if (config.isCREATE_SCHEMA()) { - for (IDatabase database : databases) { - Double registerTime = database.registerSchema(schemaList); - if (null == registerTime) { - LOGGER.error("Failed to create schema for {}.", database.getClass().getName()); - return null; - } - createSchemaTimeInSecond = Math.max(createSchemaTimeInSecond, registerTime); + for (IDatabase database : databases) { + Double registerTime = database.registerSchema(schemaList); + if (null == registerTime) { + LOGGER.error("Failed to create schema for {}.", database.getClass().getName()); + return null; } + createSchemaTimeInSecond = Math.max(createSchemaTimeInSecond, registerTime); } measurement.setCreateSchemaTime(createSchemaTimeInSecond); } catch (Exception e) { From b73b35d24e6a8ab36c24c503e18f32477c39b6ce Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 13 Dec 2023 17:07:40 +0800 Subject: [PATCH 2/3] better --- .../iot/benchmark/mode/TestWithDefaultPathMode.java | 11 +++++++++-- .../iot/benchmark/mode/VerificationWriteMode.java | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java index 8d3b03df2..78f49dd57 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java @@ -45,8 +45,15 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - return cleanUpData(dbConfigs, measurement) - && (!config.isCREATE_SCHEMA() || registerSchema(measurement)); + if (!cleanUpData(dbConfigs, measurement)) { + return false; + } + if (config.isCREATE_SCHEMA()) { + if (!registerSchema(measurement)) { + return false; + } + } + return true; } @Override diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java index 60be64bff..4d209f9c1 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java @@ -40,8 +40,15 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - return cleanUpData(dbConfigs, measurement) - && (!config.isCREATE_SCHEMA() || registerSchema(measurement)); + if (!cleanUpData(dbConfigs, measurement)) { + return false; + } + if (config.isCREATE_SCHEMA()) { + if (!registerSchema(measurement)) { + return false; + } + } + return true; } @Override From d251ae0a3b9fa792181804f0090a96fc1c813a8f Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 13 Dec 2023 17:42:42 +0800 Subject: [PATCH 3/3] is delete data --- .../cn/edu/tsinghua/iot/benchmark/mode/BaseMode.java | 12 +++++------- .../iot/benchmark/mode/TestWithDefaultPathMode.java | 6 ++++-- .../iot/benchmark/mode/VerificationWriteMode.java | 6 ++++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/BaseMode.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/BaseMode.java index ad9147f4f..4cbd14bb4 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/BaseMode.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/BaseMode.java @@ -115,13 +115,11 @@ protected boolean cleanUpData(List dbConfigs, Measurement measurement) DBWrapper dbWrapper = new DBWrapper(dbConfigs, measurement); try { dbWrapper.init(); - if (config.isIS_DELETE_DATA()) { - try { - dbWrapper.cleanup(); - } catch (TsdbException e) { - LOGGER.error("Cleanup {} failed because ", config.getNET_DEVICE(), e); - return false; - } + try { + dbWrapper.cleanup(); + } catch (TsdbException e) { + LOGGER.error("Cleanup {} failed because ", config.getNET_DEVICE(), e); + return false; } } catch (TsdbException e) { LOGGER.error("Initialize {} failed because ", config.getNET_DEVICE(), e); diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java index 78f49dd57..c7b922383 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/TestWithDefaultPathMode.java @@ -45,8 +45,10 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - if (!cleanUpData(dbConfigs, measurement)) { - return false; + if (config.isIS_DELETE_DATA()) { + if (!cleanUpData(dbConfigs, measurement)) { + return false; + } } if (config.isCREATE_SCHEMA()) { if (!registerSchema(measurement)) { diff --git a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java index 4d209f9c1..efc6143e4 100644 --- a/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java +++ b/core/src/main/java/cn/edu/tsinghua/iot/benchmark/mode/VerificationWriteMode.java @@ -40,8 +40,10 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - if (!cleanUpData(dbConfigs, measurement)) { - return false; + if (config.isIS_DELETE_DATA()) { + if (!cleanUpData(dbConfigs, measurement)) { + return false; + } } if (config.isCREATE_SCHEMA()) { if (!registerSchema(measurement)) {