Пример #1
0
 // This is the main entry point of the application.
 static void Main(string[] args)
 {
     // if you want to use a different Application Delegate class from "AppDelegate"
     // you can specify it here.
     GenericLogsInterface.SetToGenericLogs();
     UIApplication.Main(args, null, "AppDelegate");
 }
Пример #2
0
        static void Main(string[] args)
        {
            finishedTokenQ = new AsyncQueue <int>();

            int    coordinatorPort    = 1500;
            string clientInstanceName = "client";
            string serverInstanceName = "server";

            if (args.Length >= 1)
            {
                clientInstanceName = args[0];
            }

            if (args.Length == 2)
            {
                serverInstanceName = args[1];
            }

            using (var coordinatorOutput = new StreamWriter("CoordOut.txt", false))
            {
                var iCListener = new TextWriterTraceListener(coordinatorOutput);
                Trace.Listeners.Add(iCListener);
                GenericLogsInterface.SetToGenericLogs();
                using (AmbrosiaFactory.Deploy <IClient3>(clientInstanceName, new Client3(serverInstanceName, clientInstanceName), coordinatorPort))
                {
                    finishedTokenQ.DequeueAsync().Wait();
                }
            }
        }
Пример #3
0
        public App(IOSCommands inCommands)
        {
            GenericLogsInterface.SetToGenericLogs();
//            AzureBlobsLogsInterface.SetToAzureBlobsLogs();
            new Thread(new ThreadStart(() => _immortalHandle = AmbrosiaFactory.Deploy <ICommandShellImmortal>("CommandShell", new CommandShellImmortal(), 2500))).Start();
            while (CommandShellImmortal.myCommandShellImmortal == null)
            {
                ;
            }
            InitializeComponent();
            MainPage = new MainPage(inCommands);
        }
Пример #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            GenericLogsInterface.SetToGenericLogs();
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }
Пример #5
0
        static void Main(string[] args)
        {
            int    coordinatorPort = 2500;
            int    receivePort     = 2001;
            int    sendPort        = 2000;
            string serviceName     = "server";

            if (args.Length >= 1)
            {
                serviceName = args[0];
            }
            var twoProc = false;

            if (args.Length >= 2)
            {
                twoProc = true;
            }
            if (args.Length >= 3)
            {
                receivePort = int.Parse(args[2]);
            }
            if (args.Length >= 4)
            {
                sendPort = int.Parse(args[3]);
            }

            GenericLogsInterface.SetToGenericLogs();
            if (!twoProc)
            {
                using (var coordinatorOutput = new StreamWriter("CoordOut.txt", false))
                {
                    var iCListener = new TextWriterTraceListener(coordinatorOutput);
                    Trace.Listeners.Add(iCListener);
                    using (AmbrosiaFactory.Deploy <IServer>(serviceName, new Server(), coordinatorPort))
                    {
                        Thread.Sleep(14 * 24 * 3600 * 1000);
                    }
                }
            }
            else
            {
                using (AmbrosiaFactory.Deploy <IServer>(serviceName, new Server(), receivePort, sendPort))
                {
                    Thread.Sleep(14 * 24 * 3600 * 1000);
                }
            }
        }
Пример #6
0
        public App(IOSCommands inCommands)
        {
            GenericLogsInterface.SetToGenericLogs();
            // Store the logs in Azure by default. Comment the line below and uncomment the line above to store them in the file system.

            //AzureBlobsLogsInterface.SetToAzureBlobsLogs();

            // Deploy the immortal on another thread as part of startup.
            new Thread(new ThreadStart(() => _immortalHandle = AmbrosiaFactory.Deploy <ICommandShellImmortal>("CommandShell", new CommandShellImmortal(), 2500))).Start();

            // Wait for the immortal to finish recovery
            while (CommandShellImmortal.myCommandShellImmortal == null)
            {
                ;
            }
            InitializeComponent();

            // Pass along the instantiated operating system specific part of the code to the main page initializer.
            MainPage = new MainPage(inCommands);
        }
Пример #7
0
        public static void main(string[] args)
        {
            ParseAndValidateOptions(args);

            switch (_logStorageType)
            {
            case LogStorageOptions.Files:
                GenericLogsInterface.SetToGenericLogs();
                break;

            case LogStorageOptions.Blobs:
                AzureBlobsLogsInterface.SetToAzureBlobsLogs();
                break;
            }

            var replicaName = $"{_instanceName}{_replicaNumber}";

            if (_ipAddress == null)
            {
                _ipAddress = GetLocalIPAddress();
            }

            string storageConnectionString = null;

            if (storageConnectionString == null)
            {
                storageConnectionString = Environment.GetEnvironmentVariable("AZURE_STORAGE_CONN_STRING");
            }

            if (!_isActiveActive && _replicaNumber != 0)
            {
                throw new InvalidOperationException("Can't specify a replica number without the activeActive flag");
            }

            if (storageConnectionString == null)
            {
                throw new InvalidOperationException("Azure storage connection string not found. Use appSettings in your app.config to provide this using the key AZURE_STORAGE_CONN_STRING, or use the environment variable AZURE_STORAGE_CONN_STRING.");
            }

            int    connectionsPoolPerWorker;
            string connectionsPoolPerWorkerString = "0";

            if (connectionsPoolPerWorkerString != null)
            {
                try
                {
                    connectionsPoolPerWorker = Convert.ToInt32(connectionsPoolPerWorkerString);
                }
                catch
                {
                    throw new InvalidOperationException("Maximum number of connections per CRA worker is wrong. Use appSettings in your app.config to provide this using the key CRA_WORKER_MAX_CONN_POOL.");
                }
            }
            else
            {
                connectionsPoolPerWorker = 1000;
            }

            ISecureStreamConnectionDescriptor descriptor = null;

            if (_secureNetworkClassName != null)
            {
                Type type;
                if (_secureNetworkAssemblyName != null)
                {
                    var assembly = Assembly.Load(_secureNetworkAssemblyName);
                    type = assembly.GetType(_secureNetworkClassName);
                }
                else
                {
                    type = Type.GetType(_secureNetworkClassName);
                }
                descriptor = (ISecureStreamConnectionDescriptor)Activator.CreateInstance(type);
            }

            var dataProvider = new CRA.DataProvider.Azure.AzureDataProvider(storageConnectionString);
            var worker       = new CRAWorker
                                   (replicaName, _ipAddress, _port,
                                   dataProvider, descriptor, connectionsPoolPerWorker);

            worker.DisableDynamicLoading();
            worker.SideloadVertex(new AmbrosiaRuntime(), "ambrosia");

            worker.Start();
        }
Пример #8
0
        static void Main(string[] args)
        {
            ParseAndValidateOptions(args);

            if (_ICDeploymentMode == ICDeploymentMode.InProcDeploy || _ICDeploymentMode == ICDeploymentMode.InProcManual || _ICDeploymentMode == ICDeploymentMode.InProcTimeTravel)
            {
                GenericLogsInterface.SetToGenericLogs();
                _iCWriter   = new FileStream("ICOutput_" + _perfJob.ToString() + "_" + _icPort.ToString() + ".txt", FileMode.Create);
                _iCListener = new TextWriterTraceListener(_iCWriter);
                Trace.Listeners.Add(_iCListener);
            }

            try
            {
                finishedTokenQ = new AsyncQueue <int>();

                // for debugging don't want to auto continue but for test automation want this to auto continue
                if (!_autoContinue)
                {
                    Console.WriteLine("Pausing execution of " + _perfJob + ". Press enter to deploy and continue.");
                    Console.ReadLine();
                }

#if DEBUG
                Console.WriteLine("*X* Connecting to: " + _perfServer + "....");
#endif
                var myClient = new Job(_perfServer, _maxMessageSize, _numRounds, _descendingSize);

//                new Thread(() => ConsoleListen()) { IsBackground = true }.Start();

                switch (_ICDeploymentMode)
                {
                case ICDeploymentMode.SecondProc:
                    using (var c = AmbrosiaFactory.Deploy <IJob>(_perfJob, myClient, _receivePort, _sendPort))
                    {
                        WaitForJobToFinishAsync().Wait();
                    }
                    break;

                case ICDeploymentMode.InProcDeploy:
                    using (var c = AmbrosiaFactory.Deploy <IJob>(_perfJob, myClient, _icPort))
                    {
                        WaitForJobToFinishAsync().Wait();
                    }
                    break;

                case ICDeploymentMode.InProcTimeTravel:
                    using (var c = AmbrosiaFactory.Deploy <IJob>(_perfJob, myClient, _serviceLogPath, _checkpointToLoad))
                    {
                        WaitForJobToFinishAsync().Wait();
                    }
                    break;

                case ICDeploymentMode.InProcManual:
                    var myName       = _perfJob;
                    var myPort       = _icPort;
                    var ambrosiaArgs = new string[2];
                    ambrosiaArgs[0] = "-i=" + myName;
                    ambrosiaArgs[1] = "-p=" + myPort;
                    Console.WriteLine("*X* ImmortalCoordinator -i=" + myName + " -p=" + myPort.ToString());
                    _iCThread = new Thread(() => CRA.Worker.Program.main(ambrosiaArgs))
                    {
                        IsBackground = true
                    };
                    _iCThread.Start();
                    using (var c = AmbrosiaFactory.Deploy <IJob>(_perfJob, myClient, _receivePort, _sendPort))
                    {
                        WaitForJobToFinishAsync().Wait();
                    }
                    break;
                }
            }
            catch { /* Swallowing errors to make Darren's testing framework happy. */ }
            Console.Out.Flush();
            Console.Out.Flush();
            System.Environment.Exit(0);
        }
Пример #9
0
        static void Main(string[] args)
        {
            ParseAndValidateOptions(args);

            if (_ICDeploymentMode == ICDeploymentMode.InProcDeploy || _ICDeploymentMode == ICDeploymentMode.InProcManual || _ICDeploymentMode == ICDeploymentMode.InProcTimeTravel)
            {
                GenericLogsInterface.SetToGenericLogs();
                _iCWriter   = new FileStream("ICOutput_" + _perfServer.ToString() + "_" + _icPort.ToString() + ".txt", FileMode.Create);
                _iCListener = new TextWriterTraceListener(_iCWriter);
                Trace.Listeners.Add(_iCListener);
            }

            try
            {
                finishedTokenQ = new AsyncQueue <int>();

                // for debugging don't want to auto continue but for test automation want this to auto continue
                if (!_autoContinue)
                {
                    Console.WriteLine("Pausing execution of " + _perfServer + ". Press enter to deploy and continue.");
                    Console.ReadLine();
                }

                if (!_isUpgrading)
                {
                    var myServer = new Server(_perfJob, _isBidirectional, _numJobs, _memoryUsed);
                    switch (_ICDeploymentMode)
                    {
                    case ICDeploymentMode.SecondProc:
                        using (var c = AmbrosiaFactory.Deploy <IServer>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;

                    case ICDeploymentMode.InProcDeploy:
                        using (var c = AmbrosiaFactory.Deploy <IServer>(_perfServer, myServer, _icPort))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;

                    case ICDeploymentMode.InProcTimeTravel:
                        using (var c = AmbrosiaFactory.Deploy <IServer>(_perfServer, myServer, _serviceLogPath, _checkpointToLoad, _currentVersion))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;

                    case ICDeploymentMode.InProcManual:
                        var myName       = _perfServer;
                        var myPort       = _icPort;
                        var ambrosiaArgs = new string[2];
                        ambrosiaArgs[0] = "-i=" + myName;
                        ambrosiaArgs[1] = "-p=" + myPort;
                        Console.WriteLine("*X* ImmortalCoordinator -i=" + myName + " -p=" + myPort.ToString());
                        _iCThread = new Thread(() => CRA.Worker.Program.main(ambrosiaArgs))
                        {
                            IsBackground = true
                        };
                        _iCThread.Start();
                        using (var c = AmbrosiaFactory.Deploy <IServer>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;
                    }
                }
                else
                {
                    var myServer = new Server(_perfJob, _isBidirectional, _numJobs, _memoryUsed);
                    switch (_ICDeploymentMode)
                    {
                    case ICDeploymentMode.SecondProc:
                        using (var c = AmbrosiaFactory.Deploy <IServer, IServer, ServerUpgraded>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;

                    case ICDeploymentMode.InProcDeploy:
                        using (var c = AmbrosiaFactory.Deploy <IServer, IServer, ServerUpgraded>(_perfServer, myServer, _icPort))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;

                    case ICDeploymentMode.InProcTimeTravel:
                        using (var c = AmbrosiaFactory.Deploy <IServer, IServer, ServerUpgraded>(_perfServer, myServer, _serviceLogPath, _checkpointToLoad, _currentVersion))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;

                    case ICDeploymentMode.InProcManual:
                        var myName       = _perfServer;
                        var myPort       = _icPort;
                        var ambrosiaArgs = new string[2];
                        ambrosiaArgs[0] = "-i=" + myName;
                        ambrosiaArgs[1] = "-p=" + myPort;
                        Console.WriteLine("*X* ImmortalCoordinator -i=" + myName + " -p=" + myPort.ToString());
                        _iCThread = new Thread(() => CRA.Worker.Program.main(ambrosiaArgs))
                        {
                            IsBackground = true
                        };
                        _iCThread.Start();
                        using (var c = AmbrosiaFactory.Deploy <IServer, IServer, ServerUpgraded>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            WaitForJobsToFinishAndThenWaitAsync().Wait();
                        }
                        break;
                    }
                }
            }
            catch (Exception e) { Console.WriteLine(e.Message); }
            Console.Out.Flush();
            Console.Out.Flush();
            System.Environment.Exit(0);
        }
Пример #10
0
        static void Main(string[] args)
        {
            int    coordinatorPort = 2500;
            int    receivePort     = 2001;
            int    sendPort        = 2000;
            string serviceName     = "server";

            if (args.Length >= 1)
            {
                serviceName = args[0];
            }
            var    iCExecutionStyle = ICExecutionStyle.InProc;
            string logPath          = null;
            int    checkpointToLoad = 0;

            if (args.Length >= 2)
            {
                if (args[1].ToUpper().Equals("TTD"))
                {
                    iCExecutionStyle = ICExecutionStyle.TimeTravelDebugging;
                    logPath          = args[2];
                    checkpointToLoad = int.Parse(args[3]);
                }
                else if (args[1].ToUpper().Equals("TWOPROC"))
                {
                    iCExecutionStyle = ICExecutionStyle.TwoProc;
                    if (args.Length >= 3)
                    {
                        receivePort = int.Parse(args[2]);
                    }
                    if (args.Length >= 4)
                    {
                        sendPort = int.Parse(args[3]);
                    }
                }
            }
            GenericLogsInterface.SetToGenericLogs();
            switch (iCExecutionStyle)
            {
            case ICExecutionStyle.InProc:
                using (var coordinatorOutput = new StreamWriter("CoordOut.txt", false))
                {
                    var iCListener = new TextWriterTraceListener(coordinatorOutput);
                    Trace.Listeners.Add(iCListener);
                    using (AmbrosiaFactory.Deploy <IServer>(serviceName, new Server(), coordinatorPort))
                    {
                        Thread.Sleep(14 * 24 * 3600 * 1000);
                    }
                }
                break;

            case ICExecutionStyle.TwoProc:
                using (AmbrosiaFactory.Deploy <IServer>(serviceName, new Server(), receivePort, sendPort))
                {
                    Thread.Sleep(14 * 24 * 3600 * 1000);
                }
                break;

            case ICExecutionStyle.TimeTravelDebugging:
                using (var coordinatorOutput = new StreamWriter("CoordOut.txt", false))
                {
                    var iCListener = new TextWriterTraceListener(coordinatorOutput);
                    Trace.Listeners.Add(iCListener);
                    using (AmbrosiaFactory.Deploy <IServer>(serviceName, new Server(), logPath, checkpointToLoad))
                    {
                        Thread.Sleep(14 * 24 * 3600 * 1000);
                    }
                }
                break;
            }
        }
Пример #11
0
        static void Main(string[] args)
        {
            ParseAndValidateOptions(args);

            if (_ICDeploymentMode == ICDeploymentMode.InProcDeploy || _ICDeploymentMode == ICDeploymentMode.InProcManual)
            {
                GenericLogsInterface.SetToGenericLogs();
                _iCWriter   = new FileStream("ICOutput_" + _perfServer.ToString() + "_" + _icPort.ToString() + ".txt", FileMode.Create);
                _iCListener = new TextWriterTraceListener(_iCWriter);
                Trace.Listeners.Add(_iCListener);
            }

            try
            {
                // for debugging don't want to auto continue but for test automation want this to auto continue
                if (!_autoContinue)
                {
                    Console.WriteLine("Pausing execution of " + _perfServer + ". Press enter to deploy and continue.");
                    Console.ReadLine();
                }

                if (!_isUpgrading)
                {
                    var myServer = new Server(_perfJob, _isBidirectional, _numJobs, _memoryUsed);
                    switch (_ICDeploymentMode)
                    {
                    case ICDeploymentMode.SecondProc:
                        using (var c = AmbrosiaFactory.Deploy <IServer>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            // nothing to call on c, just doing this for calling Dispose.
                            Console.WriteLine("*X* Press enter to terminate program.");
                            // Doing this wait to make the bash script happy, which automatically move past the Readline.
                            Thread.Sleep(1000 * 60 * 60 * 24);
                            Console.ReadLine();
                        }
                        break;

                    case ICDeploymentMode.InProcDeploy:
                        using (var c = AmbrosiaFactory.Deploy <IServer>(_perfServer, myServer, _icPort))
                        {
                            // nothing to call on c, just doing this for calling Dispose.
                            Console.WriteLine("*X* Press enter to terminate program.");
                            Console.ReadLine();
                            Thread.Sleep(3000);
                            Trace.Flush();
                            _iCListener.Flush();
                            _iCWriter.Flush();
                            _iCWriter.Flush();
                        }
                        break;

                    case ICDeploymentMode.InProcManual:
                        var myName       = _perfServer;
                        var myPort       = _icPort;
                        var ambrosiaArgs = new string[2];
                        ambrosiaArgs[0] = "-i=" + myName;
                        ambrosiaArgs[1] = "-p=" + myPort;
                        Console.WriteLine("*X* ImmortalCoordinator -i=" + myName + " -p=" + myPort.ToString());
                        _iCThread = new Thread(() => CRA.Worker.Program.main(ambrosiaArgs))
                        {
                            IsBackground = true
                        };
                        _iCThread.Start();
                        using (var c = AmbrosiaFactory.Deploy <IServer>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            // nothing to call on c, just doing this for calling Dispose.
                            Console.WriteLine("*X* Press enter to terminate program.");
                            Console.ReadLine();
                            Thread.Sleep(3000);
                            Trace.Flush();
                            _iCListener.Flush();
                            _iCWriter.Flush();
                            _iCWriter.Flush();
                        }
                        break;
                    }
                }
                else
                {
                    var myServer = new Server(_perfJob, _isBidirectional, _numJobs, _memoryUsed);
                    switch (_ICDeploymentMode)
                    {
                    case ICDeploymentMode.SecondProc:
                        using (var c = AmbrosiaFactory.Deploy <IServer, IServer, ServerUpgraded>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            // nothing to call on c, just doing this for calling Dispose.
                            Console.WriteLine("*X* Press enter to terminate program.");
                            // Doing this wait to make the bash script happy, which automatically move past the Readline.
                            Thread.Sleep(1000 * 60 * 60 * 24);
                            Console.ReadLine();
                        }
                        break;

                    case ICDeploymentMode.InProcDeploy:
                        using (var c = AmbrosiaFactory.Deploy <IServer, IServer, ServerUpgraded>(_perfServer, myServer, _icPort))
                        {
                            // nothing to call on c, just doing this for calling Dispose.
                            Console.WriteLine("*X* Press enter to terminate program.");
                            Console.ReadLine();
                            Thread.Sleep(3000);
                            Trace.Flush();
                            _iCListener.Flush();
                            _iCWriter.Flush();
                            _iCWriter.Flush();
                        }
                        break;

                    case ICDeploymentMode.InProcManual:
                        var myName       = _perfServer;
                        var myPort       = _icPort;
                        var ambrosiaArgs = new string[2];
                        ambrosiaArgs[0] = "-i=" + myName;
                        ambrosiaArgs[1] = "-p=" + myPort;
                        Console.WriteLine("*X* ImmortalCoordinator -i=" + myName + " -p=" + myPort.ToString());
                        _iCThread = new Thread(() => CRA.Worker.Program.main(ambrosiaArgs))
                        {
                            IsBackground = true
                        };
                        _iCThread.Start();
                        using (var c = AmbrosiaFactory.Deploy <IServer, IServer, ServerUpgraded>(_perfServer, myServer, _receivePort, _sendPort))
                        {
                            // nothing to call on c, just doing this for calling Dispose.
                            Console.WriteLine("*X* Press enter to terminate program.");
                            Console.ReadLine();
                            Thread.Sleep(3000);
                            Trace.Flush();
                            _iCListener.Flush();
                            _iCWriter.Flush();
                            _iCWriter.Flush();
                        }
                        break;
                    }
                }
            }
            catch (Exception e) { Console.WriteLine(e.Message); }
            Console.WriteLine("*X* Terminating.");
            System.Environment.Exit(0);
        }