Beispiel #1
0
        static void main_impl(string[] args)
        {
            var vconfig = new VcallConfiguration();

            try
            {
                parse_appconfig(vconfig);
            }
            catch (Exception ex)
            {
                Console.WriteLine("failed to parse application configuration: {0}", ex.Message);
            }

            parse_command_line(args, vconfig);

            Vcall.StartServices(vconfig);

            Vcall.NewHosting();
            Vcall.NewProxy();

            Console.WriteLine();
            Console.WriteLine("Hosting is running (discovery is on)");
            Console.WriteLine("press Ctrl-C to stop");
            Console.WriteLine();

            UnitTestingHelpers.RunUpdateLoop(10 * 60 * 1000, () => Vcall.DebugCounters);

            Vcall.StopServices();
        }
Beispiel #2
0
        static void parse_appconfig(VcallConfiguration vconfig)
        {
            string resolvingKey = ConfigurationManager.AppSettings["ResolvingKey"];
            string port = ConfigurationManager.AppSettings["port"];

            if (String.IsNullOrEmpty(resolvingKey))
            {
                resolvingKey = "l4p.vcalltests";
            }

            vconfig.ResolvingKey = resolvingKey;

            if (port != null)
            {
                vconfig.Port = Int32.Parse(port);
            }
        }
Beispiel #3
0
        private VcallSubsystem(VcallConfiguration vconfig)
        {
            _connectivityTag = Helpers.GetRandomName();

            Logger.Config = vconfig.Logging;
            _countersDb = CountersDb.New();

            using (Context.With(_countersDb))
            {
                _self = new Self();
                _engine = new Engine(_self);

                var resolvingConfig = FillPropertiesOf<HostResolverConfiguration>.From(vconfig);

                _self.mutex = new Object();
                _self.vconfig = vconfig;
                _self.repo = Repository.New();
                _self.resolver = HostResolver.New(resolvingConfig);
                _self.connectivity = ConnectivityManager.New();

                _self.counters = _countersDb.NewCounters();
            }
        }
Beispiel #4
0
        public void ManyToMany_load_test()
        {
            var vconfig = new VcallConfiguration
            {
                Logging = new LoggingConfiguration { ToFile = @"logs\vcall.log" }
            };

            var vcall = VcallSubsystem.New(vconfig);
            vcall.Start();

            const int count = 30;
            var random = new Random();

            var nodes = new ICommNode[count];
            var timers = new Stopwatch[count];

            int proxyCount = 0;
            int hostingCount = 0;
            int closedCount = 0;

            Action<int> NewNode = indx =>
            {
                if (nodes[indx] != null)
                {
                    closedCount++;
                    nodes[indx].Close();
                }

                if (random.Next(100) % 2 == 0)
                {
                    nodes[indx] = vcall.NewProxy();
                    proxyCount++;
                }
                else
                {
                    nodes[indx] = vcall.NewHosting();
                    hostingCount++;
                }

                timers[indx] = Stopwatch.StartNew();
            };

            Console.WriteLine("Spawning {0} nodes", count);

            for (int i = 0; i < count; i++)
            {
                Thread.Sleep(random.Next(100));
                NewNode(i);
            }

            var stopTimer = Stopwatch.StartNew();
            var printTimer = Stopwatch.StartNew();

            Console.WriteLine("Spawned {0} proxies and {1} hostings", proxyCount, hostingCount);

            for (;;)
            {
                Thread.Sleep(random.Next(10));

                int indx = random.Next(count);

                if (timers[indx].ElapsedMilliseconds > 3 * 1000)
                    NewNode(indx);

                if (printTimer.ElapsedMilliseconds > 5000)
                {
                    Console.WriteLine(vcall.Counters.Format("Spawned {0} proxies and {1} hostings (closed={2})", proxyCount, hostingCount, closedCount));
                    printTimer.Restart();
                }

                if (stopTimer.ElapsedMilliseconds > 10 * 60 * 1000)
                    break;
            }

            Console.WriteLine("Spawned {0} proxies and {1} hostings (closed={2})", proxyCount, hostingCount, closedCount);

            for (int i = 0; i < count; i++)
            {
                nodes[i].Close();
            }

            UnitTestingHelpers.RunUpdateLoop(30 * 1000, () => vcall.Counters);

            vcall.Stop();

            UnitTestingHelpers.RunUpdateLoop(20 * 1000, () => vcall.Counters);
        }
Beispiel #5
0
        private static void start_services(VcallConfiguration vconfig)
        {
            if (_core != null)
                return;

            var core = Helpers.TryCatch(_log,
                () => VcallSubsystem.New(vconfig),
                ex => Helpers.ThrowNew<VcallException>(ex, _log, "Failed to create Vcall subsystem"));

            Helpers.TryCatch(_log,
                () => core.Start(),
                ex => Helpers.ThrowNew<VcallException>(ex, _log, "Failed to start Vcall subsystem"));

            _core = core;
            _defaultHosting = null;
            _defaultProxy = null;

            _log.Info("Vcall services are started");
        }
Beispiel #6
0
 /// <summary>
 /// Initialize and start essential services of Vcall system.
 /// Should be called before any other Vcall functionality is accessed </summary>
 /// <param name="vconfig">Configuration to be used</param>
 /// <remarks>Subsiquent calls to StartServices() are ignored</remarks>
 public static void StartServices(VcallConfiguration vconfig)
 {
     lock (_startMutex)
     {
         start_services(vconfig);
     }
 }
Beispiel #7
0
        /// <summary>
        /// Initialize and start essential services of Vcall system.
        /// Should be called before any other Vcall functionality is accessed </summary>
        /// <param name="resolvingKey">Resolving key of ...</param>
        /// <remarks>Subsiquent calls to StartServices() are ignored</remarks>
        public static void StartServices(string resolvingKey)
        {
            var vconfig = new VcallConfiguration
            {
                ResolvingKey = resolvingKey
            };

            lock (_startMutex)
            {
                start_services(vconfig);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Initialize and start essential services of Vcall system.
        /// Should be called before any other Vcall functionality is accessed </summary>
        /// <remarks>Subsiquent calls to StartServices() are ignored</remarks>
        public static void StartServices()
        {
            var vconfig = new VcallConfiguration();

            lock (_startMutex)
            {
                start_services(vconfig);
            }
        }
Beispiel #9
0
        static void parse_command_line(string[] args, VcallConfiguration vconfig)
        {
            int argc = args.Length;

            List<string> unnamed = new List<string>();

            int indx = 0;

            for (;;)
            {
                if (indx == argc)
                    break;

                String token = args[indx].ToLowerInvariant();
                String prm = null;

                if (indx + 1 < argc)
                    prm = args[indx + 1];

                if (token == "-port")
                {
                    if (prm == null)
                        throw NewArgumentException("-port: please specify a tcp port number");

                    try
                    {
                        vconfig.Port = Int32.Parse(prm);
                    }
                    catch (FormatException)
                    {
                        throw NewArgumentException("-port: failed to parse '%s'", prm);
                    }

                    indx += 2;
                }
                else
                if (token == "-abrakadabra")
                {
                }
                else
                {
                    unnamed.Add(token);
                    indx += 1;
                }
            }

            if (unnamed.Count == 0)
            {
                Console.WriteLine("No resolving key is specified; using defualt resolving domain");
            }

            if (unnamed.Count == 1)
            {
                string resolvingKey = unnamed[0];
                Console.WriteLine("Using resolving key '{0}'", resolvingKey);
                vconfig.ResolvingKey = resolvingKey;
            }
        }
Beispiel #10
0
        public static IVcallSubsystem New()
        {
            var vconfig = new VcallConfiguration {ResolvingKey = Helpers.GetRandomName()};

            return
                new VcallSubsystem(vconfig);
        }
Beispiel #11
0
        public static IVcallSubsystem New(string resolvingKey)
        {
            var vconfig = new VcallConfiguration { ResolvingKey = resolvingKey };

            return
                new VcallSubsystem(vconfig);
        }
Beispiel #12
0
 public static IVcallSubsystem New(VcallConfiguration vconfig)
 {
     return
         new VcallSubsystem(vconfig);
 }