@Override public void init() throws DBException { host = getProperties().getProperty("documentdb.host", null); masterKey = getProperties().getProperty("documentdb.masterKey", null); if (host == null) { System.err.println("ERROR: 'documentdb.host' must be set!"); System.exit(1); } if (masterKey == null) { System.err.println("ERROR: 'documentdb.masterKey' must be set!"); System.exit(1); } databaseId = getProperties().getProperty("documentdb.databaseId", "ycsb"); String collectionId = getProperties().getProperty("documentdb.collectionId", "usertable"); documentClient = new DocumentClient(host, masterKey, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session); try { // Initialize test database and collection. collection = getCollection(collectionId); } catch (DocumentClientException e) { throw new DBException("Initialze collection failed", e); } feedOptions = new FeedOptions(); feedOptions.setEmitVerboseTracesInQuery(false); }
DEFAULT_CONNECTION_MODE); ConnectionPolicy connectionPolicy = new ConnectionPolicy(); connectionPolicy.setEnableEndpointDiscovery(false); connectionPolicy.setConnectionMode(ConnectionMode.valueOf(connectionModeString)); connectionPolicy.setMaxPoolSize(this.getIntProperty("azurecosmos.maxConnectionPoolSize", connectionPolicy.getMaxPoolSize())); connectionPolicy.setIdleConnectionTimeout(this.getIntProperty("azurecosmos.idleConnectionTimeout", connectionPolicy.getIdleConnectionTimeout())); "azurecosmos.maxRetryWaitTimeInSeconds", retryOptions.getMaxRetryWaitTimeInSeconds())); connectionPolicy.setRetryOptions(retryOptions); + "queryText={}", uri, connectionPolicy.getConnectionMode(), consistencyLevel.toString(), connectionPolicy.getRetryOptions().getMaxRetryAttemptsOnThrottledRequests(), connectionPolicy.getRetryOptions().getMaxRetryWaitTimeInSeconds(), this.useSinglePartitionCollection, this.useUpsert,
private DocumentClient createDocumentClient() { LOG.debug("createDocumentClient"); final ConnectionPolicy policy = connectionPolicy == null ? ConnectionPolicy.GetDefault() : connectionPolicy; String userAgent = (policy.getUserAgentSuffix() == null ? "" : ";" + 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, properties.getConsistencyLevel() == null ? ConsistencyLevel.Session : properties.getConsistencyLevel()); }
this.connectionPolicy = connectionPolicy; } else { this.connectionPolicy = new ConnectionPolicy(); String userAgentSuffix = this.connectionPolicy.getUserAgentSuffix(); if (userAgentSuffix != null && userAgentSuffix.length() > 0) { userAgentContainer.setSuffix(userAgentSuffix); this.connectionPolicy.getMaxPoolSize(), this.connectionPolicy.getIdleConnectionTimeout(), this.connectionPolicy.getRequestTimeout()); this.connectionPolicy.getRequestTimeout()); this.connectionPolicy.getMediaRequestTimeout()); if (this.connectionPolicy.getConnectionMode() == ConnectionMode.DirectHttps) { if (this.globalAddressResolver == null) { this.globalAddressResolver = new GlobalAddressResolver(this.serviceEndpoint.toString(),
public DocumentDbFactory(String host, String key, boolean isBiEnabled) { Assert.hasText(host, "host must not be empty!"); Assert.hasText(key, "key must not be empty!"); final ConnectionPolicy policy = ConnectionPolicy.GetDefault(); String userAgent = ";" + USER_AGENT_SUFFIX; if (isBiEnabled && GetHashMac.getHashMac() != null) { userAgent += ";" + GetHashMac.getHashMac(); } policy.setUserAgentSuffix(userAgent); documentClient = new DocumentClient(host, key, policy, ConsistencyLevel.Session); }
public DocumentClient getDocumentClient() { final ConnectionPolicy policy = config.getConnectionPolicy(); final String userAgent = getUserAgentSuffix() + ";" + policy.getUserAgentSuffix(); policy.setUserAgentSuffix(userAgent); return new DocumentClient(config.getUri(), config.getKey(), policy, config.getConsistencyLevel()); }
this.connectionPolicy = connectionPolicy; } else { this.connectionPolicy = new ConnectionPolicy(); String userAgentSuffix = this.connectionPolicy.getUserAgentSuffix(); if (userAgentSuffix != null && userAgentSuffix.length() > 0) { userAgentContainer.setSuffix(userAgentSuffix); if (this.connectionPolicy.getConnectionMode() == ConnectionMode.DirectHttps) { throw new UnsupportedOperationException("Direct Https is not supported");
private HttpClientBuilder<ByteBuf, ByteBuf> httpClientBuilder() { HttpClientBuilder<ByteBuf, ByteBuf> builder = RxNetty .<ByteBuf, ByteBuf>newHttpClientBuilder(this.serviceEndpoint.getHost(), this.serviceEndpoint.getPort()) .withSslEngineFactory(DefaultFactories.trustAll()).withMaxConnections(connectionPolicy.getMaxPoolSize()) .withIdleConnectionsTimeoutMillis(this.connectionPolicy.getIdleConnectionTimeout() * 1000); ClientConfig config = new ClientConfig.Builder() .readTimeout(connectionPolicy.getRequestTimeout(), TimeUnit.SECONDS).build(); return builder.config(config); }
void setStoreModel(StoreModel storeModel) { if (this.connectionPolicy.getConnectionMode() == ConnectionMode.DirectHttps) { this.storeModel = storeModel; } }
/** * Gets the default connection policy. * * @return the default connection policy. */ public static ConnectionPolicy GetDefault() { if (ConnectionPolicy.default_policy == null) { ConnectionPolicy.default_policy = new ConnectionPolicy(); } return ConnectionPolicy.default_policy; }
public RxWrapperDocumentClientImpl(DocumentClient client) { this.client = client; int maxThreads = (int) (client.getConnectionPolicy().getMaxPoolSize() * 1.1); this.executorService = new ThreadPoolExecutor( Math.min(8, maxThreads), // core thread pool size maxThreads, // maximum thread pool size 30, // time to wait before killing idle threads TimeUnit.SECONDS, new SynchronousQueue<>(), new RxThreadFactory("RxDocdb-io"), new ThreadPoolExecutor.CallerRunsPolicy()); this.scheduler = Schedulers.from(executorService); }
private DocumentClient createDocumentClient() { LOG.debug("createDocumentClient"); final ConnectionPolicy policy = connectionPolicy == null ? ConnectionPolicy.GetDefault() : connectionPolicy; String userAgent = (policy.getUserAgentSuffix() == null ? "" : ";" + 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, properties.getConsistencyLevel() == null ? ConsistencyLevel.Session : properties.getConsistencyLevel()); }
public DocumentDbFactory(String host, String key, boolean isBiEnabled) { Assert.hasText(host, "host must not be empty!"); Assert.hasText(key, "key must not be empty!"); final ConnectionPolicy policy = ConnectionPolicy.GetDefault(); String userAgent = ";" + USER_AGENT_SUFFIX; if (isBiEnabled && GetHashMac.getHashMac() != null) { userAgent += ";" + GetHashMac.getHashMac(); } policy.setUserAgentSuffix(userAgent); documentClient = new DocumentClient(host, key, policy, ConsistencyLevel.Session); }
void setGatewayProxyOverride(GatewayProxy proxyOverride) { this.gatewayProxy = proxyOverride; if (this.connectionPolicy.getConnectionMode() != ConnectionMode.DirectHttps) { this.storeModel = proxyOverride; } }
/** * 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())); }
private void configConnectionPolicy(DocumentDBProperties properties, ConnectionPolicy connectionPolicy) { // This is a temp fix as DocumentDbFactory does not support loading ConnectionPolicy bean from context final ConnectionPolicy policy = connectionPolicy == null ? ConnectionPolicy.GetDefault() : connectionPolicy; properties.setConnectionPolicy(policy); } }
public AsyncDocumentClient build() { ifThrowIllegalArgException(this.serviceEndpoint == null, "cannot build client without service endpoint"); ifThrowIllegalArgException(this.masterKey == null, "cannot build client without masterKey"); if (connectionPolicy != null && ConnectionMode.DirectHttps != connectionPolicy.getConnectionMode()) { return new RxDocumentClientImpl(serviceEndpoint, masterKey, connectionPolicy, desiredConsistencyLevel, eventLoopSize, separateComputationPoolSize); } else { ifThrowIllegalArgException(this.eventLoopSize != -1, "eventLoopSize is not applicable in direct mode"); ifThrowIllegalArgException(this.separateComputationPoolSize != -1, "separateComputationPoolSize is not applicable in direct mode"); // fall back to RX wrapper with blocking IO return new RxWrapperDocumentClientImpl( new DocumentClient(serviceEndpoint.toString(), masterKey, connectionPolicy, desiredConsistencyLevel)); } } }
private void configConnectionPolicy(DocumentDBProperties properties, ConnectionPolicy connectionPolicy) { // This is a temp fix as DocumentDbFactory does not support loading ConnectionPolicy bean from context final ConnectionPolicy policy = connectionPolicy == null ? ConnectionPolicy.GetDefault() : connectionPolicy; properties.setConnectionPolicy(policy); } }
public static DocumentDBConfigBuilder builder(String uri, String key, String database) { return defaultBuilder() .uri(uri) .key(key) .database(database) .connectionPolicy(ConnectionPolicy.GetDefault()) .consistencyLevel(ConsistencyLevel.Session); }