本文整理汇总了Java中com.microsoft.azure.storage.table.CloudTable.execute方法的典型用法代码示例。如果您正苦于以下问题:Java CloudTable.execute方法的具体用法?Java CloudTable.execute怎么用?Java CloudTable.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.storage.table.CloudTable
的用法示例。
在下文中一共展示了CloudTable.execute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: partitionRangeQuery
import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
/**
* Demonstrate a partition range query whereby we are searching within a partition for a set of entities that are within a specific range.
*
* @param table The {@link CloudTable} object
* @param partitionKey The partition within which to search
* @param startRowKey The lowest bound of the row key range within which to search
* @param endRowKey The highest bound of the row key range within which to search
*
* @throws StorageException
*/
private static void partitionRangeQuery(CloudTable table, String partitionKey, String startRowKey, String endRowKey) throws StorageException {
// Create the range scan query
TableQuery<CustomerEntity> rangeQuery = TableQuery.from(CustomerEntity.class).where(
TableQuery.combineFilters(
TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.EQUAL, partitionKey),
TableQuery.Operators.AND,
TableQuery.combineFilters(
TableQuery.generateFilterCondition("RowKey", QueryComparisons.GREATER_THAN_OR_EQUAL, startRowKey),
TableQuery.Operators.AND,
TableQuery.generateFilterCondition("RowKey", QueryComparisons.LESS_THAN_OR_EQUAL, endRowKey))));
// Iterate through the results
for (CustomerEntity entity : table.execute(rangeQuery)) {
System.out.println(String.format("\tCustomer: %s,%s\t%s\t%s\t%s", entity.getPartitionKey(), entity.getRowKey(), entity.getEmail(), entity.getHomePhoneNumber(), entity.getWorkPhoneNumber()));
}
}
示例2: partitionScan
import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
/**
* Demonstrate a partition scan whereby we are searching for all the entities within a partition.
* Note this is not as efficient as a range scan - but definitely more efficient than a full table scan.
*
* @param table The {@link CloudTable} object
* @param partitionKey The partition within which to search
*
* @throws StorageException
*/
private static void partitionScan(CloudTable table, String partitionKey) throws StorageException {
// Create the partition scan query
TableQuery<CustomerEntity> partitionScanQuery = TableQuery.from(CustomerEntity.class).where(
(TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.EQUAL, partitionKey)));
// Iterate through the results
for (CustomerEntity entity : table.execute(partitionScanQuery)) {
System.out.println(String.format("\tCustomer: %s,%s\t%s\t%s\t%s", entity.getPartitionKey(), entity.getRowKey(), entity.getEmail(), entity.getHomePhoneNumber(), entity.getWorkPhoneNumber()));
}
}
示例3: testTableMaximumExecutionTime
import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
@Test
@Category({ DevFabricTests.class, DevStoreTests.class, SecondaryTests.class })
public void testTableMaximumExecutionTime() throws URISyntaxException, StorageException {
OperationContext opContext = new OperationContext();
setDelay(opContext, 2500);
opContext.getResponseReceivedEventHandler().addListener(new StorageEvent<ResponseReceivedEvent>() {
@Override
public void eventOccurred(ResponseReceivedEvent eventArg) {
// Set status code to 500 to force a retry
eventArg.getRequestResult().setStatusCode(500);
}
});
// set the maximum execution time
TableRequestOptions options = new TableRequestOptions();
options.setMaximumExecutionTimeInMs(2000);
options.setTimeoutIntervalInMs(1000);
CloudTableClient tableClient = TestHelper.createCloudTableClient();
CloudTable table = tableClient.getTableReference(generateRandomName("share"));
try {
// 1. insert entity will fail as the table does not exist
// 2. the executor will attempt to retry as we set the status code to 500
// 3. maximum execution time should prevent the retry from being made
DynamicTableEntity ent = new DynamicTableEntity("partition", "row");
TableOperation insert = TableOperation.insert(ent);
table.execute(insert, options, opContext);
fail("Maximum execution time was reached but request did not fail.");
}
catch (StorageException e) {
assertEquals(SR.MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION, e.getMessage());
}
}
示例4: processTable
import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
@RequestMapping(value = "/table", method = RequestMethod.GET)
public String processTable(HttpServletResponse response)
{
LOG.info("TableRestController processTable start...");
StringBuffer result = new StringBuffer();
try
{
result.append("Connecting to storage account..." + CR);
if (account == null)
{
account = factory.createAccountByServiceInstanceName("mystorage");
if (account == null)
{
String message = "CloudStorageAccount object not injected, lookup by name failed.";
LOG.error(message);
throw new RuntimeException(message);
}
}
// Create the table client.
CloudTableClient tableClient = account.createCloudTableClient();
// Create the table if it doesn't exist.
result.append("Creating product table..." + CR);
String tableName = "product";
CloudTable cloudTable = tableClient.getTableReference(tableName);
cloudTable.createIfNotExists();
ProductEntity product = new ProductEntity(ProductType.SOFTWARE, "pcf", "Pivotal Cloud Foundry");
result.append("Storing new product in table..." + CR);
TableOperation insert = TableOperation.insertOrReplace(product);
cloudTable.execute(insert);
result.append("Retrieving product from table..." + CR);
TableOperation retrieve = TableOperation.retrieve(ProductType.SOFTWARE.toString(), "pcf", ProductEntity.class);
ProductEntity specificEntity = cloudTable.execute(retrieve).getResultAsType();
result.append("Product = " + specificEntity + CR);
} catch (Exception e)
{
LOG.error("Error processing request ", e);
}
result.append("Processed Date = " + new Date(System.currentTimeMillis()) + CR);
LOG.info("TableRestController processTable end");
return result.toString();
}
开发者ID:pivotal-partner-solution-architecture,项目名称:azure-service-broker-client,代码行数:53,代码来源:TableRestController.java
示例5: executeQuery
import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
public Iterable<DynamicTableEntity> executeQuery(String tableName, TableQuery<DynamicTableEntity> partitionQuery)
throws InvalidKeyException, URISyntaxException, StorageException {
CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName);
return cloudTable.execute(partitionQuery);
}
示例6: executeOperation
import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
public TableResult executeOperation(String tableName, TableOperation ope)
throws InvalidKeyException, URISyntaxException, StorageException {
CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName);
return cloudTable.execute(ope);
}
示例7: main
import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
public static void main(String[] args) throws URISyntaxException,
StorageException, InvalidKeyException, NoSuchAlgorithmException {
Utility.printSampleStartInfo("TableResolverAttributes");
// Retrieve storage account information from connection string
// How to create a storage connection string -
// https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
CloudStorageAccount storageAccount = CloudStorageAccount
.parse(Utility.storageConnectionString);
CloudTableClient client = storageAccount.createCloudTableClient();
CloudTable table = client.getTableReference("encryptiontableattributes"
+ UUID.randomUUID().toString().replace("-", ""));
try {
table.createIfNotExists();
// Create the IKey used for encryption.
RsaKey key = new RsaKey("private:key1");
EncryptedEntity ent = new EncryptedEntity(UUID.randomUUID()
.toString(), String.valueOf(new Date().getTime()));
ent.Populate();
TableRequestOptions insertOptions = new TableRequestOptions();
insertOptions.setEncryptionPolicy(new TableEncryptionPolicy(key,
null));
// Insert Entity
System.out.println("Inserting the encrypted entity.");
table.execute(TableOperation.insert(ent), insertOptions, null);
// For retrieves, a resolver can be set up that will help pick the
// key based on the key id.
LocalResolver resolver = new LocalResolver();
resolver.add(key);
TableRequestOptions retrieveOptions = new TableRequestOptions();
retrieveOptions.setEncryptionPolicy(new TableEncryptionPolicy(null,
resolver));
// Retrieve Entity
System.out.println("Retrieving the encrypted entity.");
TableOperation operation = TableOperation.retrieve(
ent.getPartitionKey(), ent.getRowKey(),
EncryptedEntity.class);
TableResult result = table
.execute(operation, retrieveOptions, null);
EncryptedEntity resultEntity = result.getResultAsType();
System.out.println("EncryptedProperty2 = "
+ resultEntity.getEncryptedProperty2());
} finally {
table.deleteIfExists();
Utility.printSampleCompleteInfo("TableResolverAttributes");
}
}