本文整理汇总了Java中com.microsoft.azure.documentdb.ConnectionPolicy类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionPolicy类的具体用法?Java ConnectionPolicy怎么用?Java ConnectionPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionPolicy类属于com.microsoft.azure.documentdb包,在下文中一共展示了ConnectionPolicy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Before
public void setUp() throws DocumentClientException {
asyncClient = new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session)
.build();
// Clean up before setting up
this.cleanUpGeneratedDatabases();
databaseDefinition = new Database();
databaseDefinition.setId(DATABASE_ID);
collectionDefinition = new DocumentCollection();
collectionDefinition.setId(UUID.randomUUID().toString());
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:20,代码来源:DatabaseAndCollectionCreationAsyncAPITest.java
示例2: beforeClass
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT)
public void beforeClass() {
// set up the client
client = new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session).build();
Database databaseDefinition = new Database();
databaseDefinition.setId(DATABASE_ID);
try {
client.deleteDatabase(Utils.getDatabaseLink(databaseDefinition, true), null).toBlocking().single();
} catch (Exception e) {
// ignore failure if it doesn't exist
}
database = client.createDatabase(databaseDefinition, null).toBlocking().single().getResource();
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:22,代码来源:CollectionCrudTest.java
示例3: beforeClass
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT)
public void beforeClass() {
// set up the client
client = new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session)
.build();
registerSpyProxy();
Database databaseDefinition = new Database();
databaseDefinition.setId(DATABASE_ID);
try {
client.deleteDatabase(Utils.getDatabaseLink(databaseDefinition, true), null).toBlocking().single();
} catch (Exception e) {
// ignore failure if it doesn't exist
}
database = client.createDatabase(databaseDefinition, null).toBlocking().single().getResource();
collection = client.createCollection(database.getSelfLink(), getCollectionDefinition(), null).toBlocking().single().getResource();
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:24,代码来源:RetryCreateDocumentTest.java
示例4: createDocument
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Test(groups = { "simple" }, timeOut = TIMEOUT)
public void createDocument() throws Exception {
AsyncDocumentClient newClient = new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session)
.withWorkers(2, 1)
.build();
try {
Document docDefinition = getDocumentDefinition();
Observable<ResourceResponse<Document>> createObservable = newClient
.createDocument(collection.getSelfLink(), docDefinition, null, false);
ResourceResponseValidator<Document> validator = new ResourceResponseValidator.Builder<Document>()
.withId(docDefinition.getId())
.build();
validateSuccess(createObservable, validator);
} finally {
newClient.close();
}
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:27,代码来源:EventLoopSizeTest.java
示例5: beforeClass
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT)
public void beforeClass() {
// set up the client
client = new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session)
.build();
Database databaseDefinition = new Database();
databaseDefinition.setId(DATABASE_ID);
try {
client.deleteDatabase(Utils.getDatabaseLink(databaseDefinition, true), null).toBlocking().single();
} catch (Exception e) {
// ignore failure if it doesn't exist
}
database = client.createDatabase(databaseDefinition, null).toBlocking().single().getResource();
collection = client.createCollection(database.getSelfLink(), getCollectionDefinition(), null).toBlocking().single().getResource();
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:23,代码来源:EventLoopSizeTest.java
示例6: setup
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Before
public void setup() {
mappingContext = new DocumentDbMappingContext();
try {
mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext)
.scan(Persistent.class));
} catch (ClassNotFoundException e) {
throw new RuntimeException(e.getMessage());
}
dbConverter = new MappingDocumentDbConverter(mappingContext);
documentClient = new DocumentClient(documentDbUri, documentDbKey,
ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
dbTemplate = new DocumentDbTemplate(documentClient, dbConverter, TEST_DB_NAME);
dbTemplate.createCollectionIfNotExists(Person.class.getSimpleName(), null, null);
dbTemplate.insert(Person.class.getSimpleName(), TEST_PERSON, null);
}
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:20,代码来源:DocumentDbTemplateIT.java
示例7: createDocumentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
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());
}
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:17,代码来源:DocumentDBAutoConfiguration.java
示例8: canSetAllowTelemetryFalse
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Test
public void canSetAllowTelemetryFalse() {
PropertySettingUtil.setAllowTelemetryFalse();
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(DocumentDBAutoConfiguration.class, ConnectionPolicyConfig.class);
context.refresh();
final DocumentClient documentClient = context.getBean(DocumentClient.class);
final ConnectionPolicy connectionPolicy = documentClient.getConnectionPolicy();
assertThat(connectionPolicy.getUserAgentSuffix()).contains(PropertySettingUtil.USER_AGENT_SUFFIX);
assertThat(connectionPolicy.getUserAgentSuffix()).contains(
PropertySettingUtil.DEFAULT_USER_AGENT_SUFFIX);
}
PropertySettingUtil.unsetAllowTelemetry();
}
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:17,代码来源:DocumentDBAutoConfigurationTest.java
示例9: DocumentDBRecordWriter
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
public DocumentDBRecordWriter(Configuration conf, String host, String key, String dbName, String[] collNames,
int outputStringPrecision, boolean upsert, String offerType) throws IOException {
try {
ConnectionPolicy policy = ConnectionPolicy.GetDefault();
policy.setUserAgentSuffix(DocumentDBConnectorUtil.UserAgentSuffix);
DocumentClient client = new DocumentClient(host, key, policy,
ConsistencyLevel.Session);
Database db = DocumentDBConnectorUtil.GetDatabase(client, dbName);
this.collections = new DocumentCollection[collNames.length];
this.sprocs = new StoredProcedure[collNames.length];
for (int i = 0; i < collNames.length; i++) {
this.collections[i] = DocumentDBConnectorUtil.getOrCreateOutputCollection(client, db.getSelfLink(), collNames[i],
outputStringPrecision, offerType);
this.sprocs[i] = DocumentDBConnectorUtil.CreateBulkImportStoredProcedure(client, this.collections[i].getSelfLink());
}
this.client = client;
this.enableUpsert = upsert;
this.cachedDocs = new LinkedList<Document>();
} catch (Exception e) {
e.printStackTrace();
throw new IOException(e);
}
}
开发者ID:Azure,项目名称:azure-documentdb-hadoop,代码行数:26,代码来源:DocumentDBRecordWriter.java
示例10: setUp
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Before
public void setUp() throws DocumentClientException {
// sets up the requirements for each test
asyncClient = new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session)
.build();
// Clean up the database.
this.cleanUpGeneratedDatabases();
Database databaseDefinition = new Database();
databaseDefinition.setId(DATABASE_ID);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(UUID.randomUUID().toString());
// create database
ResourceResponse<Database> databaseCreationResponse = asyncClient.createDatabase(databaseDefinition, null)
.toBlocking().single();
// create collection
createdCollection = asyncClient
.createCollection(databaseCreationResponse.getResource().getSelfLink(), collectionDefinition, null)
.toBlocking().single().getResource();
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:30,代码来源:DocumentCRUDAsyncAPITest.java
示例11: setUp
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Before
public void setUp() throws DocumentClientException {
asyncClient = new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session)
.build();
// Clean up the database.
this.cleanUpGeneratedDatabases();
Database databaseDefinition = new Database();
databaseDefinition.setId(DATABASE_ID);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(UUID.randomUUID().toString());
// create database
ResourceResponse<Database> databaseCreationResponse = asyncClient.createDatabase(databaseDefinition, null)
.toBlocking().single();
createdDatabase = databaseCreationResponse.getResource();
// create collection
createdCollection = asyncClient
.createCollection(databaseCreationResponse.getResource().getSelfLink(), collectionDefinition, null)
.toBlocking().single().getResource();
numberOfDocuments = 20;
// add documents
for (int i = 0; i < numberOfDocuments; i++) {
Document doc = new Document(String.format("{ 'id': 'loc%d', 'counter': %d}", i, i));
asyncClient.createDocument(createdCollection.getSelfLink(), doc, null, true).toBlocking().single();
}
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:38,代码来源:DocumentQueryAsyncAPITest.java
示例12: RxGatewayStoreModel
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
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;
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:31,代码来源:RxGatewayStoreModel.java
示例13: createGatewayRxDocumentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
static protected AsyncDocumentClient.Builder createGatewayRxDocumentClient() {
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
connectionPolicy.setConnectionMode(ConnectionMode.Gateway);
return new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(connectionPolicy)
.withConsistencyLevel(ConsistencyLevel.Session);
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:10,代码来源:TestSuiteBase.java
示例14: createDirectHttpsRxDocumentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
static protected AsyncDocumentClient.Builder createDirectHttpsRxDocumentClient() {
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
connectionPolicy.setConnectionMode(ConnectionMode.DirectHttps);
return new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(connectionPolicy)
.withConsistencyLevel(ConsistencyLevel.Session);
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:10,代码来源:TestSuiteBase.java
示例15: createRxWrapperDocumentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
static protected AsyncDocumentClient.Builder createRxWrapperDocumentClient() {
return new AsyncDocumentClient.Builder() {
/* (non-Javadoc)
* @see com.microsoft.azure.documentdb.rx.AsyncDocumentClient.Builder#build()
*/
@Override
public AsyncDocumentClient build() {
return new RxWrapperDocumentClientImpl(new DocumentClient(TestConfigurations.HOST,
TestConfigurations.MASTER_KEY, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session));
}
};
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:14,代码来源:TestSuiteBase.java
示例16: invalidBuilder
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Test(groups = { "simple" }, timeOut = TIMEOUT, expectedExceptions = { IllegalArgumentException.class })
public void invalidBuilder() throws Exception {
ConnectionPolicy cp = new ConnectionPolicy();
cp.setConnectionMode(ConnectionMode.DirectHttps);
new AsyncDocumentClient.Builder()
.withServiceEndpoint(TestConfigurations.HOST)
.withMasterKey(TestConfigurations.MASTER_KEY)
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Session)
.withWorkers(2, 1)
.withConnectionPolicy(cp).build();
}
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:14,代码来源:EventLoopSizeTest.java
示例17: DocumentDbFactory
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
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);
}
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:15,代码来源:DocumentDbFactory.java
示例18: DocumentDBAutoConfiguration
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
public DocumentDBAutoConfiguration(DocumentDBProperties properties,
ObjectProvider<ConnectionPolicy> connectionPolicyObjectProvider,
ApplicationContext applicationContext) {
this.properties = properties;
this.connectionPolicy = connectionPolicyObjectProvider.getIfAvailable();
this.applicationContext = applicationContext;
}
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:8,代码来源:DocumentDBAutoConfiguration.java
示例19: canSetAllPropertiesToDocumentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Test
public void canSetAllPropertiesToDocumentClient() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(DocumentDBAutoConfiguration.class);
context.refresh();
final DocumentClient documentClient = context.getBean(DocumentClient.class);
// No way to verify the setting of key value and ConsistencyLevel.
final URI uri = documentClient.getServiceEndpoint();
assertThat(uri.toString()).isEqualTo(PropertySettingUtil.URI);
assertThat(documentClient.getConnectionPolicy()).isEqualTo(ConnectionPolicy.GetDefault());
}
}
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:15,代码来源:DocumentDBAutoConfigurationTest.java
示例20: canSetConnectionPolicyToDocumentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入依赖的package包/类
@Test
public void canSetConnectionPolicyToDocumentClient() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(DocumentDBAutoConfiguration.class, ConnectionPolicyConfig.class);
context.refresh();
final DocumentClient documentClient = context.getBean(DocumentClient.class);
final ConnectionPolicy connectionPolicy = documentClient.getConnectionPolicy();
assertThat(connectionPolicy.getRequestTimeout()).isEqualTo(PropertySettingUtil.REQUEST_TIMEOUT);
assertThat(connectionPolicy.getMediaRequestTimeout()).
isEqualTo(PropertySettingUtil.MEDIA_REQUEST_TIMEOUT);
assertThat(connectionPolicy.getConnectionMode()).isEqualTo(PropertySettingUtil.CONNECTION_MODE);
assertThat(connectionPolicy.getMediaReadMode()).isEqualTo(PropertySettingUtil.MEDIA_READ_MODE);
assertThat(connectionPolicy.getMaxPoolSize()).isEqualTo(PropertySettingUtil.MAX_POOL_SIZE);
assertThat(connectionPolicy.getIdleConnectionTimeout()).
isEqualTo(PropertySettingUtil.IDLE_CONNECTION_TIMEOUT);
assertThat(connectionPolicy.getUserAgentSuffix()).contains(PropertySettingUtil.USER_AGENT_SUFFIX);
assertThat(connectionPolicy.getUserAgentSuffix()).contains(PropertySettingUtil.DEFAULT_USER_AGENT_SUFFIX);
assertThat(connectionPolicy.getRetryOptions().getMaxRetryAttemptsOnThrottledRequests()).
isEqualTo(PropertySettingUtil.RETRY_OPTIONS_MAX_RETRY_ATTEMPTS_ON_THROTTLED_REQUESTS);
assertThat(connectionPolicy.getRetryOptions().getMaxRetryWaitTimeInSeconds()).
isEqualTo(PropertySettingUtil.RETRY_OPTIONS_MAX_RETRY_WAIT_TIME_IN_SECONDS);
assertThat(connectionPolicy.getEnableEndpointDiscovery()).
isEqualTo(PropertySettingUtil.ENABLE_ENDPOINT_DISCOVERY);
assertThat(connectionPolicy.getPreferredLocations().toString()).
isEqualTo(PropertySettingUtil.PREFERRED_LOCATIONS.toString());
}
}
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:29,代码来源:DocumentDBAutoConfigurationTest.java
注:本文中的com.microsoft.azure.documentdb.ConnectionPolicy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论