public HostPoolData(AzureLocation location, HostPoolType hostPoolType, LoadBalancerType loadBalancerType, PreferredAppGroupType preferredAppGroupType) : base(location)
 {
     HostPoolType               = hostPoolType;
     LoadBalancerType           = loadBalancerType;
     ApplicationGroupReferences = new ChangeTrackingList <string>();
     PreferredAppGroupType      = preferredAppGroupType;
 }
        public ILoadBalancer <T> Resolve(Func <List <T> > func, LoadBalancerType Type = LoadBalancerType.Random)
        {
            switch (Type)
            {
            case LoadBalancerType.Random:
                return(new RandomLoadBalancer <T>(func));

            case LoadBalancerType.RoundRoin:
                return(new RoundRoinLoadBalancer <T>(func));

            default:
                throw new ArgumentException("Undefined load balancer");
            }
        }
Example #3
0
 /// <summary>
 /// 消费端设置
 /// </summary>
 /// <param name="ReceiverMaxConnections">消费最大连接数</param>
 /// <param name="ReveiverMaxDegreeOfParallelism">消费单个连接最大Channel数量</param>
 /// <param name="ReceiverAcquireRetryAttempts">最大重试次数</param>
 /// <param name="ReceiverHandlerTimeoutMillseconds">消费处理超时时间</param>
 /// <param name="IdempotencyDurationSeconds">幂等持续时间(秒)</param>
 /// <param name="PreFetch">预取数量</param>
 /// <param name="LoadBalancer">负责均衡机类型</param>
 public RabbitMQOption WithReceiver(
     int ReceiverMaxConnections            = 2,
     int ReveiverMaxDegreeOfParallelism    = 10,
     int ReceiverAcquireRetryAttempts      = 0,
     int ReceiverHandlerTimeoutMillseconds = 0,
     LoadBalancerType LoadBalancer         = LoadBalancerType.Random,
     int IdempotencyDurationSeconds        = 15,
     ushort PreFetch = 1)
 {
     this.ReceiverMaxConnections            = ReceiverMaxConnections;
     this.ReveiverMaxDegreeOfParallelism    = ReveiverMaxDegreeOfParallelism;
     this.ReceiverAcquireRetryAttempts      = ReceiverAcquireRetryAttempts;
     this.ReceiverHandlerTimeoutMillseconds = ReceiverHandlerTimeoutMillseconds;
     this.IdempotencyDuration  = IdempotencyDurationSeconds;
     this.PreFetch             = PreFetch;
     this.ReceiverLoadBalancer = LoadBalancer;
     return(this);
 }
 internal HostPoolData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string managedBy, string kind, string etag, SystemAssignedServiceIdentity identity, ResourceModelWithAllowedPropertySetSku sku, ArmPlan plan, string objectId, string friendlyName, string description, HostPoolType hostPoolType, PersonalDesktopAssignmentType?personalDesktopAssignmentType, string customRdpProperty, int?maxSessionLimit, LoadBalancerType loadBalancerType, int?ring, bool?validationEnvironment, RegistrationInfo registrationInfo, string vmTemplate, IReadOnlyList <string> applicationGroupReferences, string ssoadfsAuthority, string ssoClientId, string ssoClientSecretKeyVaultPath, SsoSecretType?ssoSecretType, PreferredAppGroupType preferredAppGroupType, bool?startVmOnConnect, MigrationRequestProperties migrationRequest, bool?cloudPcResource) : base(id, name, resourceType, systemData, tags, location, managedBy, kind, etag, identity, sku, plan)
 {
     ObjectId     = objectId;
     FriendlyName = friendlyName;
     Description  = description;
     HostPoolType = hostPoolType;
     PersonalDesktopAssignmentType = personalDesktopAssignmentType;
     CustomRdpProperty             = customRdpProperty;
     MaxSessionLimit             = maxSessionLimit;
     LoadBalancerType            = loadBalancerType;
     Ring                        = ring;
     ValidationEnvironment       = validationEnvironment;
     RegistrationInfo            = registrationInfo;
     VmTemplate                  = vmTemplate;
     ApplicationGroupReferences  = applicationGroupReferences;
     SsoadfsAuthority            = ssoadfsAuthority;
     SsoClientId                 = ssoClientId;
     SsoClientSecretKeyVaultPath = ssoClientSecretKeyVaultPath;
     SsoSecretType               = ssoSecretType;
     PreferredAppGroupType       = preferredAppGroupType;
     StartVmOnConnect            = startVmOnConnect;
     MigrationRequest            = migrationRequest;
     CloudPcResource             = cloudPcResource;
 }
Example #5
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Optional.IsDefined(ManagedBy))
     {
         writer.WritePropertyName("managedBy");
         writer.WriteStringValue(ManagedBy);
     }
     if (Optional.IsDefined(Kind))
     {
         writer.WritePropertyName("kind");
         writer.WriteStringValue(Kind);
     }
     if (Optional.IsDefined(Identity))
     {
         writer.WritePropertyName("identity");
         JsonSerializer.Serialize(writer, Identity);
     }
     if (Optional.IsDefined(Sku))
     {
         writer.WritePropertyName("sku");
         writer.WriteObjectValue(Sku);
     }
     if (Optional.IsDefined(Plan))
     {
         writer.WritePropertyName("plan");
         JsonSerializer.Serialize(writer, Plan);
     }
     writer.WritePropertyName("tags");
     writer.WriteStartObject();
     foreach (var item in Tags)
     {
         writer.WritePropertyName(item.Key);
         writer.WriteStringValue(item.Value);
     }
     writer.WriteEndObject();
     writer.WritePropertyName("location");
     writer.WriteStringValue(Location);
     writer.WritePropertyName("properties");
     writer.WriteStartObject();
     if (Optional.IsDefined(FriendlyName))
     {
         writer.WritePropertyName("friendlyName");
         writer.WriteStringValue(FriendlyName);
     }
     if (Optional.IsDefined(Description))
     {
         writer.WritePropertyName("description");
         writer.WriteStringValue(Description);
     }
     writer.WritePropertyName("hostPoolType");
     writer.WriteStringValue(HostPoolType.ToString());
     if (Optional.IsDefined(PersonalDesktopAssignmentType))
     {
         writer.WritePropertyName("personalDesktopAssignmentType");
         writer.WriteStringValue(PersonalDesktopAssignmentType.Value.ToString());
     }
     if (Optional.IsDefined(CustomRdpProperty))
     {
         writer.WritePropertyName("customRdpProperty");
         writer.WriteStringValue(CustomRdpProperty);
     }
     if (Optional.IsDefined(MaxSessionLimit))
     {
         writer.WritePropertyName("maxSessionLimit");
         writer.WriteNumberValue(MaxSessionLimit.Value);
     }
     writer.WritePropertyName("loadBalancerType");
     writer.WriteStringValue(LoadBalancerType.ToString());
     if (Optional.IsDefined(Ring))
     {
         writer.WritePropertyName("ring");
         writer.WriteNumberValue(Ring.Value);
     }
     if (Optional.IsDefined(ValidationEnvironment))
     {
         writer.WritePropertyName("validationEnvironment");
         writer.WriteBooleanValue(ValidationEnvironment.Value);
     }
     if (Optional.IsDefined(RegistrationInfo))
     {
         writer.WritePropertyName("registrationInfo");
         writer.WriteObjectValue(RegistrationInfo);
     }
     if (Optional.IsDefined(VmTemplate))
     {
         writer.WritePropertyName("vmTemplate");
         writer.WriteStringValue(VmTemplate);
     }
     if (Optional.IsDefined(SsoadfsAuthority))
     {
         writer.WritePropertyName("ssoadfsAuthority");
         writer.WriteStringValue(SsoadfsAuthority);
     }
     if (Optional.IsDefined(SsoClientId))
     {
         writer.WritePropertyName("ssoClientId");
         writer.WriteStringValue(SsoClientId);
     }
     if (Optional.IsDefined(SsoClientSecretKeyVaultPath))
     {
         writer.WritePropertyName("ssoClientSecretKeyVaultPath");
         writer.WriteStringValue(SsoClientSecretKeyVaultPath);
     }
     if (Optional.IsDefined(SsoSecretType))
     {
         writer.WritePropertyName("ssoSecretType");
         writer.WriteStringValue(SsoSecretType.Value.ToString());
     }
     writer.WritePropertyName("preferredAppGroupType");
     writer.WriteStringValue(PreferredAppGroupType.ToString());
     if (Optional.IsDefined(StartVmOnConnect))
     {
         writer.WritePropertyName("startVMOnConnect");
         writer.WriteBooleanValue(StartVmOnConnect.Value);
     }
     if (Optional.IsDefined(MigrationRequest))
     {
         writer.WritePropertyName("migrationRequest");
         writer.WriteObjectValue(MigrationRequest);
     }
     writer.WriteEndObject();
     writer.WriteEndObject();
 }
Example #6
0
        internal static HostPoolData DeserializeHostPoolData(JsonElement element)
        {
            Optional <string> managedBy = default;
            Optional <string> kind      = default;
            Optional <string> etag      = default;
            Optional <SystemAssignedServiceIdentity>          identity = default;
            Optional <ResourceModelWithAllowedPropertySetSku> sku      = default;
            Optional <ArmPlan>           plan = default;
            IDictionary <string, string> tags = default;
            AzureLocation      location       = default;
            ResourceIdentifier id             = default;
            string             name           = default;
            ResourceType       type           = default;
            SystemData         systemData     = default;
            Optional <string>  objectId       = default;
            Optional <string>  friendlyName   = default;
            Optional <string>  description    = default;
            HostPoolType       hostPoolType   = default;
            Optional <PersonalDesktopAssignmentType> personalDesktopAssignmentType = default;
            Optional <string>                     customRdpProperty = default;
            Optional <int>                        maxSessionLimit   = default;
            LoadBalancerType                      loadBalancerType  = default;
            Optional <int>                        ring = default;
            Optional <bool>                       validationEnvironment       = default;
            Optional <RegistrationInfo>           registrationInfo            = default;
            Optional <string>                     vmTemplate                  = default;
            Optional <IReadOnlyList <string> >    applicationGroupReferences  = default;
            Optional <string>                     ssoadfsAuthority            = default;
            Optional <string>                     ssoClientId                 = default;
            Optional <string>                     ssoClientSecretKeyVaultPath = default;
            Optional <SsoSecretType>              ssoSecretType               = default;
            PreferredAppGroupType                 preferredAppGroupType       = default;
            Optional <bool>                       startVMOnConnect            = default;
            Optional <MigrationRequestProperties> migrationRequest            = default;
            Optional <bool>                       cloudPcResource             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("managedBy"))
                {
                    managedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = JsonSerializer.Deserialize <SystemAssignedServiceIdentity>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = ResourceModelWithAllowedPropertySetSku.DeserializeResourceModelWithAllowedPropertySetSku(property.Value);
                    continue;
                }
                if (property.NameEquals("plan"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    plan = JsonSerializer.Deserialize <ArmPlan>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("objectId"))
                        {
                            objectId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("friendlyName"))
                        {
                            friendlyName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("description"))
                        {
                            description = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("hostPoolType"))
                        {
                            hostPoolType = new HostPoolType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("personalDesktopAssignmentType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            personalDesktopAssignmentType = new PersonalDesktopAssignmentType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("customRdpProperty"))
                        {
                            customRdpProperty = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("maxSessionLimit"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maxSessionLimit = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("loadBalancerType"))
                        {
                            loadBalancerType = new LoadBalancerType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("ring"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            ring = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("validationEnvironment"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            validationEnvironment = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("registrationInfo"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            registrationInfo = RegistrationInfo.DeserializeRegistrationInfo(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("vmTemplate"))
                        {
                            vmTemplate = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("applicationGroupReferences"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            applicationGroupReferences = array;
                            continue;
                        }
                        if (property0.NameEquals("ssoadfsAuthority"))
                        {
                            ssoadfsAuthority = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("ssoClientId"))
                        {
                            ssoClientId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("ssoClientSecretKeyVaultPath"))
                        {
                            ssoClientSecretKeyVaultPath = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("ssoSecretType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            ssoSecretType = new SsoSecretType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("preferredAppGroupType"))
                        {
                            preferredAppGroupType = new PreferredAppGroupType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("startVMOnConnect"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            startVMOnConnect = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("migrationRequest"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            migrationRequest = MigrationRequestProperties.DeserializeMigrationRequestProperties(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("cloudPcResource"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            cloudPcResource = property0.Value.GetBoolean();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new HostPoolData(id, name, type, systemData, tags, location, managedBy.Value, kind.Value, etag.Value, identity, sku.Value, plan, objectId.Value, friendlyName.Value, description.Value, hostPoolType, Optional.ToNullable(personalDesktopAssignmentType), customRdpProperty.Value, Optional.ToNullable(maxSessionLimit), loadBalancerType, Optional.ToNullable(ring), Optional.ToNullable(validationEnvironment), registrationInfo.Value, vmTemplate.Value, Optional.ToList(applicationGroupReferences), ssoadfsAuthority.Value, ssoClientId.Value, ssoClientSecretKeyVaultPath.Value, Optional.ToNullable(ssoSecretType), preferredAppGroupType, Optional.ToNullable(startVMOnConnect), migrationRequest.Value, Optional.ToNullable(cloudPcResource)));
        }
Example #7
0
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param>
 /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param>
 /// <param name="formatProvider">not used by this TypeConverter.</param>
 /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param>
 /// <returns>
 /// an instance of <see cref="LoadBalancerType" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => LoadBalancerType.CreateFrom(sourceValue);
Example #8
0
        public async Task HostPoolCrud(
            int caseNumber,
            HostPoolType hostPoolType,
            LoadBalancerType loadBalancerType,
            LoadBalancerType expectedLoadBalancerType,
            PreferredAppGroupType preferredAppGroupType)
        {
            string hostPoolName = $"testHostPoolCrud{caseNumber}";

            string resourceGroupName = Recording.GetVariable("DESKTOPVIRTUALIZATION_RESOURCE_GROUP", DefaultResourceGroupName);
            ResourceGroupResource rg = (ResourceGroupResource)await ResourceGroups.GetAsync(resourceGroupName);

            Assert.IsNotNull(rg);
            HostPoolCollection hostPoolCollection = rg.GetHostPools();
            HostPoolData       hostPoolData       = new HostPoolData(
                DefaultLocation,
                hostPoolType,
                loadBalancerType,
                preferredAppGroupType);

            ArmOperation <HostPoolResource> op = await hostPoolCollection.CreateOrUpdateAsync(
                WaitUntil.Completed,
                hostPoolName,
                hostPoolData);

            Assert.IsNotNull(op);
            Assert.IsTrue(op.HasCompleted);
            Assert.AreEqual(op.Value.Data.Name, hostPoolName);

            Response <HostPoolResource> getOp = await hostPoolCollection.GetAsync(
                hostPoolName);

            Assert.AreEqual(hostPoolName, getOp.Value.Data.Name);
            Assert.AreEqual(hostPoolType, getOp.Value.Data.HostPoolType);
            Assert.AreEqual(expectedLoadBalancerType, getOp.Value.Data.LoadBalancerType);
            Assert.AreEqual(preferredAppGroupType, getOp.Value.Data.PreferredAppGroupType);

            hostPoolData.FriendlyName = "Friendly Name";
            op = await hostPoolCollection.CreateOrUpdateAsync(
                WaitUntil.Completed,
                hostPoolName,
                hostPoolData);

            Assert.IsNotNull(op);
            Assert.IsTrue(op.HasCompleted);
            Assert.AreEqual(op.Value.Data.Name, hostPoolName);
            Assert.AreEqual(op.Value.Data.FriendlyName, "Friendly Name");
            Assert.AreEqual(hostPoolName, getOp.Value.Data.Name);
            Assert.AreEqual(hostPoolType, getOp.Value.Data.HostPoolType);
            Assert.AreEqual(expectedLoadBalancerType, getOp.Value.Data.LoadBalancerType);
            Assert.AreEqual(preferredAppGroupType, getOp.Value.Data.PreferredAppGroupType);

            getOp = await hostPoolCollection.GetAsync(
                hostPoolName);

            HostPoolResource hostPool = getOp.Value;
            ArmOperation     deleteOp = await hostPool.DeleteAsync(WaitUntil.Completed);

            Assert.IsNotNull(deleteOp);

            Assert.AreEqual(200, deleteOp.GetRawResponse().Status);

            deleteOp = await hostPool.DeleteAsync(WaitUntil.Completed);

            Assert.IsNotNull(deleteOp);

            Assert.AreEqual(204, deleteOp.GetRawResponse().Status);

            try
            {
                getOp = await hostPoolCollection.GetAsync(
                    hostPoolName);
            }
            catch (RequestFailedException ex)
            {
                Assert.AreEqual(404, ex.Status);
            }
        }
Example #9
0
 /// <summary>
 /// 设置连接池信息
 /// </summary>
 /// <param name="SenderMaxConnections">发送端最大连接数量</param>
 /// <param name="AcquireRetryAttempts">最大重试次数</param>
 /// <param name="LoadBalancer">负责均衡机类型</param>
 public RabbitMQOption WithSender(int SenderMaxConnections = 10, int AcquireRetryAttempts = 3, LoadBalancerType LoadBalancer = LoadBalancerType.Random)
 {
     this.SenderMaxConnections       = SenderMaxConnections;
     this.SenderAcquireRetryAttempts = AcquireRetryAttempts;
     this.SenderLoadBalancer         = LoadBalancer;
     return(this);
 }