use of org.apache.samza.AzureException in project samza by apache.
the class BlobUtils method getBarrierState.
/**
* Reads the current barrier state from the blob.
* @return Barrier state published on the blob.
* @throws AzureException If an Azure storage service error occurred.
* @throws SamzaException If data retrieved from blob could not be parsed by SamzaObjectMapper.
*/
public String getBarrierState() {
LOG.info("Reading the barrier state from blob.");
byte[] data = new byte[(int) BARRIER_STATE_BLOCK_SIZE];
try {
blob.downloadRangeToByteArray(JOB_MODEL_BLOCK_SIZE, BARRIER_STATE_BLOCK_SIZE, data, 0);
} catch (StorageException e) {
LOG.error("Failed to read barrier state from blob.", e);
throw new AzureException(e);
}
try {
return SamzaObjectMapper.getObjectMapper().readValue(data, String.class);
} catch (IOException e) {
LOG.error("Failed to parse byte data: " + Arrays.toString(data) + " for barrier state retrieved from the blob.", e);
throw new SamzaException(e);
}
}
use of org.apache.samza.AzureException in project samza by apache.
the class TableUtils method deleteProcessorEntity.
/**
* Deletes a specified row in the processor table.
*
* Note: Table service uses optimistic locking by default. Hence, if there is an update after retrieving the entity,
* then the delete operation will fail.
*
* @param jmVersion Job model version of the processor row to be deleted.
* @param pid Unique processor ID of the processor row to be deleted.
* @param force True, to disable optimistic locking on the table. False, otherwise. Setting to false may result in
* AzureException when there is concurrent access to the table.
*
* @throws AzureException If an Azure storage service error occurred.
*/
public void deleteProcessorEntity(String jmVersion, String pid, boolean force) {
try {
TableOperation retrieveEntity = TableOperation.retrieve(jmVersion, pid, ProcessorEntity.class);
ProcessorEntity entity = table.execute(retrieveEntity).getResultAsType();
if (force) {
entity.setEtag("*");
}
TableOperation remove = TableOperation.delete(entity);
table.execute(remove);
} catch (StorageException e) {
LOG.error("Azure storage exception while deleting processor entity with job model version: " + jmVersion + "and pid: " + pid, e);
throw new AzureException(e);
}
}
Aggregations