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


Java TableDescription类代码示例

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.TableDescription的典型用法代码示例。如果您正苦于以下问题:Java TableDescription类的具体用法?Java TableDescription怎么用?Java TableDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TableDescription类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了TableDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: definition

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@RequestMapping("/describe/{table}")
public
@ResponseBody
TableDescription definition(@PathVariable String table) {
    TableDescription description = null;

    try {
        if (!names.isEmpty()) {
            description = amazonDynamoDBClient.describeTable(table).getTable();
        }
    } catch (AmazonClientException ex) {
        LOGGER.error(ex.getMessage());
    }

    return description;
}
 
开发者ID:simplymequeeny,项目名称:dynamodb-client-web-gui,代码行数:17,代码来源:TableController.java

示例2: testCreateTableWithWait

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Test
public void testCreateTableWithWait() throws Exception {
    // Create fake responses from AWS. First response is still creating the table, second response the table
    // has become active.
    TableDescription creatingDescription = constructTableDescription(TableStatus.CREATING);
    TableDescription createdDescription = constructTableDescription(TableStatus.ACTIVE);
    CreateTableResult mockCreateResult = new CreateTableResult().withTableDescription(creatingDescription);
    DescribeTableResult mockDescribeResultCreating = new DescribeTableResult().withTable(creatingDescription);
    DescribeTableResult mockDescribeResultCreated = new DescribeTableResult().withTable(createdDescription);

    // Create the table.
    CreateTableRequest expectedRequest = dynamoDB.constructCreateTableRequest();
    when(mockDynamoDBClient.createTable(expectedRequest)).thenReturn(mockCreateResult);
    when(mockDynamoDBClient.describeTable(tableName)).thenReturn(mockDescribeResultCreating, mockDescribeResultCreated);
    assertEquals(dynamoDB.create(), TEST_ARN);

    verify(mockDynamoDBClient, times(1)).createTable(expectedRequest);
    verify(mockDynamoDBClient, times(2)).describeTable(tableName);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:20,代码来源:GenericDynamoDBTest.java

示例3: waitForActiveTableStatus

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
private static Task<TableDescription> waitForActiveTableStatus(final DynamoDBConnection dynamoDBConnection, final String tableName)
{
    try
    {
        for (int i = 0; i < WAITING_FOR_ACTIVE_TABLE_STATUS_MAX_ATTEMPTS; i++)
        {
            final DescribeTableResult describe = dynamoDBConnection.getDynamoClient().describeTable(tableName);
            if (describe.getTable().getTableStatus().equals(TableStatus.ACTIVE.name()))
            {
                return Task.fromValue(describe.getTable());
            }

            Thread.sleep(WAITING_FOR_ACTIVE_TABLE_STATUS_RETRY_DELAY_MILLIS);
        }

    }
    catch (InterruptedException e)
    {
        throw new UncheckedException(e);
    }

    throw new UncheckedException("Hit max retry attempts while waiting for table to become active: " + tableName);
}
 
开发者ID:orbit,项目名称:orbit-dynamodb,代码行数:24,代码来源:DynamoDBUtils.java

示例4: setTableProperties

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
private void setTableProperties(JobConf jobConf, String tableName, Double writeRatio) {
  jobConf.set(DynamoDBConstants.OUTPUT_TABLE_NAME, tableName);
  jobConf.set(DynamoDBConstants.INPUT_TABLE_NAME, tableName);
  jobConf.set(DynamoDBConstants.TABLE_NAME, tableName);

  DynamoDBClient client = new DynamoDBClient(jobConf);
  TableDescription description = client.describeTable(tableName);

  Long readThroughput = description.getProvisionedThroughput().getReadCapacityUnits();
  Long writeThroughput = description.getProvisionedThroughput().getWriteCapacityUnits();

  jobConf.set(DynamoDBConstants.READ_THROUGHPUT, readThroughput.toString());
  jobConf.set(DynamoDBConstants.WRITE_THROUGHPUT, writeThroughput.toString());

  log.info("Read throughput:       " + readThroughput);
  log.info("Write throughput:      " + writeThroughput);

  // Optional properties
  if (writeRatio != null) {
    jobConf.set(DynamoDBConstants.THROUGHPUT_WRITE_PERCENT, writeRatio.toString());
    log.info("Throughput write ratio: " + writeRatio);
  }
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:24,代码来源:DynamoDBImport.java

示例5: preCreateTable

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Override
public void preCreateTable(Table table) throws MetaException {
  DynamoDBClient client = createDynamoDBClient(table);
  try {

    boolean isExternal = MetaStoreUtils.isExternalTable(table);

    if (!isExternal) {
      throw new MetaException("Only EXTERNAL tables are supported for DynamoDB.");
    }

    String tableName = HiveDynamoDBUtil.getDynamoDBTableName(table.getParameters()
        .get(DynamoDBConstants.TABLE_NAME), table.getTableName());
    TableDescription tableDescription = client.describeTable(tableName);

    checkTableStatus(tableDescription);
    checkTableSchemaMapping(tableDescription, table);
    checkTableSchemaType(tableDescription, table);
  } finally {
    client.close();
  }
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:23,代码来源:DynamoDBStorageHandler.java

示例6: checkTableSchemaMapping

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
void checkTableSchemaMapping(TableDescription tableDescription, Table table) throws
    MetaException {
  String mapping = table.getParameters().get(DynamoDBConstants.DYNAMODB_COLUMN_MAPPING);
  Map<String, String> columnMapping = HiveDynamoDBUtil.getHiveToDynamoDBSchemaMapping(mapping);

  List<FieldSchema> tableSchema = table.getSd().getCols();
  for (FieldSchema fieldSchema : tableSchema) {
    if (HiveDynamoDBTypeFactory.isHiveDynamoDBItemMapType(fieldSchema.getType())) {
      // We don't need column mapping as this column contains full
      // DynamoDB row
      continue;
    }

    String fieldSchemaName = fieldSchema.getName().toLowerCase();
    if (columnMapping.containsKey(fieldSchemaName)) {
      if (columnMapping.get(fieldSchemaName).isEmpty()) {
        throw new MetaException("Invalid column mapping for column: " + fieldSchemaName);
      }
    } else {
      throw new MetaException("Could not find column mapping for column: " + fieldSchemaName);
    }
  }
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:24,代码来源:DynamoDBStorageHandler.java

示例7: checkTableSchemaType

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
void checkTableSchemaType(TableDescription tableDescription, Table table) throws MetaException {
  List<FieldSchema> tableSchema = table.getSd().getCols();

  for (FieldSchema fieldSchema : tableSchema) {
    for (AttributeDefinition definition : tableDescription.getAttributeDefinitions()) {
      validateKeySchema(definition.getAttributeName(), definition.getAttributeType(),
          fieldSchema);
    }

    // Check for each field type
    if (HiveDynamoDBTypeFactory.getTypeObjectFromHiveType(fieldSchema.getType()) == null) {
      throw new MetaException("The hive type " + fieldSchema.getType() + " is not supported in "
          + "DynamoDB");
    }
  }
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:17,代码来源:DynamoDBStorageHandler.java

示例8: testCheckTableSchemaMappingMissingColumn

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Test
public void testCheckTableSchemaMappingMissingColumn() throws MetaException {
  TableDescription description = getHashRangeTable();

  Table table = new Table();
  Map<String, String> parameters = Maps.newHashMap();
  parameters.put(DynamoDBConstants.DYNAMODB_COLUMN_MAPPING, "col1:dynamo_col1$,hashKey:hashKey");
  table.setParameters(parameters);
  StorageDescriptor sd = new StorageDescriptor();
  List<FieldSchema> cols = Lists.newArrayList();
  cols.add(new FieldSchema("col1", "string", ""));
  cols.add(new FieldSchema("col2", "tinyint", ""));
  cols.add(new FieldSchema("col3", "map<string,string>", ""));
  cols.add(new FieldSchema("hashMap", "string", ""));
  sd.setCols(cols);
  table.setSd(sd);

  exceptionRule.expect(MetaException.class);
  exceptionRule.expectMessage("Could not find column mapping for column: col2");
  storageHandler.checkTableSchemaMapping(description, table);
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:22,代码来源:DynamoDBStorageHandlerTest.java

示例9: testCheckTableSchemaMappingValid

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Test
public void testCheckTableSchemaMappingValid() throws MetaException {
  TableDescription description = getHashRangeTable();

  Table table = new Table();
  Map<String, String> parameters = Maps.newHashMap();
  parameters.put(DynamoDBConstants.DYNAMODB_COLUMN_MAPPING, "col1:dynamo_col1$," +
      "col2:dynamo_col2#,hashKey:hashKey");
  table.setParameters(parameters);
  StorageDescriptor sd = new StorageDescriptor();
  List<FieldSchema> cols = Lists.newArrayList();
  cols.add(new FieldSchema("col1", "string", ""));
  cols.add(new FieldSchema("col2", "bigint", ""));
  cols.add(new FieldSchema("hashKey", "string", ""));
  sd.setCols(cols);
  table.setSd(sd);
  storageHandler.checkTableSchemaMapping(description, table);
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:19,代码来源:DynamoDBStorageHandlerTest.java

示例10: testCheckTableSchemaTypeInvalidType

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Test
public void testCheckTableSchemaTypeInvalidType() throws MetaException {
  TableDescription description = getHashRangeTable();

  Table table = new Table();
  Map<String, String> parameters = Maps.newHashMap();
  parameters.put(DynamoDBConstants.DYNAMODB_COLUMN_MAPPING, "col1:dynamo_col1$," +
      "col2:dynamo_col2#,hashKey:hashKey");
  table.setParameters(parameters);
  StorageDescriptor sd = new StorageDescriptor();
  List<FieldSchema> cols = Lists.newArrayList();
  cols.add(new FieldSchema("col1", "string", ""));
  cols.add(new FieldSchema("col2", "tinyint", ""));
  cols.add(new FieldSchema("hashKey", "string", ""));
  sd.setCols(cols);
  table.setSd(sd);

  exceptionRule.expect(MetaException.class);
  exceptionRule.expectMessage("The hive type tinyint is not supported in DynamoDB");
  storageHandler.checkTableSchemaType(description, table);
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:22,代码来源:DynamoDBStorageHandlerTest.java

示例11: testCheckTableSchemaTypeInvalidHashKeyType

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Test
public void testCheckTableSchemaTypeInvalidHashKeyType() throws MetaException {
  TableDescription description = getHashRangeTable();

  Table table = new Table();
  Map<String, String> parameters = Maps.newHashMap();
  parameters.put(DynamoDBConstants.DYNAMODB_COLUMN_MAPPING, "col1:dynamo_col1$," +
      "col2:dynamo_col2#,hashKey:hashKey");
  table.setParameters(parameters);
  StorageDescriptor sd = new StorageDescriptor();
  List<FieldSchema> cols = Lists.newArrayList();
  cols.add(new FieldSchema("col1", "string", ""));
  cols.add(new FieldSchema("col2", "bigint", ""));
  cols.add(new FieldSchema("hashKey", "map<string,string>", ""));
  sd.setCols(cols);
  table.setSd(sd);

  exceptionRule.expect(MetaException.class);
  exceptionRule.expectMessage("The key element hashKey does not match type. DynamoDB Type: S " +
      "Hive type: " + "map<string,string>");
  storageHandler.checkTableSchemaType(description, table);
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:23,代码来源:DynamoDBStorageHandlerTest.java

示例12: testCheckTableSchemaTypeValid

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Test
public void testCheckTableSchemaTypeValid() throws MetaException {
  TableDescription description = getHashRangeTable();

  Table table = new Table();
  Map<String, String> parameters = Maps.newHashMap();
  parameters.put(DynamoDBConstants.DYNAMODB_COLUMN_MAPPING, "col1:dynamo_col1$," +
      "col2:dynamo_col2#,hashKey:hashKey");
  table.setParameters(parameters);
  StorageDescriptor sd = new StorageDescriptor();
  List<FieldSchema> cols = Lists.newArrayList();
  cols.add(new FieldSchema("col1", "string", ""));
  cols.add(new FieldSchema("col2", "bigint", ""));
  cols.add(new FieldSchema("hashKey", "string", ""));
  sd.setCols(cols);
  table.setSd(sd);
  // This check is expected to pass for the given input
  storageHandler.checkTableSchemaType(description, table);
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:20,代码来源:DynamoDBStorageHandlerTest.java

示例13: describeTable

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
public TableDescription describeTable(String tableName) {
  final DescribeTableRequest describeTablesRequest = new DescribeTableRequest()
      .withTableName(tableName);
  try {
    RetryResult<DescribeTableResult> describeResult = getRetryDriver().runWithRetry(
        new Callable<DescribeTableResult>() {
          @Override
          public DescribeTableResult call() {
            DescribeTableResult result = dynamoDB.describeTable(describeTablesRequest);
            log.info("Describe table output: " + result);
            return result;
          }
        }, null, null);
    return describeResult.result.getTable();
  } catch (Exception e) {
    throw new RuntimeException("Could not lookup table " + tableName + " in DynamoDB.", e);
  }
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:19,代码来源:DynamoDBClient.java

示例14: setup

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
@Before
public void setup() {
  when(dynamoDBClient.describeTable(TABLE_NAME)).thenReturn(new TableDescription()
      .withProvisionedThroughput(new ProvisionedThroughputDescription().withWriteCapacityUnits
          (WRITE_CAPACITY_UNITS)));

  JobConf jobConf = new JobConf();
  jobConf.setNumMapTasks(TOTAL_MAP_TASKS);
  jobConf.set("mapreduce.task.attempt.id", "attempt_m_1");
  jobConf.set(DynamoDBConstants.THROUGHPUT_WRITE_PERCENT, String.valueOf
      (THROUGHPUT_WRITE_PERCENT));
  when(jobClient.getConf()).thenReturn(jobConf);

  writeIopsCalculator = new WriteIopsCalculator(jobClient, dynamoDBClient, TABLE_NAME) {
    @Override
    int calculateMaxMapTasks(int totalMapTasks) {
      return MAX_CONCURRENT_MAP_TASKS;
    }
  };
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:21,代码来源:WriteIopsCalculatorTest.java

示例15: getTableDescription

import com.amazonaws.services.dynamodbv2.model.TableDescription; //导入依赖的package包/类
private TableDescription getTableDescription(String hashType, String rangeType) {
  List<KeySchemaElement> keySchema = new ArrayList<>();
  List<AttributeDefinition> definitions = new ArrayList<>();

  keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH));
  definitions.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType
      (hashType));

  if (rangeType != null) {
    keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType
        .RANGE));
    definitions.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType
        (rangeType));
  }

  TableDescription description = new TableDescription().withKeySchema(keySchema)
      .withAttributeDefinitions(definitions).withProvisionedThroughput(new
          ProvisionedThroughputDescription().withReadCapacityUnits(1000L)
          .withWriteCapacityUnits(1000L));
  return description;
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:22,代码来源:DynamoDBRecordReaderTest.java


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