Newer
Older
import java.util.concurrent.TimeUnit;
import akka.actor.ActorSystem;
import akka.actor.Address;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
Simon Könnecke
committed
import fucoin.wallet.WalletImpl;
import scala.concurrent.Await;
import javax.swing.*;
public static ActorRef remoteSuperVisorActor;
public static void main(String[] args) throws InterruptedException {
//Load configuration from current directory or from resources directory of jar
File file = new File("application.conf");
Config config = ConfigFactory.parseFile(file);
if (!file.exists()) {
System.out.println("Load default application.conf");
config = ConfigFactory.parseResources("application.conf");
} else {
System.out.println("Load local application.conf");
}
//Init System Actor System
ActorSystem system = ActorSystem.create("Remote", config);
Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
ActorRef preknownNeighbour = null;
while (preknownNeighbour == null) {
// get an address from a node which should be our preknown neighbour
String path = JOptionPane.showInputDialog(null, "Enter a neighbour node address: ");
// terminate if user clicked abort
if (path == null) {
system.terminate();
}
// tell the node that we want to join the network
ActorSelection selection = system.actorSelection(path);
try {
preknownNeighbour = Await.result(selection.resolveOne(timeout), timeout.duration());
} catch (Exception e) {
System.err.println("Something went wrong while resolving: " + e.getMessage());
}
}
system.actorOf(WalletImpl.props(preknownNeighbour, "Remote1"), "Remote1");