Class Event

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    Collection, Count, CountGroup, Crash, Histogram, Progress, Reloaded, Reloading, Started, Starting, State, Stopped, Stopping, Unknown, Value, ValueGroup

    public abstract class Event
    extends java.lang.Object
    implements java.io.Serializable
    The Event class is the base class for all VESPA defined events. All specific Event classes extend this abstract class. An event is more or less a type and a set of properties. For convenience we use the logging system to transport Event instances, so the typical use is to serialize events into the payload of log messages.

    Note that the static methods started(), stopped() etc are for use with this class so using them in the subclasses isn't really sanctioned. These methods are what the user wants to use for logging events, rather than making events him/herself and stuffing them through the logging API.

    Author:
    Bjorn Borud
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Event()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void count​(java.lang.String name, long value)
      Static method for logging the count event.
      static void countGroup​(java.lang.String name, java.lang.String value)
      Static method for logging a set of count events.
      static void crash​(java.lang.String name, int pid, int signal)
      Static method for logging the crash event.
      java.lang.String getName()
      Get the name of the event instance.
      long getTime()
      Get the timestamp of this event
      java.lang.String getValue​(java.lang.String name)
      Get a property value.
      java.lang.String getValuePossiblyQuote​(java.lang.String name)
      Convenience method which returns a property.
      int getVersion()
      Get the event version.
      static void histogram​(java.lang.String name, java.lang.String value, java.lang.String representation)
      Static method for logging the histogram event.
      static Event parse​(java.lang.String s)
      Parse string representation of Event and emit correct Event subtype.
      static void progress​(java.lang.String name, long value, long total)
      Static method for logging the progress event.
      static void reloaded​(java.lang.String name)
      Static method for logging the reloaded event.
      static void reloading​(java.lang.String name)
      Static method for logging the reloading event.
      void setTime​(long time)
      Set the timestamp of this event.
      Event setValue​(java.lang.String name, java.lang.String value)
      Set a property.
      Event setVersion​(int version)
      Set event version
      static void started​(java.lang.String name)
      Static method for logging the started event.
      static void starting​(java.lang.String name)
      Static method for logging the starting event.
      static void state​(java.lang.String name, java.lang.String value)
      Static method for logging the state event.
      static void stopped​(java.lang.String name, int pid, int exitcode)
      Static method for logging the stopped event.
      static void stopping​(java.lang.String name, java.lang.String why)
      Static method for logging the stopping event.
      java.lang.String toString()
      This method returns the string representation of the event and must return something that can be parsed by the parse method.
      static void value​(java.lang.String name, double value)
      Static method for logging the value event.
      static void valueGroup​(java.lang.String name, java.lang.String value)
      Static method for logging a set of value events.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Event

        protected Event()
    • Method Detail

      • setValue

        public Event setValue​(java.lang.String name,
                              java.lang.String value)
        Set a property.
        Parameters:
        name - The name of the property
        value - The value of the property
      • getValue

        public java.lang.String getValue​(java.lang.String name)
        Get a property value.
      • setTime

        public void setTime​(long time)
        Set the timestamp of this event.
      • getTime

        public long getTime()
        Get the timestamp of this event
        Returns:
        returns the timestamp of this event
      • setVersion

        public Event setVersion​(int version)
        Set event version
        Parameters:
        version - The version of the event.
      • getVersion

        public int getVersion()
        Get the event version.
        Returns:
        event version
      • getValuePossiblyQuote

        public java.lang.String getValuePossiblyQuote​(java.lang.String name)
        Convenience method which returns a property. If the property contains whitespace the property will be enclosed in quotes. FIXME: quotes inside the value are not quoted
      • getName

        public java.lang.String getName()
        Get the name of the event instance.
        Returns:
        the name of the event instance.
      • toString

        public java.lang.String toString()
        This method returns the string representation of the event and must return something that can be parsed by the parse method.
        Overrides:
        toString in class java.lang.Object
      • parse

        public static Event parse​(java.lang.String s)
                           throws MalformedEventException
        Parse string representation of Event and emit correct Event subtype.
        Parameters:
        s - A string containing an event
        Returns:
        Event represented by s.
        Throws:
        MalformedEventException - if unable to deciper Event from string.
      • starting

        public static final void starting​(java.lang.String name)
        Static method for logging the starting event.
      • started

        public static final void started​(java.lang.String name)
        Static method for logging the started event.
      • stopping

        public static final void stopping​(java.lang.String name,
                                          java.lang.String why)
        Static method for logging the stopping event.
      • stopped

        public static final void stopped​(java.lang.String name,
                                         int pid,
                                         int exitcode)
        Static method for logging the stopped event.
      • reloading

        public static final void reloading​(java.lang.String name)
        Static method for logging the reloading event.
      • reloaded

        public static final void reloaded​(java.lang.String name)
        Static method for logging the reloaded event.
      • count

        public static final void count​(java.lang.String name,
                                       long value)
        Static method for logging the count event.
      • value

        public static final void value​(java.lang.String name,
                                       double value)
        Static method for logging the value event.
      • histogram

        public static final void histogram​(java.lang.String name,
                                           java.lang.String value,
                                           java.lang.String representation)
        Static method for logging the histogram event.
      • valueGroup

        public static final void valueGroup​(java.lang.String name,
                                            java.lang.String value)
        Static method for logging a set of value events.
      • countGroup

        public static final void countGroup​(java.lang.String name,
                                            java.lang.String value)
        Static method for logging a set of count events.
      • progress

        public static final void progress​(java.lang.String name,
                                          long value,
                                          long total)
        Static method for logging the progress event.
      • state

        public static final void state​(java.lang.String name,
                                       java.lang.String value)
        Static method for logging the state event.
      • crash

        public static final void crash​(java.lang.String name,
                                       int pid,
                                       int signal)
        Static method for logging the crash event.