use of com.bonree.brfs.disknode.data.write.buf.ByteArrayFileBuffer in project BRFS by zhangnianli.
the class FileWriterManager method buildDiskWriter.
private Pair<RecordFileWriter, WriteWorker> buildDiskWriter(String filePath) {
Pair<RecordFileWriter, WriteWorker> binding = runningWriters.get(filePath);
if (binding == null) {
synchronized (runningWriters) {
binding = runningWriters.get(filePath);
if (binding == null) {
try {
File file = new File(filePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
RecordFileWriter writer = new RecordFileWriter(recorderManager.getRecordCollection(filePath, false, recordCacheSize, true), new BufferedFileWriter(filePath, new ByteArrayFileBuffer(dataCacheSize)));
binding = new Pair<RecordFileWriter, WriteWorker>(writer, workerSelector.select(workerGroup.getWorkerList()));
runningWriters.put(filePath, binding);
} catch (Exception e) {
LOG.error("build disk writer error", e);
}
}
}
}
return binding;
}
Aggregations