-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-2.x-local-dev' into 'master-2.x'
update version to 2.1.0 See merge request changming.xie/tcc-transaction!2
- Loading branch information
Showing
29 changed files
with
1,250 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tcc-transaction-core/src/main/java/org/mengyun/tcctransaction/stats/CounterStatsItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.mengyun.tcctransaction.stats; | ||
|
||
import java.util.concurrent.atomic.LongAdder; | ||
|
||
/** | ||
* @author Nervose.Wu | ||
* @date 2024/1/19 14:14 | ||
*/ | ||
public class CounterStatsItem extends StatsItem { | ||
private final LongAdder count; | ||
|
||
public CounterStatsItem(String statsName, String statsKey) { | ||
super(statsName, statsKey); | ||
this.count = new LongAdder(); | ||
} | ||
|
||
public void record(long inc) { | ||
count.add(inc); | ||
} | ||
|
||
public long getCount() { | ||
return count.sum(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
tcc-transaction-core/src/main/java/org/mengyun/tcctransaction/stats/HistogramStatsItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.mengyun.tcctransaction.stats; | ||
|
||
import java.util.Arrays; | ||
import java.util.concurrent.atomic.LongAdder; | ||
|
||
/** | ||
* @author Nervose.Wu | ||
* @date 2024/1/29 11:14 | ||
*/ | ||
public class HistogramStatsItem extends StatsItem { | ||
private final LongAdder sum; | ||
|
||
private final long[] buckets; | ||
private final LongAdder[] distribution; | ||
|
||
|
||
public HistogramStatsItem(String statsName, String statsKey, long[] buckets) { | ||
super(statsName, statsKey); | ||
this.buckets = buckets; | ||
this.sum = new LongAdder(); | ||
this.distribution = new LongAdder[buckets.length]; | ||
Arrays.setAll(this.distribution, key -> new LongAdder()); | ||
} | ||
|
||
public void record(long inc) { | ||
for (int i = 0; i < buckets.length; i++) { | ||
if (inc <= buckets[i]) { | ||
distribution[i].add(1); | ||
break; | ||
} | ||
} | ||
sum.add(inc); | ||
} | ||
|
||
public long getSum() { | ||
return sum.sum(); | ||
} | ||
|
||
public long[] getDistribution() { | ||
return Arrays.stream(distribution).mapToLong(LongAdder::sum).toArray(); | ||
} | ||
} |
Oops, something went wrong.