Class: DynamoAutoscale::DynamoActioner
Instance Attribute Summary
Attributes inherited from Actioner
#downscales, #table, #upscales
Instance Method Summary
collapse
Methods included from Logger
included, logger, #logger, logger=
Methods inherited from Actioner
#check_day_reset!, #clear_pending!, #downscale, #flush_operations!, #initialize, maximum_throughput, maximum_throughput=, minimum_throughput, minimum_throughput=, #pending_reads?, #pending_writes?, #provisioned_for, #provisioned_reads, #provisioned_writes, #queue_operation!, #set, #should_flush?, #try_flush!, #upscale
Instance Method Details
#can_run? ⇒ Boolean
38
39
40
|
# File 'lib/dynamo-autoscale/dynamo_actioner.rb', line 38
def can_run?
dynamo.status == :active
end
|
#dynamo ⇒ Object
5
6
7
|
# File 'lib/dynamo-autoscale/dynamo_actioner.rb', line 5
def dynamo
@dynamo ||= AWS::DynamoDB.new.tables[table.name]
end
|
#scale(metric, value) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/dynamo-autoscale/dynamo_actioner.rb', line 9
def scale metric, value
aws_throughput_key = case metric
when :reads
:read_capacity_units
when :writes
:write_capacity_units
end
if throughput_synced?
dynamo_scale(aws_throughput_key => value)
else
clear_pending!
false
end
end
|
#scale_both(reads, writes) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/dynamo-autoscale/dynamo_actioner.rb', line 27
def scale_both reads, writes
if throughput_synced?
dynamo_scale(read_capacity_units: reads, write_capacity_units: writes)
else
clear_pending!
false
end
end
|
#throughput_synced? ⇒ Boolean
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/dynamo-autoscale/dynamo_actioner.rb', line 42
def throughput_synced?
time, datum = table.data.last
return false if time.nil? or datum.nil?
if dynamo.read_capacity_units != datum[:provisioned_reads]
logger.error "[actioner] DynamoDB disagrees with CloudWatch on what " +
"the provisioned reads are. To be on the safe side, operations are " +
"not being applied."
return false
end
if dynamo.write_capacity_units != datum[:provisioned_writes]
logger.error "[actioner] DynamoDB disagrees with CloudWatch on what " +
"the provisioned writes are. To be on the safe side, operations are " +
"not being applied."
return false
end
return true
end
|