All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.raft.util.pmem.FileProvider Maven / Gradle / Ivy

There is a newer version: 1.0.13.Final
Show newest version
package org.jgroups.raft.util.pmem;

import java.io.File;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;

/**
 * Creates {@link FileChannel}.
 * 

* If a Persistence Memory drive is available, support is provided by https://github.com/jhalliday/mashona * * @author Pedro Ruivo * @since 0.5.4 */ public class FileProvider { private static final boolean ATTEMPT_PMEM; static { boolean attemptPmem = false; try { Class.forName("io.mashona.logwriting.PmemUtil"); // use persistent memory if available, otherwise fallback to regular file. attemptPmem = true; } catch (ClassNotFoundException e) { //no op } ATTEMPT_PMEM = attemptPmem; } public static boolean isPMEMAvailable() { return ATTEMPT_PMEM; } public static FileChannel openPMEMChannel(File file, int length, boolean create, boolean readSharedMetadata) throws IOException { if (!isPMEMAvailable()) { return null; } return PmemUtilWrapper.pmemChannelFor(file, length, create, readSharedMetadata); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy