Exemplo n.º 1
0
        public async Task GivenAFeedRequest_WithAStrongerConsistencyLevelThanTheDefault_ThenABadRequestExceptionIsThrown(ConsistencyLevel defaultConsistencyLevel, ConsistencyLevel requestedConsistencyLevel)
        {
            _innerClient.ConsistencyLevel.Returns(defaultConsistencyLevel);
            _requestHeaders.Add(CosmosDbHeaders.ConsistencyLevel, requestedConsistencyLevel.ToString());

            await Assert.ThrowsAsync <BadRequestException>(() => _fhirClient.ReadDatabaseFeedAsync());
        }
Exemplo n.º 2
0
 private static string GetConsistencyName(ConsistencyLevel consistency)
 {
     if (!GraphOptions.ConsistencyLevelNames.TryGetValue(consistency, out string name))
     {
         //If not defined, use upper case representation
         name = consistency.ToString().ToUpper();
     }
     return(name);
 }
 public WriteTimeoutException(ConsistencyLevel consistency, int received, int required,
                              string writeType)
     : base(string.Format("Cassandra timeout during write query at consitency {0} ({1} replica acknowledged the write over {2} required)", consistency.ToString().ToUpper(), received, required),
       consistency,
       received,
       required)
 {
     this.WriteType = writeType;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of <see cref="WriteFailureException"/>.
 /// </summary>
 public WriteFailureException(ConsistencyLevel consistency, int received, int required, string writeType,
                              int failures) : base(string.Format(FailureMessage,
                                                                 consistency.ToString().ToUpper(), required, received, failures))
 {
     ConsistencyLevel         = consistency;
     ReceivedAcknowledgements = received;
     RequiredAcknowledgements = required;
     WriteType = writeType;
     Failures  = failures;
 }
Exemplo n.º 5
0
 public WriteFailureException(ConsistencyLevel consistency, int received, int required, string writeType, int failures) :
     base(string.Format(
              "Cassandra timeout during write query at consistency {0} ({1} replica(s) acknowledged the write over {2} required)",
              consistency.ToString().ToUpper(), received, required))
 {
     ConsistencyLevel         = consistency;
     ReceivedAcknowledgements = received;
     RequiredAcknowledgements = required;
     WriteType = writeType;
     Failures  = failures;
 }
 public WriteFailureException(ConsistencyLevel consistency, int received, int required, string writeType, int failures) :
                                  base(string.Format(
                                      "Cassandra timeout during write query at consistency {0} ({1} replica(s) acknowledged the write over {2} required)",
                                      consistency.ToString().ToUpper(), received, required))
 {
     ConsistencyLevel = consistency;
     ReceivedAcknowledgements = received;
     RequiredAcknowledgements = required;
     WriteType = writeType;
     Failures = failures;
 }
 public WriteTimeoutException(ConsistencyLevel consistency, int received, int required,
                              string writeType) :
     base(
         string.Format(
             "Cassandra timeout during write query at consistency {0} ({1} replica(s) acknowledged the write over {2} required)",
             consistency.ToString().ToUpper(), received, required),
         consistency,
         received,
         required)
 {
     WriteType = writeType;
 }
Exemplo n.º 8
0
 public ConsistencyConfig(
     ConsistencyLevel?consistencyLevel,
     IReadOnlyList <string> preferredRegions)
 {
     this.ConsistencyLevel = consistencyLevel;
     this.PreferredRegions = preferredRegions;
     this.lazyString       = new Lazy <string>(() => string.Format(CultureInfo.InvariantCulture,
                                                                   "(consistency: {0}, prgns:[{1}])",
                                                                   consistencyLevel?.ToString() ?? "NotSet",
                                                                   ConsistencyConfig.PreferredRegionsInternal(preferredRegions)));
     this.lazyJsonString = new Lazy <string>(() => Newtonsoft.Json.JsonConvert.SerializeObject(this));
 }
 public static Apache.Cassandra.ConsistencyLevel ToThriftConsistencyLevel(this ConsistencyLevel consistencyLevel)
 {
     return((Apache.Cassandra.ConsistencyLevel)Enum.Parse(typeof(Apache.Cassandra.ConsistencyLevel), consistencyLevel.ToString()));
 }
Exemplo n.º 10
0
        private static string GetMessage(string writeType, ConsistencyLevel consistency, int received, int required)
        {
            var message = writeType == BatchLogWriteType ? BatchLogMessage : QueryMessage;

            return(string.Format(message, consistency.ToString().ToUpper(), received, required));
        }