当前位置: 首页>>代码示例>>Java>>正文


Java ResourceNotFoundException类代码示例

本文整理汇总了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));
}
 
开发者ID:orbit,项目名称:orbit-dynamodb,代码行数:21,代码来源:DynamoDBPersistenceTest.java

示例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;
  }
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:23,代码来源:AbstractDynamoDBRecordWriter.java

示例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");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:AmazonDDBClientMock.java

示例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;
			}
		}
	}
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:34,代码来源:DynamoUtils.java

示例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;
}
 
开发者ID:apache,项目名称:gora,代码行数:23,代码来源:GoraDynamoDBTestDriver.java

示例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();
	}

}
 
开发者ID:aws-samples,项目名称:reinvent2013-mobile-photo-share,代码行数:19,代码来源:Utilities.java

示例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));
}
 
开发者ID:mdaley,项目名称:quartz-dynamodb,代码行数:22,代码来源:DynamoDbJobStore.java

示例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 "";
    }
 
开发者ID:awslabs,项目名称:aws-sdk-android-samples,代码行数:22,代码来源:DynamoDBManager.java

示例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();
	}

}
 
开发者ID:awslabs,项目名称:dynamodb-geo,代码行数:19,代码来源:Utilities.java

示例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();
    }

}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:10,代码来源:GenericDynamoDB.java

示例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);
    }
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:14,代码来源:DefaultSecretsGroupManager.java

示例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;
    }
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:9,代码来源:IntegrationTestHelper.java

示例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);
        }
    }
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:29,代码来源:IntegrationTestHelper.java

示例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);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:16,代码来源:GenericDynamoDBTest.java

示例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;
    }
}
 
开发者ID:BackendButters,项目名称:AwsCommons,代码行数:8,代码来源:DynamoCommons.java


注:本文中的com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。