Skip to content
Snippets Groups Projects
Unverified Commit bc93e370 authored by Luca Keidel's avatar Luca Keidel
Browse files

Reduced log message spam, callback added for when a random transactions are finished

parent 4e64d4d7
Branches
No related tags found
1 merge request!6Overlay topology
......@@ -28,7 +28,7 @@ public class ActionJoinAnswer extends ClientAction {
protected void onAction(ActorRef sender, ActorRef self,
UntypedActorContext context, AbstractWallet wallet) {
wallet.addLogMsg("Addressed to " + self.path().name() + " from " + sender.path().name() + ": someNeighbors:" + someNeighbors);
//wallet.addLogMsg("Addressed to " + self.path().name() + " from " + sender.path().name() + ": someNeighbors:" + someNeighbors);
// your neighbours? my neighbours!
for (Entry<String, ActorRef> neighbor : someNeighbors.entrySet()) {
......
......@@ -43,7 +43,7 @@ public class ActionCommitDistributedCommittedTransfer extends ClientAction {
@Override
protected void onAction(ActorRef sender, ActorRef self,
UntypedActorContext context, AbstractWallet wallet) {
wallet.addLogMsg("ActionCommitDistributedCommittedTransfer is granted? " + granted);
//wallet.addLogMsg("ActionCommitDistributedCommittedTransfer is granted? " + granted);
if (granted) {
if (source.compareTo(self) == 0) {
......@@ -75,7 +75,6 @@ public class ActionCommitDistributedCommittedTransfer extends ClientAction {
}
}
//wallet.addLogMsg("wallet.amounts:" + wallet.amounts);
}
}
......@@ -28,9 +28,9 @@ public class ActionInvokeDistributedCommittedTransfer extends CoordinatorTransac
@Override
protected void onAction(ActorRef sender, ActorRef self,
UntypedActorContext context, SuperVisorImpl superVisor) {
superVisor.addLogMsg("invoke transaction " + source.path().name() +
/*superVisor.addLogMsg("invoke transaction " + source.path().name() +
" sends " + amount +
" to " + target.path().name());
" to " + target.path().name());*/
long timeout = System.currentTimeMillis() + 500;
......
......@@ -28,7 +28,7 @@ public class ActionPrepareDistributedCommittedTransferAnswer extends Coordinator
protected void onAction(ActorRef sender, ActorRef self,
UntypedActorContext context, SuperVisorImpl superVisor) {
superVisor.addLogMsg("granted?" + granted);
//superVisor.addLogMsg("granted?" + granted);
DistributedCommittedTransferRequest request = superVisor.getRequest(id);
......
......@@ -38,6 +38,7 @@ public abstract class AbstractConfiguration extends AbstractNode {
private Timeout timeout = new Timeout(Duration.create(10, "seconds"));
private int remainingTransactions;
private Callback callback;
private ActorRef lastWallet = null;
......@@ -117,7 +118,11 @@ public abstract class AbstractConfiguration extends AbstractNode {
}
protected void randomTransactions(int number, int maxTransactionsAtTheSameTime) {
randomTransactions(number, maxTransactionsAtTheSameTime, null);
}
protected void randomTransactions(int number, int maxTransactionsAtTheSameTime, Callback callback) {
this.callback = callback;
remainingTransactions = number;
for (int i = 0; i < Math.min(number, maxTransactionsAtTheSameTime); i++) {
......@@ -131,8 +136,9 @@ public abstract class AbstractConfiguration extends AbstractNode {
try {
randomTransaction();
} catch (Exception e) {
System.err.println("Error while trying to perform a random transaction: "+e.getMessage());
System.err.println("Error while trying to perform a random transaction: " + e.getMessage());
remainingTransactions = 0;
callback = null;
}
}
......@@ -184,6 +190,11 @@ public abstract class AbstractConfiguration extends AbstractNode {
if (remainingTransactions > 0) {
nextRandomTransaction();
} else {
if (callback != null) {
callback.transactionsFinished();
}
callback = null;
}
}
}
......@@ -223,4 +234,8 @@ public abstract class AbstractConfiguration extends AbstractNode {
wallet.tell(new ActionAddOverlayNeighbours(overlayNeighbours), self());
});
}
interface Callback {
public void transactionsFinished();
}
}
......@@ -17,7 +17,7 @@ public class MassWalletConfiguration extends AbstractConfiguration {
System.out.println("Wallet spawning timed out!");
}
randomTransactions(100, 10);
randomTransactions(10, 2, () -> System.out.println("All random transactions finished!"));
}
@Override
......
......@@ -61,7 +61,7 @@ public class WalletImpl extends AbstractWallet {
@Override
public void onReceive(Object message) {
addLogMsg(getSender().path().name() + " invokes " + getSelf().path().name() + " to do " + message.getClass().getSimpleName());
//addLogMsg(getSender().path().name() + " invokes " + getSelf().path().name() + " to do " + message.getClass().getSimpleName());
if (message instanceof ActionInvokeRevive) {
((ActionInvokeRevive) message).doAction(this);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment