public RemoveNode ( Node node, bool cleanly, bool output ) : void | ||
node | Node | |
cleanly | bool | |
output | bool | |
Résultat | void |
public static void HeavyChurn(Simulator sim, int time) { sim.Complete(); Dictionary<Node, Node> volatile_nodes = new Dictionary<Node, Node>(); int fifteen_mins = (int) ((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 2; Random rand = new Random(); DateTime end = DateTime.UtcNow.AddSeconds(time); while(end > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); List<Node> to_remove = new List<Node>(); foreach(Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if(prob <= .7) { continue; } // This is due to some bug that I can no longer remember // sim.RemoveNode(node, prob > .9); sim.RemoveNode(node, true); to_remove.Add(node); } foreach(Node node in to_remove) { volatile_nodes.Remove(node); } Console.WriteLine("Removed: {0} Nodes" , to_remove.Count); while(volatile_nodes.Count < max) { Node node = sim.AddNode(); volatile_nodes.Add(node, node); } } }
public static void HeavyChurn(Simulator sim, int time) { sim.Complete(); Dictionary <Node, Node> volatile_nodes = new Dictionary <Node, Node>(); int fifteen_mins = (int)((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 2; Random rand = new Random(); DateTime end = DateTime.UtcNow.AddSeconds(time); while (end > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); List <Node> to_remove = new List <Node>(); foreach (Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if (prob <= .7) { continue; } // This is due to some bug that I can no longer remember // sim.RemoveNode(node, prob > .9); sim.RemoveNode(node, true); to_remove.Add(node); } foreach (Node node in to_remove) { volatile_nodes.Remove(node); } Console.WriteLine("Removed: {0} Nodes", to_remove.Count); while (volatile_nodes.Count < max) { Node node = sim.AddNode(); volatile_nodes.Add(node, node); } } }
public static void Main(string []args) { Simulator sim = new Simulator(); bool complete; Runner.ParseCommandLine(args, out complete, sim); DateTime start = DateTime.UtcNow; sim.Complete(); Dictionary<Node, Node> volatile_nodes = new Dictionary<Node, Node>(); int fifteen_mins = (int) ((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 10; Random rand = new Random(); while(start.AddHours(24) > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); List<Node> to_remove = new List<Node>(); foreach(Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if(prob <= .7) { continue; } // sim.RemoveNode(node, prob > .9); sim.RemoveNode(node, true); to_remove.Add(node); } foreach(Node node in to_remove) { volatile_nodes.Remove(node); } Console.WriteLine("Removed: {0} Nodes" , to_remove.Count); while(volatile_nodes.Count < max) { Node node = sim.AddNode(); volatile_nodes.Add(node, node); } } }
public static void Commands(Simulator sim) { string command = String.Empty; Console.WriteLine("Type HELP for a list of commands.\n"); while (command != "Q") { bool secure = false; Console.Write("#: "); // Commands can have parameters separated by spaces string[] parts = Console.ReadLine().Split(' '); command = parts[0]; try { if(command.Equals("S")) { secure = true; command = parts[1]; } switch(command) { case "C": sim.CheckRing(true); break; case "P": sim.PrintConnections(); break; case "M": Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true)); break; case "CR": sim.Crawl(true, secure); break; case "A2A": sim.AllToAll(secure); break; case "A": sim.AddNode(); break; case "D": sim.RemoveNode(true, true); break; case "R": sim.RemoveNode(true, false); break; case "RUN": int steps = (parts.Length >= 2) ? Int32.Parse(parts[1]) : 0; if(steps > 0) { SimpleTimer.RunSteps(steps); } else { SimpleTimer.RunStep(); } break; case "Q": break; case "CONSTATE": sim.PrintConnectionState(); break; case "H": Console.WriteLine("Commands: \n"); Console.WriteLine("A - add a node"); Console.WriteLine("D - remove a node"); Console.WriteLine("R - abort a node"); Console.WriteLine("C - check the ring using ConnectionTables"); Console.WriteLine("P - Print connections for each node to the screen"); Console.WriteLine("M - Current memory usage according to the garbage collector"); Console.WriteLine("[S] CR - Perform a (secure) crawl of the network using RPC"); Console.WriteLine("[S] A2A - Perform all-to-all measurement of the network using RPC"); Console.WriteLine("Q - Quit"); break; default: Console.WriteLine("Invalid command"); break; } } catch(Exception e) { Console.WriteLine("Error: " + e); } Console.WriteLine(); } }
public static void Commands(Simulator sim) { string command = String.Empty; Console.WriteLine("Type HELP for a list of commands.\n"); while (command != "Q") { bool secure = false; Console.Write("#: "); // Commands can have parameters separated by spaces string[] parts = Console.ReadLine().Split(' '); command = parts[0]; try { if (command.Equals("S")) { secure = true; command = parts[1]; } switch (command) { case "C": sim.CheckRing(true); break; case "P": sim.PrintConnections(); break; case "M": Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true)); break; case "CR": sim.Crawl(true, secure); break; case "A2A": sim.AllToAll(secure); break; case "A": sim.AddNode(); break; case "D": sim.RemoveNode(true, true); break; case "R": sim.RemoveNode(true, false); break; case "RUN": int steps = (parts.Length >= 2) ? Int32.Parse(parts[1]) : 0; if (steps > 0) { SimpleTimer.RunSteps(steps); } else { SimpleTimer.RunStep(); } break; case "Q": break; case "CONSTATE": sim.PrintConnectionState(); break; case "H": Console.WriteLine("Commands: \n"); Console.WriteLine("A - add a node"); Console.WriteLine("D - remove a node"); Console.WriteLine("R - abort a node"); Console.WriteLine("C - check the ring using ConnectionTables"); Console.WriteLine("P - Print connections for each node to the screen"); Console.WriteLine("M - Current memory usage according to the garbage collector"); Console.WriteLine("[S] CR - Perform a (secure) crawl of the network using RPC"); Console.WriteLine("[S] A2A - Perform all-to-all measurement of the network using RPC"); Console.WriteLine("Q - Quit"); break; default: Console.WriteLine("Invalid command"); break; } } catch (Exception e) { Console.WriteLine("Error: " + e); } Console.WriteLine(); } }
public static void Commands(Simulator sim) { string command = String.Empty; Console.WriteLine("Type HELP for a list of commands.\n"); while (command != "Q") { bool secure = false; Console.Write("#: "); // Commands can have parameters separated by spaces string[] parts = Console.ReadLine().Split(' '); command = parts[0].ToUpper(); try { if (command.Equals("S")) { secure = true; command = parts[1].ToUpper();; } switch (command) { case "B": int forwarders = (parts.Length >= 2) ? Int32.Parse(parts[1]) : -1; Broadcast bcast = new Broadcast(sim.SimBroadcastHandler, sim.RandomNode().Node, forwarders, TaskFinished); bcast.Start(); RunUntilTaskFinished(); break; case "C": sim.CheckRing(true); break; case "P": sim.PrintConnections(); break; case "M": Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true)); break; case "CR": NodeMapping nm = sim.Nodes.Values[0]; SymphonySecurityOverlord bso = null; if (secure) { bso = nm.Sso; } Crawl c = new Crawl(nm.Node, sim.Nodes.Count, bso, TaskFinished); c.Start(); RunUntilTaskFinished(); break; case "A2A": AllToAll atoa = new AllToAll(sim.Nodes, secure, TaskFinished); atoa.Start(); RunUntilTaskFinished(); break; case "A": sim.AddNode(); break; case "D": sim.RemoveNode(true, true); break; case "R": sim.RemoveNode(false, true); break; case "REVOKE": sim.Revoke(true); break; case "RUN": int steps = (parts.Length >= 2) ? Int32.Parse(parts[1]) : 0; if (steps > 0) { SimpleTimer.RunSteps(steps); } else { SimpleTimer.RunStep(); } break; case "Q": break; case "CONSTATE": sim.PrintConnectionState(); break; case "H": Console.WriteLine("Commands: \n"); Console.WriteLine("A - add a node"); Console.WriteLine("D - remove a node"); Console.WriteLine("R - abort a node"); Console.WriteLine("C - check the ring using ConnectionTables"); Console.WriteLine("P - Print connections for each node to the screen"); Console.WriteLine("M - Current memory usage according to the garbage collector"); Console.WriteLine("[S] CR - Perform a (secure) crawl of the network using RPC"); Console.WriteLine("[S] A2A - Perform all-to-all measurement of the network using RPC"); Console.WriteLine("Q - Quit"); break; default: Console.WriteLine("Invalid command"); break; } } catch (Exception e) { Console.WriteLine("Error: " + e); } Console.WriteLine(); } }
public static void HeavyChurn(Simulator sim, int time) { sim.Complete(false); Dictionary <Node, Node> volatile_nodes = new Dictionary <Node, Node>(); int fifteen_mins = (int)((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 2; Random rand = new Random(); DateTime end = DateTime.UtcNow.AddSeconds(time); List <Node> to_disconnect = new List <Node>(); List <Node> to_abort = new List <Node>(); while (end > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); foreach (Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if (prob <= .7) { continue; } if (prob > .9) { to_disconnect.Add(node); } else { to_abort.Add(node); } } int added = 0; int removed = to_disconnect.Count + to_abort.Count; while (volatile_nodes.Count < max + removed) { added++; Node node = sim.AddNode(); volatile_nodes.Add(node, node); } foreach (Node node in to_disconnect) { sim.RemoveNode(node, true, false); volatile_nodes.Remove(node); } to_disconnect.Clear(); foreach (Node node in to_abort) { // This is due to bugs in Abort don't handle closing of ELs and maybe other stuff // sim.RemoveNode(node, false, false); sim.RemoveNode(node, true, false); volatile_nodes.Remove(node); } to_abort.Clear(); Console.WriteLine("Nodes: Added: {0}, Removed: {1}", added, removed); } }