Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


com.tangosol.io.journal
Class AbstractJournalRM.JournalFile

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

All Implemented Interfaces:
com.oracle.common.base.Disposable
Direct Known Subclasses:
AbstractJournalRM.CollectorDaemon.InvokeGCJournalFile, FlashJournalRM.JournalFile, RamJournalRM.JournalFile
Enclosing class:
AbstractJournalRM

protected abstract class AbstractJournalRM.JournalFile
extends java.lang.Object
implements com.oracle.common.base.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).
static long STATE_RESERVED
          State: File is reserved by the CollectorDaemon.

 

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

 

Method Summary
protected  boolean compareAndSetOffset(long lPrevValue, long lOffset)
          Specify the new offset value of this JournalFile.
protected  boolean compareAndSetState(long lPrevValue, long lState)
          Specify the current state of this JournalFile unless the state is STATE_RESERVED as it is a special case and should be set via setReserved(boolean).
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.
protected  long getOffset(long lStateOffset)
          Determine the current append offset (or length) from the provided long.
 long getReleased()
          Determine the number of bytes that have been released from this JournalFile.
 long getState()
          Determine the current state of this JournalFile.
protected  long getState(long lState)
          Determine the state of the provided (potentially) unmasked lState.
 boolean isAppending()
          Return whether the JournalFile can be appended to.
 boolean isReserved()
          Return whether the JournalFile has been reserved thus can not be used by clients.
 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 setReserved(boolean fReserved)
          Specify whether the current JournalFile is reserved.
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_RESERVED

public static final long STATE_RESERVED
State: File is reserved by the CollectorDaemon. This state differs from the others as it may exist in combination with the other states thus is a marker.
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-510 (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

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()
Return whether the JournalFile can be appended to.
Returns:
whether the JournalFile can be appended to

isReserved

public boolean isReserved()
Return whether the JournalFile has been reserved thus can not be used by clients.
Returns:
whether the JournalFile has been reserved

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.

setReserved

protected void setReserved(boolean fReserved)
Specify whether the current JournalFile is reserved.
Parameters:
fReserved - whether the JournalFile is reserved

dispose

public abstract void dispose()
Specified by:
dispose in interface com.oracle.common.base.Disposable

toString

public java.lang.String toString()

getState

protected long getState(long lState)
Determine the state of the provided (potentially) unmasked lState.
Parameters:
lState - the journal file state
Returns:
the state only value

setState

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

compareAndSetState

protected boolean compareAndSetState(long lPrevValue,
                                     long lState)
Specify the current state of this JournalFile unless the state is STATE_RESERVED as it is a special case and should be set via setReserved(boolean).
Parameters:
lPrevValue - the expected state value
lState - one of the STATE_* constants, except STATE_RESERVED
Returns:
true if the value was successfully cas'd

compareAndSetOffset

protected boolean compareAndSetOffset(long lPrevValue,
                                      long lOffset)
Specify the new offset value of this JournalFile.
Parameters:
lPrevValue - the expected state value
lOffset - the new offset value
Returns:
true if the value was successfully cas'd

getOffset

protected long getOffset(long lStateOffset)
Determine the current append offset (or length) from the provided long.
Parameters:
lStateOffset - the long value holding both the state and offset
Returns:
the current append offset

Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


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