Class TPC


  • public class TPC
    extends java.lang.Object

    TPC = Thread Performance Context

    The intent of thread performance context is to annotate a thread with information that describes some information about what that thread is doing and what system its task belongs to.

    Dedicated threads may be permanently annotated, whereas tasks running on shared threads may annotate their thread temporarily and remove the annotation when the task is finished.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TPC.Systems
      This class simply contains some constant strings for common systems to encourage consistency.
      static class  TPC.ThreadEntry
      Describes the context in which a thread is executing
      static interface  TPC.TPCUnset
      Callback object returned by the various "set*" methods that is used to un-set whatever was previously set.
    • Constructor Summary

      Constructors 
      Constructor Description
      TPC()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static TPC.ThreadEntry get​(java.lang.Thread thread)  
      static void initTimer​(java.util.Timer timer, java.lang.String system)
      If you know that a java.util.Timer will always be used for a specific system, you can set it up here, rather than try to set/unset in your timer tasks.
      static java.util.concurrent.ThreadFactory newThreadFactory​(java.lang.String name, java.lang.String system)
      Creates a new thread factory that will set the name and TPC system on each thread created.
      static TPC.TPCUnset setScope​(int scope)
      Sets the "scope" of the current thread to either Gateway, Designer, or Client.
      static TPC.TPCUnset setSystem​(java.lang.String system)
      Sets the system for the current (calling) thread.
      static TPC.TPCUnset setSystem​(java.lang.Thread thread, java.lang.String system)
      Sets the system for a thread other than the current (calling) thread.
      • Methods inherited from class java.lang.Object

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

      • TPC

        public TPC()
    • Method Detail

      • setScope

        public static TPC.TPCUnset setScope​(int scope)
        Sets the "scope" of the current thread to either Gateway, Designer, or Client. This will correctly default to whatever scope the current JVM is defined by. However, in the Gateway it will be overridden by tasks coming in from the client/designer so that thread load can be understood in context of the originating scope.
        Parameters:
        scope - an ApplicationScope code.
        Returns:
        a TPCUnset used to clear the scope that was set. It will return to whatever scope was set before setScope was called.
        See Also:
        ApplicationScope
      • setSystem

        public static TPC.TPCUnset setSystem​(java.lang.String system)

        Sets the system for the current (calling) thread. A "system" is an arbitrary string describing roughly what part of the system owns the task running on this thread. See constants in System for some examples.

        If your thread is dedicated to a system, you may safely ignore and never use the TPCUnset returned from this call.

        Returns:
        a TPCUnset object that can be used to return the system to whatever it was previous to this call
      • setSystem

        public static TPC.TPCUnset setSystem​(java.lang.Thread thread,
                                             java.lang.String system)
        Sets the system for a thread other than the current (calling) thread.
      • initTimer

        public static void initTimer​(java.util.Timer timer,
                                     java.lang.String system)

        If you know that a java.util.Timer will always be used for a specific system, you can set it up here, rather than try to set/unset in your timer tasks.

        The implementation will schedule a task immediately on the timer, which will set the system on it's calling thread (which will be the timer's private TimerThread)

      • newThreadFactory

        public static java.util.concurrent.ThreadFactory newThreadFactory​(java.lang.String name,
                                                                          java.lang.String system)
        Creates a new thread factory that will set the name and TPC system on each thread created. It is encouraged that this be used instead of NamedThreadFactory
        Parameters:
        name - Thread name used for threads created by this factory
        system - TPC system name that will be attached to all threads created by this factory.
        Returns:
        A ThreadFactory that will automatically name and annotate threads with TPC system information.