Skip to content

Commit

Permalink
Don't show "Registering schema..." when CREATE_SCHEMA=false (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 authored Dec 13, 2023
1 parent bb0f9d9 commit 9d8c666
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,11 @@ protected boolean cleanUpData(List<DBConfig> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,13 @@ public Double registerSchema(List<DeviceSchema> 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) {
Expand Down

0 comments on commit 9d8c666

Please sign in to comment.