コード例 #1
0
ファイル: Main.cs プロジェクト: johnynek/brunet
    public static int Main(string []args)
    {
      Parameters p = new Parameters("Simulator", "Simulator - Brunet Time Based Simulator");
      if(p.Parse(args) != 0) {
        Console.WriteLine(p.ErrorMessage);
        p.ShowHelp();
        return -1;
      } else if(p.Help) {
        p.ShowHelp();
        return -1;
      }

      Simulator sim = new Simulator(p);

      if(p.Complete) {
        sim.Complete();
      } else if(p.Evaluation) {
        DateTime now = DateTime.UtcNow;
        sim.Complete();
        SimpleTimer.RunSteps(p.EvaluationTime, false);
        sim.Complete();
        Console.WriteLine("Time spent setting up: " + (DateTime.UtcNow - now).ToString());
        sim.AllToAll();
        sim.Crawl();
      } else if(p.HeavyChurn) {
        HeavyChurn(sim, p.EvaluationTime);
      } else {
        Commands(sim);
      }
       return 0;
    }
コード例 #2
0
        public static int Main(string [] args)
        {
            Parameters p = new Parameters("Simulator", "Simulator - Brunet Time Based Simulator");

            if (p.Parse(args) != 0)
            {
                Console.WriteLine(p.ErrorMessage);
                p.ShowHelp();
                return(-1);
            }
            else if (p.Help)
            {
                p.ShowHelp();
                return(-1);
            }

            Simulator sim = new Simulator(p);

            if (p.Complete)
            {
                sim.Complete();
            }
            else if (p.Evaluation)
            {
                DateTime now = DateTime.UtcNow;
                sim.Complete();
                SimpleTimer.RunSteps(p.EvaluationTime, false);
                sim.Complete();
                Console.WriteLine("Time spent setting up: " + (DateTime.UtcNow - now).ToString());
                sim.AllToAll();
                sim.Crawl();
            }
            else if (p.HeavyChurn)
            {
                HeavyChurn(sim, p.EvaluationTime);
            }
            else
            {
                Commands(sim);
            }
            return(0);
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: johnynek/brunet
    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();
      }
    }
コード例 #4
0
        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();
            }
        }