Skip to content

Commit

Permalink
[#6112] Use a variable to unify Derby path
Browse files Browse the repository at this point in the history
  • Loading branch information
realJackSun committed Jun 20, 2021
1 parent 0d3bf61 commit 67eeb20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,7 @@ public class Constants {
public static final String CONFIG_EXPORT_METADATA = ".meta.yml";

public static final String CONFIG_EXPORT_METADATA_NEW = ".metadata.yml";

public static final String DERBY_PATH_NAME = "derby-data";

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class LocalDataSourceServiceImpl implements DataSourceService {

private final String password = "nacos";

private final String derbyBaseDir = "data" + File.separator + "derby-data";
private final String derbyBaseDir = "data" + File.separator + Constants.DERBY_PATH_NAME;

private final String derbyShutdownErrMsg = "Derby system shutdown.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.alibaba.nacos.config.server.service.repository.embedded;

import com.alibaba.nacos.common.notify.NotifyCenter;
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.model.event.DerbyLoadEvent;
import com.alibaba.nacos.config.server.service.datasource.DataSourceService;
import com.alibaba.nacos.config.server.service.datasource.DynamicDataSource;
Expand Down Expand Up @@ -61,7 +62,7 @@ public class DerbySnapshotOperation implements SnapshotOperation {

private final String snapshotArchive = "derby_data.zip";

private final String derbyBaseDir = Paths.get(EnvUtil.getNacosHome(), "data", "derby-data").toString();
private final String derbyBaseDir = Paths.get(EnvUtil.getNacosHome(), "data", Constants.DERBY_PATH_NAME).toString();

private final String restoreDB = "jdbc:derby:" + derbyBaseDir;

Expand Down Expand Up @@ -127,7 +128,7 @@ public boolean onSnapshotLoad(Reader reader) {
}
}

final String loadPath = Paths.get(readerPath, snapshotDir, "derby-data").toString();
final String loadPath = Paths.get(readerPath, snapshotDir, Constants.DERBY_PATH_NAME).toString();
LogUtil.FATAL_LOG.info("snapshot load from : {}, and copy to : {}", loadPath, derbyBaseDir);

doDerbyRestoreFromBackup(() -> {
Expand Down

0 comments on commit 67eeb20

Please sign in to comment.