com.endeca.infront.assembler.perf.serializers
Class PerfLogTimeEventSerializer

java.lang.Object
  extended by com.endeca.infront.assembler.perf.serializers.PerfLogTimeEventSerializer
All Implemented Interfaces:
EventSerializer

public class PerfLogTimeEventSerializer
extends Object

An implementation of EventSerializer that logs time taken, per request, into the assembler performance log.


Constructor Summary
PerfLogTimeEventSerializer(String outputPath, RecordedEventsConfiguration loggableEvents)
          Constructs a PerfLogTimeEventSerializer with a log file count of 5 and a log file limit of 1000 (that is, 1000 megabytes).
PerfLogTimeEventSerializer(String outputPath, RecordedEventsConfiguration loggableEvents, int logFileCount, int logFileLimit)
          Constructs a PerfLogTimeEventSerializer.
 
Method Summary
protected  void createHeaderForEventSummary(StringBuilder builder, String eventID)
          Appends header text describing the event formatting and time units.
protected  List<String> createLoggables(RecordedEventsConfiguration loggableEvents)
          Iterates through the recorded events in the input RecordedEventsConfiguration to create a list of Strings describing the events.
protected  Logger createLogger(String outputPath, int logFileCount, int logFileLimit)
          Creates a Logger and sets up appropriate formatting.
protected  void emptySummary(StringBuilder builder)
          Generates an empty summary for the event type.
 EventFactory getEventFactory()
          Get the factory which is responsible for creating events for this serializer.
protected  void outputHeaderLine()
          Creates the header line, which involves calling createHeaderForEventSummary(StringBuilder, String) for each loggable entry.
 void serialize(Map<String,EventSummary> events, javax.servlet.http.HttpServletRequest request)
          Record performance events with this serializer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerfLogTimeEventSerializer

public PerfLogTimeEventSerializer(String outputPath,
                                  RecordedEventsConfiguration loggableEvents)
                           throws IOException
Constructs a PerfLogTimeEventSerializer with a log file count of 5 and a log file limit of 1000 (that is, 1000 megabytes).

Parameters:
outputPath - The path to the log file to output. The log file name can contain all the wildcards supported by FileHandler. The parameter "%g" must be included in the file name to reflect the number of the log file, or this value will be appended to the name.
loggableEvents - The performance events for CartridgeHandler that this listener should output
Throws:
IOException

PerfLogTimeEventSerializer

public PerfLogTimeEventSerializer(String outputPath,
                                  RecordedEventsConfiguration loggableEvents,
                                  int logFileCount,
                                  int logFileLimit)
                           throws IOException
Constructs a PerfLogTimeEventSerializer.

Parameters:
outputPath - The path to the log file to output. The log file name can contain all the wildcards supported by FileHandler. The parameter "%g" must be included in the file name to reflect the number of the log file, or this value will be appended to the name.
loggableEvents - The performance events for CartridgeHandler that this listener should output
logFileCount - The number of log files to cycle through.
logFileLimit - The maximum size of a log file, in Megabytes. Once this limit is reached, the log file will rotate.
Throws:
IOException
Method Detail

createHeaderForEventSummary

protected void createHeaderForEventSummary(StringBuilder builder,
                                           String eventID)
Appends header text describing the event formatting and time units.

Parameters:
builder - the StringBuilder to append to
eventID - the event ID

emptySummary

protected void emptySummary(StringBuilder builder)
Generates an empty summary for the event type.

Parameters:
builder - the StringBuilder to append to

getEventFactory

public EventFactory getEventFactory()
Get the factory which is responsible for creating events for this serializer.

Specified by:
getEventFactory in interface EventSerializer
Returns:
EventFactory

outputHeaderLine

protected void outputHeaderLine()
Creates the header line, which involves calling createHeaderForEventSummary(StringBuilder, String) for each loggable entry.

See Also:
createLoggables(RecordedEventsConfiguration)

createLogger

protected Logger createLogger(String outputPath,
                              int logFileCount,
                              int logFileLimit)
                       throws IOException
Creates a Logger and sets up appropriate formatting.

Parameters:
outputPath - The path to the log file to output. The log file name can contain all the wildcards supported by FileHandler. The parameter "%g" must be included in the file name to reflect the number of the log file, or this value will be appended to the name.
logFileCount - The number of log files to cycle through.
logFileLimit - The maximum size of a log file, in Megabytes. Once this limit is reached, the log file will rotate.
Throws:
IOException - if a File cannot be created corresponding to the outputPath.

createLoggables

protected List<String> createLoggables(RecordedEventsConfiguration loggableEvents)
Iterates through the recorded events in the input RecordedEventsConfiguration to create a list of Strings describing the events.

Returns:
list of event descriptions to be logged

serialize

public void serialize(Map<String,EventSummary> events,
                      javax.servlet.http.HttpServletRequest request)
Record performance events with this serializer.

Specified by:
serialize in interface EventSerializer
Parameters:
events - the events to serialize
request - the request that generated the given events.


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