Search in sources :

Example 1 with TableBatchOperation

use of com.microsoft.azure.storage.table.TableBatchOperation in project components by Talend.

the class AzureStorageTableWriter method processBatch.

private void processBatch() throws IOException {
    TableBatchOperation batch = new TableBatchOperation();
    batch.addAll(batchOperations);
    // 
    try {
        tableservice.executeOperation(tableName, batch);
        handleSuccess(null, batchOperationsCount);
    } catch (StorageException e) {
        LOGGER.error(i18nMessages.getMessage("error.ProcessBatch", actionData, e.getLocalizedMessage()));
        handleReject(null, e, batchOperationsCount);
        if (dieOnError) {
            throw new ComponentException(e);
        }
    } catch (URISyntaxException | InvalidKeyException e) {
        // connection problem so next operation will also fail, we stop the process
        throw new ComponentException(e);
    }
    // reset operations, count and marker
    batchOperations.clear();
    batchRecords.clear();
    batchOperationsCount = 0;
    latestPartitionKey = "";
}
Also used : ComponentException(org.talend.components.api.exception.ComponentException) URISyntaxException(java.net.URISyntaxException) InvalidKeyException(java.security.InvalidKeyException) TableBatchOperation(com.microsoft.azure.storage.table.TableBatchOperation) StorageException(com.microsoft.azure.storage.StorageException)

Example 2 with TableBatchOperation

use of com.microsoft.azure.storage.table.TableBatchOperation in project timbuctoo by HuygensING.

the class AzureVreAuthorizationAccess method deleteVreAuthorizations.

@Override
public void deleteVreAuthorizations(String vreId) throws AuthorizationUnavailableException {
    String condition = TableQuery.generateFilterCondition("PartitionKey", TableQuery.QueryComparisons.EQUAL, vreId);
    TableBatchOperation deletes = new TableBatchOperation();
    for (DynamicTableEntity entity : table.execute(TableQuery.from(DynamicTableEntity.class).where(condition))) {
        deletes.delete(entity);
    }
    try {
        table.execute(deletes);
    } catch (StorageException e) {
        LOG.error("deleteVreAuthorizations failed", e);
        throw new AuthorizationUnavailableException("Could not delete authorizations");
    }
}
Also used : DynamicTableEntity(com.microsoft.azure.storage.table.DynamicTableEntity) TableBatchOperation(com.microsoft.azure.storage.table.TableBatchOperation) StorageException(com.microsoft.azure.storage.StorageException) AuthorizationUnavailableException(nl.knaw.huygens.timbuctoo.v5.security.exceptions.AuthorizationUnavailableException)

Example 3 with TableBatchOperation

use of com.microsoft.azure.storage.table.TableBatchOperation in project stdlib by petergeneric.

the class AzureLogStore method storeAsBatch.

@Retry
public void storeAsBatch(final List<LogLineTableEntity> lines) throws StorageException {
    if (lines.isEmpty())
        // nothing to do!
        return;
    TableBatchOperation operation = new TableBatchOperation();
    for (LogLineTableEntity line : lines) {
        if (log.isTraceEnabled())
            log.trace("Storing entity with partition=" + line.getPartitionKey() + ", row=" + line.getRowKey());
        operation.insertOrReplace(line);
    }
    logdata.execute(operation);
}
Also used : LogLineTableEntity(com.peterphi.servicemanager.service.logging.LogLineTableEntity) TableBatchOperation(com.microsoft.azure.storage.table.TableBatchOperation) Retry(com.peterphi.std.guice.common.retry.annotation.Retry)

Aggregations

TableBatchOperation (com.microsoft.azure.storage.table.TableBatchOperation)3 StorageException (com.microsoft.azure.storage.StorageException)2 DynamicTableEntity (com.microsoft.azure.storage.table.DynamicTableEntity)1 LogLineTableEntity (com.peterphi.servicemanager.service.logging.LogLineTableEntity)1 Retry (com.peterphi.std.guice.common.retry.annotation.Retry)1 URISyntaxException (java.net.URISyntaxException)1 InvalidKeyException (java.security.InvalidKeyException)1 AuthorizationUnavailableException (nl.knaw.huygens.timbuctoo.v5.security.exceptions.AuthorizationUnavailableException)1 ComponentException (org.talend.components.api.exception.ComponentException)1