/** * Creates the table in the storage service with default request options. * <p> * This method invokes the <a href="http://msdn.microsoft.com/en-us/library/azure/dd135729.aspx">Create Table</a> * REST API to create the specified table, using the Table service endpoint and storage account credentials of this * instance. * * @throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest public void create() throws StorageException { this.create(null /* options */, null /* opContext */); }
public void handleActionOnTable(String tableName, ActionOnTable actionTable) throws IOException, StorageException, InvalidKeyException, URISyntaxException { // FIXME How does this will behave in a distributed runtime ? See where to place correctly this // instruction... CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName); switch (actionTable) { case Create_table: cloudTable.create(null, AzureStorageUtils.getTalendOperationContext()); break; case Create_table_if_does_not_exist: cloudTable.createIfNotExists(null, AzureStorageUtils.getTalendOperationContext()); break; case Drop_and_create_table: cloudTable.delete(null, AzureStorageUtils.getTalendOperationContext()); createTableAfterDeletion(cloudTable); break; case Drop_table_if_exist_and_create: cloudTable.deleteIfExists(null, AzureStorageUtils.getTalendOperationContext()); createTableAfterDeletion(cloudTable); break; case Default: default: return; } }
public void handleActionOnTable(String tableName, ActionOnTable actionTable) throws IOException, StorageException, InvalidKeyException, URISyntaxException { // FIXME How does this will behave in a distributed runtime ? See where to place correctly this // instruction... CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName); switch (actionTable) { case Create_table: cloudTable.create(null, AzureStorageUtils.getTalendOperationContext()); break; case Create_table_if_does_not_exist: cloudTable.createIfNotExists(null, AzureStorageUtils.getTalendOperationContext()); break; case Drop_and_create_table: cloudTable.delete(null, AzureStorageUtils.getTalendOperationContext()); createTableAfterDeletion(cloudTable); break; case Drop_table_if_exist_and_create: cloudTable.deleteIfExists(null, AzureStorageUtils.getTalendOperationContext()); createTableAfterDeletion(cloudTable); break; case Default: default: return; } }
/** * Creates the table in the storage service with default request options. * <p> * This method invokes the <a href="http://msdn.microsoft.com/en-us/library/azure/dd135729.aspx">Create Table</a> * REST API to create the specified table, using the Table service endpoint and storage account credentials of this * instance. * * @throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest public void create() throws StorageException { this.create(null /* options */, null /* opContext */); }
cloudTable.create(null, AzureStorageUtils.getTalendOperationContext()); } catch (TableServiceException e) { if (!e.getErrorCode().equals(StorageErrorCodeStrings.TABLE_BEING_DELETED)) { throw new IOException("Wait process for recreating table interrupted."); cloudTable.create(null, AzureStorageUtils.getTalendOperationContext()); LOGGER.debug("Table {} created.", cloudTable.getName());
cloudTable.create(null, AzureStorageUtils.getTalendOperationContext()); } catch (TableServiceException e) { if (!e.getErrorCode().equals(StorageErrorCodeStrings.TABLE_BEING_DELETED)) { throw new IOException("Wait process for recreating table interrupted."); cloudTable.create(null, AzureStorageUtils.getTalendOperationContext()); LOGGER.debug("Table {} created.", cloudTable.getName());
this.create(options, opContext); return true;
this.create(options, opContext); return true;
String name = String.format("%s%s", tableBaseName, new DecimalFormat("#0000").format(m)); CloudTable table = tClient.getTableReference(name); table.create(); tables.add(name);
String name = String.format("%s%s", tableBaseName, new DecimalFormat("#0000").format(m)); CloudTable table = tClient.getTableReference(name); table.create(); tables.add(name);
String name = String.format("%s%s", tableBaseName, new DecimalFormat("#0000").format(m)); CloudTable table = tClient.getTableReference(name); table.create(); tables.add(name);
@Test public void testTableCreateAndAttemptCreateOnceExists() throws StorageException, URISyntaxException { CloudTableClient tClient = TableTestHelper.createCloudTableClient(); String tableName = TableTestHelper.generateRandomTableName(); CloudTable table = tClient.getTableReference(tableName); tClient.getDefaultRequestOptions().setTablePayloadFormat(TablePayloadFormat.Json); try { table.create(); assertTrue(table.exists()); // Should fail as it already exists try { table.create(); fail(); } catch (StorageException ex) { assertEquals(ex.getErrorCode(), "TableAlreadyExists"); } } finally { // cleanup table.deleteIfExists(); } }
@Test public void testTableDeleteIfExists() throws StorageException, URISyntaxException { CloudTableClient tClient = TableTestHelper.createCloudTableClient(); String tableName = TableTestHelper.generateRandomTableName(); CloudTable table = tClient.getTableReference(tableName); assertFalse(table.deleteIfExists()); table.create(); assertTrue(table.exists()); assertTrue(table.deleteIfExists()); assertFalse(table.deleteIfExists()); }
@Test public void testCloudTableDeleteIfExistsErrorCode() throws StorageException, URISyntaxException { final CloudTable table = TableTestHelper.getRandomTableReference(); try { assertFalse(table.deleteIfExists()); OperationContext ctx = new OperationContext(); ctx.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() { @Override public void eventOccurred(SendingRequestEvent eventArg) { if (((HttpURLConnection) eventArg.getConnectionObject()).getRequestMethod().equals("DELETE")) { try { table.delete(); assertFalse(table.exists()); } catch (StorageException e) { fail("Delete should succeed."); } } } }); table.create(); // The second delete of a table will return a 404 assertFalse(table.deleteIfExists(null, ctx)); } finally { table.deleteIfExists(); } }
CloudTable table = TableTestHelper.getRandomTableReference(); try { table.create();
@Test public void testTableDeleteWhenExistAndNotExists() throws StorageException, URISyntaxException { CloudTableClient tClient = TableTestHelper.createCloudTableClient(); String tableName = TableTestHelper.generateRandomTableName(); CloudTable table = tClient.getTableReference(tableName); try { // Should fail as it doesnt already exists try { table.delete(); fail(); } catch (StorageException ex) { assertEquals(ex.getMessage(), "Not Found"); } table.create(); assertTrue(table.exists()); table.delete(); assertFalse(table.exists()); } finally { table.deleteIfExists(); } }
CloudTable table = TableTestHelper.getRandomTableReference(); try { table.create();
CloudTable table = TableTestHelper.getRandomTableReference(); try { table.create();