Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.io.journal
Class AbstractJournalRM.JournalFile

java.lang.Object
  extended by com.tangosol.io.journal.AbstractJournalRM.JournalFile

All Implemented Interfaces:
Disposable
Direct Known Subclasses:
FlashJournalRM.JournalFile, RamJournalRM.JournalFile
Enclosing class:
AbstractJournalRM

protected abstract class AbstractJournalRM.JournalFile
extends java.lang.Object
implements Disposable

A JournalFile object is created for each file used to store the journal contents. It is created in an initial "append" mode -- which may be interrupted from time to time by a "congested" mode if writes are falling too far behind, it then transitions to a "full" mode, and once enough of its storage has been released it transitions to an "evacuating" mode, which (once evacuated) becomes "garbage" and (upon deletion) is "discarded".


Field Summary
protected  java.util.concurrent.atomic.AtomicLong m_cbReleased
          Amount of data that has been released.
protected  java.util.concurrent.atomic.AtomicLong m_cbWritten
          Amount of data that has been written.
protected  boolean m_fNotifiedFull
          Set to true when the JournalFile is notified that it is full and its contents have been fully written.
protected  AbstractJournalRM.JournalFile m_jrnlfileNext
          The JournalFile that "comes after" this JournalFile in the journal.
protected  java.util.concurrent.atomic.AtomicLong m_lStateOffset
          Current state of the JournalFile and the appending offset within the file.
protected  int m_nFile
          The file index.
static long STATE_APPENDING
          State: File is being appended to.
static long STATE_CONGESTION
          State: File is appending, but there is congestion forcing a wait by all appending threads.
static long STATE_DISCARDED
          State: File has been discarded.
static long STATE_EVACUATING
          State: Remaining entries in the file are being evacuated.
static long STATE_FULL
          State: File is full and appends are no longer occurring.
static long STATE_GARBAGE
          State: File is garbage and can safely be discarded.
static long STATE_MASK
          The bits of the m_lStateOffset that are used for the current state of the file (one of the STATE_* constants).

 

Constructor Summary
AbstractJournalRM.JournalFile(int nFile)
          Construct a Journal File.

 

Method Summary
abstract  void dispose()
          
abstract  long enqueue(Binary bin)
          Enqueue a Binary value to be written to this file, returning a ticket, or return 0L if this file is full and the append has to occur to a new file.
 void evacuate()
          Called by the CollectorDaemon to evacuate all remaining data from the JournalFile.
 long getBytesWritten()
          Determine the number of bytes written.
protected  java.lang.String getDescription()
          Format the object attributes into a String for inclusion in the String returned from the toString() method.
 int getFileId()
          Determine the file id (0-511) for this JournalFile.
 AbstractJournalRM.JournalFile getNextJournalFile()
          Determine the JournalFile for the file in the journal that follows the file represented by this JournalFile.
 long getOffset()
          Determine the current append offset (or length) of this JournalFile.
 long getReleased()
          Determine the number of bytes that have been released from this JournalFile.
 long getState()
          Determine the current state of this JournalFile.
 boolean isAppending()
          Determine the current state of this JournalFile.
 void notifyWriteCompleted()
          Called by the CollectorDaemon the first time that the JournalFile is encountered in its FULL state and its data has all been written.
abstract  Binary read(long lTicket)
          Read the Binary associated with the specified ticket from the journal file.
 void release(int cbValue)
          Release the specified number of bytes from this journal file.
 void setNextJournalFile(AbstractJournalRM.JournalFile jrnlfileNext)
          Once this file has been filled, it gets a reference to the file that follows it.
protected  void setState(long lState)
          Specify the current state of this JournalFile.
 java.lang.String toString()
          
 void touch()
          This method is called periodically by the collector daemon to indicate that the file is still being used.

 

Field Detail

STATE_APPENDING

public static final long STATE_APPENDING
State: File is being appended to.
See Also:
Constant Field Values

STATE_CONGESTION

public static final long STATE_CONGESTION
State: File is appending, but there is congestion forcing a wait by all appending threads.
See Also:
Constant Field Values

STATE_FULL

public static final long STATE_FULL
State: File is full and appends are no longer occurring.
See Also:
Constant Field Values

STATE_EVACUATING

public static final long STATE_EVACUATING
State: Remaining entries in the file are being evacuated.
See Also:
Constant Field Values

STATE_GARBAGE

public static final long STATE_GARBAGE
State: File is garbage and can safely be discarded.
See Also:
Constant Field Values

STATE_DISCARDED

public static final long STATE_DISCARDED
State: File has been discarded.
See Also:
Constant Field Values

STATE_MASK

public static final long STATE_MASK
The bits of the m_lStateOffset that are used for the current state of the file (one of the STATE_* constants).
See Also:
Constant Field Values

m_nFile

protected final int m_nFile
The file index. Immutable field.

m_lStateOffset

protected final java.util.concurrent.atomic.AtomicLong m_lStateOffset
Current state of the JournalFile and the appending offset within the file. These two values are maintained in a single "long" value so that the file can be appended to and transitioned from state to state in an atomic manner, i.e. when the file gets close to being full, it can be transitioned from the "appending" state in the same manner as an append itself is done (which simply updates the offset).

m_cbWritten

protected final java.util.concurrent.atomic.AtomicLong m_cbWritten
Amount of data that has been written.

m_cbReleased

protected final java.util.concurrent.atomic.AtomicLong m_cbReleased
Amount of data that has been released.

m_jrnlfileNext

protected volatile AbstractJournalRM.JournalFile m_jrnlfileNext
The JournalFile that "comes after" this JournalFile in the journal.

m_fNotifiedFull

protected boolean m_fNotifiedFull
Set to true when the JournalFile is notified that it is full and its contents have been fully written.

Constructor Detail

AbstractJournalRM.JournalFile

public AbstractJournalRM.JournalFile(int nFile)
Construct a Journal File.
Parameters:
nFile - the file number in the range 0-511 (inclusive)

Method Detail

enqueue

public abstract long enqueue(Binary bin)
Enqueue a Binary value to be written to this file, returning a ticket, or return 0L if this file is full and the append has to occur to a new file.
Parameters:
bin - the value to append to the journal file
Returns:
a ticket if the Binary has successfully been enqueued, or 0L if the file is full

read

public abstract Binary read(long lTicket)
Read the Binary associated with the specified ticket from the journal file.
Parameters:
lTicket - a ticket previously returned from enqueue(com.tangosol.util.Binary)
Returns:
the Binary value that is associated with the ticket

release

public void release(int cbValue)
Release the specified number of bytes from this journal file.
Parameters:
cbValue - the number of bytes that are being released

getFileId

public int getFileId()
Determine the file id (0-511) for this JournalFile.
Returns:
the file id for this JournalFile

getState

public long getState()
Determine the current state of this JournalFile.
Returns:
the one of the STATE_* constants

setState

protected void setState(long lState)
Specify the current state of this JournalFile.
Parameters:
lState - the one of the STATE_* constants

getOffset

public long getOffset()
Determine the current append offset (or length) of this JournalFile.
Returns:
the current append offset

getBytesWritten

public long getBytesWritten()
Determine the number of bytes written.
Returns:
the number of bytes that have been reported to have been written

getReleased

public long getReleased()
Determine the number of bytes that have been released from this JournalFile.
Returns:
the number of bytes that have been released from this file

isAppending

public boolean isAppending()
Determine the current state of this JournalFile.
Returns:
the one of the STATE_* constants

touch

public void touch()
This method is called periodically by the collector daemon to indicate that the file is still being used.

getNextJournalFile

public AbstractJournalRM.JournalFile getNextJournalFile()
Determine the JournalFile for the file in the journal that follows the file represented by this JournalFile.
Returns:
the next file in the journal, or null if it has not yet been set

setNextJournalFile

public void setNextJournalFile(AbstractJournalRM.JournalFile jrnlfileNext)
Once this file has been filled, it gets a reference to the file that follows it.
Parameters:
jrnlfileNext - the next file in the journal

getDescription

protected java.lang.String getDescription()
Format the object attributes into a String for inclusion in the String returned from the toString() method.
Returns:
a comma-delimited String listing the attributes of this object in the form "attribute=value"

notifyWriteCompleted

public void notifyWriteCompleted()
Called by the CollectorDaemon the first time that the JournalFile is encountered in its FULL state and its data has all been written.

evacuate

public void evacuate()
Called by the CollectorDaemon to evacuate all remaining data from the JournalFile.

dispose

public abstract void dispose()

toString

public java.lang.String toString()

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.