@@ -53,25 +53,32 @@ const provisioner = new ConfigurableProvisioner({
53
53
54
54
let readCapacityPercent = Throughput . getReadCapacityUtilisationPercent ( data ) ;
55
55
let isAboveThreshold = readCapacityPercent > config . readCapacity . increment . thresholdPercent ;
56
- let isBelowMin = data . ProvisionedThroughput . ReadCapacityUnits <
57
- config . readCapacity . min ;
56
+ let isBelowMin = data . ProvisionedThroughput . ReadCapacityUnits < config . readCapacity . min ;
57
+ let isAtMax = data . ProvisionedThroughput . ReadCapacityUnits >= config . readCapacity . max ;
58
58
let isAdjustmentRequired = isAboveThreshold || isBelowMin ;
59
59
60
- let logName = typeof data . IndexName === 'undefined' ? data . TableName :
60
+ // Logging
61
+ let logMessage = typeof data . IndexName === 'undefined' ? data . TableName :
61
62
data . TableName + '.' + data . IndexName ;
62
-
63
- if ( isAboveThreshold ) {
64
- log ( logName + ' is at ' + readCapacityPercent +
65
- '% read capacity and above threshold of ' +
66
- config . readCapacity . increment . thresholdPercent + '%' ) ;
67
- } else if ( isBelowMin ) {
68
- log ( logName + ' is at ' + readCapacityPercent +
69
- '% read capacity and below minimum of ' + config . readCapacity . min + '%' ) ;
70
- } else if ( readCapacityPercent > 0 ) {
71
- log ( logName + ' is at ' + readCapacityPercent +
72
- '% read capacity and within minimum of ' + config . readCapacity . min +
73
- '% and threshold of ' + config . readCapacity . increment . thresholdPercent + '%' ) ;
63
+ logMessage += ' is consuming ' + data . ConsumedThroughput . ReadCapacityUnits + ' of ' +
64
+ data . ProvisionedThroughput . ReadCapacityUnits + ' (' + readCapacityPercent +
65
+ '%) read capacity units' ;
66
+ if ( isAtMax ) {
67
+ logMessage += ' and is already at max allowed ' + config . readCapacity . max + ' units' ;
68
+ }
69
+ if ( isAboveThreshold && ! isAtMax ) {
70
+ logMessage += ' and is above maximum threshold of ' +
71
+ config . readCapacity . increment . thresholdPercent + '%' ;
72
+ }
73
+ if ( isBelowMin ) {
74
+ logMessage += ' and is below the min allowed ' + config . readCapacity . min + ' units' ;
75
+ }
76
+ if ( isAdjustmentRequired ) {
77
+ logMessage += ' so an increment is REQUIRED' ;
78
+ } else {
79
+ logMessage += ' so an increment is not required' ;
74
80
}
81
+ log ( logMessage ) ;
75
82
76
83
return isAdjustmentRequired ;
77
84
} ,
@@ -101,11 +108,37 @@ const provisioner = new ConfigurableProvisioner({
101
108
102
109
let readCapacityPercent = Throughput . getReadCapacityUtilisationPercent ( data ) ;
103
110
let isBelowThreshold = readCapacityPercent < config . readCapacity . decrement . thresholdPercent ;
104
- let isAboveMax = data . ProvisionedThroughput . ReadCapacityUnits >
105
- config . readCapacity . max ;
106
-
107
- let isAdjustmentWanted = isBelowThreshold || isAboveMax ;
111
+ let isAboveMax = data . ProvisionedThroughput . ReadCapacityUnits > config . readCapacity . max ;
112
+ let isAtMin = data . ProvisionedThroughput . ReadCapacityUnits <= config . readCapacity . min ;
113
+ let isAdjustmentWanted = ( isBelowThreshold || isAboveMax ) && ! isAtMin ;
108
114
let isAdjustmentRequired = isReadDecrementAllowed && isAdjustmentWanted ;
115
+
116
+ // Logging
117
+ let logMessage = typeof data . IndexName === 'undefined' ? data . TableName :
118
+ data . TableName + '.' + data . IndexName ;
119
+ logMessage += ' is consuming ' + data . ConsumedThroughput . ReadCapacityUnits + ' of ' +
120
+ data . ProvisionedThroughput . ReadCapacityUnits + ' (' + readCapacityPercent +
121
+ '%) read capacity units' ;
122
+ if ( isAtMin ) {
123
+ logMessage += ' and is already at min allowed ' + config . readCapacity . min + ' units' ;
124
+ }
125
+ if ( isBelowThreshold && ! isAtMin ) {
126
+ logMessage += ' and is below minimum threshold of ' +
127
+ config . readCapacity . decrement . thresholdPercent + '%' ;
128
+ }
129
+ if ( isAboveMax ) {
130
+ logMessage += ' and is above the max allowed ' + config . readCapacity . max + ' units' ;
131
+ }
132
+ if ( isAdjustmentWanted ) {
133
+ logMessage += ' so a decrement is REQUESTED' ;
134
+ } else {
135
+ logMessage += ' so a decrement is not required' ;
136
+ }
137
+ if ( isAdjustmentWanted && ! isReadDecrementAllowed ) {
138
+ logMessage += ' but has been DISALLOWED due to rate limiting' ;
139
+ }
140
+ log ( logMessage ) ;
141
+
109
142
return isAdjustmentRequired ;
110
143
} ,
111
144
calculateValue : data => {
@@ -125,24 +158,32 @@ const provisioner = new ConfigurableProvisioner({
125
158
let writeCapacityPercent = Throughput . getWriteCapacityUtilisationPercent ( data ) ;
126
159
let isAboveThreshold = writeCapacityPercent >
127
160
config . writeCapacity . increment . thresholdPercent ;
161
+ let isAtMax = data . ProvisionedThroughput . WriteCapacityUnits >= config . writeCapacity . max ;
128
162
let isBelowMin = data . ProvisionedThroughput . WriteCapacityUnits < config . writeCapacity . min ;
129
163
let isAdjustmentRequired = isAboveThreshold || isBelowMin ;
130
164
131
- let logName = typeof data . IndexName === 'undefined' ? data . TableName :
165
+ // Logging
166
+ let logMessage = typeof data . IndexName === 'undefined' ? data . TableName :
132
167
data . TableName + '.' + data . IndexName ;
133
-
134
- if ( isAboveThreshold ) {
135
- log ( logName + ' is at ' + writeCapacityPercent +
136
- '% write capacity and above threshold of ' +
137
- config . writeCapacity . increment . thresholdPercent + '%' ) ;
138
- } else if ( isBelowMin ) {
139
- log ( logName + ' is at ' + writeCapacityPercent +
140
- '% write capacity and below minimum of ' + config . writeCapacity . min + '%' ) ;
141
- } else if ( writeCapacityPercent > 0 ) {
142
- log ( logName + ' is at ' + writeCapacityPercent +
143
- '% write capacity and within minimum of ' + config . writeCapacity . min +
144
- '% and threshold of ' + config . writeCapacity . increment . thresholdPercent + '%' ) ;
168
+ logMessage += ' is consuming ' + data . ConsumedThroughput . WriteCapacityUnits + ' of ' +
169
+ data . ProvisionedThroughput . WriteCapacityUnits + ' (' + writeCapacityPercent +
170
+ '%) write capacity units' ;
171
+ if ( isAtMax ) {
172
+ logMessage += ' and is already at max allowed ' + config . writeCapacity . max + ' units' ;
173
+ }
174
+ if ( isAboveThreshold && ! isAtMax ) {
175
+ logMessage += ' and is above maximum threshold of ' +
176
+ config . writeCapacity . increment . thresholdPercent + '%' ;
177
+ }
178
+ if ( isBelowMin ) {
179
+ logMessage += ' and is below the min allowed ' + config . writeCapacity . min + ' units' ;
180
+ }
181
+ if ( isAdjustmentRequired ) {
182
+ logMessage += ' so an increment is REQUIRED' ;
183
+ } else {
184
+ logMessage += ' so an increment is not required' ;
145
185
}
186
+ log ( logMessage ) ;
146
187
147
188
return isAdjustmentRequired ;
148
189
} ,
@@ -173,10 +214,37 @@ const provisioner = new ConfigurableProvisioner({
173
214
let writeCapacityPercent = Throughput . getWriteCapacityUtilisationPercent ( data ) ;
174
215
let isBelowThreshold = writeCapacityPercent <
175
216
config . writeCapacity . decrement . thresholdPercent ;
176
-
217
+ let isAtMin = data . ProvisionedThroughput . WriteCapacityUnits <= config . writeCapacity . min ;
177
218
let isAboveMax = data . ProvisionedThroughput . WriteCapacityUnits > config . writeCapacity . max ;
178
- let isAdjustmentWanted = isBelowThreshold || isAboveMax ;
219
+ let isAdjustmentWanted = ( isBelowThreshold || isAboveMax ) && ! isAtMin ;
179
220
let isAdjustmentRequired = isWriteDecrementAllowed && isAdjustmentWanted ;
221
+
222
+ // Logging
223
+ let logMessage = typeof data . IndexName === 'undefined' ? data . TableName :
224
+ data . TableName + '.' + data . IndexName ;
225
+ logMessage += ' is consuming ' + data . ConsumedThroughput . WriteCapacityUnits + ' of ' +
226
+ data . ProvisionedThroughput . WriteCapacityUnits + ' (' + writeCapacityPercent +
227
+ '%) write capacity units' ;
228
+ if ( isAtMin ) {
229
+ logMessage += ' and is already at min allowed ' + config . writeCapacity . min + ' units' ;
230
+ }
231
+ if ( isBelowThreshold && ! isAtMin ) {
232
+ logMessage += ' and is below minimum threshold of ' +
233
+ config . writeCapacity . decrement . thresholdPercent + '%' ;
234
+ }
235
+ if ( isAboveMax ) {
236
+ logMessage += ' and is above the max allowed ' + config . writeCapacity . max + ' units' ;
237
+ }
238
+ if ( isAdjustmentWanted ) {
239
+ logMessage += ' so a decrement is REQUESTED' ;
240
+ } else {
241
+ logMessage += ' so a decrement is not required' ;
242
+ }
243
+ if ( isAdjustmentWanted && ! isWriteDecrementAllowed ) {
244
+ logMessage += ' but has been DISALLOWED due to rate limiting' ;
245
+ }
246
+ log ( logMessage ) ;
247
+
180
248
return isAdjustmentRequired ;
181
249
} ,
182
250
calculateValue : data => {
0 commit comments