未验证 提交 b30bd870 编写于 作者: G Git_Yang 提交者: GitHub

[ISSUE #2667] Repair 'file doesn't exist on this path'

Signed-off-by: Nzhangyang <Git_Yang@163.com>
上级 d429aa24
......@@ -164,6 +164,8 @@ public class DefaultMessageStore implements MessageStore {
File file = new File(StorePathConfigHelper.getLockFile(messageStoreConfig.getStorePathRootDir()));
MappedFile.ensureDirOK(file.getParent());
MappedFile.ensureDirOK(getStorePathPhysic());
MappedFile.ensureDirOK(getStorePathLogic());
lockFile = new RandomAccessFile(file, "rw");
}
......@@ -779,8 +781,8 @@ public class DefaultMessageStore implements MessageStore {
return this.storeStatsService.toString();
}
private String getStorePathPhysic() {
String storePathPhysic = "";
public String getStorePathPhysic() {
String storePathPhysic;
if (DefaultMessageStore.this.getMessageStoreConfig().isEnableDLegerCommitLog()) {
storePathPhysic = ((DLedgerCommitLog)DefaultMessageStore.this.getCommitLog()).getdLedgerServer().getdLedgerConfig().getDataStorePath();
} else {
......@@ -789,6 +791,10 @@ public class DefaultMessageStore implements MessageStore {
return storePathPhysic;
}
public String getStorePathLogic() {
return StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir());
}
@Override
public HashMap<String, String> getRuntimeInfo() {
HashMap<String, String> result = this.storeStatsService.getRuntimeInfo();
......@@ -807,9 +813,7 @@ public class DefaultMessageStore implements MessageStore {
}
{
String storePathLogics = StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir());
double logicsRatio = UtilAll.isPathExists(storePathLogics) ?
UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogics) : -1;
double logicsRatio = UtilAll.getDiskPartitionSpaceUsedPercent(getStorePathLogic());
result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio));
}
......
......@@ -605,6 +605,22 @@ public class DefaultMessageStoreTest {
}
}
@Test
public void testStorePathOK() {
if (messageStore instanceof DefaultMessageStore) {
assertTrue(fileExists(((DefaultMessageStore) messageStore).getStorePathPhysic()));
assertTrue(fileExists(((DefaultMessageStore) messageStore).getStorePathLogic()));
}
}
private boolean fileExists(String path) {
if (path != null) {
File f = new File(path);
return f.exists();
}
return false;
}
private void damageCommitlog(long offset) throws Exception {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
File file = new File(messageStoreConfig.getStorePathCommitLog() + File.separator + "00000000000000000000");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册