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

snapshot load

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