Class EntityImpl

java.lang.Object
com.amazonaws.xray.entities.EntityImpl
All Implemented Interfaces:
Entity, java.lang.AutoCloseable
Direct Known Subclasses:
FacadeSegment, SegmentImpl, SubsegmentImpl

public abstract class EntityImpl
extends java.lang.Object
implements Entity
The base class from which Segment and Subsegment extend.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.lang.Object lock  
    protected static com.fasterxml.jackson.databind.ObjectMapper mapper
    Deprecated.
    For internal use only.
    protected int referenceCount  
    protected java.util.concurrent.atomic.LongAdder totalSize  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected EntityImpl()  
    protected EntityImpl​(AWSXRayRecorder creator, java.lang.String name)  
  • Method Summary

    Modifier and Type Method Description
    void addException​(java.lang.Throwable exception)
    Adds an exception to the entity's cause and sets fault to true.
    void addSubsegment​(Subsegment subsegment)
    Adds a subsegment.
    protected void checkAlreadyEmitted()
    Checks if the entity has already been emitted to the X-Ray daemon.
    boolean decrementReferenceCount()
    Decrements the subsegment-reference counter.
    java.util.Map<java.lang.String,​java.lang.Object> getAnnotations()  
    java.util.Map<java.lang.String,​java.lang.Object> getAws()  
    Cause getCause()  
    AWSXRayRecorder getCreator()  
    double getEndTime()  
    java.util.Map<java.lang.String,​java.lang.Object> getHttp()  
    java.lang.String getId()  
    java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getMetadata()  
    java.lang.String getName()  
    @Nullable java.lang.String getNamespace()  
    Entity getParent()  
    @Nullable java.lang.String getParentId()  
    abstract Segment getParentSegment()  
    int getReferenceCount()
    Returns the reference count of the segment.
    java.util.Map<java.lang.String,​java.lang.Object> getSql()  
    double getStartTime()  
    java.util.List<Subsegment> getSubsegments()  
    java.util.concurrent.locks.ReentrantLock getSubsegmentsLock()  
    java.util.concurrent.atomic.LongAdder getTotalSize()  
    TraceID getTraceId()  
    void incrementReferenceCount()
    Increments the subsegment-reference counter.
    boolean isEmitted()  
    boolean isError()  
    boolean isFault()  
    boolean isInProgress()  
    boolean isThrottle()  
    java.lang.String prettySerialize()  
    void putAllAws​(java.util.Map<java.lang.String,​java.lang.Object> all)
    Puts AWS information.
    void putAllHttp​(java.util.Map<java.lang.String,​java.lang.Object> all)
    Puts HTTP information.
    void putAllSql​(java.util.Map<java.lang.String,​java.lang.Object> all)
    Puts SQL information.
    void putAnnotation​(java.lang.String key, java.lang.Boolean value)
    Puts a Boolean annotation.
    void putAnnotation​(java.lang.String key, java.lang.Number value)
    Puts a Number annotation.
    void putAnnotation​(java.lang.String key, java.lang.String value)
    Puts a String annotation.
    void putAws​(java.lang.String key, java.lang.Object value)
    Puts AWS information.
    void putHttp​(java.lang.String key, java.lang.Object value)
    Puts HTTP information.
    void putMetadata​(java.lang.String key, java.lang.Object object)
    Puts metadata under the namespace 'default'.
    void putMetadata​(java.lang.String namespace, java.lang.String key, java.lang.Object object)
    Puts metadata.
    void putSql​(java.lang.String key, java.lang.Object value)
    Puts SQL information.
    void removeSubsegment​(Subsegment subsegment)
    Removes a subsegment from the subsegment list.
    java.lang.String serialize()  
    void setAnnotations​(java.util.Map<java.lang.String,​java.lang.Object> annotations)  
    void setAws​(java.util.Map<java.lang.String,​java.lang.Object> aws)  
    void setCreator​(AWSXRayRecorder creator)  
    void setEmitted​(boolean emitted)  
    void setEndTime​(double endTime)  
    void setError​(boolean error)
    Sets the error value of the entity.
    void setFault​(boolean fault)  
    void setHttp​(java.util.Map<java.lang.String,​java.lang.Object> http)  
    void setId​(java.lang.String id)  
    void setInProgress​(boolean inProgress)  
    void setMetadata​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> metadata)  
    void setNamespace​(java.lang.String namespace)  
    void setParent​(Entity parent)  
    void setParentId​(@Nullable java.lang.String parentId)  
    void setSql​(java.util.Map<java.lang.String,​java.lang.Object> sql)  
    void setStartTime​(double startTime)  
    void setSubsegmentsLock​(java.util.concurrent.locks.ReentrantLock subsegmentsLock)  
    void setThrottle​(boolean throttle)
    Sets the throttle value.
    void setTraceId​(TraceID traceId)  
    static void validateNotNull​(java.lang.Object object)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.AutoCloseable

    close

    Methods inherited from interface com.amazonaws.xray.entities.Entity

    run, run
  • Field Details

    • mapper

      @Deprecated protected static final com.fasterxml.jackson.databind.ObjectMapper mapper
      Deprecated.
      For internal use only.
    • lock

      protected final java.lang.Object lock
    • referenceCount

      protected int referenceCount
    • totalSize

      protected java.util.concurrent.atomic.LongAdder totalSize
  • Constructor Details

  • Method Details

    • checkAlreadyEmitted

      protected void checkAlreadyEmitted()
      Checks if the entity has already been emitted to the X-Ray daemon.
      Throws:
      AlreadyEmittedException - if the entity has already been emitted to the X-Ray daemon and the ContextMissingStrategy of the AWSXRayRecorder used to create this entity is configured to throw exceptions
    • getName

      public java.lang.String getName()
      Specified by:
      getName in interface Entity
    • getId

      public java.lang.String getId()
      Specified by:
      getId in interface Entity
      Returns:
      the id
    • setId

      public void setId​(java.lang.String id)
      Specified by:
      setId in interface Entity
      Parameters:
      id - the id to set
    • getStartTime

      public double getStartTime()
      Specified by:
      getStartTime in interface Entity
      Returns:
      the startTime
    • setStartTime

      public void setStartTime​(double startTime)
      Specified by:
      setStartTime in interface Entity
      Parameters:
      startTime - the startTime to set
    • getEndTime

      public double getEndTime()
      Specified by:
      getEndTime in interface Entity
      Returns:
      the endTime
    • setEndTime

      public void setEndTime​(double endTime)
      Specified by:
      setEndTime in interface Entity
      Parameters:
      endTime - the endTime to set
    • isFault

      public boolean isFault()
      Specified by:
      isFault in interface Entity
      Returns:
      the fault
    • setFault

      public void setFault​(boolean fault)
      Specified by:
      setFault in interface Entity
      Parameters:
      fault - the fault to set
    • isError

      public boolean isError()
      Specified by:
      isError in interface Entity
      Returns:
      the error
    • setError

      public void setError​(boolean error)
      Description copied from interface: Entity
      Sets the error value of the entity.
      Specified by:
      setError in interface Entity
      Parameters:
      error - the error to set
    • getNamespace

      public @Nullable java.lang.String getNamespace()
      Specified by:
      getNamespace in interface Entity
      Returns:
      the namespace
    • setNamespace

      public void setNamespace​(java.lang.String namespace)
      Specified by:
      setNamespace in interface Entity
      Parameters:
      namespace - the namespace to set
    • getSubsegmentsLock

      public java.util.concurrent.locks.ReentrantLock getSubsegmentsLock()
      Specified by:
      getSubsegmentsLock in interface Entity
      Returns:
      the subsegmentsLock
    • setSubsegmentsLock

      public void setSubsegmentsLock​(java.util.concurrent.locks.ReentrantLock subsegmentsLock)
      Specified by:
      setSubsegmentsLock in interface Entity
      Parameters:
      subsegmentsLock - the subsegmentsLock to set
    • getCause

      public Cause getCause()
      Specified by:
      getCause in interface Entity
      Returns:
      the cause
    • getHttp

      public java.util.Map<java.lang.String,​java.lang.Object> getHttp()
      Specified by:
      getHttp in interface Entity
      Returns:
      the http
    • setHttp

      public void setHttp​(java.util.Map<java.lang.String,​java.lang.Object> http)
      Specified by:
      setHttp in interface Entity
      Parameters:
      http - the http to set
    • getAws

      public java.util.Map<java.lang.String,​java.lang.Object> getAws()
      Specified by:
      getAws in interface Entity
      Returns:
      the aws
    • setAws

      public void setAws​(java.util.Map<java.lang.String,​java.lang.Object> aws)
      Specified by:
      setAws in interface Entity
      Parameters:
      aws - the aws to set
    • getSql

      public java.util.Map<java.lang.String,​java.lang.Object> getSql()
      Specified by:
      getSql in interface Entity
      Returns:
      the sql
    • setSql

      public void setSql​(java.util.Map<java.lang.String,​java.lang.Object> sql)
      Specified by:
      setSql in interface Entity
      Parameters:
      sql - the sql to set
    • getMetadata

      public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getMetadata()
      Specified by:
      getMetadata in interface Entity
      Returns:
      the metadata
    • setMetadata

      public void setMetadata​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> metadata)
      Specified by:
      setMetadata in interface Entity
      Parameters:
      metadata - the metadata to set
    • getAnnotations

      public java.util.Map<java.lang.String,​java.lang.Object> getAnnotations()
      Specified by:
      getAnnotations in interface Entity
      Returns:
      the annotations
    • setAnnotations

      public void setAnnotations​(java.util.Map<java.lang.String,​java.lang.Object> annotations)
      Specified by:
      setAnnotations in interface Entity
      Parameters:
      annotations - the annotations to set
    • getParent

      public Entity getParent()
      Specified by:
      getParent in interface Entity
      Returns:
      the parent
    • setParent

      public void setParent​(Entity parent)
      Specified by:
      setParent in interface Entity
      Parameters:
      parent - the parent to set
    • getCreator

      public AWSXRayRecorder getCreator()
      Specified by:
      getCreator in interface Entity
      Returns:
      the creator
    • setCreator

      public void setCreator​(AWSXRayRecorder creator)
      Specified by:
      setCreator in interface Entity
      Parameters:
      creator - the creator to set
    • isThrottle

      public boolean isThrottle()
      Specified by:
      isThrottle in interface Entity
      Returns:
      the throttle
    • setThrottle

      public void setThrottle​(boolean throttle)
      Description copied from interface: Entity
      Sets the throttle value. When setting to true, error is also set to true and fault set to false.
      Specified by:
      setThrottle in interface Entity
      Parameters:
      throttle - the throttle to set
    • isInProgress

      public boolean isInProgress()
      Specified by:
      isInProgress in interface Entity
      Returns:
      the inProgress
    • setInProgress

      public void setInProgress​(boolean inProgress)
      Specified by:
      setInProgress in interface Entity
      Parameters:
      inProgress - the inProgress to set
    • getTraceId

      public TraceID getTraceId()
      Specified by:
      getTraceId in interface Entity
      Returns:
      the traceId
    • setTraceId

      @EnsuresNonNull("this.traceId") public void setTraceId​(TraceID traceId)
      Specified by:
      setTraceId in interface Entity
      Parameters:
      traceId - the traceId to set
    • getParentId

      public @Nullable java.lang.String getParentId()
      Specified by:
      getParentId in interface Entity
      Returns:
      the parentId
    • setParentId

      public void setParentId​(@Nullable java.lang.String parentId)
      Specified by:
      setParentId in interface Entity
      Parameters:
      parentId - the parentId to set
    • getParentSegment

      public abstract Segment getParentSegment()
      Specified by:
      getParentSegment in interface Entity
    • getSubsegments

      public java.util.List<Subsegment> getSubsegments()
      Specified by:
      getSubsegments in interface Entity
      Returns:
      the subsegments
    • addSubsegment

      public void addSubsegment​(Subsegment subsegment)
      Description copied from interface: Entity
      Adds a subsegment.
      Specified by:
      addSubsegment in interface Entity
      Parameters:
      subsegment - the subsegment to add
    • addException

      public void addException​(java.lang.Throwable exception)
      Description copied from interface: Entity
      Adds an exception to the entity's cause and sets fault to true.
      Specified by:
      addException in interface Entity
      Parameters:
      exception - the exception to add
    • putHttp

      public void putHttp​(java.lang.String key, java.lang.Object value)
      Description copied from interface: Entity
      Puts HTTP information.
      Specified by:
      putHttp in interface Entity
      Parameters:
      key - the key under which the HTTP information is stored
      value - the HTTP information
    • putAllHttp

      public void putAllHttp​(java.util.Map<java.lang.String,​java.lang.Object> all)
      Description copied from interface: Entity
      Puts HTTP information.
      Specified by:
      putAllHttp in interface Entity
      Parameters:
      all - the HTTP information to put
    • putAws

      public void putAws​(java.lang.String key, java.lang.Object value)
      Description copied from interface: Entity
      Puts AWS information.
      Specified by:
      putAws in interface Entity
      Parameters:
      key - the key under which the AWS information is stored
      value - the AWS information
    • putAllAws

      public void putAllAws​(java.util.Map<java.lang.String,​java.lang.Object> all)
      Description copied from interface: Entity
      Puts AWS information.
      Specified by:
      putAllAws in interface Entity
      Parameters:
      all - the AWS information to put
    • putSql

      public void putSql​(java.lang.String key, java.lang.Object value)
      Description copied from interface: Entity
      Puts SQL information.
      Specified by:
      putSql in interface Entity
      Parameters:
      key - the key under which the SQL information is stored
      value - the SQL information
    • putAllSql

      public void putAllSql​(java.util.Map<java.lang.String,​java.lang.Object> all)
      Description copied from interface: Entity
      Puts SQL information.
      Specified by:
      putAllSql in interface Entity
      Parameters:
      all - the SQL information to put
    • putAnnotation

      public void putAnnotation​(java.lang.String key, java.lang.String value)
      Description copied from interface: Entity
      Puts a String annotation.
      Specified by:
      putAnnotation in interface Entity
      Parameters:
      key - the key under which the annotation is stored
      value - the String annotation
    • putAnnotation

      public void putAnnotation​(java.lang.String key, java.lang.Number value)
      Description copied from interface: Entity
      Puts a Number annotation.
      Specified by:
      putAnnotation in interface Entity
      Parameters:
      key - the key under which the annotation is stored
      value - the Number annotation
    • putAnnotation

      public void putAnnotation​(java.lang.String key, java.lang.Boolean value)
      Description copied from interface: Entity
      Puts a Boolean annotation.
      Specified by:
      putAnnotation in interface Entity
      Parameters:
      key - the key under which the annotation is stored
      value - the Boolean annotation
    • putMetadata

      public void putMetadata​(java.lang.String key, java.lang.Object object)
      Description copied from interface: Entity
      Puts metadata under the namespace 'default'.
      Specified by:
      putMetadata in interface Entity
      Parameters:
      key - the key under which the metadata is stored
      object - the metadata
    • putMetadata

      public void putMetadata​(java.lang.String namespace, java.lang.String key, java.lang.Object object)
      Description copied from interface: Entity
      Puts metadata.
      Specified by:
      putMetadata in interface Entity
      Parameters:
      namespace - the namespace under which the metadata is stored
      key - the key under which the metadata is stored
      object - the metadata
    • incrementReferenceCount

      public void incrementReferenceCount()
      Description copied from interface: Entity
      Increments the subsegment-reference counter.
      Specified by:
      incrementReferenceCount in interface Entity
    • decrementReferenceCount

      public boolean decrementReferenceCount()
      Description copied from interface: Entity
      Decrements the subsegment-reference counter.
      Specified by:
      decrementReferenceCount in interface Entity
      Returns:
      true if the segment is no longer in progress and the reference count is less than or equal to zero.
    • getReferenceCount

      public int getReferenceCount()
      Returns the reference count of the segment. This number represents how many open subsegments are children of this segment. The segment is emitted when its reference count reaches 0.
      Specified by:
      getReferenceCount in interface Entity
      Returns:
      the reference count
    • getTotalSize

      public java.util.concurrent.atomic.LongAdder getTotalSize()
      Specified by:
      getTotalSize in interface Entity
      Returns:
      the totalSize
    • isEmitted

      public boolean isEmitted()
      Specified by:
      isEmitted in interface Entity
      Returns:
      the emitted
    • setEmitted

      public void setEmitted​(boolean emitted)
      Specified by:
      setEmitted in interface Entity
      Parameters:
      emitted - the emitted to set
    • serialize

      public java.lang.String serialize()
      Specified by:
      serialize in interface Entity
    • prettySerialize

      public java.lang.String prettySerialize()
      Specified by:
      prettySerialize in interface Entity
    • removeSubsegment

      public void removeSubsegment​(Subsegment subsegment)
      Description copied from interface: Entity
      Removes a subsegment from the subsegment list. Decrements the total size of the parentSegment. Marks the removed subsegment as emitted future modification on this subsegment may raise an AlreadyEmittedException.
      Specified by:
      removeSubsegment in interface Entity
      Parameters:
      subsegment - the subsegment to remove
    • validateNotNull

      public static void validateNotNull​(java.lang.Object object)