Brunet.Applications.MultiNode.Run C# (CSharp) Method

Run() public method

This is where the magic happens! Sets up Shutdown, creates all the nodes, and call Connect on them in separate threads.
public Run ( ) : void
return void
    public override void Run()
    {
      string node_addr = _node_config.NodeAddress;
      for(int i = 1; i < _count; i++) {
        _node_config.NodeAddress = (Utils.GenerateAHAddress()).ToString();
        ApplicationNode node = CreateNode(_node_config);
        new Information(node.Node, "MultiNode", node.SecurityOverlord);
        _nodes.Add(node);
        Thread thread = new Thread(node.Node.Connect);
        thread.Start();
        _threads.Add(thread);

        if(node.PrivateNode != null) {
          ApplicationNode pnode = node.PrivateNode;
          new Information(pnode.Node, "MultiPrivateNode", pnode.SecurityOverlord);
          thread = new Thread(pnode.Node.Connect);
          thread.Start();
          _threads.Add(thread);
        }
      }

      _node_config.NodeAddress = node_addr;
      _app_node = CreateNode(_node_config);
      new Information(_app_node.Node, "MultiNode", _app_node.SecurityOverlord);
      _nodes.Add(_app_node);
      Console.WriteLine("Starting at {0}, {1} is connecting to {2}.",
          DateTime.UtcNow, _app_node.Node.Address, _app_node.Node.Realm);

      if(_app_node.PrivateNode != null) {
        ApplicationNode pnode = _app_node.PrivateNode;
        new Information(pnode.Node, "MultiPrivateNode", pnode.SecurityOverlord);
        Thread thread = new Thread(pnode.Node.Connect);
        thread.Start();
        _threads.Add(thread);
      }
      _app_node.Node.Connect();
    }

Usage Example

Beispiel #1
0
    /**
    <summary>Runs the MultiNode.</summary>
    <remarks>
    <para>To execute this at a command-line using Mono with 10 nodes:</para>
    <code>
    mono MultiNode.exe path/to/node_config 10
    </code>
    <para>To execute this at a command-line using Windows .NET with 15 nodes:
    </para>
    <code>
    MultiNode.exe path/to/node_config 15
    </code>
    </remarks>
    <param name="args">The command line arguments required are a path to a
    NodeConfig and the count of Brunet.Nodes to run.</param>
    */
    public static new int Main(String[] args) {
      int count = 0;
      try {
        count = Int32.Parse(args[1]);
      }
      catch {
        Console.WriteLine("Input paramters are %0 %1, where %0 is a config" +
            " file and %1 is the count of nodes.");
        return 0;
      }

      MultiNode node = new MultiNode(args[0], count);
      node.Run();
      return 0;
    }
All Usage Examples Of Brunet.Applications.MultiNode::Run