3232 */
3333public class RpcStatus {
3434
35- private static final ConcurrentMap <String , RpcStatus > SERVICE_STATISTICS = new ConcurrentHashMap <String , RpcStatus >();
35+ private static final ConcurrentMap <String , RpcStatus > SERVICE_STATISTICS = new ConcurrentHashMap <String ,
36+ RpcStatus >();
37+
38+ private static final ConcurrentMap <String , ConcurrentMap <String , RpcStatus >> METHOD_STATISTICS =
39+ new ConcurrentHashMap <String , ConcurrentMap <String , RpcStatus >>();
3640
37- private static final ConcurrentMap <String , ConcurrentMap <String , RpcStatus >> METHOD_STATISTICS = new ConcurrentHashMap <String , ConcurrentMap <String , RpcStatus >>();
3841 private final ConcurrentMap <String , Object > values = new ConcurrentHashMap <String , Object >();
42+
3943 private final AtomicInteger active = new AtomicInteger ();
4044 private final AtomicLong total = new AtomicLong ();
4145 private final AtomicInteger failed = new AtomicInteger ();
@@ -103,14 +107,18 @@ public static boolean beginCount(URL url, String methodName, int max) {
103107 }
104108 for (int i ; ; ) {
105109 i = methodStatus .active .get ();
106- if (i + 1 > max ) {
110+
111+ if (i == Integer .MAX_VALUE || i + 1 > max ) {
107112 return false ;
108113 }
114+
109115 if (methodStatus .active .compareAndSet (i , i + 1 )) {
110116 break ;
111117 }
112118 }
119+
113120 appStatus .active .incrementAndGet ();
121+
114122 return true ;
115123 }
116124
@@ -128,13 +136,16 @@ private static void endCount(RpcStatus status, long elapsed, boolean succeeded)
128136 status .active .decrementAndGet ();
129137 status .total .incrementAndGet ();
130138 status .totalElapsed .addAndGet (elapsed );
139+
131140 if (status .maxElapsed .get () < elapsed ) {
132141 status .maxElapsed .set (elapsed );
133142 }
143+
134144 if (succeeded ) {
135145 if (status .succeededMaxElapsed .get () < elapsed ) {
136146 status .succeededMaxElapsed .set (elapsed );
137147 }
148+
138149 } else {
139150 status .failed .incrementAndGet ();
140151 status .failedElapsed .addAndGet (elapsed );
0 commit comments