DEFAULT_INCLUDE_EXCEPTION_STACK_IN_LOG); ConsistencyLevel consistencyLevel = ConsistencyLevel.valueOf(this.getStringProperty( "azurecosmos.consistencyLevel", DEFAULT_CONSISTENCY_LEVEL)); uri, connectionPolicy.getConnectionMode(), consistencyLevel.toString(), connectionPolicy.getRetryOptions().getMaxRetryAttemptsOnThrottledRequests(), connectionPolicy.getRetryOptions().getMaxRetryWaitTimeInSeconds(),
/** * Get the name of the resource. * * @return the default consistency level. */ public ConsistencyLevel getDefaultConsistencyLevel() { ConsistencyLevel result = ConsistencyPolicy.DEFAULT_DEFAULT_CONSISTENCY_LEVEL; try { result = ConsistencyLevel.valueOf( WordUtils.capitalize(super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL))); } catch (IllegalArgumentException e) { // ignore the exception and return the default this.getLogger().warn("Unknown consistency level {}, value ignored.", super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL)); } return result; }
private void applySessionToken(RxDocumentServiceRequest request) { Map<String, String> headers = request.getHeaders(); if (headers != null && !StringUtils.isEmpty(headers.get(HttpConstants.HttpHeaders.SESSION_TOKEN))) { return; // User is explicitly controlling the session. } String requestConsistency = request.getHeaders().get(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL); boolean sessionConsistency = this.consistencyLevel == ConsistencyLevel.Session || (!StringUtils.isEmpty(requestConsistency) && StringUtils.equalsIgnoreCase(requestConsistency, ConsistencyLevel.Session.toString())); if (!sessionConsistency) { return; // Only apply the session token in case of session consistency } // Apply the ambient session. if (!StringUtils.isEmpty(request.getResourceAddress())) { String sessionToken = this.sessionContainer.resolveGlobalSessionToken(request); if (!StringUtils.isEmpty(sessionToken)) { headers.put(HttpConstants.HttpHeaders.SESSION_TOKEN, sessionToken); } } }
/** * Set the name of the resource. * * @param level the consistency level. */ public void setDefaultConsistencyLevel(ConsistencyLevel level) { super.set(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL, level.name()); }
/** * Create document client. * * @param properties the properties * @return the document client */ public DocumentClient createDocumentClient(final BaseCosmosDbProperties properties) { val policy = ConnectionPolicy.GetDefault(); var userAgent = (policy.getUserAgentSuffix() == null ? StringUtils.EMPTY : ';' + policy.getUserAgentSuffix()) + ';' + USER_AGENT_SUFFIX; if (properties.isAllowTelemetry() && GetHashMac.getHashMac() != null) { userAgent += ';' + GetHashMac.getHashMac(); } policy.setUserAgentSuffix(userAgent); return new DocumentClient(properties.getUri(), properties.getKey(), policy, ConsistencyLevel.valueOf(properties.getConsistencyLevel())); }
public RxGatewayStoreModel(ConnectionPolicy connectionPolicy, ConsistencyLevel consistencyLevel, QueryCompatibilityMode queryCompatibilityMode, String masterKey, Map<String, String> resourceTokens, UserAgentContainer userAgentContainer, EndpointManager globalEndpointManager, HttpClient<ByteBuf, ByteBuf> httpClient) { this.defaultHeaders = new HashMap<String, String>(); this.defaultHeaders.put(HttpConstants.HttpHeaders.CACHE_CONTROL, "no-cache"); this.defaultHeaders.put(HttpConstants.HttpHeaders.VERSION, HttpConstants.Versions.CURRENT_VERSION); if (userAgentContainer == null) { userAgentContainer = new UserAgentContainer(); } this.defaultHeaders.put(HttpConstants.HttpHeaders.USER_AGENT, userAgentContainer.getUserAgent()); if (consistencyLevel != null) { this.defaultHeaders.put(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL, consistencyLevel.toString()); } this.globalEndpointManager = globalEndpointManager; this.queryCompatibilityMode = queryCompatibilityMode; this.httpClient = httpClient; }
headers.put(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL, options.getConsistencyLevel().name());