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.

This class contains unsupported APIs that are subject to change


Nested Class Summary
static class RogLogUtil.AlwaysEqualComparator<T>
          A comparator that always considers 2 objects equal.
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.
static class RogLogUtil.FilterComparisonFactory
          A comparison factory passed to UtlObjectGraph that uses a supplied RogLogUtil.FieldFilter to allow ignoring fields.
static class RogLogUtil.JsonPrettyPrintStyle
          Json pretty printer styles.
static class RogLogUtil.MetadataDisplayPolicy
          Enumerates options for displaying object metadata.
 
Field Summary
static String DIVERGENCE_FILTERS_RESOUCE_PATH
          The search path used to lookup field filters on the class path.
static String JSON_CUSTOM_PRETTY_PRINTER_PROP
          The property name used to look up a custom json pretty printer implementation class that implements PrettyPrinter
static String JSON_SORT_PROPERTIES_ALPHABETICALLY_PROP
          The property name indicating whether objects dumped in json are sorted alphabetically.
 
Constructor Summary
RogLogUtil()
           
 
Method Summary
static boolean compareEntries(RogLog source, RogLog target, RogLogUtil.FieldFilter filter, BufferedWriter summary, int diffLimit, boolean metadata, boolean verbose, 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, UtlTableFormatter.Format format)
          Compares state for the given logs.
static File createExecutableArchive(File archiveFolder, String archiveName, PrintStream out, Tracer tracer, List<String> additionalContent, 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 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, boolean filterUnsetFields, RogLogUtil.JsonPrettyPrintStyle style, Writer writer)
          Dumps a log entry in json format.
static void dumpObjectAsJson(IRogMetadata metadata, IStoreObject object, boolean dumpMetadata, boolean dumpObject, boolean filterUnsetFields, RogLogUtil.JsonPrettyPrintStyle style, Writer writer)
          Dumps an IStoreObject object or its metadata in json format.
static void dumpResultSetRowCsv(RogLogResultSet resultSet, Writer writer)
          Dumps a query result's selected fields in csv format.
static void dumpResultSetRowJson(RogLogResultSet resultSet, boolean includeMetadata, boolean includePayload, boolean filterUnsetFields, RogLogUtil.JsonPrettyPrintStyle style, Writer writer)
          Dumps the query result set row, rendering the entry object as json.
static void dumpResultSetRowTabular(RogLogResultSet resultSet, Writer writer)
          Dumps a query result's selected fields in tabular 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.
static String objectToJson(String prefix, IRogNode object, RogLogUtil.MetadataDisplayPolicy metadataDisplay, boolean filterUnsetFields, RogLogUtil.JsonPrettyPrintStyle style)
          Returns an IRogNode as a json formatted String.
static void traceObjectJson(String prefix, IRogNode object, RogLogUtil.MetadataDisplayPolicy metadataDisplay, boolean filterUnsetFields, RogLogUtil.JsonPrettyPrintStyle style, Tracer tracer, Tracer.Level traceLevel)
          Dumps an IRogNode object or its metadata in json format.
 
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

JSON_CUSTOM_PRETTY_PRINTER_PROP

public static final String JSON_CUSTOM_PRETTY_PRINTER_PROP
The property name used to look up a custom json pretty printer implementation class that implements PrettyPrinter

See Also:
Constant Field Values

JSON_SORT_PROPERTIES_ALPHABETICALLY_PROP

public static final String JSON_SORT_PROPERTIES_ALPHABETICALLY_PROP
The property name indicating whether objects dumped in json are sorted alphabetically.

See Also:
Constant Field Values
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

createExecutableArchive

public static File createExecutableArchive(File archiveFolder,
                                           String archiveName,
                                           PrintStream out,
                                           Tracer tracer,
                                           List<String> additionalContent,
                                           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.
additionalContent - List of = entries to include in the archive
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,
                                           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,
                                         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,
                                          boolean filterUnsetFields,
                                          RogLogUtil.JsonPrettyPrintStyle style,
                                          Writer writer)
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.
filterUnsetFields - Whether unset fields should be filtered from the object
style - The json pretty printer style to use.
writer - The writer to write to.

dumpResultSetRowJson

public static void dumpResultSetRowJson(RogLogResultSet resultSet,
                                        boolean includeMetadata,
                                        boolean includePayload,
                                        boolean filterUnsetFields,
                                        RogLogUtil.JsonPrettyPrintStyle style,
                                        Writer writer)
Dumps the query result set row, rendering the entry object as json.

Parameters:
resultSet - The result set row.
includeMetadata - Whether or not to include entry metadata.
includePayload - If false no payload information will be shown.
filterUnsetFields - Whether unset fields should be filtered from the object
style - The json pretty printer style to use.
writer - The writer to write to.

dumpResultSetRowCsv

public static void dumpResultSetRowCsv(RogLogResultSet resultSet,
                                       Writer writer)
Dumps a query result's selected fields in csv format.

Parameters:
resultSet - The result set.
writer - The writer to which to dump.

dumpResultSetRowTabular

public static void dumpResultSetRowTabular(RogLogResultSet resultSet,
                                           Writer writer)
Dumps a query result's selected fields in tabular format.

Parameters:
resultSet - The result set.
writer - The writer to which to dump.

traceObjectJson

public static final void traceObjectJson(String prefix,
                                         IRogNode object,
                                         RogLogUtil.MetadataDisplayPolicy metadataDisplay,
                                         boolean filterUnsetFields,
                                         RogLogUtil.JsonPrettyPrintStyle style,
                                         Tracer tracer,
                                         Tracer.Level traceLevel)
Dumps an IRogNode object or its metadata in json format.

Parameters:
object - The object to dump
metadataDisplay - How to display object metadata
filterUnsetFields - Whether unset fields should be filtered from the object
style - The json pretty printer style to use.
tracer - The tracer to trace to.
traceLevel - The traceLevel to use.

objectToJson

public static final String objectToJson(String prefix,
                                        IRogNode object,
                                        RogLogUtil.MetadataDisplayPolicy metadataDisplay,
                                        boolean filterUnsetFields,
                                        RogLogUtil.JsonPrettyPrintStyle style)
Returns an IRogNode as a json formatted String.

Parameters:
object - The object to dump
metadataDisplay - How to display object metadata
filterUnsetFields - Whether unset fields should be filtered from the object
style - The json pretty printer style to use.

dumpObjectAsJson

public static final void dumpObjectAsJson(IRogMetadata metadata,
                                          IStoreObject object,
                                          boolean dumpMetadata,
                                          boolean dumpObject,
                                          boolean filterUnsetFields,
                                          RogLogUtil.JsonPrettyPrintStyle style,
                                          Writer writer)
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
filterUnsetFields - Whether unset fields should be filtered from the object
style - The json pretty printer style to use.
writer - The writer to write to.


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