Skip to content
Snippets Groups Projects
Commit a6413b36 authored by Simon Könnecke's avatar Simon Könnecke
Browse files

avg fix

parent a290d0a7
Branches dev-group1-simon
No related tags found
No related merge requests found
...@@ -21,6 +21,10 @@ public class ActionInterchangeState extends ClientAction { ...@@ -21,6 +21,10 @@ public class ActionInterchangeState extends ClientAction {
@Override @Override
protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet abstractNode) { protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet abstractNode) {
if (abstractNode.getStatistics().getAvg() == -1) {
abstractNode.getStatistics().setAvg(abstractNode.getAmount());
}
abstractNode.getStatistics().update(currentAmount); abstractNode.getStatistics().update(currentAmount);
} }
} }
...@@ -89,7 +89,7 @@ public class StatisticsWalletConfiguration extends AbstractConfiguration { ...@@ -89,7 +89,7 @@ public class StatisticsWalletConfiguration extends AbstractConfiguration {
numberOfInterchangeStatistic--; numberOfInterchangeStatistic--;
if (numberOfInterchangeStatistic == 0) { if (numberOfInterchangeStatistic == 0) {
createDump(); createSnapshot();
} else { } else {
interchangeStatistic(numberOfInterchangeStatistic); interchangeStatistic(numberOfInterchangeStatistic);
} }
...@@ -98,7 +98,7 @@ public class StatisticsWalletConfiguration extends AbstractConfiguration { ...@@ -98,7 +98,7 @@ public class StatisticsWalletConfiguration extends AbstractConfiguration {
/** /**
* Create a Dump of the SuperVisor and all active Wallets. * Create a Dump of the SuperVisor and all active Wallets.
*/ */
private void createDump() { private void createSnapshot() {
superVisor.tell(new ActionCreateSuperVisorSnapshot(LocalDateTime.now()), self()); superVisor.tell(new ActionCreateSuperVisorSnapshot(LocalDateTime.now()), self());
} }
......
...@@ -15,21 +15,14 @@ public class WalletStatistics implements Serializable { ...@@ -15,21 +15,14 @@ public class WalletStatistics implements Serializable {
public WalletStatistics() { public WalletStatistics() {
this.min = Integer.MAX_VALUE; this.min = Integer.MAX_VALUE;
this.max = Integer.MIN_VALUE; this.max = Integer.MIN_VALUE;
this.avg = 0; this.avg = -1;
this.count = 0; this.count = 0;
} }
public WalletStatistics(int min, int max, int avg, int count) {
this.min = min;
this.max = max;
this.avg = avg;
this.count = count;
}
public void update(int currentWalletAmount) { public void update(int currentWalletAmount) {
setMin(currentWalletAmount); setMin(currentWalletAmount);
setMax(currentWalletAmount); setMax(currentWalletAmount);
setAvg((getAvg() + currentWalletAmount) / 2); setMax((getAvg() + currentWalletAmount) / 2);
} }
public int getMin() { public int getMin() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment