类 Entry

java.lang.Object
com.alibaba.csp.sentinel.Entry
所有已实现的接口:
AutoCloseable
直接已知子类:
AsyncEntry

public abstract class Entry extends Object implements AutoCloseable
Each SphU#entry() will return an Entry. This class holds information of current invocation:
  • createTime, the create time of this entry, using for rt statistics.
  • current Node, that is statistics of the resource in current context.
  • origin Node, that is statistics for the specific origin. Usually the origin could be the Service Consumer's app name, see ContextUtil.enter(String name, String origin)
  • ResourceWrapper, that is resource name.

A invocation tree will be created if we invoke SphU#entry() multi times in the same Context, so parent or child entry may be held by this to form the tree. Since Context always holds the current entry in the invocation tree, every exit() call should modify Context.setCurEntry(Entry) as parent entry of this.

作者:
qinan.qn, jialiang.linjl, leyou(lihao), Eric Zhao
另请参阅:
  • 字段详细资料

    • OBJECTS0

      protected static final Object[] OBJECTS0
    • resourceWrapper

      protected final ResourceWrapper resourceWrapper
    • count

      protected final int count
    • args

      protected final Object[] args
  • 构造器详细资料

  • 方法详细资料

    • getResourceWrapper

      public ResourceWrapper getResourceWrapper()
    • exit

      public void exit() throws ErrorEntryFreeException
      Complete the current resource entry and restore the entry stack in context. Do not need to carry count or args parameter, initialization does
      抛出:
      ErrorEntryFreeException - if entry in current context does not match current entry
    • exit

      public void exit(int count) throws ErrorEntryFreeException
      抛出:
      ErrorEntryFreeException
    • close

      public void close()
      Equivalent to exit(). Support try-with-resources since JDK 1.7.
      指定者:
      close 在接口中 AutoCloseable
      从以下版本开始:
      1.5.0
    • exit

      public abstract void exit(int count, Object... args) throws ErrorEntryFreeException
      Exit this entry. This method should invoke if and only if once at the end of the resource protection.
      参数:
      count - tokens to release.
      args - extra parameters
      抛出:
      ErrorEntryFreeException
    • trueExit

      protected abstract Entry trueExit(int count, Object... args) throws ErrorEntryFreeException
      Exit this entry.
      参数:
      count - tokens to release.
      args - extra parameters
      返回:
      next available entry after exit, that is the parent entry.
      抛出:
      ErrorEntryFreeException
    • getLastNode

      public abstract Node getLastNode()
      Get related Node of the parent Entry.
      返回:
    • getCreateTimestamp

      public long getCreateTimestamp()
    • getCompleteTimestamp

      public long getCompleteTimestamp()
    • setCompleteTimestamp

      public Entry setCompleteTimestamp(long completeTimestamp)
    • getCurNode

      public Node getCurNode()
    • setCurNode

      public void setCurNode(Node node)
    • getBlockError

      public BlockException getBlockError()
    • setBlockError

      public Entry setBlockError(BlockException blockError)
    • getError

      public Throwable getError()
    • setError

      public void setError(Throwable error)
    • getOriginNode

      public Node getOriginNode()
      Get origin Node of the this Entry.
      返回:
      origin Node of the this Entry, may be null if no origin specified by ContextUtil.enter(String name, String origin).
    • setOriginNode

      public void setOriginNode(Node originNode)
    • whenTerminate

      public abstract void whenTerminate(BiConsumer<Context,Entry> handler)
      Like CompletableFuture since JDK 8, it guarantees specified handler is invoked when this entry terminated (exited), no matter it's blocked or permitted. Use it when you did some STATEFUL operations on entries.
      参数:
      handler - handler function on the invocation terminates
      从以下版本开始:
      1.8.0