public async Task ExecuteAsync(RestartPool command, CancellationToken cancellationToken)
        {
            if (await _pools.IsActive(command.PoolId))
            {
                _terminal.Write($"{command.PoolId}, pool started, stopping and deleting pool...");
                await _pools.StopPoolAsync(command.PoolId);

                await _pools.DeletePoolAsync(command.PoolId);

                _terminal.Write("pool removed");
            }

            _terminal.Write($"{command.PoolId}, starting pool");
            var request = new StartPoolRequest(
                isServiceStateful: command.IsServiceStateful,
                hasPersistedState: command.HasPersistedState,
                minReplicas: command.MinReplicas,
                targetReplicas: command.TargetReplicas,
                partitionScheme: command.PartitionScheme,
                maxPoolSize: command.MaxPoolSize,
                idleServicesPoolSize: command.IdleServicesPoolSize,
                servicesAllocationBlockSize: command.ServicesAllocationBlockSize,
                expirationQuanta: TimeSpan.FromMinutes(command.ExpirationQuanta)
                );
            await _pools.StartPoolAsync(command.PoolId, request);

            _terminal.Write($"{command.PoolId}, pool started. pausing for service creation");
            _terminal.Write($"{command.PoolId}, pool ready.");
        }
        public async Task StartAsync(StartPoolRequest request)
        {
            await _mediator.ExecuteAsync(
                new StartPool(
                    this.GetActorId().GetStringId(),
                    request.IsServiceStateful,
                    request.HasPersistedState,
                    request.MinReplicas,
                    request.TargetReplicas,
                    (PartitionSchemeDescription)Enum.Parse(typeof(PartitionSchemeDescription), request.PartitionScheme.ToString()),
                    request.MaxPoolSize,
                    request.IdleServicesPoolSize,
                    request.ServicesAllocationBlockSize,
                    request.ExpirationQuanta),
                default(CancellationToken));

            await SetReminderAsync(EnsurePoolSizeReminderKey, null, TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(20));
        }
        static async Task ResetPool(IPoolProxy pools)
        {
            WriteConsole("Removing old pool");
            await pools.StopPoolAsync(NoOpServiceTypeUri);

            await pools.DeletePoolAsync(NoOpServiceTypeUri);

            WriteConsole("Registering Service with Pool Manager...");
            var request = new StartPoolRequest(
                isServiceStateful: true,
                hasPersistedState: true,
                minReplicas: 1,
                targetReplicas: 3,
                partitionScheme: SDK.PartitionSchemeDescription.Singleton,
                maxPoolSize: 20,
                idleServicesPoolSize: 5,
                servicesAllocationBlockSize: 2,
                expirationQuanta: TimeSpan.FromMinutes(1)
                );
            await pools.StartPoolAsync(NoOpServiceTypeUri, request);

            WriteConsole("Registration Completed");
        }
 public async Task StartPoolAsync(string serviceTypeUri, StartPoolRequest request) =>
 await GetProxy(serviceTypeUri).StartAsync(request);