Пример #1
0
        private void RunCRAWorker(Object obj)
        {
            CRAWorkerThreadStartParams threadParams = (CRAWorkerThreadStartParams)obj;
            CRAWorker worker = new CRAWorker(
                threadParams._instanceName,
                threadParams._ipAddress,
                threadParams._port,
                threadParams._storageConnectionString,
                threadParams._descriptor,
                threadParams._streamsPoolSize);

            worker.DisableDynamicLoading();
            worker.Start();
        }
Пример #2
0
        private void RunCRAWorker(Object obj)
        {
            CRAWorkerThreadStartParams threadParams = (CRAWorkerThreadStartParams)obj;

            worker = new CRAWorker(
                threadParams._craInstanceName,
                threadParams._ipAddress,
                threadParams._port,
                threadParams._storageConnectionString,
                threadParams._descriptor,
                threadParams._streamsPoolSize);
            worker.DisableDynamicLoading();
            worker.SideloadVertex(new AmbrosiaRuntime(), threadParams._ambrosiaInstanceName);
            worker.Start();
        }
Пример #3
0
        static void startIC(string _instanceName,
                            int port,
                            int replicaNumber,
                            string secureNetworkClassName,
                            string secureNetworkAssemblyName)
        {
            StartupParamOverrides.sendPort    = 0;
            StartupParamOverrides.receivePort = 0;
            var replicaName = $"{_instanceName}{replicaNumber}";

            var ipAddress = GetLocalIPAddress();

            string storageConnectionString = null;

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

            if (storageConnectionString == null)
            {
                throw new InvalidOperationException("Cannot start the IC. 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();
        }
Пример #4
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Worker for Common Runtime for Applications (CRA) [http://github.com/Microsoft/CRA]");
                Console.WriteLine("Usage: CRA.Worker.exe instancename (e.g., instance1) port (e.g., 11000) [ipaddress (null for default)] [secure_network_assembly_name secure_network_class_name]");
                return;
            }

            string ipAddress = "";

            if (args.Length < 3 || args[2] == "null")
            {
                ipAddress = GetLocalIPAddress();
            }
            else
            {
                ipAddress = args[2];
            }


            string storageConnectionString = null;

#if !DOTNETCORE
            storageConnectionString = ConfigurationManager.AppSettings.Get("AZURE_STORAGE_CONN_STRING");
#endif

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

            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 !DOTNETCORE
            ConfigurationManager.AppSettings.Get("CRA_WORKER_MAX_CONN_POOL");
#endif
            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 (args.Length > 3)
            {
                if (args.Length < 5)
                {
                    throw new InvalidOperationException("Invalid secure network info provided");
                }

                Type type;
                if (args[3] != "null")
                {
                    var assembly = Assembly.Load(args[3]);
                    type = assembly.GetType(args[4]);
                }
                else
                {
                    type = Type.GetType(args[4]);
                }
                descriptor = (ISecureStreamConnectionDescriptor)Activator.CreateInstance(type);
            }

            Console.WriteLine("Starting CRA Worker [http://github.com/Microsoft/CRA]");
            Console.WriteLine("   Worker Instance Name: " + args[0]);
            Console.WriteLine("   IP address: " + ipAddress);
            Console.WriteLine("   Port: " + Convert.ToInt32(args[1]));
            Console.WriteLine("   Azure connection string: " + storageConnectionString);

            if (descriptor != null)
            {
                Console.WriteLine("   Secure network connections enabled using assembly=" + args[3] + "; type=" + args[4]);
            }
            else
            if (args.Length > 3)
            {
                Console.WriteLine("   WARNING: Secure network could not be configured");
            }

            var worker = new CRAWorker
                             (args[0], ipAddress, Convert.ToInt32(args[1]),
                             storageConnectionString, descriptor, connectionsPoolPerWorker);

            worker.Start();
        }
Пример #5
0
        public override async Task <IShardedDataset <TKeyO, TPayloadO, TDataSetO> > Deploy()
        {
            if (!_isDeployed)
            {
                OperatorsToplogy toplogy = OperatorsToplogy.GetInstance();

                TaskBase subscribeTask = new SubscribeTask();
                subscribeTask.OperationTypes = TransformUtils.FillBinaryTransformTypes(
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO));
                subscribeTask.IsRightOperandInput = false;
                OperatorTransforms subscribeInputTransforms = new OperatorTransforms();
                Deploy(ref subscribeTask, ref toplogy, ref subscribeInputTransforms);
                subscribeTask.InputIds.SetInputId1(subscribeTask.NextInputIds.InputId1);
                subscribeTask.InputIds.SetInputId2(subscribeTask.NextInputIds.InputId2);
                subscribeTask.OutputId = typeof(ShardedSubscribeOperator).Name.ToLower() + Guid.NewGuid().ToString();
                subscribeTask.PrepareTaskTransformations(subscribeInputTransforms);

                toplogy.AddOperatorBase(subscribeTask.OutputId, subscribeTask);
                toplogy.AddOperatorInput(subscribeTask.OutputId, subscribeTask.InputIds.InputId1);
                toplogy.AddOperatorSecondaryInput(subscribeTask.OutputId, subscribeTask.InputIds.InputId2);
                toplogy.AddOperatorOutput(subscribeTask.InputIds.InputId1, subscribeTask.OutputId);
                toplogy.AddOperatorOutput(subscribeTask.InputIds.InputId2, subscribeTask.OutputId);

                if (subscribeTask.Transforms != null)
                {
                    foreach (OperatorInputs inputs in subscribeTask.TransformsInputs)
                    {
                        toplogy.AddOperatorSecondaryInput(subscribeTask.OutputId, inputs.InputId2);
                        toplogy.AddOperatorOutput(inputs.InputId2, subscribeTask.OutputId);
                    }

                    foreach (OperatorInputs inputs in subscribeTask.TransformsInputs)
                    {
                        if (!toplogy.ContainsSecondaryOperatorInput(subscribeTask.OutputId, inputs.InputId1))
                        {
                            toplogy.AddOperatorInput(subscribeTask.OutputId, inputs.InputId1);
                            toplogy.AddOperatorOutput(inputs.InputId1, subscribeTask.OutputId);
                        }
                    }
                }

                _clientTerminalTask = new ClientTerminalTask();
                _clientTerminalTask.InputIds.SetInputId1(subscribeTask.OutputId);
                _clientTerminalTask.OutputId       = typeof(ShardedSubscribeClientOperator).Name.ToLower() + Guid.NewGuid().ToString();
                _clientTerminalTask.OperationTypes = TransformUtils.FillBinaryTransformTypes(
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO));

                _craClient = new CRAClientLibrary(_dataProvider);
                toplogy.AddOperatorBase(_clientTerminalTask.OutputId, _clientTerminalTask);
                toplogy.AddOperatorInput(_clientTerminalTask.OutputId, _clientTerminalTask.InputIds.InputId1);
                toplogy.AddOperatorInput(_clientTerminalTask.OutputId, _clientTerminalTask.InputIds.InputId2);
                toplogy.AddOperatorOutput(_clientTerminalTask.InputIds.InputId1, _clientTerminalTask.OutputId);
                toplogy.AddOperatorOutput(_clientTerminalTask.InputIds.InputId2, _clientTerminalTask.OutputId);

                _isDeployed = await DeploymentUtils.DeployOperators(_craClient, toplogy);

                if (_isDeployed)
                {
                    string craWorkerName = typeof(ShardedSubscribeClientOperator).Name.ToLower() + "worker" + Guid.NewGuid().ToString();
                    _craWorker = new CRAWorker(craWorkerName, "127.0.0.1", NetworkUtils.GetAvailablePort(), _craClient.DataProvider, null, 1000);
                    _craWorker.DisableDynamicLoading();
                    _craWorker.SideloadVertex(new ShardedSubscribeClientOperator(), typeof(ShardedSubscribeClientOperator).Name.ToLower());
                    new Thread(() => _craWorker.Start()).Start();
                    Thread.Sleep(1000);

                    _isDeployed = await DeploymentUtils.DeployClientTerminal(_craClient, craWorkerName, _clientTerminalTask, toplogy);
                }
                else
                {
                    return(null);
                }
            }

            return(this);
        }
Пример #6
0
        static void Main(string[] args)
        {
            ParseAndValidateOptions(args);

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

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

            string storageConnectionString = null;

#if !DOTNETCORE
            storageConnectionString = ConfigurationManager.AppSettings.Get("AZURE_STORAGE_CONN_STRING");
#endif

            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 !DOTNETCORE
            ConfigurationManager.AppSettings.Get("CRA_WORKER_MAX_CONN_POOL");
#endif
            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 worker = new CRAWorker
                             (replicaName, _ipAddress, _port,
                             storageConnectionString, descriptor, connectionsPoolPerWorker);

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

            worker.Start();
        }
Пример #7
0
        static void Main(string[] args)
        {
            TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out);

            Trace.Listeners.Add(myWriter);

            if (args.Length < 2)
            {
                Console.WriteLine("Worker for Common Runtime for Applications (CRA) [http://github.com/Microsoft/CRA]");
                Console.WriteLine("Usage: CRA.Worker.exe instancename (e.g., instance1) port (e.g., 11000) [ipaddress (null for default)] [secure_network_assembly_name secure_network_class_name]");
                return;
            }

            string        ipAddress = "";
            string        storageConnectionString = null;
            IDataProvider dataProvider            = null;
            int           connectionsPoolPerWorker;
            string        connectionsPoolPerWorkerString = null;

            if (args.Length < 3 || args[2] == "null")
            {
                ipAddress = GetLocalIPAddress();
            }
            else
            {
                ipAddress = args[2];
            }


#if !DOTNETCORE
            storageConnectionString = ConfigurationManager.AppSettings.Get("AZURE_STORAGE_CONN_STRING");
#endif

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

            if (storageConnectionString != null)
            {
                dataProvider = new AzureDataProvider(storageConnectionString);
            }
            else if (storageConnectionString == null)
            {
                dataProvider = new FileDataProvider();
            }

#if !DOTNETCORE
            connectionsPoolPerWorkerString = ConfigurationManager.AppSettings.Get("CRA_WORKER_MAX_CONN_POOL");
#endif
            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 (args.Length > 3)
            {
                if (args.Length < 5)
                {
                    throw new InvalidOperationException("Invalid secure network info provided");
                }

                Type type;
                if (args[3] != "null")
                {
                    var assembly = Assembly.Load(args[3]);
                    type = assembly.GetType(args[4]);
                }
                else
                {
                    type = Type.GetType(args[4]);
                }

                descriptor = (ISecureStreamConnectionDescriptor)Activator.CreateInstance(type);
            }

            var worker = new CRAWorker(
                args[0],
                ipAddress,
                Convert.ToInt32(args[1]),
                dataProvider,
                descriptor,
                connectionsPoolPerWorker);

            worker.Start();
        }