本文整理汇总了Java中com.microsoft.windowsazure.services.table.client.TableOperation类的典型用法代码示例。如果您正苦于以下问题:Java TableOperation类的具体用法?Java TableOperation怎么用?Java TableOperation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableOperation类属于com.microsoft.windowsazure.services.table.client包,在下文中一共展示了TableOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rawGet
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
private AzureEntity rawGet(Object row, Object column) {
if (!(row instanceof Bytes && column instanceof Bytes)) {
return null;
}
String rowAsString = encode((Bytes) row);
String columnAsString = encode((Bytes) column);
TableOperation retrieveEntityOperation = azureTableRequestFactory.retrieve(rowAsString, columnAsString);
try {
return azureTableCloudClient.execute(tableName, retrieveEntityOperation);
} catch (StorageException e) {
throw Throwables.propagate(e);
}
}
示例2: remove
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Override
public Bytes remove(Object row, Object column) {
AzureEntity entityToBeDeleted = rawGet(row, column);
if (entityToBeDeleted == null) {
return null;
}
TableOperation deleteStringieOperation = azureTableRequestFactory.delete(entityToBeDeleted);
try {
return entityToValue(azureTableCloudClient.execute(tableName, deleteStringieOperation));
} catch (StorageException e) {
if (notFound(e)) {
return null;
}
throw Throwables.propagate(e);
}
}
示例3: getUsedSpace
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
private Size getUsedSpace(int daysOffset) throws StorageException, IOException {
final String partitionKey = getAzureMetricsPartitionKey(daysOffset);
final AzureCapacityEntity capacity;
try {
capacity = capacityCache.get(partitionKey, new Callable<AzureCapacityEntity>() {
@Override
public AzureCapacityEntity call() throws StorageException, IOException {
final TableOperation readCapacityOperation = TableOperation.retrieve(partitionKey, AZURE_METRICS_KEY, AzureCapacityEntity.class);
final AzureCapacityEntity result = tableClient.execute(AZURE_METRICS_TABLE, readCapacityOperation).getResultAsType();
if (result == null) {
throw new IOException("No capacity details for " + partitionKey);
}
return result;
}
});
}
catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof StorageException) {
throw (StorageException) cause;
}
if (cause instanceof IOException) {
throw (IOException) cause;
}
LOG.warn("Failed to fetch azure storage capacity", e);
return Size.bytes(0);
}
return Size.bytes(capacity.getCapacity());
}
示例4: put
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Override
public Bytes put(Bytes row, Bytes column, Bytes value) {
checkNotNull(row);
checkNotNull(column);
checkNotNull(value);
TableOperation putStringieOperation = azureTableRequestFactory.put(encode(row), encode(column), encode(value));
try {
return entityToValue(azureTableCloudClient.execute(tableName, putStringieOperation));
} catch (StorageException e) {
throw Throwables.propagate(e);
}
}
示例5: when_put_then_value_added_or_replaced_in_azure
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Test
public void when_put_then_value_added_or_replaced_in_azure() throws StorageException {
TableOperation putTableOperationMock = mockPutTableOperation(CELL_2);
baseAzureTable.put(ROW_KEY_2, COLUMN_KEY_2, VALUE_2);
verify(azureTableCloudClientMock).execute(TABLE_NAME, putTableOperationMock);
}
示例6: when_table_client_throws_storage_exception_during_put_then_exception_rethrown
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void when_table_client_throws_storage_exception_during_put_then_exception_rethrown() throws StorageException {
TableOperation putTableOperationMock = mockPutTableOperation(CELL_1);
setupThrowStorageExceptionOnTableOperation(putTableOperationMock);
baseAzureTable.put(ROW_KEY_1, COLUMN_KEY_1, VALUE_1);
}
示例7: when_delete_then_deleted_in_azure
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Test
public void when_delete_then_deleted_in_azure() throws StorageException {
setAzureTableToContain(CELL_1);
TableOperation deleteTableOperationMock = mockDeleteTableOperation(CELL_1);
baseAzureTable.remove(ROW_KEY_1, COLUMN_KEY_1);
verify(azureTableCloudClientMock).execute(TABLE_NAME, deleteTableOperationMock);
}
示例8: when_table_client_throws_storage_exception_during_delete_then_exception_rethrown
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void when_table_client_throws_storage_exception_during_delete_then_exception_rethrown() throws StorageException {
setAzureTableToContain(CELL_1);
TableOperation deleteTableOperationMock = mockDeleteTableOperation(CELL_1);
setupThrowStorageExceptionOnTableOperation(deleteTableOperationMock);
baseAzureTable.remove(ROW_KEY_1, COLUMN_KEY_1);
}
示例9: clear_deletes_all_in_cell_set
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Test
public void clear_deletes_all_in_cell_set() throws StorageException {
setAzureTableToContain(CELL_1, CELL_2);
TableOperation deleteTableOperationMock1 = mockDeleteTableOperation(CELL_1);
TableOperation deleteTableOperationMock2 = mockDeleteTableOperation(CELL_2);
baseAzureTable.clear();
verify(azureTableCloudClientMock).execute(TABLE_NAME, deleteTableOperationMock1);
verify(azureTableCloudClientMock).execute(TABLE_NAME, deleteTableOperationMock2);
}
示例10: put_all_puts_all_the_values
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@Test
public void put_all_puts_all_the_values() throws StorageException {
Table<Bytes, Bytes, Bytes> sourceTable = HashBasedTable.create();
sourceTable.put(ROW_KEY_1, COLUMN_KEY_1, VALUE_1);
sourceTable.put(ROW_KEY_2, COLUMN_KEY_2, VALUE_2);
TableOperation putTableOperationMock1 = mockPutTableOperation(CELL_1);
TableOperation putTableOperationMock2 = mockPutTableOperation(CELL_2);
baseAzureTable.putAll(sourceTable);
verify(azureTableCloudClientMock).execute(TABLE_NAME, putTableOperationMock1);
verify(azureTableCloudClientMock).execute(TABLE_NAME, putTableOperationMock2);
}
示例11: mockDeleteTableOperation
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
private TableOperation mockDeleteTableOperation(Table.Cell<Bytes, Bytes, Bytes> cell) throws StorageException {
TableOperation retrieveOperation = azureTableRequestFactoryMock.retrieve(encode(cell.getRowKey()), encode(cell.getColumnKey()));
AzureEntity result = azureTableCloudClientMock.execute(TABLE_NAME, retrieveOperation);
TableOperation deleteTableOperationMock = mock(TableOperation.class);
when(azureTableRequestFactoryMock.delete(result)).thenReturn(deleteTableOperationMock);
return deleteTableOperationMock;
}
示例12: setAzureTableToContain
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
@SafeVarargs
static void setAzureTableToContain(String tableName,
AzureTableRequestFactory azureTableRequestFactoryMock,
AzureTableCloudClient azureTableCloudClientMock,
Table.Cell<Bytes, Bytes, Bytes>... cells) throws StorageException {
// retrieve setup in general
TableOperation blanketRetrieveOperationMock = mock(TableOperation.class);
when(azureTableRequestFactoryMock.retrieve(any(String.class), any(String.class))).thenReturn(blanketRetrieveOperationMock);
// per entity setup
TableQuery<AzureEntity> emptyQuery = mock(TableQuery.class);
when(azureTableRequestFactoryMock.containsValueQuery(anyString(), anyString())).thenReturn(emptyQuery);
when(azureTableCloudClientMock.execute(emptyQuery)).thenReturn(Collections.<AzureEntity>emptyList());
Collection<AzureEntity> encodedStringEntities = Lists.newArrayList();
for (Table.Cell<Bytes, Bytes, Bytes> cell : cells) {
encodedStringEntities.add(encodedEntity(cell));
setAzureTableToRetrieve(tableName, azureTableRequestFactoryMock, azureTableCloudClientMock, cell);
TableQuery<AzureEntity> valueQuery = mock(TableQuery.class);
when(azureTableRequestFactoryMock.containsValueQuery(tableName, encode(cell.getValue()))).thenReturn(valueQuery);
when(azureTableCloudClientMock.execute(valueQuery)).thenReturn(Collections.singleton(ENCODE_CELL.apply(cell)));
}
// select query
TableQuery<AzureEntity> tableQuery = mock(TableQuery.class);
when(azureTableRequestFactoryMock.selectAll(tableName)).thenReturn(tableQuery);
when(azureTableCloudClientMock.execute(tableQuery)).thenReturn(encodedStringEntities);
setupRowQueries(tableName, azureTableRequestFactoryMock, azureTableCloudClientMock, cells);
setupColumnQueries(tableName, azureTableRequestFactoryMock, azureTableCloudClientMock, cells);
}
示例13: setAzureTableToRetrieve
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
private static void setAzureTableToRetrieve(
String tableName,
AzureTableRequestFactory azureTableRequestFactoryMock,
AzureTableCloudClient azureTableCloudClientMock,
Table.Cell<Bytes, Bytes, Bytes> cell) throws StorageException {
TableOperation retriveTableOperationMock = mock(TableOperation.class);
when(azureTableRequestFactoryMock.retrieve(encode(cell.getRowKey()), encode(cell.getColumnKey()))).thenReturn(retriveTableOperationMock);
when(azureTableCloudClientMock.execute(tableName, retriveTableOperationMock)).thenReturn(encodedEntity(cell));
}
示例14: put
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
TableOperation put(String rowString, String columnString, String value) {
AzureEntity secretieEntity = new AzureEntity(rowString, columnString, value);
return TableOperation.insertOrReplace(secretieEntity);
}
示例15: retrieve
import com.microsoft.windowsazure.services.table.client.TableOperation; //导入依赖的package包/类
TableOperation retrieve(String row, String column) {
return TableOperation.retrieve(row, column, AzureEntity.class);
}