Java Code Examples for org.apache.cassandra.io.util.FileUtils#isCleanerAvailable()

The following examples show how to use org.apache.cassandra.io.util.FileUtils#isCleanerAvailable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MappedBuffer.java    From sasi with Apache License 2.0 6 votes vote down vote up
@Override
public void close()
{
    if (!FileUtils.isCleanerAvailable())
        return;

    /*
     * Try forcing the unmapping of pages using undocumented unsafe sun APIs.
     * If this fails (non Sun JVM), we'll have to wait for the GC to finalize the mapping.
     * If this works and a thread tries to access any page, hell will unleash on earth.
     */
    try
    {
        for (MappedByteBuffer segment : pages)
            FileUtils.clean(segment);
    }
    catch (Exception e)
    {
        // This is not supposed to happen
    }
}
 
Example 2
Source File: DatabaseDescriptor.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public static MemtablePool getMemtableAllocatorPool()
{
    long heapLimit = ((long) conf.memtable_heap_space_in_mb) << 20;
    long offHeapLimit = ((long) conf.memtable_offheap_space_in_mb) << 20;
    switch (conf.memtable_allocation_type)
    {
        case unslabbed_heap_buffers:
            return new HeapPool(heapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
        case heap_buffers:
            return new SlabPool(heapLimit, 0, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
        case offheap_buffers:
            if (!FileUtils.isCleanerAvailable())
            {
                logger.error("Could not free direct byte buffer: offheap_buffers is not a safe memtable_allocation_type without this ability, please adjust your config. This feature is only guaranteed to work on an Oracle JVM. Refusing to start.");
                System.exit(-1);
            }
            return new SlabPool(heapLimit, offHeapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
        case offheap_objects:
            return new NativePool(heapLimit, offHeapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
        default:
            throw new AssertionError();
    }
}
 
Example 3
Source File: CommitLogSegment.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
void internalClose()
{
    try
    {
        if (FileUtils.isCleanerAvailable())
            FileUtils.clean(buffer);
        logFileAccessor.close();
    }
    catch (IOException e)
    {
        throw new FSWriteError(e, getPath());
    }
}