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

snapshot load

parent 6041bba0
Branches
No related tags found
No related merge requests found
......@@ -14,9 +14,7 @@ import scala.concurrent.Future;
import scala.concurrent.duration.Duration;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
public class SuperVisorGuiControlImpl implements SuperVisorGuiControl {
private SuperVisorImpl superVisor;
......@@ -61,14 +59,24 @@ public class SuperVisorGuiControlImpl implements SuperVisorGuiControl {
loadedSnapshotsOfWallets.clear();
loadedSnapshotDateTime = time;
fucoin.supervisor.Snapshot snapshot = superVisor.readSnapShot(time);
try {
Timeout timeout = new Timeout(Duration.create(10, "seconds"));
for (Map.Entry<String, ActorRef> item : superVisor.getKnownNeighbors().entrySet()) {
Future<Object> futureNeighbour = Patterns.ask(item.getValue(), new ActionWalletGetSnapshot(time), timeout);
ActionWalletGetSnapshotAnswer snapshot = (ActionWalletGetSnapshotAnswer)
Vector data = snapshot.getAmountTableModel().getDataVector();
/*AbstractNode node = new AbstractNode() {
@Override
public void onReceive(Object message) {
}
};*/
for (Object aData : data) {
String name = (String) ((ArrayList<Object>) aData).get(1);
ActorRef ref = superVisor.getKnownNeighbors().get(name);
Future<Object> futureNeighbour = Patterns.ask(ref, new ActionWalletGetSnapshot(time), timeout);
ActionWalletGetSnapshotAnswer snapshotAnswer = (ActionWalletGetSnapshotAnswer)
Await.result(futureNeighbour, timeout.duration());
addSnapshot(snapshot.getSnapshot());
addSnapshot(snapshotAnswer.getSnapshot());
//addSnapshot(new Gson().fromJson(node.readSnapshot(name, time), Snapshot.class) );
}
} catch (Exception e) {
e.printStackTrace();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment