ChannelProxy (apache-cassandra API)
Date: 2018-02-14

org.apache.cassandra.io.util

## Class ChannelProxy

- java.lang.Object
- - org.apache.cassandra.utils.concurrent.SharedCloseableImpl
  - - org.apache.cassandra.io.util.ChannelProxy

- All Implemented Interfaces:
    java.lang.AutoCloseable, SharedCloseable

      public final class ChannelProxy
      extends SharedCloseableImpl

  A proxy of a FileChannel that: - implements reference counting - exports only thread safe FileChannel operations - wraps IO exceptions into runtime exceptions Tested by RandomAccessReaderTest.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ChannelProxy(ChannelProxy copy)`
    `ChannelProxy(java.io.File file)`
    `ChannelProxy(java.lang.String path)`
    `ChannelProxy(java.lang.String filePath, java.nio.channels.FileChannel channel)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `filePath()`
    `int` | `getFileDescriptor()`
    `java.nio.MappedByteBuffer` | `map(java.nio.channels.FileChannel.MapMode mode, long position, long size)`
    `static java.nio.channels.FileChannel` | `openChannel(java.io.File file)`
    `int` | `read(java.nio.ByteBuffer buffer, long position)`
    `ChannelProxy` | `sharedCopy()`
    `long` | `size()`
    `java.lang.String` | `toString()`
    `long` | `transferTo(long position, long count, java.nio.channels.WritableByteChannel target)`

    - ### Methods inherited from class org.apache.cassandra.utils.concurrent.SharedCloseableImpl

      `addTo, close, close, isCleanedUp`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ChannelProxy

          public ChannelProxy(java.lang.String path)

    - #### ChannelProxy

          public ChannelProxy(java.io.File file)

    - #### ChannelProxy

          public ChannelProxy(java.lang.String filePath,
                              java.nio.channels.FileChannel channel)

    - #### ChannelProxy

          public ChannelProxy(ChannelProxy copy)

  - ### Method Detail

    - #### openChannel

          public static java.nio.channels.FileChannel openChannel(java.io.File file)

    - #### sharedCopy

          public ChannelProxy sharedCopy()

      Returns:
        a new instance of the object representing the same state and backed by the same underlying resources. Coordinates with the original (and other instances) when the underlying resource should be closed. Throws an exception if the shared resource has already been closed.

    - #### filePath

          public java.lang.String filePath()

    - #### read

          public int read(java.nio.ByteBuffer buffer,
                          long position)

    - #### transferTo

          public long transferTo(long position,
                                 long count,
                                 java.nio.channels.WritableByteChannel target)

    - #### map

          public java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode mode,
                                               long position,
                                               long size)

    - #### size

          public long size()

    - #### getFileDescriptor

          public int getFileDescriptor()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright © 2018 The Apache Software Foundation