Java Code Examples for com.microsoft.azure.storage.table.CloudTable#execute()
The following examples show how to use
com.microsoft.azure.storage.table.CloudTable#execute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AzureTableStore.java From data-transfer-project with Apache License 2.0 | 6 votes |
@Override public PortabilityJob findJob(UUID jobId) { Preconditions.checkNotNull(jobId, "Job id is null"); try { CloudTable table = tableClient.getTableReference(JOB_TABLE); TableOperation retrieve = TableOperation.retrieve( configuration.getPartitionKey(), jobId.toString(), DataWrapper.class); TableResult result = table.execute(retrieve); DataWrapper wrapper = result.getResultAsType(); return configuration.getMapper().readValue(wrapper.getSerialized(), PortabilityJob.class); } catch (StorageException | URISyntaxException | IOException e) { throw new MicrosoftStorageException("Error finding job: " + jobId, e); } }
Example 2
Source File: AzureTableStore.java From data-transfer-project with Apache License 2.0 | 6 votes |
private void create(String rowKey, String tableName, String state, Object type) throws IOException { try { CloudTable table = tableClient.getTableReference(tableName); String serializedJob = configuration.getMapper().writeValueAsString(type); DataWrapper wrapper = new DataWrapper( configuration.getPartitionKey(), rowKey, state, serializedJob); // job id used as key TableOperation insert = TableOperation.insert(wrapper); table.execute(insert); } catch (JsonProcessingException | StorageException | URISyntaxException e) { throw new IOException("Error creating data for rowKey: " + rowKey, e); } }
Example 3
Source File: AzureTableStore.java From data-transfer-project with Apache License 2.0 | 6 votes |
private void remove(UUID jobId, String tableName) throws IOException { try { CloudTable table = tableClient.getTableReference(tableName); TableOperation retrieve = TableOperation.retrieve( configuration.getPartitionKey(), jobId.toString(), DataWrapper.class); TableResult result = table.execute(retrieve); DataWrapper wrapper = result.getResultAsType(); TableOperation delete = TableOperation.delete(wrapper); table.execute(delete); } catch (StorageException | URISyntaxException e) { throw new IOException("Error removing data for job: " + jobId, e); } }
Example 4
Source File: AzureTableStore.java From data-transfer-project with Apache License 2.0 | 5 votes |
@Override protected void updateJob(UUID jobId, PortabilityJob job, JobUpdateValidator validator) throws IOException { Preconditions.checkNotNull(jobId, "Job is null"); Preconditions.checkNotNull(job, "Job is null"); try { CloudTable table = tableClient.getTableReference(JOB_TABLE); String serializedJob = configuration.getMapper().writeValueAsString(job); DataWrapper wrapper = new DataWrapper( configuration.getPartitionKey(), jobId.toString(), job.jobAuthorization().state().name(), serializedJob); if (validator != null) { PortabilityJob previousJob = findJob(jobId); if (previousJob == null) { throw new IOException("Could not find record for jobId: " + jobId); } validator.validate(previousJob, job); } TableOperation insert = TableOperation.insertOrReplace(wrapper); table.execute(insert); } catch (JsonProcessingException | StorageException | URISyntaxException e) { throw new IOException("Error updating job: " + jobId, e); } }
Example 5
Source File: AzureTableStore.java From data-transfer-project with Apache License 2.0 | 5 votes |
private <T> T find(Class<T> type, String rowKey, String tableName) { try { CloudTable table = tableClient.getTableReference(tableName); TableOperation retrieve = TableOperation.retrieve(configuration.getPartitionKey(), rowKey, DataWrapper.class); TableResult result = table.execute(retrieve); DataWrapper wrapper = result.getResultAsType(); return configuration.getMapper().readValue(wrapper.getSerialized(), type); } catch (StorageException | IOException | URISyntaxException e) { throw new MicrosoftStorageException("Error finding data for rowKey: " + rowKey, e); } }
Example 6
Source File: AzureStorageClient.java From azure-kusto-java with MIT License | 5 votes |
void azureTableInsertEntity(String tableUri, TableServiceEntity entity) throws StorageException, URISyntaxException { // Ensure Ensure.stringIsNotBlank(tableUri, "tableUri"); Ensure.argIsNotNull(entity, "entity"); CloudTable table = new CloudTable(new URI(tableUri)); // Create an operation to add the new customer to the table basics table. TableOperation insert = TableOperation.insert(entity); // Submit the operation to the table service. table.execute(insert); }
Example 7
Source File: MaximumExecutionTimeTests.java From azure-storage-android with Apache License 2.0 | 5 votes |
@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()); } }
Example 8
Source File: AzureStorageTableService.java From components with Apache License 2.0 | 4 votes |
public Iterable<DynamicTableEntity> executeQuery(String tableName, TableQuery<DynamicTableEntity> partitionQuery) throws InvalidKeyException, URISyntaxException, StorageException { CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName); return cloudTable.execute(partitionQuery, null, AzureStorageUtils.getTalendOperationContext()); }
Example 9
Source File: AzureStorageTableService.java From components with Apache License 2.0 | 4 votes |
public TableResult executeOperation(String tableName, TableOperation ope) throws InvalidKeyException, URISyntaxException, StorageException { CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName); return cloudTable.execute(ope, null, AzureStorageUtils.getTalendOperationContext()); }
Example 10
Source File: AzureStorageTableService.java From components with Apache License 2.0 | 4 votes |
public ArrayList<TableResult> executeOperation(String tableName, TableBatchOperation batchOpe) throws InvalidKeyException, URISyntaxException, StorageException { CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName); return cloudTable.execute(batchOpe, null, AzureStorageUtils.getTalendOperationContext()); }