FileCacheBug

This commit is contained in:
userA
2023-05-06 23:41:47 +08:00
parent 6b32c162b6
commit e56c3d21f0
6 changed files with 25 additions and 10 deletions

View File

@@ -39,5 +39,9 @@ public class Test {
System.out.println(dsmTask + "(运行状态):" + manager.isTaskRunning(dsmTask));
System.out.println(dsmTask + "(缓存中弹幕条数):" + manager.getCacheSize(dsmTask));
}
while(true){
}
}
}

View File

@@ -32,8 +32,7 @@ public class PipelineWriteJson implements Pipeline {
this.loadConfig = loadConfig;
this.cache = new ConcurrentLinkedQueue<>();
this.barrageSaveFile = new BarrageSaveFile(loadConfig, cache);
this.filecache = new FileCache(barrageSaveFile);
FileCacheManagerInstance.getInstance().addFileCache(filecache);
this.filecache = new FileCache(barrageSaveFile,0,10*1024);
} catch (FileCacheException e) {
throw new RuntimeException(e);
}
@@ -57,7 +56,9 @@ public class PipelineWriteJson implements Pipeline {
Barrage barrage;
while ((barrage = cache.poll()) != null) {
System.out.print("写入:" + successCount);
if(successCount%1000==0){
System.out.print("写入:" + successCount);
}
try {
filecache.append(barrage, "-1");
} catch (InterruptedException | FileCacheException e) {
@@ -65,7 +66,7 @@ public class PipelineWriteJson implements Pipeline {
}
successCount++;
}
filecache.forceSync();
return successCount;
}

View File

@@ -45,10 +45,13 @@ public class BarrageSaveFile extends ConfigFile<ConcurrentLinkedQueue<Barrage>>
setFileName(fileName);
String rootPath = Paths.get(BARRAGE_ROOT, loadConfig.getAnchorName()).toString(); //获取当前主播的文件夹路径
setFilePath(rootPath);
Path path = Path.of(rootPath);
//TODO 待移除 建立主播文件夹
try {
Files.createDirectory(Path.of(rootPath));
if(!Files.exists(path)){
Files.createDirectory(path);
}
} catch (IOException e) {
return false;
}