类 Context

java.lang.Object
com.alibaba.csp.sentinel.context.Context
直接已知子类:
NullContext

public class Context extends Object
This class holds metadata of current invocation:
  • the EntranceNode: the root of the current invocation tree.
  • the current Entry: the current invocation point.
  • the current Node: the statistics related to the Entry.
  • the origin: The origin is useful when we want to control different invoker/consumer separately. Usually the origin could be the Service Consumer's app name or origin IP.

Each SphU#entry() or SphO#entry() should be in a Context, if we don't invoke ContextUtil#enter() explicitly, DEFAULT context will be used.

A invocation tree will be created if we invoke SphU#entry() multi times in the same context.

Same resource in different context will count separately, see NodeSelectorSlot.

作者:
jialiang.linjl, leyou(lihao), Eric Zhao
另请参阅:
  • 构造器详细资料

  • 方法详细资料

    • newAsyncContext

      public static Context newAsyncContext(DefaultNode entranceNode, String name)
      Create a new async context.
      参数:
      entranceNode - entrance node of the context
      name - context name
      返回:
      the new created context
      从以下版本开始:
      0.2.0
    • isAsync

      public boolean isAsync()
    • getName

      public String getName()
    • getCurNode

      public Node getCurNode()
    • setCurNode

      public Context setCurNode(Node node)
    • getCurEntry

      public Entry getCurEntry()
    • setCurEntry

      public Context setCurEntry(Entry curEntry)
    • getOrigin

      public String getOrigin()
    • setOrigin

      public Context setOrigin(String origin)
    • getOriginTotalQps

      public double getOriginTotalQps()
    • getOriginBlockQps

      public double getOriginBlockQps()
    • getOriginPassReqQps

      public double getOriginPassReqQps()
    • getOriginPassQps

      public double getOriginPassQps()
    • getOriginTotalRequest

      public long getOriginTotalRequest()
    • getOriginBlockRequest

      public long getOriginBlockRequest()
    • getOriginAvgRt

      public double getOriginAvgRt()
    • getOriginCurThreadNum

      public int getOriginCurThreadNum()
    • getEntranceNode

      public DefaultNode getEntranceNode()
    • getLastNode

      public Node getLastNode()
      Get the parent Node of the current.
      返回:
      the parent node of the current.
    • getOriginNode

      public Node getOriginNode()
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object