本文整理汇总了Java中com.microsoft.azure.documentdb.DocumentCollection.setId方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentCollection.setId方法的具体用法?Java DocumentCollection.setId怎么用?Java DocumentCollection.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.documentdb.DocumentCollection
的用法示例。
在下文中一共展示了DocumentCollection.setId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的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: createMultiPartitionCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
private DocumentCollection createMultiPartitionCollection(String databaseLink, String collectionId,
String partitionKeyPath) throws DocumentClientException {
PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition();
ArrayList<String> paths = new ArrayList<String>();
paths.add(partitionKeyPath);
partitionKeyDef.setPaths(paths);
RequestOptions options = new RequestOptions();
options.setOfferThroughput(10100);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
collectionDefinition.setPartitionKey(partitionKeyDef);
DocumentCollection createdCollection = asyncClient
.createCollection(databaseLink, collectionDefinition, options).toBlocking().single().getResource();
return createdCollection;
}
示例3: setup
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
public void setup(DocumentClient client) throws Exception {
logger.debug("setting up ...");
cleanUpDatabase(client);
Thread.sleep(5000);
Database d = new Database();
d.setId(databaseId);
Database database = client.createDatabase(d, null).getResource();
PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition();
ArrayList<String> paths = new ArrayList<String>();
paths.add("/mypk");
partitionKeyDef.setPaths(paths);
pCollection = new DocumentCollection();
pCollection.setId(collectionId);
pCollection.setPartitionKey(partitionKeyDef);
RequestOptions options = new RequestOptions();
options.setOfferThroughput(10100);
pCollection = client.createCollection(database.getSelfLink(), pCollection, options).getResource();
logger.debug("setting up done.");
}
示例4: setUp
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的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();
}
示例5: setUp
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的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();
}
}
示例6: getCollectionDefinition
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
static protected DocumentCollection getCollectionDefinition() {
PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition();
ArrayList<String> paths = new ArrayList<String>();
paths.add("/mypk");
partitionKeyDef.setPaths(paths);
RequestOptions options = new RequestOptions();
options.setOfferThroughput(10100);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(UUID.randomUUID().toString());
collectionDefinition.setPartitionKey(partitionKeyDef);
return collectionDefinition;
}
示例7: beforeClass
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
@BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT)
public void beforeClass() {
houseKeepingClient = createRxWrapperDocumentClient().build();
Database d = new Database();
d.setId(DATABASE_ID);
createdDatabase = safeCreateDatabase(client1, d);
DocumentCollection cl = new DocumentCollection();
cl.setId(UUID.randomUUID().toString());
createdCollection = safeCreateCollection(houseKeepingClient, createdDatabase.getSelfLink(), cl);
}
示例8: createDBAndAddCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的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;
}
}
示例9: createDBAndAddCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的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;
}
}
示例10: getTodoCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
private DocumentCollection getTodoCollection() {
if (collectionCache == null) {
// Get the collection if it exists.
List<DocumentCollection> collectionList = documentClient
.queryCollections(
getTodoDatabase().getSelfLink(),
"SELECT * FROM root r WHERE r.id='"
+ properties.getResourceId()
+ "'", null).getQueryIterable().toList();
if (collectionList.size() > 0) {
// Cache the collection object so we won't have to query for it
// later to retrieve the selfLink.
collectionCache = collectionList.get(0);
} else {
// Create the collection if it doesn't exist.
try {
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(properties
.getResourceId());
collectionCache = documentClient.createCollection(
getTodoDatabase().getSelfLink(),
collectionDefinition, null).getResource();
} catch (DocumentClientException e) {
// TODO: Something has gone terribly wrong - the app wasn't
// able to query or create the collection.
// Verify your connection, endpoint, and key.
e.printStackTrace();
}
}
}
return collectionCache;
}
开发者ID:pivotal-partner-solution-architecture,项目名称:azure-service-broker-client,代码行数:38,代码来源:DocDbDao.java
示例11: getTodoCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
private DocumentCollection getTodoCollection() {
if (collectionCache == null) {
// Get the collection if it exists.
List<DocumentCollection> collectionList = documentClient
.queryCollections(
getTodoDatabase().getSelfLink(),
"SELECT * FROM root r WHERE r.id='" + COLLECTION_ID
+ "'", null).getQueryIterable().toList();
if (collectionList.size() > 0) {
// Cache the collection object so we won't have to query for it
// later to retrieve the selfLink.
collectionCache = collectionList.get(0);
} else {
// Create the collection if it doesn't exist.
try {
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(COLLECTION_ID);
collectionCache = documentClient.createCollection(
getTodoDatabase().getSelfLink(),
collectionDefinition, null).getResource();
} catch (DocumentClientException e) {
// TODO: Something has gone terribly wrong - the app wasn't
// able to query or create the collection.
// Verify your connection, endpoint, and key.
e.printStackTrace();
}
}
}
return collectionCache;
}
示例12: createMultiPartitionCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
private void createMultiPartitionCollection() throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
// set /city as the partition key path
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();
Collection<String> paths = new ArrayList<String>();
paths.add(partitionKeyPath);
partitionKeyDefinition.setPaths(paths);
collectionDefinition.setPartitionKey(partitionKeyDefinition);
// set the throughput to be 10,200
RequestOptions options = new RequestOptions();
options.setOfferThroughput(10200);
// set indexing policy to be range range for string and number
IndexingPolicy indexingPolicy = new IndexingPolicy();
Collection<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<Index>();
Index stringIndex = Index.Range(DataType.String);
stringIndex.set("precision", -1);
indexes.add(stringIndex);
Index numberIndex = Index.Range(DataType.Number);
numberIndex.set("precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
// create a collection
client.createCollection(databaseLink, collectionDefinition, options);
}
示例13: createSinglePartitionCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
@Test
public void createSinglePartitionCollection() throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
String collectionId = "testCollection";
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
// create a collection
client.createCollection(databaseLink, collectionDefinition, null);
}
示例14: deleteCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
@Test
public void deleteCollection() throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
String collectionId = "testCollection";
// create collection
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
client.createCollection(databaseLink, collectionDefinition, null);
// delete collection
String collectionLink = String.format("/dbs/%s/colls/%s", databaseId, collectionId);
client.deleteCollection(collectionLink, null);
}
示例15: createMultiPartitionCollection
import com.microsoft.azure.documentdb.DocumentCollection; //导入方法依赖的package包/类
private void createMultiPartitionCollection() throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
// set /city as the partition key path
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();
Collection<String> paths = new ArrayList<String>();
paths.add(partitionKeyPath);
partitionKeyDefinition.setPaths(paths);
collectionDefinition.setPartitionKey(partitionKeyDefinition);
// set the throughput to be 10,200
RequestOptions options = new RequestOptions();
options.setOfferThroughput(10200);
// set indexing policy to be range range for string and number
IndexingPolicy indexingPolicy = new IndexingPolicy();
Collection<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<Index>();
Index stringIndex = Index.Range(DataType.String);
stringIndex.set("precision", -1);
indexes.add(stringIndex);
Index numberIndex = Index.Range(DataType.Number);
numberIndex.set("precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
// create a collection
this.collection = client.createCollection(databaseLink, collectionDefinition, options).getResource();
}