Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate BeanColloctor into Partitioner #138

Merged
merged 32 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
90b588a
ask questions
wycccccc Dec 3, 2021
b2b4052
ask questions
wycccccc Dec 3, 2021
5576ea5
Merge branch 'main' of https://github.com/skiptests/astraea into clea…
wycccccc Dec 4, 2021
3f02758
mission completed
wycccccc Dec 5, 2021
dc3ed59
Little perfect
wycccccc Dec 6, 2021
fd50b9e
add test
wycccccc Dec 7, 2021
8e2b28d
dependency send
wycccccc Dec 10, 2021
cdd6197
spotless
wycccccc Dec 10, 2021
610bbc9
static beancolloctor
wycccccc Dec 10, 2021
0ab1a15
fix BeanCollectorFactory
wycccccc Dec 11, 2021
c21366d
use Receiver replace beanCollector
wycccccc Dec 14, 2021
105e9b9
Redundant code
wycccccc Dec 14, 2021
27dd6e6
private static
wycccccc Dec 14, 2021
a8a0ddf
a question
wycccccc Dec 16, 2021
e740052
Merge branch 'main' of https://github.com/skiptests/astraea into clea…
wycccccc Dec 17, 2021
2ccd68d
complete
wycccccc Dec 17, 2021
b0b786a
lambda
wycccccc Dec 18, 2021
a0ebab7
integrate SmoothWeightPartitioner and brokersWeight
wycccccc Dec 20, 2021
f10cced
remove static of brokerHashMap
wycccccc Dec 20, 2021
a265516
Some improvements
wycccccc Dec 21, 2021
832f6ee
remove duplicate code
wycccccc Dec 21, 2021
0ae477f
reflection of dependency
wycccccc Dec 22, 2021
93372ed
Edit comment
wycccccc Dec 22, 2021
255ef3a
some improvements
wycccccc Dec 25, 2021
c5a81a1
Annotation modification
wycccccc Dec 25, 2021
6710422
remove no need state
wycccccc Dec 25, 2021
1404866
dependency Control
wycccccc Dec 27, 2021
1a504ee
Dependency client interface
wycccccc Dec 28, 2021
7ccf9ac
Integration beginDependency
wycccccc Dec 29, 2021
e0ff448
reset
wycccccc Jan 5, 2022
2d98146
spotlessApply
wycccccc Jan 5, 2022
a873c68
TODO
wycccccc Jan 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,41 @@
import java.util.HashMap;
import java.util.Map;

/** do poisson for node's load situation */
public class LoadPoisson {
private NodeLoadClient nodeLoadClient;

public LoadPoisson(NodeLoadClient nodeLoadClient) {
this.nodeLoadClient = nodeLoadClient;
}

public synchronized HashMap<String, Double> setAllPoisson() {
HashMap<String, Double> poissonMap = new HashMap<>();
int lambda = nodeLoadClient.getAvgLoadCount();
for (Map.Entry<String, Integer> entry : nodeLoadClient.getAllOverLoadCount().entrySet()) {
int x = nodeLoadClient.getBinOneCount(entry.getValue());
poissonMap.put(entry.getKey(), doPoisson(lambda, x));
}
public HashMap<Integer, Double> allPoisson(Map<Integer, Integer> overLoadCount) {
var poissonMap = new HashMap<Integer, Double>();
var lambda = avgLoadCount(overLoadCount);
overLoadCount.forEach((nodeID, count) -> poissonMap.put(nodeID, doPoisson(lambda, count)));
return poissonMap;
}

public double doPoisson(int lambda, int x) {
double Probability = 0;
double ans = 0;

for (int i = 0; i <= x; i++) {
double j = Math.pow(lambda, i);
double e = Math.exp(-lambda);
long h = factorial(i);
// visible for test
double doPoisson(int lambda, int x) {
var Probability = 0.0;
var ans = 0.0;
var i = 0;
while (i <= x) {
var j = Math.pow(lambda, i);
var e = Math.exp(-lambda);
var h = factorial(i);
Probability = (j * e) / h;
ans += Probability;
i++;
}

return ans;
}

public long factorial(long number) {
// visible for test
long factorial(long number) {
if (number <= 1) return 1;
else return number * factorial(number - 1);
}

private int avgLoadCount(Map<Integer, Integer> overLoadCount) {
var avgLoadCount =
overLoadCount.values().stream().mapToDouble(Integer::doubleValue).average().orElse(0);
return (int) avgLoadCount;
}
}
Loading