From 9d8c6668f19d5f12e1ecd11eacb372dd40a0b4a5 Mon Sep 17 00:00:00 2001 From: Li Yu Heng Date: Wed, 13 Dec 2023 17:45:37 +0800 Subject: [PATCH] Don't show "Registering schema..." when CREATE_SCHEMA=false (#381) --- .../edu/tsinghua/iot/benchmark/mode/BaseMode.java | 12 +++++------- .../benchmark/mode/TestWithDefaultPathMode.java | 12 +++++++++++- .../iot/benchmark/mode/VerificationWriteMode.java | 12 +++++++++++- .../edu/tsinghua/iot/benchmark/tsdb/DBWrapper.java | 14 ++++++-------- 4 files changed, 33 insertions(+), 17 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 4e7c83b85..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,7 +45,17 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - return cleanUpData(dbConfigs, measurement) && registerSchema(measurement); + if (config.isIS_DELETE_DATA()) { + 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 f56446179..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,7 +40,17 @@ protected boolean preCheck() { if (config.isIS_DOUBLE_WRITE()) { dbConfigs.add(config.getANOTHER_DBConfig()); } - return cleanUpData(dbConfigs, measurement) && registerSchema(measurement); + if (config.isIS_DELETE_DATA()) { + 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/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) {