List of usage examples for com.amazonaws.services.dynamodbv2.model ProvisionedThroughputDescription getNumberOfDecreasesToday
public Long getNumberOfDecreasesToday()
The number of provisioned throughput decreases for this table during this UTC calendar day.
From source file:com.cfelde.aws.ddb.management.TableThroughput.java
License:Open Source License
public void updateDownscaleCounter() { synchronized (lock) { try {//from w w w . ja v a 2 s . c o m ProvisionedThroughputDescription ptd = ddb.describeTable(new DescribeTableRequest(tableName)) .getTable().getProvisionedThroughput(); downscaleCounter.set(ptd.getNumberOfDecreasesToday()); LOG.info("Current scale down counter value on " + tableName + ": " + ptd.getNumberOfDecreasesToday()); } catch (Throwable t) { LOG.error("Exception in updateDownscaleCounter: " + t.getMessage(), t); exceptionCounter.incrementAndGet(); } } }
From source file:com.cfelde.aws.ddb.management.TableThroughput.java
License:Open Source License
public void updateCapacity() { synchronized (lock) { try {/*from www. j ava 2s . c o m*/ if (lastTableChange.plusMinutes(3).isAfter(new DateTime())) return; long readCapacity = requestedReadCapacity.get(); long writeCapacity = requestedWriteCapacity.get(); if (readCapacity > maxReadLimit) readCapacity = maxReadLimit; if (readCapacity < minReadLimit) readCapacity = minReadLimit; if (writeCapacity > maxWriteLimit) writeCapacity = maxWriteLimit; if (writeCapacity < minWriteLimit) writeCapacity = minWriteLimit; ProvisionedThroughputDescription ptd = ddb.describeTable(new DescribeTableRequest(tableName)) .getTable().getProvisionedThroughput(); downscaleCounter.set(ptd.getNumberOfDecreasesToday()); final long currentReadCapacity = ptd.getReadCapacityUnits(); final long currentWriteCapacity = ptd.getWriteCapacityUnits(); // Make sure we don't try to scale up more than 100% if (readCapacity > currentReadCapacity * 2) readCapacity = currentReadCapacity * 2; if (writeCapacity > currentWriteCapacity * 2) writeCapacity = currentWriteCapacity * 2; if (!isDownscaleAllowed() && readCapacity < currentReadCapacity) readCapacity = currentReadCapacity; if (!isDownscaleAllowed() && writeCapacity < currentWriteCapacity) writeCapacity = currentWriteCapacity; // Check if no change if (readCapacity == currentReadCapacity && writeCapacity == currentWriteCapacity) return; /* if (readCapacity < currentReadCapacity || writeCapacity < currentWriteCapacity) downscaleAllowed.set(false); */ ProvisionedThroughput throughput = new ProvisionedThroughput(); throughput.withReadCapacityUnits(readCapacity); throughput.withWriteCapacityUnits(writeCapacity); UpdateTableRequest request = new UpdateTableRequest(tableName, throughput); LOG.info("Changing throughput on " + tableName + " to: reads: " + throughput.getReadCapacityUnits() + ", writes: " + throughput.getWriteCapacityUnits()); ddb.updateTable(request); lastTableChange = new DateTime(); } catch (Throwable t) { LOG.error("Exception in updateCapacity: " + t.getMessage(), t); exceptionCounter.incrementAndGet(); } } }
From source file:org.xmlsh.aws.util.AWSDDBCommand.java
License:BSD License
private void writeProvisionedThroughput(ProvisionedThroughputDescription provisionedThroughput) throws XMLStreamException { startElement("provisioned-throughput"); attribute("last-decrease", provisionedThroughput.getLastDecreaseDateTime()); attribute("last-increase", provisionedThroughput.getLastIncreaseDateTime()); attribute("decreases-today", provisionedThroughput.getNumberOfDecreasesToday()); attribute("read-capacity", provisionedThroughput.getReadCapacityUnits()); attribute("write-capacity", provisionedThroughput.getWriteCapacityUnits()); endElement();/*from w w w. j av a2s . c om*/ }