Java Code Examples for com.microsoft.azure.storage.table.TableOperation#replace()

The following examples show how to use com.microsoft.azure.storage.table.TableOperation#replace() . 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: TableUtils.java    From samza with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the liveness value of a particular processor with a randomly generated integer, which in turn updates the last modified since timestamp of the row.
 * @param jmVersion Job model version of the processor row to be updated.
 * @param pid Unique processor ID of the processor row to be updated.
 */
public void updateHeartbeat(String jmVersion, String pid) {
  try {
    TableOperation retrieveEntity = TableOperation.retrieve(jmVersion, pid, ProcessorEntity.class);
    ProcessorEntity entity = table.execute(retrieveEntity).getResultAsType();
    entity.updateLiveness();
    TableOperation update = TableOperation.replace(entity);
    table.execute(update);
  } catch (StorageException e) {
    LOG.error("Azure storage exception while updating heartbeat for job model version: " + jmVersion + "and pid: " + pid, e);
  }
}
 
Example 2
Source File: TableUtils.java    From samza with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the isLeader value when the processor starts or stops being a leader.
 * @param jmVersion Job model version of the processor row to be updated.
 * @param pid Unique processor ID of the processor row to be updated.
 * @param isLeader Denotes whether the processor is a leader or not.
 * @throws AzureException If an Azure storage service error occurred.
 */
public void updateIsLeader(String jmVersion, String pid, boolean isLeader) {
  try {
    TableOperation retrieveEntity = TableOperation.retrieve(jmVersion, pid, ProcessorEntity.class);
    ProcessorEntity entity = table.execute(retrieveEntity).getResultAsType();
    entity.setIsLeader(isLeader);
    TableOperation update = TableOperation.replace(entity);
    table.execute(update);
  } catch (StorageException e) {
    LOG.error("Azure storage exception while updating isLeader value for job model version: " + jmVersion + "and pid: " + pid, e);
    throw new AzureException(e);
  }
}
 
Example 3
Source File: AzureStorageTableWriter.java    From components with Apache License 2.0 5 votes vote down vote up
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;
}