| 2938 | |
| 2939 | template <class F> |
| 2940 | Future<KeyRangeLocationInfo> getKeyLocation(Database const& cx, |
| 2941 | TenantInfo const& tenant, |
| 2942 | Key const& key, |
| 2943 | F StorageServerInterface::*member, |
| 2944 | SpanContext spanContext, |
| 2945 | Optional<UID> debugID, |
| 2946 | UseProvisionalProxies useProvisionalProxies, |
| 2947 | Reverse isBackward, |
| 2948 | Version version) { |
| 2949 | // we first check whether this range is cached |
| 2950 | Optional<KeyRangeLocationInfo> locationInfo = cx->getCachedLocation(tenant.name, key, isBackward); |
| 2951 | if (!locationInfo.present()) { |
| 2952 | return getKeyLocation_internal( |
| 2953 | cx, tenant, key, spanContext, debugID, useProvisionalProxies, isBackward, version); |
| 2954 | } |
| 2955 | |
| 2956 | bool onlyEndpointFailedAndNeedRefresh = false; |
| 2957 | for (int i = 0; i < locationInfo.get().locations->size(); i++) { |
| 2958 | if (checkOnlyEndpointFailed(cx, locationInfo.get().locations->get(i, member).getEndpoint())) { |
| 2959 | onlyEndpointFailedAndNeedRefresh = true; |
| 2960 | } |
| 2961 | } |
| 2962 | |
| 2963 | if (onlyEndpointFailedAndNeedRefresh) { |
| 2964 | cx->invalidateCache(locationInfo.get().tenantEntry.prefix, key); |
| 2965 | |
| 2966 | // Refresh the cache with a new getKeyLocations made to proxies. |
| 2967 | return getKeyLocation_internal( |
| 2968 | cx, tenant, key, spanContext, debugID, useProvisionalProxies, isBackward, version); |
| 2969 | } |
| 2970 | |
| 2971 | return locationInfo.get(); |
| 2972 | } |
| 2973 | |
| 2974 | template <class F> |
| 2975 | Future<KeyRangeLocationInfo> getKeyLocation(Reference<TransactionState> trState, |
no test coverage detected