public InitServer(ReadOnlyCollection <IActorRef> a, AllConcurConfig ac, ReadOnlyCollection <HostInfo> h, int sn, HostInfo sh, int r) { AllActors = a; AlgortihmConfig = ac; Hosts = h; ServerNumber = sn; ServerHost = sh; Round = r; }
public static void InitActors(ActorSystem system, List <IActorRef> thisHostActors, List <IActorRef> allActors, List <HostInfo> hosts, AllConcurConfig algConfig, HostInfo currentHost, int stage, int interval) { int number = 0; foreach (var a in thisHostActors) { a.Tell(new Messages.InitServer(allActors.AsReadOnly(), algConfig, hosts.AsReadOnly(), number, currentHost, stage)); number++; } Props props = Props.Create(() => new ClientSimulationActor(thisHostActors, currentHost, interval)); IActorRef newActor = system.ActorOf(props, $"client"); }
public MemberAckActor(ActorSystem system, List <IActorRef> thisHostActors, List <HostInfo> hosts, AllConcurConfig algConfig, HostInfo currentHost, int interval) { Receive <Messages.MembershipResponse>((m) => { if (!init) { foreach (var rh in m.Hosts) { hosts.Add(rh); } List <IActorRef> allActors = Deployment.ReachActors(hosts, system); int stage = m.NextStage; Deployment.InitActors(system, thisHostActors, allActors, hosts, algConfig, currentHost, stage, interval); init = true; } }); }
public void Initialize(Messages.InitServer m) { currentRound = m.Round; algorithmConfig = m.AlgortihmConfig; deploymentConfig = new DeploymentConfig(m.Hosts.ToHashSet(), m.ServerHost, m.ServerNumber); foreach (var a in m.AllActors) { allActors.Add(a); } reliableOverlayGraph = GraphCreator.ComputeAllReliableSuccessors(algorithmConfig, allActors); SendGraphLogMsg(reliableOverlayGraph); foreach (var a in reliableOverlayGraph[Self]) { reliableSuccessors.Add(a); Context.Watch(a); } predecessors = GraphCreator.ComputeInverse(reliableOverlayGraph, Self); foreach (var a in predecessors) { Context.Watch(a); } foreach (var a in allActors) { trackingGraphs[a] = new TrackingGraph(reliableOverlayGraph, a); } trackingGraphs[Self].Clear(); BecomeReady(); }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("AkkaAllConcur (hostname port actors_count [hostname_to_connect port_to_connect])"); return; } DeploymentMode chosenMode; if (args.Length > 4) { chosenMode = DeploymentMode.Remote; } else { chosenMode = DeploymentMode.Local; } string hostname = args[0]; string port = args[1]; int n; try { n = Convert.ToInt32(args[2]); } catch (Exception) { Console.WriteLine("AkkaAllConcur (hostname port actors_count [hostname_to_connect port_to_connect])"); return; } AllConcurConfig algConfig = SettingsParser.ParseAlgConfig(); ActorSystem system = null; try { system = CreateActorSystem(hostname, port); } catch (Exception) { Console.WriteLine($"[ERR]: Actor system creation has failed. Hostname : {hostname}, Port : {port}."); return; } List <IActorRef> thisHostActors = CreateActors(system, n, chosenMode); HostInfo currentHost = new HostInfo { HostName = hostname, Port = port, ActorsNumber = n }; int stage = 0; List <IActorRef> allActors; List <HostInfo> hosts = new List <HostInfo>(); int interval; try { if (chosenMode == DeploymentMode.Remote) { interval = Convert.ToInt32(args[5]); } else //if (chosenMode == DeploymentMode.Local) { interval = Convert.ToInt32(args[3]); } } catch (Exception) { interval = DEFAULT_INTERVAL; } if (chosenMode == DeploymentMode.Remote) { string remoteHost = args[3]; string remotePort = args[4]; // Seed node is always srv0 string remoteActorPath = $"akka.tcp://{SystemName}@{remoteHost}:{remotePort}/user/svr0"; var remoteActor = system.ActorSelection(remoteActorPath); try { var t = remoteActor.ResolveOne(TimeSpan.FromSeconds(30)); t.Wait(); } catch (Exception) { Console.WriteLine($"[ERR]: Connection to actor system on {remoteHost}:{remotePort} was not established."); return; } Props ps = Props.Create(() => new MemberAckActor(system, thisHostActors, hosts, algConfig, currentHost, interval)); var ackA = system.ActorOf(ps, "ack"); remoteActor.Tell(new Messages.Abroadcast(new Messages.MembershipRequest(currentHost))); Console.WriteLine($"Connecting to {remoteHost}:{remotePort}..."); } else //if (chosenMode == DeploymentMode.Local) { Console.WriteLine($"Starting system on {hostname}:{port}"); hosts.Add(currentHost); allActors = thisHostActors; Deployment.InitActors(system, thisHostActors, allActors, hosts, algConfig, currentHost, stage, interval); } Thread.Sleep(TimeSpan.FromMinutes(10)); system.Dispose(); }
public static Dictionary <IActorRef, List <IActorRef> > ComputeAllReliableSuccessors(AllConcurConfig config, List <IActorRef> actors) { return(config.OverlayGraph == AllConcurConfig.OverlayGraphType.BINOMIAL ? ComputeUsingBinomial(actors) : ComputeUsingGs(actors)); }