Search in sources :

Example 1 with ByteArrayFileBuffer

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;
}
Also used : ByteArrayFileBuffer(com.bonree.brfs.disknode.data.write.buf.ByteArrayFileBuffer) File(java.io.File) WriteWorker(com.bonree.brfs.disknode.data.write.worker.WriteWorker) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

ByteArrayFileBuffer (com.bonree.brfs.disknode.data.write.buf.ByteArrayFileBuffer)1 WriteWorker (com.bonree.brfs.disknode.data.write.worker.WriteWorker)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1