com.neeve.rog.log
Class RogLogUtil

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

public class RogLogUtil
extends Object

This class contains utility methods that are useful for working with ROG transaction logs.


Nested Class Summary
static interface RogLogUtil.FieldFilter
          Allows field paths to the filter for a type.
static class RogLogUtil.FileBasedFieldFilter
          A field filter that can be configured with filter information from a text based input stream.
 
Field Summary
static String DIVERGENCE_FILTERS_RESOUCE_PATH
          The search path used to lookup field filters on the class path.
static String NEWLINE
           
 
Constructor Summary
RogLogUtil()
           
 
Method Summary
static boolean compareEntries(RogLog source, RogLog target, RogLogUtil.FieldFilter filter, BufferedWriter summary, int diffLimit, boolean metadata, boolean verbose, com.neeve.util.UtlTableFormatter.Format format)
          Compares entries between the given RogLogs.
static boolean compareRogNodes(IRogNode node1, IRogNode node2, RogLogUtil.FieldFilter filter, StringBuffer diffBuffer)
          Compares two nodes to one another.
static boolean compareState(RogLog source, RogLog target, RogLogUtil.FieldFilter filter, BufferedWriter summary, boolean metadata, boolean verbose, com.neeve.util.UtlTableFormatter.Format format)
          Compares state for the given logs.
static File createExecutableArchive(File archiveFolder, String archiveName, PrintStream out, Tracer tracer, RogLog... logs)
          Creates an executable uber jar comprised of current classpath with the TransactionLogTool as the Main-Class, and bundled copies of the specified RogLog's files.
static void dumpLogEntryJson(RogLog.Entry entry, boolean includeMetadata, boolean includePayload, Appendable a)
          Dumps a log entry in json format.
static void dumpObjectAsJson(IRogMetadata metadata, IStoreObject object, boolean dumpMetadata, boolean dumpObject, Appendable a)
          Dumps an IStoreObject object or its metadata in json format.
static List<File> extractArchivedLogs(PrintStream out, File extractionFolder)
          Extracts archived log files from the current classpath.
static RogLogUtil.FileBasedFieldFilter loadComparisonFilter()
          Loads the default field comparison filter from configuration files on the classpath.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIVERGENCE_FILTERS_RESOUCE_PATH

public static final String DIVERGENCE_FILTERS_RESOUCE_PATH
The search path used to lookup field filters on the class path.

See Also:
RogLogUtil.FileBasedFieldFilter, loadComparisonFilter(), Constant Field Values

NEWLINE

public static final String NEWLINE
Constructor Detail

RogLogUtil

public RogLogUtil()
Method Detail

createExecutableArchive

public static File createExecutableArchive(File archiveFolder,
                                           String archiveName,
                                           PrintStream out,
                                           Tracer tracer,
                                           RogLog... logs)
                                    throws Exception
Creates an executable uber jar comprised of current classpath with the TransactionLogTool as the Main-Class, and bundled copies of the specified RogLog's files.

Parameters:
archiveFolder - The directory under which to create the archive
archiveName - The archive name (which will be suffixed with a timestamp).
tracer - The tracer to use to log output of the archiving operation.
logs - The RogLogs to include in the archive.
Returns:
The archive bundle.
Throws:
IllegalArgumentException - If no logs are specified.
IOException - If the archive can't be created.
Exception

extractArchivedLogs

public static List<File> extractArchivedLogs(PrintStream out,
                                             File extractionFolder)
                                      throws IOException
Extracts archived log files from the current classpath.

Returns:
The list of extracted logs files or null if no archived logs files are on the classpath
Throws:
IOException - If there is an error extracting log files

compareEntries

public static final boolean compareEntries(RogLog source,
                                           RogLog target,
                                           RogLogUtil.FieldFilter filter,
                                           BufferedWriter summary,
                                           int diffLimit,
                                           boolean metadata,
                                           boolean verbose,
                                           com.neeve.util.UtlTableFormatter.Format format)
                                    throws Exception
Compares entries between the given RogLogs.

Parameters:
source - The source log
target - The target log
filter - A RogLogUtil.FieldFilter for ignoring fields in the comparison
summary - If provided difference are written to this writer
diffLimit - The maximum number of divergent entries to summarize
metadata - Whether internal platform data should be considered.
verbose - Enables debug information on the comparison in the output.
Returns:
True if the logs are not divergent
Throws:
Exception - If there is an error comparing the state.

compareState

public static final boolean compareState(RogLog source,
                                         RogLog target,
                                         RogLogUtil.FieldFilter filter,
                                         BufferedWriter summary,
                                         boolean metadata,
                                         boolean verbose,
                                         com.neeve.util.UtlTableFormatter.Format format)
                                  throws Exception
Compares state for the given logs.

Parameters:
source - The source log
target - The target log
filter - A RogLogUtil.FieldFilter for ignoring fields in the comparison
summary - If provided difference are written to this writer
metadata - Whether internal platform data should be considered.
verbose - Enables debug information on the comparison in the output.
Returns:
True if the state is the same.
Throws:
Exception - If there is an error comparing the state.

compareRogNodes

public static final boolean compareRogNodes(IRogNode node1,
                                            IRogNode node2,
                                            RogLogUtil.FieldFilter filter,
                                            StringBuffer diffBuffer)
                                     throws Exception
Compares two nodes to one another.

Parameters:
node1 - The first node.
node2 - The second node.
filter - The field filter to ignore fields. If null the default filter will be used.
diffBuffer - An optional buffer into which to dump differences.
Returns:
True if the object are equivalent, false if they are different.
Throws:
Exception - If a failure occurs comparing the nodes.

loadComparisonFilter

public static final RogLogUtil.FileBasedFieldFilter loadComparisonFilter()
                                                                  throws IOException
Loads the default field comparison filter from configuration files on the classpath.

This method searches for field filters on the classpath found at "META-INF/com/neeve/rog/divergence.filters"

Returns:
A comparison filter from the classpath.
Throws:
IOException - If there is an error loading the field filters.
IllegalArgumentException - If there is an error parsing the discovered field filters

dumpLogEntryJson

public static final void dumpLogEntryJson(RogLog.Entry entry,
                                          boolean includeMetadata,
                                          boolean includePayload,
                                          Appendable a)
Dumps a log entry in json format.

Parameters:
entry - The entry to dump.
includeMetadata - Whether or not to include entry metadata.
includePayload - If false no payload information will be shown.
a - The target appendable.

dumpObjectAsJson

public static final void dumpObjectAsJson(IRogMetadata metadata,
                                          IStoreObject object,
                                          boolean dumpMetadata,
                                          boolean dumpObject,
                                          Appendable a)
Dumps an IStoreObject object or its metadata in json format.

Parameters:
metadata - The IRogMetadata for the object.
object - The object to dump
dumpMetadata - Whether metadata should be dumped.
dumpObject - Whether object payload should be included in the dump
a - The target Appendable to which to dump.


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