Log warn when amount of context exceeds the max capacity for the first time
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
87076a6977
commit
9c2683e6ba
|
|
@ -203,6 +203,16 @@ public class CtSph implements Sph {
|
||||||
return chain;
|
return chain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current size of created slot chains.
|
||||||
|
*
|
||||||
|
* @return size of created slot chains
|
||||||
|
* @since 0.2.0
|
||||||
|
*/
|
||||||
|
public static int entrySize() {
|
||||||
|
return chainMap.size();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the slot chain map. Only for internal test.
|
* Reset the slot chain map. Only for internal test.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ public class ContextUtil {
|
||||||
DefaultNode node = localCacheNameMap.get(name);
|
DefaultNode node = localCacheNameMap.get(name);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
if (localCacheNameMap.size() > Constants.MAX_CONTEXT_NAME_SIZE) {
|
if (localCacheNameMap.size() > Constants.MAX_CONTEXT_NAME_SIZE) {
|
||||||
contextHolder.set(NULL_CONTEXT);
|
setNullContext();
|
||||||
return NULL_CONTEXT;
|
return NULL_CONTEXT;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
@ -131,7 +131,7 @@ public class ContextUtil {
|
||||||
node = contextNameNodeMap.get(name);
|
node = contextNameNodeMap.get(name);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
if (contextNameNodeMap.size() > Constants.MAX_CONTEXT_NAME_SIZE) {
|
if (contextNameNodeMap.size() > Constants.MAX_CONTEXT_NAME_SIZE) {
|
||||||
contextHolder.set(NULL_CONTEXT);
|
setNullContext();
|
||||||
return NULL_CONTEXT;
|
return NULL_CONTEXT;
|
||||||
} else {
|
} else {
|
||||||
node = new EntranceNode(new StringResourceWrapper(name, EntryType.IN), null);
|
node = new EntranceNode(new StringResourceWrapper(name, EntryType.IN), null);
|
||||||
|
|
@ -158,6 +158,18 @@ public class ContextUtil {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean shouldWarn = true;
|
||||||
|
|
||||||
|
private static void setNullContext() {
|
||||||
|
contextHolder.set(NULL_CONTEXT);
|
||||||
|
// Don't need to be thread-safe.
|
||||||
|
if (shouldWarn) {
|
||||||
|
RecordLog.warn("[SentinelStatusChecker] WARN: Amount of context exceeds the threshold "
|
||||||
|
+ Constants.MAX_CONTEXT_NAME_SIZE + ". Entries in new contexts will NOT take effect!");
|
||||||
|
shouldWarn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Enter the invocation context. The context is ThreadLocal, meaning that
|
* Enter the invocation context. The context is ThreadLocal, meaning that
|
||||||
|
|
@ -192,6 +204,16 @@ public class ContextUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current size of context entrance node map.
|
||||||
|
*
|
||||||
|
* @return current size of context entrance node map
|
||||||
|
* @since 0.2.0
|
||||||
|
*/
|
||||||
|
public static int contextSize() {
|
||||||
|
return contextNameNodeMap.size();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if provided context is a default auto-created context.
|
* Check if provided context is a default auto-created context.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue