Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cassandra.db.commitlog
Class CommitLogAllocator

    java.lang.Object
      org.apache.cassandra.db.commitlog.CommitLogAllocator

    public class CommitLogAllocator

extends java.lang.Object

Performs the pre-allocation of commit log segments in a background thread. All the public methods are thread safe.

Field Summary
`static int` | `TICK_CYCLE_TIME` The (theoretical) max milliseconds between loop runs to perform janitorial tasks

Constructor Summary
`CommitLogAllocator()`

Method Summary
`void` | `awaitTermination()` Returns when the allocator thread terminates.
`long` | `bytesUsed()`
`void` | `enableReserveSegmentCreation()` Throws a flag that enables the behavior of keeping at least one spare segment available at all times.
`CommitLogSegment` | `fetchSegment()` Fetches an empty segment file.
`java.util.Collection<CommitLogSegment>` | `getActiveSegments()`
`boolean` | `manages(java.lang.String name)`
`void` | `recycleSegment(CommitLogSegment segment)` Indicates that a segment is no longer in use and that it should be recycled.
`void` | `recycleSegment(java.io.File file)` Differs from the above because it can work on any file instead of just existing commit log segments managed by this allocator.
`void` | `resetUnsafe()` Resets all the segments, for testing purposes.
`void` | `shutdown()` Initiates the shutdown process for the allocator thread.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TICK_CYCLE_TIME

    public static final int TICK_CYCLE_TIME

  The (theoretical) max milliseconds between loop runs to perform janitorial tasks

  See Also:
    Constant Field Values

Constructor Detail

### CommitLogAllocator

    public CommitLogAllocator()

Method Detail

### fetchSegment

    public CommitLogSegment fetchSegment()

  Fetches an empty segment file.

  Returns:
    the next writable segment

### recycleSegment

    public void recycleSegment(CommitLogSegment segment)

  Indicates that a segment is no longer in use and that it should be recycled.

  Parameters:
    `segment` - segment that is no longer in use

### recycleSegment

    public void recycleSegment(java.io.File file)

  Differs from the above because it can work on any file instead of just existing commit log segments managed by this allocator.

  Parameters:
    `file` - segment file that is no longer in use.

### bytesUsed

    public long bytesUsed()

  Returns:
    the space (in bytes) used by all segment files.

### manages

    public boolean manages(java.lang.String name)

  Parameters:
    `name` - the filename to check
  Returns:
    true if file is managed by this allocator.

### enableReserveSegmentCreation

    public void enableReserveSegmentCreation()

  Throws a flag that enables the behavior of keeping at least one spare segment available at all times.

### resetUnsafe

    public void resetUnsafe()

  Resets all the segments, for testing purposes. DO NOT USE THIS OUTSIDE OF TESTS.

### shutdown

    public void shutdown()

  Initiates the shutdown process for the allocator thread.

### awaitTermination

    public void awaitTermination()
                          throws java.lang.InterruptedException

  Returns when the allocator thread terminates.

  Throws:
    `java.lang.InterruptedException`

### getActiveSegments

    public java.util.Collection<CommitLogSegment> getActiveSegments()

  Returns:
    a read-only collection of the active commit log segments

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 The Apache Software Foundation