Skip to content

Commit 61bd618

Browse files
committed
Fixeslocation cache for thinclient read and write locations.
1 parent d3e98de commit 61bd618

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

Microsoft.Azure.Cosmos/src/Routing/LocationCache.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -689,26 +689,26 @@ private void UpdateLocationCache(
689689
nextLocationInfo.AvailableWriteLocationByEndpoint = availableWriteLocationsByEndpoint;
690690
}
691691

692-
if (thinClientReadLocations != null)
692+
if (thinClientReadLocations != null && thinClientReadLocations.Count() > 0)
693693
{
694694
nextLocationInfo.ThinClientReadEndpointByLocation = this.GetEndpointByLocation(
695695
thinClientReadLocations,
696-
out ReadOnlyCollection<string> tcreadLocations,
697-
out ReadOnlyDictionary<Uri, string> tcReadLocByEndpoint);
696+
out ReadOnlyCollection<string> thinClientAvailableReadLocations,
697+
out ReadOnlyDictionary<Uri, string> thinClientAvailableReadLocationsByEndpoint);
698698

699-
nextLocationInfo.ThinClientReadLocations = tcreadLocations;
700-
nextLocationInfo.ThinClientReadLocationByEndpoint = tcReadLocByEndpoint;
699+
nextLocationInfo.ThinClientReadLocations = thinClientAvailableReadLocations;
700+
nextLocationInfo.ThinClientReadLocationByEndpoint = thinClientAvailableReadLocationsByEndpoint;
701701
}
702702

703-
if (thinClientWriteLocations != null)
703+
if (thinClientWriteLocations != null && thinClientWriteLocations.Count() > 0)
704704
{
705705
nextLocationInfo.ThinClientWriteEndpointByLocation = this.GetEndpointByLocation(
706706
thinClientWriteLocations,
707-
out ReadOnlyCollection<string> tcwriteLocations,
708-
out ReadOnlyDictionary<Uri, string> tcWriteLocByEndpoint);
707+
out ReadOnlyCollection<string> thinClientAvailableWriteLocations,
708+
out ReadOnlyDictionary<Uri, string> thinClientAvailableWriteLocationsByEndpoint);
709709

710-
nextLocationInfo.ThinClientWriteLocations = tcwriteLocations;
711-
nextLocationInfo.ThinClientWriteLocationByEndpoint = tcWriteLocByEndpoint;
710+
nextLocationInfo.ThinClientWriteLocations = thinClientAvailableWriteLocations;
711+
nextLocationInfo.ThinClientWriteLocationByEndpoint = thinClientAvailableWriteLocationsByEndpoint;
712712
}
713713

714714
nextLocationInfo.WriteEndpoints = this.GetPreferredAvailableEndpoints(
@@ -725,18 +725,18 @@ private void UpdateLocationCache(
725725

726726
nextLocationInfo.EffectivePreferredLocations = nextLocationInfo.PreferredLocations;
727727

728+
nextLocationInfo.ThinClientWriteEndpoints = this.GetPreferredAvailableEndpoints(
729+
endpointsByLocation: nextLocationInfo.ThinClientWriteEndpointByLocation,
730+
orderedLocations: nextLocationInfo.ThinClientWriteLocations,
731+
expectedAvailableOperation: OperationType.Write,
732+
fallbackEndpoint: this.defaultEndpoint);
733+
728734
nextLocationInfo.ThinClientReadEndpoints = this.GetPreferredAvailableEndpoints(
729735
endpointsByLocation: nextLocationInfo.ThinClientReadEndpointByLocation,
730736
orderedLocations: nextLocationInfo.ThinClientReadLocations,
731737
expectedAvailableOperation: OperationType.Read,
732-
fallbackEndpoint: this.defaultEndpoint);
738+
fallbackEndpoint: nextLocationInfo.ThinClientWriteEndpoints[0]);
733739

734-
nextLocationInfo.ThinClientWriteEndpoints = this.GetPreferredAvailableEndpoints(
735-
endpointsByLocation: nextLocationInfo.ThinClientWriteEndpointByLocation,
736-
orderedLocations: nextLocationInfo.ThinClientWriteLocations,
737-
expectedAvailableOperation: OperationType.Write,
738-
fallbackEndpoint: this.defaultEndpoint);
739-
740740
if (nextLocationInfo.PreferredLocations == null || nextLocationInfo.PreferredLocations.Count == 0)
741741
{
742742
if (!nextLocationInfo.AvailableReadLocationByEndpoint.TryGetValue(this.defaultEndpoint, out string regionForDefaultEndpoint))

0 commit comments

Comments
 (0)