Class XTraceBufferedImpl

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Iterable<XEvent>, java.util.Collection<XEvent>, java.util.List<XEvent>, XAttributable, XElement, XTrace

    public class XTraceBufferedImpl
    extends java.lang.Object
    implements XTrace
    Soft-buffered implementation of the XTrace interface. Uses the virtual NikeFS filesystem for event log data for transparently storing the data on disk, so that main memory is freed for other tasks.
    Author:
    Christian W. Guenther (christian@deckfour.org)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ID_PREFIX
      ID prefix used for this implementation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(XVisitor visitor, XLog log)  
      void add​(int index, XEvent event)  
      boolean add​(XEvent event)  
      boolean addAll​(int index, java.util.Collection<? extends XEvent> c)  
      boolean addAll​(java.util.Collection<? extends XEvent> c)  
      void clear()  
      java.lang.Object clone()
      Creates an identical clone of this trace.
      boolean consolidate()
      Trigger consolidation of this trace.
      boolean contains​(java.lang.Object o)  
      boolean containsAll​(java.util.Collection<?> c)  
      boolean equals​(java.lang.Object o)
      List equality for XTrace Equality as defined in the List interface and as implemented in the AbstractList class, with a small tweak for efficiency.
      protected void finalize()  
      XEvent get​(int index)  
      XAttributeMap getAttributes()
      Retrieves the attributes set for this element.
      java.util.Set<XExtension> getExtensions()
      Retrieves the extensions used by this element, i.e.
      boolean hasAttributes()
      Checks for the existence of attributes.
      int indexOf​(java.lang.Object o)  
      int insertOrdered​(XEvent event)
      Insert the event in an ordered manner, if timestamp information is available in this trace.
      boolean isEmpty()  
      java.util.Iterator<XEvent> iterator()  
      int lastIndexOf​(java.lang.Object o)  
      java.util.ListIterator<XEvent> listIterator()  
      java.util.ListIterator<XEvent> listIterator​(int index)  
      XEvent remove​(int index)  
      boolean remove​(java.lang.Object o)  
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      XEvent set​(int index, XEvent event)  
      void setAttributes​(XAttributeMap attributes)
      Sets the map of attributes for this element.
      int size()  
      java.util.List<XEvent> subList​(int fromIndex, int toIndex)  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        hashCode, replaceAll, sort, spliterator
    • Field Detail

      • ID_PREFIX

        public static final java.lang.String ID_PREFIX
        ID prefix used for this implementation.
        See Also:
        Constant Field Values
    • Constructor Detail

      • XTraceBufferedImpl

        public XTraceBufferedImpl​(XAttributeMap attributeMap,
                                  XAttributeMapSerializer attributeMapSerializer)
        Creates a new trace.
        Parameters:
        attributeMap - Map to store the attributes of this trace.
        attributeMapSerializer - Serializer used to serialize the attribute maps of events in this buffered trace.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        List equality for XTrace Equality as defined in the List interface and as implemented in the AbstractList class, with a small tweak for efficiency.
        Specified by:
        equals in interface java.util.Collection<XEvent>
        Specified by:
        equals in interface java.util.List<XEvent>
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - Object to be compared with this XTrace implementation.
        Returns:
        Returns true if both objects are lists and the elements of both lists are equal.
      • hasAttributes

        public boolean hasAttributes()
        Description copied from interface: XAttributable
        Checks for the existence of attributes. This method can be a more efficient way of checking for the existance of attributes than using XAttributable.getAttributes() in certain situations.
        Specified by:
        hasAttributes in interface XAttributable
        Returns:
        whether this element has any attributes
      • getExtensions

        public java.util.Set<XExtension> getExtensions()
        Description copied from interface: XAttributable
        Retrieves the extensions used by this element, i.e. the extensions used by all attributes of this element, and the element itself.
        Specified by:
        getExtensions in interface XAttributable
        Returns:
        A set of extensions.
      • setAttributes

        public void setAttributes​(XAttributeMap attributes)
        Description copied from interface: XAttributable
        Sets the map of attributes for this element.
        Specified by:
        setAttributes in interface XAttributable
        Parameters:
        attributes - A map of attributes.
      • add

        public boolean add​(XEvent event)
        Specified by:
        add in interface java.util.Collection<XEvent>
        Specified by:
        add in interface java.util.List<XEvent>
      • add

        public void add​(int index,
                        XEvent event)
        Specified by:
        add in interface java.util.List<XEvent>
      • addAll

        public boolean addAll​(java.util.Collection<? extends XEvent> c)
        Specified by:
        addAll in interface java.util.Collection<XEvent>
        Specified by:
        addAll in interface java.util.List<XEvent>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends XEvent> c)
        Specified by:
        addAll in interface java.util.List<XEvent>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<XEvent>
        Specified by:
        clear in interface java.util.List<XEvent>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<XEvent>
        Specified by:
        contains in interface java.util.List<XEvent>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<XEvent>
        Specified by:
        containsAll in interface java.util.List<XEvent>
      • get

        public XEvent get​(int index)
        Specified by:
        get in interface java.util.List<XEvent>
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<XEvent>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<XEvent>
        Specified by:
        isEmpty in interface java.util.List<XEvent>
      • iterator

        public java.util.Iterator<XEvent> iterator()
        Specified by:
        iterator in interface java.util.Collection<XEvent>
        Specified by:
        iterator in interface java.lang.Iterable<XEvent>
        Specified by:
        iterator in interface java.util.List<XEvent>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<XEvent>
      • listIterator

        public java.util.ListIterator<XEvent> listIterator()
        Specified by:
        listIterator in interface java.util.List<XEvent>
      • listIterator

        public java.util.ListIterator<XEvent> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<XEvent>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<XEvent>
        Specified by:
        remove in interface java.util.List<XEvent>
      • remove

        public XEvent remove​(int index)
        Specified by:
        remove in interface java.util.List<XEvent>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<XEvent>
        Specified by:
        removeAll in interface java.util.List<XEvent>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<XEvent>
        Specified by:
        retainAll in interface java.util.List<XEvent>
      • set

        public XEvent set​(int index,
                          XEvent event)
        Specified by:
        set in interface java.util.List<XEvent>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<XEvent>
        Specified by:
        size in interface java.util.List<XEvent>
      • subList

        public java.util.List<XEvent> subList​(int fromIndex,
                                              int toIndex)
        Specified by:
        subList in interface java.util.List<XEvent>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<XEvent>
        Specified by:
        toArray in interface java.util.List<XEvent>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<XEvent>
        Specified by:
        toArray in interface java.util.List<XEvent>
      • clone

        public java.lang.Object clone()
        Creates an identical clone of this trace.
        Specified by:
        clone in interface XElement
        Overrides:
        clone in class java.lang.Object
        Returns:
        An identical clone.
      • consolidate

        public boolean consolidate()
        Trigger consolidation of this trace.
        Returns:
        whether consolidation has been performed.
      • insertOrdered

        public int insertOrdered​(XEvent event)
        Insert the event in an ordered manner, if timestamp information is available in this trace.
        Specified by:
        insertOrdered in interface XTrace
        Parameters:
        event - the event to be inserted.
        Returns:
        index of the inserted event.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable