use of com.microsoft.azure.storage.table.CloudTable in project components by Talend.
the class AzureStorageTableService method handleActionOnTable.
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();
break;
case Create_table_if_does_not_exist:
cloudTable.createIfNotExists();
break;
case Drop_and_create_table:
cloudTable.delete();
createTableAfterDeletion(cloudTable);
break;
case Drop_table_if_exist_and_create:
cloudTable.deleteIfExists();
createTableAfterDeletion(cloudTable);
break;
case Default:
default:
return;
}
}
use of com.microsoft.azure.storage.table.CloudTable in project stdlib by petergeneric.
the class ServiceManagerGuiceModule method getLogDataTable.
/**
* For the Azure Log Store, the underlying table to use
*
* @param storageConnectionString
*
* @return
*
* @throws URISyntaxException
* @throws StorageException
* @throws InvalidKeyException
*/
@Provides
@Named("logdata")
public CloudTable getLogDataTable(@Named("azure.storage-connection-string") String storageConnectionString, @Named("azure.logging-table") String logTableName) throws URISyntaxException, StorageException, InvalidKeyException {
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
// Create the table client.
CloudTableClient tableClient = storageAccount.createCloudTableClient();
// Create the table if it doesn't exist.
CloudTable table = tableClient.getTableReference(logTableName);
table.createIfNotExists();
return table;
}
use of com.microsoft.azure.storage.table.CloudTable in project data-transfer-project by google.
the class AzureTableStore method findJob.
@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);
}
}
use of com.microsoft.azure.storage.table.CloudTable in project data-transfer-project by google.
the class AzureTableStore method create.
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, // job id used as key
serializedJob);
TableOperation insert = TableOperation.insert(wrapper);
table.execute(insert);
} catch (JsonProcessingException | StorageException | URISyntaxException e) {
throw new IOException("Error creating data for rowKey: " + rowKey, e);
}
}
use of com.microsoft.azure.storage.table.CloudTable in project data-transfer-project by google.
the class AzureTableStore method remove.
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);
}
}
Aggregations