Exemple #1
0
        private List <PSRedisLinkedServer> GetAllLinksByRoleType(string cacheName, ReplicationRole roleType)
        {
            List <PSRedisLinkedServer> list = GetAllLinks(cacheName);

            if (roleType == ReplicationRole.Primary)
            {
                List <PSRedisLinkedServer> allPrimary = new List <PSRedisLinkedServer>();
                foreach (var link in list)
                {
                    if (link.PrimaryServerName.Equals(cacheName, StringComparison.OrdinalIgnoreCase))
                    {
                        allPrimary.Add(link);
                    }
                }
                return(allPrimary);
            }
            else
            {
                List <PSRedisLinkedServer> allSecondary = new List <PSRedisLinkedServer>();
                foreach (var link in list)
                {
                    if (link.SecondaryServerName.Equals(cacheName, StringComparison.OrdinalIgnoreCase))
                    {
                        allSecondary.Add(link);
                    }
                }
                return(allSecondary);
            }
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the
 /// RedisLinkedServerCreateParametersInner class.
 /// </summary>
 /// <param name="linkedRedisCacheId">Fully qualified resourceId of the
 /// linked redis cache.</param>
 /// <param name="linkedRedisCacheLocation">Location of the linked redis
 /// cache.</param>
 /// <param name="serverRole">Role of the linked server. Possible values
 /// include: 'Primary', 'Secondary'</param>
 public RedisLinkedServerCreateParametersInner(string linkedRedisCacheId, string linkedRedisCacheLocation, ReplicationRole serverRole)
 {
     LinkedRedisCacheId       = linkedRedisCacheId;
     LinkedRedisCacheLocation = linkedRedisCacheLocation;
     ServerRole = serverRole;
     CustomInit();
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the RedisLinkedServerWithProperties
 /// class.
 /// </summary>
 /// <param name="linkedRedisCacheId">Fully qualified resourceId of the
 /// linked redis cache.</param>
 /// <param name="linkedRedisCacheLocation">Location of the linked redis
 /// cache.</param>
 /// <param name="serverRole">Role of the linked server. Possible values
 /// include: 'Primary', 'Secondary'</param>
 /// <param name="id">Resource ID.</param>
 /// <param name="name">Resource name.</param>
 /// <param name="type">Resource type.</param>
 /// <param name="provisioningState">Terminal state of the link between
 /// primary and secondary redis cache.</param>
 public RedisLinkedServerWithProperties(string linkedRedisCacheId, string linkedRedisCacheLocation, ReplicationRole serverRole, string id = default(string), string name = default(string), string type = default(string), string provisioningState = default(string))
     : base(id, name, type)
 {
     LinkedRedisCacheId       = linkedRedisCacheId;
     LinkedRedisCacheLocation = linkedRedisCacheLocation;
     ServerRole        = serverRole;
     ProvisioningState = provisioningState;
     CustomInit();
 }
Exemple #4
0
        internal static string ToSerializedValue(this ReplicationRole value)
        {
            switch (value)
            {
            case ReplicationRole.Primary:
                return("Primary");

            case ReplicationRole.Secondary:
                return("Secondary");
            }
            return(null);
        }
        internal static string ToSerializedValue(this ReplicationRole value)
        {
            switch (value)
            {
            case ReplicationRole.Primary:
                return("Primary");

            case ReplicationRole.Secondary:
                return("Secondary");

            case ReplicationRole.NonReadableSecondary:
                return("NonReadableSecondary");

            case ReplicationRole.Source:
                return("Source");

            case ReplicationRole.Copy:
                return("Copy");
            }
            return(null);
        }
 public static string ToSerialString(this ReplicationRole value) => value switch
 {
 internal RedisLinkedServerWithProperties SetLinkedServer(string resourceGroupName, string cacheName,
                                                          string linkedCacheName, string linkedCacheId, string linkedCacheLocation, ReplicationRole serverRole)
 {
     return(_client.LinkedServer.BeginCreate(resourceGroupName, cacheName, linkedCacheName, new RedisLinkedServerCreateParameters
     {
         LinkedRedisCacheId = linkedCacheId,
         LinkedRedisCacheLocation = linkedCacheLocation,
         ServerRole = serverRole
     }));
 }
 /// <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="ReplicationRole" />, 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) => ReplicationRole.CreateFrom(sourceValue);
 /// <summary>
 /// Adds a linked server to the current Redis cache instance.
 /// </summary>
 /// <param name="linkedRedisCacheId">The resource Id of the Redis instance to link with.</param>
 /// <param name="linkedServerLocation">The location of the linked Redis instance.</param>
 /// <param name="role">The role of the linked server.</param>
 /// <return>Name of the linked server.</return>
 async Task <string> Microsoft.Azure.Management.Redis.Fluent.IRedisCachePremiumBeta.AddLinkedServerAsync(string linkedRedisCacheId, string linkedServerLocation, ReplicationRole role, CancellationToken cancellationToken)
 {
     return(await this.AddLinkedServerAsync(linkedRedisCacheId, linkedServerLocation, role, cancellationToken));
 }
 /// <summary>
 /// Adds a linked server to the current Redis cache instance.
 /// </summary>
 /// <param name="linkedRedisCacheId">The resource Id of the Redis instance to link with.</param>
 /// <param name="linkedServerLocation">The location of the linked Redis instance.</param>
 /// <param name="role">The role of the linked server.</param>
 /// <return>Name of the linked server.</return>
 string Microsoft.Azure.Management.Redis.Fluent.IRedisCachePremiumBeta.AddLinkedServer(string linkedRedisCacheId, string linkedServerLocation, ReplicationRole role)
 {
     return(this.AddLinkedServer(linkedRedisCacheId, linkedServerLocation, role));
 }
        public async Task <string> AddLinkedServerAsync(string linkedRedisCacheId, string linkedServerLocation, ReplicationRole role, CancellationToken cancellationToken)
        {
            var linkedRedisName = ResourceUtils.NameFromResourceId(linkedRedisCacheId);
            var linkParams      = new RedisLinkedServerCreateParametersInner
            {
                LinkedRedisCacheId       = linkedRedisCacheId,
                LinkedRedisCacheLocation = linkedServerLocation,
                ServerRole = role
            };

            var linkedServerInner = await this.Manager.Inner.LinkedServer.CreateAsync(
                this.ResourceGroupName,
                this.Name,
                linkedRedisName,
                linkParams,
                cancellationToken);

            return(linkedServerInner.Name);
        }
 ///GENMHASH:76A2D10D5E76A25A6A9353EC8DA14C51:3AF62FAEC73DB2510F1598C12DAC9DB2
 public string AddLinkedServer(string linkedRedisCacheId, string linkedServerLocation, ReplicationRole role)
 {
     return(Extensions.Synchronize(() => this.AddLinkedServerAsync(linkedRedisCacheId, linkedServerLocation, role, default(CancellationToken))));
 }