本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java ResourceNotFoundException类的具体用法?Java ResourceNotFoundException怎么用?Java ResourceNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceNotFoundException类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了ResourceNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: closeStorage
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
@Override
public void closeStorage()
{
try
{
dynamoDBConnection.getDynamoClient().describeTable(getTableName());
dynamoDBConnection.getDynamoClient().deleteTable(getTableName());
}
catch(ResourceNotFoundException e)
{
}
dynamoDBConnection.getDynamoDB().createTable(getTableName(),
Collections.singletonList(
new KeySchemaElement("_id", KeyType.HASH)),
Collections.singletonList(
new AttributeDefinition("_id", ScalarAttributeType.S)),
new ProvisionedThroughput(1L, 1L));
}
示例2: AbstractDynamoDBRecordWriter
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
public AbstractDynamoDBRecordWriter(JobConf jobConf, Progressable progressable) {
this.progressable = progressable;
client = new DynamoDBClient(jobConf);
tableName = jobConf.get(DynamoDBConstants.OUTPUT_TABLE_NAME);
if (tableName == null) {
throw new ResourceNotFoundException("No output table name was specified.");
}
IopsCalculator iopsCalculator = new WriteIopsCalculator(createJobClient(jobConf), client,
tableName);
iopsController = new IopsController(iopsCalculator, DEFAULT_AVERAGE_ITEM_SIZE_IN_BYTES,
DynamoDBOperationType.WRITE);
permissibleWritesPerSecond = iopsController.getTargetItemsPerSecond();
log.info("Number of allocated item writes per second: " + permissibleWritesPerSecond);
// Hive may not have a valid Reporter and pass in null progressable
// TODO Check whether this would happen when excluding Hive
if (progressable instanceof Reporter) {
reporter = (Reporter) progressable;
}
}
示例3: describeTable
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
@Override
public DescribeTableResult describeTable(DescribeTableRequest describeTableRequest) {
this.describeTableRequest = describeTableRequest;
String tableName = describeTableRequest.getTableName();
if ("activeTable".equals(tableName)) {
return tableWithStatus(TableStatus.ACTIVE);
} else if ("creatibleTable".equals(tableName) && createTableRequest != null) {
return tableWithStatus(TableStatus.ACTIVE);
} else if ("FULL_DESCRIBE_TABLE".equals(tableName)) {
return new DescribeTableResult().withTable(new TableDescription()
.withTableName(tableName)
.withTableStatus(TableStatus.ACTIVE)
.withCreationDateTime(new Date(NOW))
.withItemCount(100L)
.withKeySchema(new KeySchemaElement().withAttributeName("name"))
.withProvisionedThroughput(new ProvisionedThroughputDescription()
.withReadCapacityUnits(20L)
.withWriteCapacityUnits(10L))
.withTableSizeBytes(1000L));
}
throw new ResourceNotFoundException(tableName + " is missing");
}
示例4: safeDescribeTable
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
/**
* Private interface for describing tables which handles any instances of
* Throttling of the API
*
* @param dynamoClient
* @param dynamoTable
* @return
* @throws Exception
*/
public static DescribeTableResult safeDescribeTable(
final AmazonDynamoDB dynamoClient, final String dynamoTable)
throws Exception {
DescribeTableResult res = null;
final int tryMax = 10;
int tries = 0;
while (true) {
try {
res = dynamoClient.describeTable(dynamoTable);
return res;
} catch (ResourceNotFoundException e) {
if (tries < tryMax) {
// sleep for a short time as this is potentially an eventual
// consistency issue with the table having been created ms
// ago
Thread.sleep(10);
tries++;
} else {
throw e;
}
}
}
}
示例5: checkResource
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
/**
* Checks if a resource exists or not
*
* @param tableName
* Table name to be checked
* @return
*/
public TableDescription checkResource(String tableName){
TableDescription tableDescription = null;
try{
DescribeTableRequest describeTableRequest = new DescribeTableRequest()
.withTableName(tableName);
tableDescription = dynamoDBClient.describeTable(describeTableRequest)
.getTable();
}
catch(ResourceNotFoundException e){
tableDescription = null;
}
return tableDescription;
}
示例6: setupTable
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
public void setupTable() {
setupGeoDataManager();
GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();
DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(config.getTableName());
try {
config.getDynamoDBClient().describeTable(describeTableRequest);
if (status == Status.NOT_STARTED) {
status = Status.READY;
}
} catch (ResourceNotFoundException e) {
PhotoLocationsTable photoLocationsTable = new PhotoLocationsTable();
photoLocationsTable.start();
}
}
示例7: waitForTable
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
private void waitForTable(String name) {
log.info(String.format("Waiting for creation of table '%s' to complete.", name));
long startTime = System.currentTimeMillis();
long endTime = startTime + (10 * 60 * 1000);
while (System.currentTimeMillis() < endTime) {
sleep(1000 * 20);
try {
DescribeTableRequest request = new DescribeTableRequest().withTableName(name);
TableDescription tableDescription = client.describeTable(request).getTable();
String tableStatus = tableDescription.getTableStatus();
log.info(String.format("Table '%s' is in state: '%s'.", name, tableStatus));
if (tableStatus.equals(TableStatus.ACTIVE.toString())) {
return;
}
} catch (ResourceNotFoundException e) {
// nop - maybe the table isn't showing up yet.
}
}
throw new RuntimeException(String.format("Table '%s' never went active.", name));
}
示例8: getTestTableStatus
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
public static String getTestTableStatus() {
try {
AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager
.ddb();
DescribeTableRequest request = new DescribeTableRequest()
.withTableName(Constants.TEST_TABLE_NAME);
DescribeTableResult result = ddb.describeTable(request);
String status = result.getTable().getTableStatus();
return status == null ? "" : status;
} catch (ResourceNotFoundException e) {
} catch (AmazonServiceException ex) {
UserPreferenceDemoActivity.clientManager
.wipeCredentialsOnAuthError(ex);
}
return "";
}
示例9: setupTable
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
public void setupTable() {
setupGeoDataManager();
GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();
DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(config.getTableName());
try {
config.getDynamoDBClient().describeTable(describeTableRequest);
if (status == Status.NOT_STARTED) {
status = Status.READY;
}
} catch (ResourceNotFoundException e) {
SchoolDataLoader schoolDataLoader = new SchoolDataLoader();
schoolDataLoader.start();
}
}
示例10: describeTable
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
private Optional<TableDescription> describeTable() {
try {
DescribeTableResult result = client.describeTable(tableName);
return Optional.of(result.getTable());
} catch (ResourceNotFoundException e) {
return Optional.empty();
}
}
示例11: getCurrentStore
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
private Store getCurrentStore(SecretsGroupIdentifier group, ReadWriteLock readWriteLock) {
if (userConfig.getLocalFilePath(group).isPresent()) {
// TODO: load encryptor once
final KMSEncryptor kmsEncryptor = getEncryptor(group);
return new File(userConfig.getLocalFilePath(group).get(), kmsEncryptor, new FileEncryptionContext(group), readWriteLock);
}
try {
DynamoDB dynamoDB = DynamoDB.fromCredentials(awsCredentials, clientConfiguration, group, readWriteLock);
return dynamoDB;
} catch (ResourceNotFoundException e) {
throw new DoesNotExistException("No storage backend found!", e);
}
}
示例12: groupExists
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
public static boolean groupExists(SecretsGroupManager secretsGroupManager, SecretsGroupIdentifier identifier) {
try {
secretsGroupManager.info(identifier);
return true;
} catch (NoSuchElementException | ResourceNotFoundException | NoSuchEntityException e) {
return false;
}
}
示例13: cleanUpDynamoDBTables
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
private static void cleanUpDynamoDBTables(Regions testRegion, String testResourcePrefix, Date createdBeforeThreshold,
AWSCredentialsProvider awsCredentials) {
LOG.info("Cleaning DynamoDB...");
AmazonDynamoDB dynamoDBClient = AmazonDynamoDBClientBuilder.standard()
.withCredentials(awsCredentials)
.withRegion(testRegion)
.build();
List<String> tableNames = dynamoDBClient.listTables().getTableNames();
for (String tableName: tableNames) {
if (!tableName.startsWith(testResourcePrefix)) {
continue;
}
LOG.info(String.format("Checking if table %s needs cleaning...", tableName));
try {
TableDescription desc = dynamoDBClient.describeTable(tableName).getTable();
if (!desc.getTableName().equals(TableStatus.DELETING.toString()) &&
desc.getCreationDateTime() != null &&
desc.getCreationDateTime().before(createdBeforeThreshold)) {
LOG.info("Cleaning up table: " + tableName);
dynamoDBClient.deleteTable(tableName);
}
} catch (ResourceNotFoundException e) {
LOG.info("Looks like table was already cleaned up: " + tableName);
}
}
}
示例14: testDeleteTableWithWait
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
@Test
public void testDeleteTableWithWait() throws Exception {
// Create fake responses from AWS.
TableDescription deletingDescription = constructTableDescription(TableStatus.DELETING);
DescribeTableResult mockDescribeResult = new DescribeTableResult().withTable(deletingDescription);
// Delete the table. First response the table is still deleting, the second response the table has deleted
// and the ResourceNotFoundException is thrown.
when(mockDynamoDBClient.describeTable(tableName)).thenReturn(mockDescribeResult).thenThrow(
new ResourceNotFoundException("Table not found"));
dynamoDB.delete();
verify(mockDynamoDBClient, times(1)).deleteTable(tableName);
verify(mockDynamoDBClient, times(2)).describeTable(tableName);
}
示例15: tableExists
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException; //导入依赖的package包/类
public boolean tableExists(final String tableName) {
try {
return TableStatus.ACTIVE.toString().equals(db.getTable(tableName).describe().getTableStatus().toUpperCase());
} catch (final ResourceNotFoundException rnfe) {
return false;
}
}