public CRAWorkerThreadStartParams(string instanceName, string ipAddress, int port, string storageConnectionString, ISecureStreamConnectionDescriptor descriptor, int streamsPoolSize) { _instanceName = instanceName; _ipAddress = ipAddress; _port = port; _storageConnectionString = storageConnectionString; _descriptor = descriptor; _streamsPoolSize = streamsPoolSize; }
/// <summary> /// Define a new worker instance of Common Runtime for Applications (CRA) /// </summary> /// <param name="workerInstanceName">Name of the worker instance</param> /// <param name="address">IP address</param> /// <param name="port">Port</param> /// <param name="storageConnectionString">Storage account to store metadata</param> /// <param name="streamsPoolSize">Maximum number of stream connections will be cached in the CRA client</param> /// <param name="descriptor">Secure stream connection callbacks</param> public CRAWorker( string workerInstanceName, string address, int port, IDataProvider azureDataProvider, ISecureStreamConnectionDescriptor descriptor = null, int streamsPoolSize = 0) { Console.WriteLine("Starting CRA Worker instance [http://github.com/Microsoft/CRA]"); Console.WriteLine(" Instance Name: " + workerInstanceName); Console.WriteLine(" IP address: " + address); Console.WriteLine(" Port: " + port); if (descriptor != null) { Console.WriteLine(" Secure network connections: Enabled using assembly " + descriptor.GetType().FullName); } else { Console.WriteLine(" Secure network connections: Disabled"); } _craClient = new CRAClientLibrary(azureDataProvider, this); _workerinstanceName = workerInstanceName; _address = address; _port = port; _streamsPoolSize = streamsPoolSize; _vertexInfoProvider = azureDataProvider.GetVertexInfoProvider(); _connectionInfoProvider = azureDataProvider.GetVertexConnectionInfoProvider(); if (descriptor != null) { _craClient.SecureStreamConnectionDescriptor = descriptor; } }
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(); }
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(); }
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(); }
/// <summary> /// Define secure stream connections /// </summary> /// <param name="descriptor"></param> public void DefineSecureStreamConnection(ISecureStreamConnectionDescriptor descriptor) { this.SecureStreamConnectionDescriptor = descriptor; }
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(); }
/// <summary> /// Define a new worker instance of Common Runtime for Applications (CRA) /// </summary> /// <param name="workerInstanceName">Name of the worker instance</param> /// <param name="address">IP address</param> /// <param name="port">Port</param> /// <param name="storageConnectionString">Storage account to store metadata</param> /// <param name="streamsPoolSize">Maximum number of stream connections will be cached in the CRA client</param> /// <param name="descriptor">Secure stream connection callbacks</param> public CRAWorker(string workerInstanceName, string address, int port, string storageConnectionString, ISecureStreamConnectionDescriptor descriptor = null, int streamsPoolSize = 0) { _craClient = new CRAClientLibrary(storageConnectionString, this); _workerinstanceName = workerInstanceName; _address = address; _port = port; _streamsPoolSize = streamsPoolSize; _storageConnectionString = storageConnectionString; _storageAccount = CloudStorageAccount.Parse(_storageConnectionString); _blobClient = _storageAccount.CreateCloudBlobClient(); _tableClient = _storageAccount.CreateCloudTableClient(); _workerInstanceTable = CreateTableIfNotExists("cravertextable"); _connectionTable = CreateTableIfNotExists("craconnectiontable"); if (descriptor != null) { _craClient.SecureStreamConnectionDescriptor = descriptor; } }
/// <summary> /// Define a new worker instance of Common Runtime for Applications (CRA) /// </summary> /// <param name="workerInstanceName">Name of the worker instance</param> /// <param name="address">IP address</param> /// <param name="port">Port</param> /// <param name="storageConnectionString">Storage account to store metadata</param> /// <param name="streamsPoolSize">Maximum number of stream connections will be cached in the CRA client</param> /// <param name="descriptor">Secure stream connection callbacks</param> public CRAWorker(string workerInstanceName, string address, int port, string storageConnectionString, ISecureStreamConnectionDescriptor descriptor = null, int streamsPoolSize = 0) { Console.WriteLine("Starting CRA Worker instance [http://github.com/Microsoft/CRA]"); Console.WriteLine(" Instance Name: " + workerInstanceName); Console.WriteLine(" IP address: " + address); Console.WriteLine(" Port: " + port); Console.WriteLine(" Azure connection string: " + storageConnectionString); if (descriptor != null) { Console.WriteLine(" Secure network connections: Enabled using assembly " + descriptor.GetType().FullName); } else { Console.WriteLine(" Secure network connections: Disabled"); } _craClient = new CRAClientLibrary(storageConnectionString, this); _workerinstanceName = workerInstanceName; _address = address; _port = port; _streamsPoolSize = streamsPoolSize; _storageConnectionString = storageConnectionString; _storageAccount = CloudStorageAccount.Parse(_storageConnectionString); _blobClient = _storageAccount.CreateCloudBlobClient(); _tableClient = _storageAccount.CreateCloudTableClient(); _workerInstanceTable = CreateTableIfNotExists("cravertextable"); _connectionTable = CreateTableIfNotExists("craconnectiontable"); if (descriptor != null) { _craClient.SecureStreamConnectionDescriptor = descriptor; } }