Example usage for org.apache.cassandra.config DatabaseDescriptor getDiskAccessMode

List of usage examples for org.apache.cassandra.config DatabaseDescriptor getDiskAccessMode

Introduction

In this page you can find the example usage for org.apache.cassandra.config DatabaseDescriptor getDiskAccessMode.

Prototype

public static Config.DiskAccessMode getDiskAccessMode() 

Source Link

Usage

From source file:com.datastax.brisk.BriskServer.java

License:Apache License

private LocalOrRemoteBlock get_cfs_sblock(String callerHostName, String subBlockCFName, ByteBuffer blockId,
        ByteBuffer sblockId, int offset, ColumnParent subBlockDataPath)
        throws TException, TimedOutException, UnavailableException, InvalidRequestException, NotFoundException {

    // This logic is only used on mmap spec machines
    if (DatabaseDescriptor.getDiskAccessMode() == DiskAccessMode.mmap) {
        if (logger.isDebugEnabled())
            logger.debug("Checking for local block: " + blockId + " from " + callerHostName + " on "
                    + FBUtilities.getLocalAddress().getHostName());

        List<String> hosts = getKeyLocations(blockId);
        boolean isLocal = false;

        for (String hostName : hosts) {
            if (logger.isDebugEnabled())
                logger.debug("Block " + blockId + " lives on " + hostName);

            if (hostName.equals(callerHostName)
                    && hostName.equals(FBUtilities.getLocalAddress().getHostName())) {
                isLocal = true;//from   ww  w .java2s .co  m

                break;
            }
        }

        if (isLocal) {
            if (logger.isDebugEnabled())
                logger.debug("Local block should be on this node " + blockId);

            LocalBlock localBlock = getLocalSubBlock(subBlockCFName, blockId, sblockId, offset);

            if (localBlock != null) {
                if (logger.isDebugEnabled())
                    logger.debug("Local block found: " + localBlock);

                return new LocalOrRemoteBlock().setLocal_block(localBlock);
            }
        }
    }

    if (logger.isDebugEnabled())
        logger.debug("Checking for remote block: " + blockId);

    //Fallback to storageProxy
    return getRemoteSubBlock(blockId, sblockId, offset, subBlockDataPath);

}