if (getProvisionedThroughput() != null) sb.append("ProvisionedThroughput: ").append(getProvisionedThroughput()).append(","); if (getTableSizeBytes() != null) sb.append("TableSizeBytes: ").append(getTableSizeBytes()).append(","); if (getItemCount() != null) sb.append("ItemCount: ").append(getItemCount()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributeDefinitions() == null) ? 0 : getAttributeDefinitions().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getKeySchema() == null) ? 0 : getKeySchema().hashCode()); hashCode = prime * hashCode + ((getTableStatus() == null) ? 0 : getTableStatus().hashCode()); hashCode = prime * hashCode + ((getCreationDateTime() == null) ? 0 : getCreationDateTime().hashCode()); hashCode = prime * hashCode + ((getProvisionedThroughput() == null) ? 0 : getProvisionedThroughput().hashCode()); hashCode = prime * hashCode + ((getTableSizeBytes() == null) ? 0 : getTableSizeBytes().hashCode()); hashCode = prime * hashCode + ((getItemCount() == null) ? 0 : getItemCount().hashCode()); hashCode = prime * hashCode + ((getTableArn() == null) ? 0 : getTableArn().hashCode()); hashCode = prime * hashCode + ((getTableId() == null) ? 0 : getTableId().hashCode()); hashCode = prime * hashCode + ((getBillingModeSummary() == null) ? 0 : getBillingModeSummary().hashCode()); hashCode = prime * hashCode + ((getLocalSecondaryIndexes() == null) ? 0 : getLocalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getGlobalSecondaryIndexes() == null) ? 0 : getGlobalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getStreamSpecification() == null) ? 0 : getStreamSpecification().hashCode()); hashCode = prime * hashCode + ((getLatestStreamLabel() == null) ? 0 : getLatestStreamLabel().hashCode()); hashCode = prime * hashCode + ((getLatestStreamArn() == null) ? 0 : getLatestStreamArn().hashCode()); hashCode = prime * hashCode + ((getRestoreSummary() == null) ? 0 : getRestoreSummary().hashCode()); hashCode = prime * hashCode + ((getSSEDescription() == null) ? 0 : getSSEDescription().hashCode()); return hashCode; }
if (other.getProvisionedThroughput() != null && other.getProvisionedThroughput().equals(this.getProvisionedThroughput()) == false) return false; if (other.getTableSizeBytes() == null ^ this.getTableSizeBytes() == null) return false; if (other.getTableSizeBytes() != null && other.getTableSizeBytes().equals(this.getTableSizeBytes()) == false) return false; if (other.getItemCount() == null ^ this.getItemCount() == null)
/** * Marshall the given parameter object. */ public void marshall(TableDescription tableDescription, ProtocolMarshaller protocolMarshaller) { if (tableDescription == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(tableDescription.getAttributeDefinitions(), ATTRIBUTEDEFINITIONS_BINDING); protocolMarshaller.marshall(tableDescription.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(tableDescription.getKeySchema(), KEYSCHEMA_BINDING); protocolMarshaller.marshall(tableDescription.getTableStatus(), TABLESTATUS_BINDING); protocolMarshaller.marshall(tableDescription.getCreationDateTime(), CREATIONDATETIME_BINDING); protocolMarshaller.marshall(tableDescription.getProvisionedThroughput(), PROVISIONEDTHROUGHPUT_BINDING); protocolMarshaller.marshall(tableDescription.getTableSizeBytes(), TABLESIZEBYTES_BINDING); protocolMarshaller.marshall(tableDescription.getItemCount(), ITEMCOUNT_BINDING); protocolMarshaller.marshall(tableDescription.getTableArn(), TABLEARN_BINDING); protocolMarshaller.marshall(tableDescription.getTableId(), TABLEID_BINDING); protocolMarshaller.marshall(tableDescription.getBillingModeSummary(), BILLINGMODESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getLocalSecondaryIndexes(), LOCALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getGlobalSecondaryIndexes(), GLOBALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getStreamSpecification(), STREAMSPECIFICATION_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamLabel(), LATESTSTREAMLABEL_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamArn(), LATESTSTREAMARN_BINDING); protocolMarshaller.marshall(tableDescription.getRestoreSummary(), RESTORESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getSSEDescription(), SSEDESCRIPTION_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
if (getProvisionedThroughput() != null) sb.append("ProvisionedThroughput: " + getProvisionedThroughput() + ","); if (getTableSizeBytes() != null) sb.append("TableSizeBytes: " + getTableSizeBytes() + ","); if (getItemCount() != null) sb.append("ItemCount: " + getItemCount() + ",");
+ ((getTableSizeBytes() == null) ? 0 : getTableSizeBytes().hashCode()); hashCode = prime * hashCode + ((getItemCount() == null) ? 0 : getItemCount().hashCode()); hashCode = prime * hashCode + ((getTableArn() == null) ? 0 : getTableArn().hashCode());
&& other.getProvisionedThroughput().equals(this.getProvisionedThroughput()) == false) return false; if (other.getTableSizeBytes() == null ^ this.getTableSizeBytes() == null) return false; if (other.getTableSizeBytes() != null && other.getTableSizeBytes().equals(this.getTableSizeBytes()) == false) return false; if (other.getItemCount() == null ^ this.getItemCount() == null)
public static Double calculateAverageItemSize(TableDescription description) { if (description.getItemCount() != 0) { return ((double) description.getTableSizeBytes()) / ((double) description.getItemCount()); } return 0.0; }
public static Double calculateAverageItemSize(TableDescription description) { if (description.getItemCount() != 0) { return ((double) description.getTableSizeBytes()) / ((double) description.getItemCount()); } return 0.0; }
@Override @Retries.OnceRaw public Map<String, String> getDiagnostics() throws IOException { Map<String, String> map = new TreeMap<>(); if (table != null) { TableDescription desc = getTableDescription(true); map.put("name", desc.getTableName()); map.put(STATUS, desc.getTableStatus()); map.put("ARN", desc.getTableArn()); map.put("size", desc.getTableSizeBytes().toString()); map.put(TABLE, desc.toString()); ProvisionedThroughputDescription throughput = desc.getProvisionedThroughput(); map.put(READ_CAPACITY, throughput.getReadCapacityUnits().toString()); map.put(WRITE_CAPACITY, throughput.getWriteCapacityUnits().toString()); map.put(TABLE, desc.toString()); map.put(MetadataStoreCapabilities.PERSISTS_AUTHORITATIVE_BIT, Boolean.toString(true)); } else { map.put("name", "DynamoDB Metadata Store"); map.put(TABLE, "none"); map.put(STATUS, "undefined"); } map.put("description", DESCRIPTION); map.put("region", region); if (batchWriteRetryPolicy != null) { map.put("retryPolicy", batchWriteRetryPolicy.toString()); } return map; }
Long tableSizeBytes = description.getTableSizeBytes(); Double averageItemSize = DynamoDBUtil.calculateAverageItemSize(description);
/** * returns the approximate number of segments a table should be broken up * when parallel scanning. This function is based off of either read and * write capacity, with which you can scan much faster, or the size of your * table, which should need many more segments in order to scan the table * fast enough in parallel so that one worker does not finish long before * other workers. * * @throws NullReadCapacityException * if the table returns a null readCapacity units. */ public static int getNumberOfSegments(TableDescription description) throws NullReadCapacityException { ProvisionedThroughputDescription provisionedThroughput = description .getProvisionedThroughput(); double tableSizeInGigabytes = Math.ceil(description.getTableSizeBytes() / BootstrapConstants.GIGABYTE); Long readCapacity = provisionedThroughput.getReadCapacityUnits(); Long writeCapacity = provisionedThroughput.getWriteCapacityUnits(); if (writeCapacity == null) { writeCapacity = 1L; } if (readCapacity == null) { throw new NullReadCapacityException( "Cannot scan with a null readCapacity provisioned throughput"); } double throughput = (readCapacity + 3 * writeCapacity) / 3000.0; return (int) (10 * Math.max(Math.ceil(throughput), Math.ceil(tableSizeInGigabytes) / 10)); }
/** * Gives basic information about a DynamoDB table (status, creation date, size). * @param appid name of the {@link com.erudika.para.core.App} * @return a map */ public static Map<String, Object> getTableStatus(final String appid) { if (StringUtils.isBlank(appid)) { return Collections.emptyMap(); } try { final TableDescription td = getClient().describeTable(getTableNameForAppid(appid)).getTable(); HashMap<String, Object> dbStatus = new HashMap<>(); dbStatus.put("id", appid); dbStatus.put("status", td.getTableStatus()); dbStatus.put("created", td.getCreationDateTime().getTime()); dbStatus.put("sizeBytes", td.getTableSizeBytes()); dbStatus.put("itemCount", td.getItemCount()); dbStatus.put("readCapacityUnits", td.getProvisionedThroughput().getReadCapacityUnits()); dbStatus.put("writeCapacityUnits", td.getProvisionedThroughput().getWriteCapacityUnits()); return dbStatus; } catch (Exception e) { logger.error(null, e); } return Collections.emptyMap(); }
/** * Gives basic information about a DynamoDB table (status, creation date, size). * @param appid name of the {@link com.erudika.para.core.App} * @return a map */ public static Map<String, Object> getTableStatus(final String appid) { if (StringUtils.isBlank(appid)) { return Collections.emptyMap(); } try { final TableDescription td = getClient().describeTable(getTableNameForAppid(appid)).getTable(); HashMap<String, Object> dbStatus = new HashMap<>(); dbStatus.put("id", appid); dbStatus.put("status", td.getTableStatus()); dbStatus.put("created", td.getCreationDateTime().getTime()); dbStatus.put("sizeBytes", td.getTableSizeBytes()); dbStatus.put("itemCount", td.getItemCount()); dbStatus.put("readCapacityUnits", td.getProvisionedThroughput().getReadCapacityUnits()); dbStatus.put("writeCapacityUnits", td.getProvisionedThroughput().getWriteCapacityUnits()); return dbStatus; } catch (Exception e) { logger.error(null, e); } return Collections.emptyMap(); }
if (getProvisionedThroughput() != null) sb.append("ProvisionedThroughput: ").append(getProvisionedThroughput()).append(","); if (getTableSizeBytes() != null) sb.append("TableSizeBytes: ").append(getTableSizeBytes()).append(","); if (getItemCount() != null) sb.append("ItemCount: ").append(getItemCount()).append(",");
/** * Gives basic information about a DynamoDB table (status, creation date, size). * @param appid name of the {@link com.erudika.para.core.App} * @return a map */ public static Map<String, Object> getTableStatus(String appid) { if (StringUtils.isBlank(appid)) { return Collections.emptyMap(); } try { Map<String, Object> map = new HashMap<String, Object>(); final TableDescription td = getClient().describeTable(getTablNameForAppid(appid)).getTable(); return new HashMap<String, Object>() { { put("status", td.getTableStatus()); put("created", td.getCreationDateTime().getTime()); put("sizeBytes", td.getTableSizeBytes()); put("itemCount", td.getItemCount()); put("readCapacityUnits", td.getProvisionedThroughput().getReadCapacityUnits()); put("writeCapacityUnits", td.getProvisionedThroughput().getWriteCapacityUnits()); } }; } catch (Exception e) { logger.error(null, e); } return Collections.emptyMap(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAttributeDefinitions() == null) ? 0 : getAttributeDefinitions().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getKeySchema() == null) ? 0 : getKeySchema().hashCode()); hashCode = prime * hashCode + ((getTableStatus() == null) ? 0 : getTableStatus().hashCode()); hashCode = prime * hashCode + ((getCreationDateTime() == null) ? 0 : getCreationDateTime().hashCode()); hashCode = prime * hashCode + ((getProvisionedThroughput() == null) ? 0 : getProvisionedThroughput().hashCode()); hashCode = prime * hashCode + ((getTableSizeBytes() == null) ? 0 : getTableSizeBytes().hashCode()); hashCode = prime * hashCode + ((getItemCount() == null) ? 0 : getItemCount().hashCode()); hashCode = prime * hashCode + ((getTableArn() == null) ? 0 : getTableArn().hashCode()); hashCode = prime * hashCode + ((getTableId() == null) ? 0 : getTableId().hashCode()); hashCode = prime * hashCode + ((getBillingModeSummary() == null) ? 0 : getBillingModeSummary().hashCode()); hashCode = prime * hashCode + ((getLocalSecondaryIndexes() == null) ? 0 : getLocalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getGlobalSecondaryIndexes() == null) ? 0 : getGlobalSecondaryIndexes().hashCode()); hashCode = prime * hashCode + ((getStreamSpecification() == null) ? 0 : getStreamSpecification().hashCode()); hashCode = prime * hashCode + ((getLatestStreamLabel() == null) ? 0 : getLatestStreamLabel().hashCode()); hashCode = prime * hashCode + ((getLatestStreamArn() == null) ? 0 : getLatestStreamArn().hashCode()); hashCode = prime * hashCode + ((getRestoreSummary() == null) ? 0 : getRestoreSummary().hashCode()); hashCode = prime * hashCode + ((getSSEDescription() == null) ? 0 : getSSEDescription().hashCode()); return hashCode; }
provisionedThroughput, jsonWriter); if (tableDescription.getTableSizeBytes() != null) { Long tableSizeBytes = tableDescription.getTableSizeBytes(); jsonWriter.name("TableSizeBytes"); jsonWriter.value(tableSizeBytes);
public DynamoTable(Table table) { table.describe(); tableName = table.getTableName(); attributeDefinitions = table.getDescription().getAttributeDefinitions().toString(); tableStatus = table.getDescription().getTableStatus(); keySchema = table.getDescription().getKeySchema().toString(); creationDateTime = new DateTime(table.getDescription().getCreationDateTime()); numberOfDecreasesToday = table.getDescription().getProvisionedThroughput().getNumberOfDecreasesToday(); readCapacityUnits = table.getDescription().getProvisionedThroughput().getReadCapacityUnits(); writeCapacityUnits = table.getDescription().getProvisionedThroughput().getWriteCapacityUnits(); tableSizeBytes = table.getDescription().getTableSizeBytes(); itemCount = table.getDescription().getItemCount(); tableArn = table.getDescription().getTableArn(); provisionedThroughput = table.getDescription().getProvisionedThroughput().toString(); globalSecondaryIndexes = new ArrayList<>(); if (table.getDescription().getGlobalSecondaryIndexes() != null) { for (GlobalSecondaryIndexDescription gsiDesc : table .getDescription() .getGlobalSecondaryIndexes()) { globalSecondaryIndexes.add(new DynamoGSI(gsiDesc)); } } }
/** * Marshall the given parameter object. */ public void marshall(TableDescription tableDescription, ProtocolMarshaller protocolMarshaller) { if (tableDescription == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(tableDescription.getAttributeDefinitions(), ATTRIBUTEDEFINITIONS_BINDING); protocolMarshaller.marshall(tableDescription.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(tableDescription.getKeySchema(), KEYSCHEMA_BINDING); protocolMarshaller.marshall(tableDescription.getTableStatus(), TABLESTATUS_BINDING); protocolMarshaller.marshall(tableDescription.getCreationDateTime(), CREATIONDATETIME_BINDING); protocolMarshaller.marshall(tableDescription.getProvisionedThroughput(), PROVISIONEDTHROUGHPUT_BINDING); protocolMarshaller.marshall(tableDescription.getTableSizeBytes(), TABLESIZEBYTES_BINDING); protocolMarshaller.marshall(tableDescription.getItemCount(), ITEMCOUNT_BINDING); protocolMarshaller.marshall(tableDescription.getTableArn(), TABLEARN_BINDING); protocolMarshaller.marshall(tableDescription.getTableId(), TABLEID_BINDING); protocolMarshaller.marshall(tableDescription.getBillingModeSummary(), BILLINGMODESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getLocalSecondaryIndexes(), LOCALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getGlobalSecondaryIndexes(), GLOBALSECONDARYINDEXES_BINDING); protocolMarshaller.marshall(tableDescription.getStreamSpecification(), STREAMSPECIFICATION_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamLabel(), LATESTSTREAMLABEL_BINDING); protocolMarshaller.marshall(tableDescription.getLatestStreamArn(), LATESTSTREAMARN_BINDING); protocolMarshaller.marshall(tableDescription.getRestoreSummary(), RESTORESUMMARY_BINDING); protocolMarshaller.marshall(tableDescription.getSSEDescription(), SSEDESCRIPTION_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }