com.neeve.rog.log
Class RogLogMetadata

java.lang.Object
  extended by com.neeve.rog.log.RogLogMetadata

public final class RogLogMetadata
extends Object

Holds an ROG transaction log metadata. This class is not intended for public use. Format:

 -------------------------------- Metadata -----------------------------
 Bytes     0   : metadata version (identifies metadata format)
         1-4   : Flags
         5-8   : Live log number (log # that is the live log)
         9-12  : CDC log number (long # on which CDC is occurring (-1 = CDC disabled))
         13-20 : CDC checkpoint number (checkpoint # on which CDC is occurring (-1 = CDC disabled))
         21-28 : CDC cursor (pos in the checkpoint being CDC'd that has been handled by the CDC handler)
         29-36 : Log UUID low
         37-44 : Log UUID high
         45-52 : Last Validated Sequence Number
 --------------------------------  END  --------------------------------
 

Threading:
This class is safe for concurrent access by multiple threads.

Constructor Summary
RogLogMetadata(File root, String name)
           
 
Method Summary
 void close()
          Syncs the metadata to disk and close the underlying file.
 void deserialize(PktBuffer from, IStoreBinding.Role role)
          Deserializes the metadata
 void disableCdc()
          Disable CDC
 void enableCdc()
          Enable CDC
 boolean exists()
          Tests if the metadata file exists.
 long getCdcCheckpointVersion()
          Set the last checkpoint version successfully CDC'd
 long getCdcCursor()
          Gets the current CDC cursor in the log file being CDC'd.
 int getCdcLogNumber()
          Get the number of the log being CDC'd
 boolean getIsBackup()
          Gets whether or not the log is for a cluster backup
 boolean getIsPureMessageLogger()
          Gets whether or not the log is is purely for message logging.
 long getLastValidatedPosition()
          Gets the last validated log position, or -1 if none has been set.
 int getLiveLogNumber()
          Get the number of the live log
static int getLiveLogNumber(PktBuffer buffer)
          Get the number of the live log from serialized metadata
 com.eaio.uuid.UUID getLogUUID()
          Gets the log uuid.
 String getName()
          Get the unsuffixed name of the log file this metadata represents.
 File getRoot()
          Get the location root of the metadata file
 byte getVersion()
          Get the metadata version
 boolean isCdcEnabled()
          Get if CDC is enabled
 boolean isOpen()
          Tests if the metadata is open.
 void open()
          Opens and deserializes current metadata
 void open(PktBuffer from, IStoreBinding.Role role)
          Opens using specified serialized metadata
 void renameTo(String newName)
          Renames the metadata file.
 void serialize(PktBuffer to)
          Serializes the metadata
 void setCdcCheckpointVersion(long val)
          Set the last checkpoint version successfully CDC'd
 void setCdcCursor(long val)
          Sets the current CDC cursor in the log file being CDC'd.
 void setCdcLogNumber(int val)
          Set the number of the log being CDC'd
 void setIsBackup(boolean isBackup)
          Sets whether or not the log is for a cluster backup
 void setIsPureMessageLogger(boolean isMessageLogger)
          Sets whether or not the log is purely for message logging.
 void setLastValidatedPosition(long position)
          Sets the last validated write entry position.
 void setLiveLogNumber(int val)
          Set the number of the live log
 void setLogUUID(com.eaio.uuid.UUID uuid)
          Sets the log uuid.
 void sync()
          Syncs the metadata changes to disk.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RogLogMetadata

public RogLogMetadata(File root,
                      String name)
Method Detail

sync

public final void sync()
                throws IOException
Syncs the metadata changes to disk.

Throws:
IOException - If there is an error syncing

exists

public final boolean exists()
Tests if the metadata file exists.


open

public final void open(PktBuffer from,
                       IStoreBinding.Role role)
                throws Exception
Opens using specified serialized metadata

Parameters:
from - The buffer to initialize the metadata from. Can be null in which case the metadata is initialized from the backing file if one exists and, if not, then created fresh with defaults
role - The role to set in the metadata. Can be null in which case the role information in the metadata is initialized from the backin file if one exists and, if not, initialized to the default value of primary/standalone
Throws:
IOException - If there is an error opening the metadata
Exception

open

public final void open()
                throws Exception
Opens and deserializes current metadata

Throws:
IOException - If there is an error opening the metadata
Exception

getRoot

public final File getRoot()
Get the location root of the metadata file

Returns:
The location root of the metadata file.

getName

public final String getName()
Get the unsuffixed name of the log file this metadata represents.

Returns:
The unsuffixed name of the log file this metadata represents.

isOpen

public final boolean isOpen()
Tests if the metadata is open.

Returns:
true if the metadata is open

getVersion

public final byte getVersion()
Get the metadata version


setIsBackup

public final void setIsBackup(boolean isBackup)
Sets whether or not the log is for a cluster backup

Parameters:
isBackup - Whether or not the log is for a cluster backup

getIsBackup

public final boolean getIsBackup()
Gets whether or not the log is for a cluster backup


setIsPureMessageLogger

public final void setIsPureMessageLogger(boolean isMessageLogger)
Sets whether or not the log is purely for message logging.

Parameters:
isMessageLogger - Whether or not the log is purely for message logging.

getIsPureMessageLogger

public final boolean getIsPureMessageLogger()
Gets whether or not the log is is purely for message logging.


setLiveLogNumber

public final void setLiveLogNumber(int val)
Set the number of the live log


getLiveLogNumber

public static final int getLiveLogNumber(PktBuffer buffer)
Get the number of the live log from serialized metadata


getLiveLogNumber

public final int getLiveLogNumber()
Get the number of the live log


setCdcLogNumber

public final void setCdcLogNumber(int val)
Set the number of the log being CDC'd


getCdcLogNumber

public final int getCdcLogNumber()
Get the number of the log being CDC'd


setCdcCheckpointVersion

public final void setCdcCheckpointVersion(long val)
Set the last checkpoint version successfully CDC'd


getCdcCheckpointVersion

public final long getCdcCheckpointVersion()
Set the last checkpoint version successfully CDC'd


setCdcCursor

public final void setCdcCursor(long val)
Sets the current CDC cursor in the log file being CDC'd.


getCdcCursor

public final long getCdcCursor()
Gets the current CDC cursor in the log file being CDC'd.


isCdcEnabled

public final boolean isCdcEnabled()
Get if CDC is enabled


enableCdc

public final void enableCdc()
Enable CDC


disableCdc

public final void disableCdc()
Disable CDC


setLogUUID

public final void setLogUUID(com.eaio.uuid.UUID uuid)
Sets the log uuid.


getLogUUID

public final com.eaio.uuid.UUID getLogUUID()
Gets the log uuid.


setLastValidatedPosition

public final void setLastValidatedPosition(long position)
Sets the last validated write entry position.


getLastValidatedPosition

public final long getLastValidatedPosition()
Gets the last validated log position, or -1 if none has been set.


renameTo

public final void renameTo(String newName)
                    throws IOException
Renames the metadata file. The new name is just the base name with no .metdata suffix.

Parameters:
newName - The new log file name.
Throws:
IOException - if the rename operation fails

serialize

public final void serialize(PktBuffer to)
Serializes the metadata


deserialize

public final void deserialize(PktBuffer from,
                              IStoreBinding.Role role)
                       throws Exception
Deserializes the metadata

Throws:
Exception

close

public final void close()
                 throws IOException
Syncs the metadata to disk and close the underlying file.

Throws:
IOException - If there is an error closing.

toString

public final String toString()
Overrides:
toString in class Object


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.