未验证 提交 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 { ...@@ -164,6 +164,8 @@ public class DefaultMessageStore implements MessageStore {
File file = new File(StorePathConfigHelper.getLockFile(messageStoreConfig.getStorePathRootDir())); File file = new File(StorePathConfigHelper.getLockFile(messageStoreConfig.getStorePathRootDir()));
MappedFile.ensureDirOK(file.getParent()); MappedFile.ensureDirOK(file.getParent());
MappedFile.ensureDirOK(getStorePathPhysic());
MappedFile.ensureDirOK(getStorePathLogic());
lockFile = new RandomAccessFile(file, "rw"); lockFile = new RandomAccessFile(file, "rw");
} }
...@@ -779,8 +781,8 @@ public class DefaultMessageStore implements MessageStore { ...@@ -779,8 +781,8 @@ public class DefaultMessageStore implements MessageStore {
return this.storeStatsService.toString(); return this.storeStatsService.toString();
} }
private String getStorePathPhysic() { public String getStorePathPhysic() {
String storePathPhysic = ""; String storePathPhysic;
if (DefaultMessageStore.this.getMessageStoreConfig().isEnableDLegerCommitLog()) { if (DefaultMessageStore.this.getMessageStoreConfig().isEnableDLegerCommitLog()) {
storePathPhysic = ((DLedgerCommitLog)DefaultMessageStore.this.getCommitLog()).getdLedgerServer().getdLedgerConfig().getDataStorePath(); storePathPhysic = ((DLedgerCommitLog)DefaultMessageStore.this.getCommitLog()).getdLedgerServer().getdLedgerConfig().getDataStorePath();
} else { } else {
...@@ -789,6 +791,10 @@ public class DefaultMessageStore implements MessageStore { ...@@ -789,6 +791,10 @@ public class DefaultMessageStore implements MessageStore {
return storePathPhysic; return storePathPhysic;
} }
public String getStorePathLogic() {
return StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir());
}
@Override @Override
public HashMap<String, String> getRuntimeInfo() { public HashMap<String, String> getRuntimeInfo() {
HashMap<String, String> result = this.storeStatsService.getRuntimeInfo(); HashMap<String, String> result = this.storeStatsService.getRuntimeInfo();
...@@ -807,9 +813,7 @@ public class DefaultMessageStore implements MessageStore { ...@@ -807,9 +813,7 @@ public class DefaultMessageStore implements MessageStore {
} }
{ {
String storePathLogics = StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()); double logicsRatio = UtilAll.getDiskPartitionSpaceUsedPercent(getStorePathLogic());
double logicsRatio = UtilAll.isPathExists(storePathLogics) ?
UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogics) : -1;
result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio)); result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio));
} }
......
...@@ -605,6 +605,22 @@ public class DefaultMessageStoreTest { ...@@ -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 { private void damageCommitlog(long offset) throws Exception {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig(); MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
File file = new File(messageStoreConfig.getStorePathCommitLog() + File.separator + "00000000000000000000"); 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.
先完成此消息的编辑!
想要评论请 注册