本文整理汇总了Java中com.microsoft.azure.documentdb.ConnectionPolicy.GetDefault方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionPolicy.GetDefault方法的具体用法?Java ConnectionPolicy.GetDefault怎么用?Java ConnectionPolicy.GetDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.documentdb.ConnectionPolicy
的用法示例。
在下文中一共展示了ConnectionPolicy.GetDefault方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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());
}
示例3: 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);
}
}
示例4: 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));
}
};
}
示例5: 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);
}
示例6: createDBAndAddCollection
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入方法依赖的package包/类
private static void createDBAndAddCollection(String masterKey, String endPoint) throws DocumentClientException {
try {
DocumentClient documentClient = new DocumentClient(endPoint,
masterKey, ConnectionPolicy.GetDefault(),
ConsistencyLevel.Session);
// Define a new database using the id above.
Database myDatabase = new Database();
myDatabase.setId(DATABASE_ID);
myDatabase = documentClient.createDatabase(myDatabase, null)
.getResource();
System.out.println("Created a new database:");
System.out.println(myDatabase.toString());
// Define a new collection using the id above.
DocumentCollection myCollection = new DocumentCollection();
myCollection.setId(COLLECTION_ID);
// Set the provisioned throughput for this collection to be 1000 RUs.
RequestOptions requestOptions = new RequestOptions();
requestOptions.setOfferThroughput(4000);
// Create a new collection.
myCollection = documentClient.createCollection(
"dbs/" + DATABASE_ID, myCollection, requestOptions)
.getResource();
} catch (Exception ex) {
throw ex;
}
}
示例7: createDBAndAddCollection
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入方法依赖的package包/类
private static void createDBAndAddCollection(String masterKey, String endPoint) throws DocumentClientException {
try {
DocumentClient documentClient = new DocumentClient(endPoint,
masterKey, ConnectionPolicy.GetDefault(),
ConsistencyLevel.Session);
// Define a new database using the id above.
Database myDatabase = new Database();
myDatabase.setId(DATABASE_ID);
myDatabase = documentClient.createDatabase(myDatabase, null)
.getResource();
System.out.println("Created a new database:");
System.out.println(myDatabase.toString());
// Define a new collection using the id above.
DocumentCollection myCollection = new DocumentCollection();
myCollection.setId(COLLECTION_ID);
// Set the provisioned throughput for this collection to be 1000 RUs.
RequestOptions requestOptions = new RequestOptions();
requestOptions.setOfferThroughput(1000);
// Create a new collection.
myCollection = documentClient.createCollection(
"dbs/" + DATABASE_ID, myCollection, requestOptions)
.getResource();
} catch (Exception ex) {
throw ex;
}
}
示例8: documentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入方法依赖的package包/类
public DocumentClient documentClient() {
return new DocumentClient(uri, key, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
}
示例9: documentClient
import com.microsoft.azure.documentdb.ConnectionPolicy; //导入方法依赖的package包/类
@Override
public DocumentClient documentClient() {
return new DocumentClient(dbUri, dbKey, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
}