Exemple #1
0
        public TcpReactiveEnvironment(string azureConnectionString, ITcpReactivePlatformSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            StorageType           = MetadataStorageType.Azure;
            AzureConnectionString = azureConnectionString;
            MessagingService      = new TcpMessagingService(settings.GetExecutablePath("MessagingHost"), settings.MessagingPort, settings.MessagingUri);
            StateStoreService     = new TcpStateStoreService(settings.GetExecutablePath("StateStoreHost"), settings.StateStorePort, settings.StateStoreUri);
            KeyValueStoreService  = new TcpKeyValueStoreService(settings.GetExecutablePath("KeyValueStoreHost"), settings.KeyValueStorePort, settings.KeyValueStoreUri);
        }
        private static IReactiveEnvironment GetEnvironment(ReactiveServiceType[][] groups, TcpMultiRoleRunnable[] runnables)
        {
            var metadata      = default(IReactiveMetadataService);
            var messaging     = default(IReactiveMessagingService);
            var stateStore    = default(IReactiveStateStoreService);
            var keyValueStore = default(IKeyValueStoreService);

            for (var i = 0; i < groups.Length; ++i)
            {
                for (var j = 0; j < groups[i].Length; ++j)
                {
#pragma warning disable CA2000 // Dispose objects before losing scope. (Ownership transfer.)
                    switch (groups[i][j])
                    {
                    case ReactiveServiceType.MetadataService:
                        metadata = new TcpMetadataService(new TcpMultiRoleInstance(((object[])runnables[i].Instance)[j], runnables[i]));
                        break;

                    case ReactiveServiceType.MessagingService:
                        messaging = new TcpMessagingService(new TcpMultiRoleInstance(((object[])runnables[i].Instance)[j], runnables[i]));
                        break;

                    case ReactiveServiceType.StateStoreService:
                        stateStore = new TcpStateStoreService(new TcpMultiRoleInstance(((object[])runnables[i].Instance)[j], runnables[i]));
                        break;

                    case ReactiveServiceType.KeyValueStoreService:
                        keyValueStore = new TcpKeyValueStoreService(new TcpMultiRoleInstance(((object[])runnables[i].Instance)[j], runnables[i]));
                        break;

                    case ReactiveServiceType.DeployerService:
                    case ReactiveServiceType.QueryCoordinator:
                    case ReactiveServiceType.QueryEvaluator:
                    default:
                        break;
                    }
#pragma warning restore CA2000
                }
            }

            return(new ReactiveEnvironment(metadata, messaging, stateStore, keyValueStore));
        }