public abstract class Entry extends Object implements AutoCloseable
SphU#entry() will return an Entry. This class holds information of current invocation:Node, that is statistics of the resource in current context.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.
SphU,
Context,
ContextUtil| Modifier and Type | Field and Description |
|---|---|
protected ResourceWrapper |
resourceWrapper |
| Constructor and Description |
|---|
Entry(ResourceWrapper resourceWrapper) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Equivalent to
exit(). |
void |
exit()
Complete the current resource entry and restore the entry stack in context.
|
void |
exit(int count) |
abstract void |
exit(int count,
Object... args)
Exit this entry.
|
BlockException |
getBlockError() |
long |
getCompleteTimestamp() |
long |
getCreateTimestamp() |
Node |
getCurNode() |
Throwable |
getError() |
abstract Node |
getLastNode()
|
Node |
getOriginNode()
|
ResourceWrapper |
getResourceWrapper() |
Entry |
setBlockError(BlockException blockError) |
Entry |
setCompleteTimestamp(long completeTimestamp) |
void |
setCurNode(Node node) |
void |
setError(Throwable error) |
void |
setOriginNode(Node originNode) |
protected abstract Entry |
trueExit(int count,
Object... args)
Exit this entry.
|
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. |
protected final ResourceWrapper resourceWrapper
public Entry(ResourceWrapper resourceWrapper)
public ResourceWrapper getResourceWrapper()
public void exit()
throws ErrorEntryFreeException
ErrorEntryFreeException - if entry in current context does not match current entrypublic void exit(int count)
throws ErrorEntryFreeException
ErrorEntryFreeExceptionpublic void close()
exit(). Support try-with-resources since JDK 1.7.close in interface AutoCloseablepublic abstract void exit(int count,
Object... args)
throws ErrorEntryFreeException
count - tokens to release.args - extra parametersErrorEntryFreeException, - if Context.getCurEntry() is not this entry.ErrorEntryFreeExceptionprotected abstract Entry trueExit(int count, Object... args) throws ErrorEntryFreeException
count - tokens to release.args - extra parametersErrorEntryFreeException, - if Context.getCurEntry() is not this entry.ErrorEntryFreeExceptionpublic abstract Node getLastNode()
public long getCreateTimestamp()
public long getCompleteTimestamp()
public Entry setCompleteTimestamp(long completeTimestamp)
public Node getCurNode()
public void setCurNode(Node node)
public BlockException getBlockError()
public Entry setBlockError(BlockException blockError)
public Throwable getError()
public void setError(Throwable error)
public Node getOriginNode()
Node of the this Entry, may be null if no origin specified by
ContextUtil.enter(String name, String origin).public void setOriginNode(Node originNode)
public abstract void whenTerminate(BiConsumer<Context,Entry> handler)
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 terminatesCopyright © 2021 Alibaba Group. All rights reserved.