public async Task ThenThePoolConfigurationShouldBe(string serviceTypeUri, Table table)
        {
            var expected = table.CreateImmutableInstance <ConfigurationResponse>();
            var response = await _pools.GetConfigurationAsync(serviceTypeUri);

            response.ExpirationQuanta.Should().Be(expected.ExpirationQuanta);
            response.HasPersistedState.Should().Be(expected.HasPersistedState);
            response.IdleServicesPoolSize.Should().Be(expected.IdleServicesPoolSize);
            response.IsServiceStateful.Should().Be(expected.IsServiceStateful);
            response.MaxPoolSize.Should().Be(expected.MaxPoolSize);
            response.MinReplicaSetSize.Should().Be(expected.MinReplicaSetSize);
            response.PartitionScheme.Should().Be(expected.PartitionScheme);
            response.ServicesAllocationBlockSize.Should().Be(expected.ServicesAllocationBlockSize);
            response.ServiceTypeUri.Should().Be(expected.ServiceTypeUri);
            response.TargetReplicasetSize.Should().Be(expected.TargetReplicasetSize);
        }
예제 #2
0
        public async Task <ActionResult <Pool> > Get([Required] string serviceTypeUri)
        {
            var configuration = await pools.GetConfigurationAsync(serviceTypeUri);

            if (configuration == null)
            {
                return(NotFound($"Pool {serviceTypeUri} does not exist or has not yet been started."));
            }

            var getInstancesResponse = await pools.GetInstancesAsync(serviceTypeUri, CancellationToken.None);

            var response = new Pool(
                new PoolConfiguration(configuration.ExpirationQuanta, configuration.HasPersistedState, configuration.IdleServicesPoolSize,
                                      configuration.IsServiceStateful, configuration.MaxPoolSize, configuration.MinReplicaSetSize,
                                      (PartitionSchemeDescription)Enum.Parse(typeof(PartitionSchemeDescription), configuration.PartitionScheme.ToString()),
                                      configuration.ServicesAllocationBlockSize, configuration.TargetReplicasetSize),
                getInstancesResponse.OccupiedInstances?.Select(i => i.PartitionId).Distinct(),
                getInstancesResponse.VacantInstances,
                getInstancesResponse.OccupiedInstances?.Select(i => new OccupiedInstance(i.Id, i.ServiceName, i.InstanceName, i.PartitionId))
                );

            return(Ok(response));
        }