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


Java CloudTable.execute方法代码示例

本文整理汇总了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()));
    }
}
 
开发者ID:Azure-Samples,项目名称:storage-table-java-getting-started,代码行数:28,代码来源:TableBasics.java

示例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()));
    }
}
 
开发者ID:Azure-Samples,项目名称:storage-table-java-getting-started,代码行数:21,代码来源:TableBasics.java

示例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());
    }
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:37,代码来源:MaximumExecutionTimeTests.java

示例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);
}
 
开发者ID:Talend,项目名称:components,代码行数:7,代码来源:AzureStorageTableService.java

示例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);
}
 
开发者ID:Talend,项目名称:components,代码行数:7,代码来源:AzureStorageTableService.java

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


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