Java Code Examples for com.microsoft.azure.storage.table.TableOperation#insert()
The following examples show how to use
com.microsoft.azure.storage.table.TableOperation#insert() .
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 |
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 2
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 3
Source File: TableUtils.java From samza with Apache License 2.0 | 5 votes |
/** * Add a row which denotes an active processor to the processor table. * @param jmVersion Job model version that the processor is operating on. * @param pid Unique processor ID. * @param isLeader Denotes whether the processor is a leader or not. * @throws AzureException If an Azure storage service error occurred. */ public void addProcessorEntity(String jmVersion, String pid, boolean isLeader) { ProcessorEntity entity = new ProcessorEntity(jmVersion, pid); entity.setIsLeader(isLeader); entity.updateLiveness(); TableOperation add = TableOperation.insert(entity); try { table.execute(add); } catch (StorageException e) { LOG.error("Azure storage exception while adding processor entity with job model version: " + jmVersion + "and pid: " + pid, e); throw new AzureException(e); } }
Example 4
Source File: AzureStorageTableWriter.java From components with Apache License 2.0 | 5 votes |
private TableOperation getTableOperation(DynamicTableEntity entity) { TableOperation tableOpe = null; switch (actionData) { case Insert: tableOpe = TableOperation.insert(entity); break; case Insert_Or_Merge: tableOpe = TableOperation.insertOrMerge(entity); break; case Insert_Or_Replace: tableOpe = TableOperation.insertOrReplace(entity); break; case Merge: tableOpe = TableOperation.merge(entity); break; case Replace: tableOpe = TableOperation.replace(entity); break; case Delete: tableOpe = TableOperation.delete(entity); break; default: LOGGER.error("No specified operation for table"); } return tableOpe; }
Example 5
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()); } }