当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionPolicy.GetDefault方法代码示例

本文整理汇总了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);
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:20,代码来源:DocumentDbTemplateIT.java

示例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());
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:17,代码来源:DocumentDBAutoConfiguration.java

示例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);
    }
}
 
开发者ID:Azure,项目名称:azure-documentdb-hadoop,代码行数:26,代码来源:DocumentDBRecordWriter.java

示例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));
            }
        };
    }
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:14,代码来源:TestSuiteBase.java

示例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);
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:15,代码来源:DocumentDbFactory.java

示例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;
    }
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:33,代码来源:ManageHACosmosDB.java

示例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;
    }
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:33,代码来源:CreateCosmosDBWithEventualConsistency.java

示例8: documentClient

import com.microsoft.azure.documentdb.ConnectionPolicy; //导入方法依赖的package包/类
public DocumentClient documentClient() {
    return new DocumentClient(uri, key, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:4,代码来源:AppConfiguration.java

示例9: documentClient

import com.microsoft.azure.documentdb.ConnectionPolicy; //导入方法依赖的package包/类
@Override
public DocumentClient documentClient() {
    return new DocumentClient(dbUri, dbKey, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:5,代码来源:ContactRepositoryConfig.java


注:本文中的com.microsoft.azure.documentdb.ConnectionPolicy.GetDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。