@@ -71,13 +71,14 @@ public TSStatus setTTL(SetTTLPlan plan) {
7171 // check ttl rule capacity
7272 final int tTlRuleCapacity = CommonDescriptor .getInstance ().getConfig ().getTTlRuleCapacity ();
7373 final int newTTLRuleCount = calculateNewTTLRuleCount (plan );
74- if (newTTLRuleCount > 0 && ttlCache .getTtlCount () + newTTLRuleCount > tTlRuleCapacity ) {
74+ final int requestedTTLRuleCount = ttlCache .getTtlCount () + newTTLRuleCount ;
75+ if (newTTLRuleCount > 0 && requestedTTLRuleCount > tTlRuleCapacity ) {
7576 TSStatus errorStatus = new TSStatus (TSStatusCode .OVERSIZE_TTL .getStatusCode ());
7677 errorStatus .setMessage (
7778 String .format (
78- "The number of TTL rules has reached the limit (%d). Please delete "
79- + "some existing rules first." ,
80- tTlRuleCapacity ));
79+ "The number of TTL rules has reached the limit "
80+ + "(capacity: %d, requested total: %d). Please delete some existing rules first." ,
81+ tTlRuleCapacity , requestedTTLRuleCount ));
8182 return errorStatus ;
8283 }
8384 ttlCache .setTTL (plan .getPathPattern (), plan .getTTL ());
@@ -94,17 +95,17 @@ public TSStatus setTTL(SetTTLPlan plan) {
9495 }
9596
9697 private int calculateNewTTLRuleCount (SetTTLPlan plan ) {
97- int newTTLRuleCount = getNewTTLRuleCount (plan .getPathPattern ());
98+ int newTTLRuleCount = isNewTTLRule (plan .getPathPattern ()) ? 1 : 0 ;
9899 if (plan .isDataBase ()) {
99100 String [] pathNodes = Arrays .copyOf (plan .getPathPattern (), plan .getPathPattern ().length + 1 );
100101 pathNodes [pathNodes .length - 1 ] = IoTDBConstant .MULTI_LEVEL_PATH_WILDCARD ;
101- newTTLRuleCount += getNewTTLRuleCount (pathNodes );
102+ newTTLRuleCount += isNewTTLRule (pathNodes ) ? 1 : 0 ;
102103 }
103104 return newTTLRuleCount ;
104105 }
105106
106- private int getNewTTLRuleCount (String [] pathNodes ) {
107- return ttlCache .getLastNodeTTL (pathNodes ) == TTLCache .NULL_TTL ? 1 : 0 ;
107+ private boolean isNewTTLRule (String [] pathNodes ) {
108+ return ttlCache .getLastNodeTTL (pathNodes ) == TTLCache .NULL_TTL ;
108109 }
109110
110111 /** Only used for upgrading from database level ttl to device level ttl. */
0 commit comments