Class: RubyAemAws::Component::PublishDispatcher

Inherits:
Object
  • Object
show all
Includes:
AbstractGroupedComponent, AbstractSnapshot, HealthyResourceVerifier, MetricVerifier, SnapshotVerifier
Defined in:
lib/ruby_aem_aws/component/publish_dispatcher.rb

Overview

Interface to the AWS instance running the PublishDispatcher component of a full-set AEM stack.

Constant Summary collapse

EC2_COMPONENT =
'publish-dispatcher'.freeze
EC2_NAME =
'AEM Publish Dispatcher'.freeze
ELB_ID =
'PublishDispatcherLoadBalancer'.freeze
ELB_NAME =
'AEM Publish Dispatcher Load Balancer'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SnapshotVerifier

#snapshot?, #snapshots?

Methods included from MetricVerifier

#alarm?, #component_alarm?, #component_ec2_metric?, #component_log_event?, #component_log_stream?, #component_loggroup?, #component_metric?, #log_event?, #log_stream?, #loggroup?, #metric?

Methods included from RubyAemAws::CloudwatchClient

#get_alarm, #get_log_event, #get_log_streams, #get_metrics

Methods included from HealthyResourceVerifier

#health_state_asg, #health_state_elb, #healthy_asg?, #healthy_elb?, #wait_until_healthy_asg, #wait_until_healthy_elb

Methods included from AbstractSnapshot

#get_snapshot_by_id, #get_snapshots_by_type

Methods included from AbstractComponent

#to_s

Methods included from InstanceDescriber

#describe_instance, #describe_instances

Methods included from AbstractGroupedComponent

#get_all_instances, #get_instance_by_id, #get_num_of_instances, #get_random_instance

Constructor Details

#initialize(stack_prefix, params) ⇒ Object

  • AutoScalingClient: AWS AutoScalingGroup Client.

  • CloudWatchClient: AWS Cloudwatch Client.

  • CloudWatchLogsClient: AWS Cloudwatch Logs Client.

  • Ec2Resource: AWS EC2 Resource connection.

  • ElbClient: AWS ElasticLoadBalancer Client.

Parameters:

  • stack_prefix

    AWS tag: StackPrefix

  • params

    Array of AWS Clients and Resource connections:



45
46
47
48
49
50
51
52
53
54
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 45

def initialize(stack_prefix, params)
  @descriptor = ComponentDescriptor.new(stack_prefix,
                                        EC2Descriptor.new(EC2_COMPONENT, EC2_NAME),
                                        ELBDescriptor.new(ELB_ID, ELB_NAME))
  @asg_client = params[:AutoScalingClient]
  @cloud_watch_client = params[:CloudWatchClient]
  @cloud_watch_log_client = params[:CloudWatchLogsClient]
  @ec2_resource = params[:Ec2Resource]
  @elb_client = params[:ElbClient]
end

Instance Attribute Details

#asg_clientObject (readonly)

Returns the value of attribute asg_client.



25
26
27
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 25

def asg_client
  @asg_client
end

#cloud_watch_clientObject (readonly)

Returns the value of attribute cloud_watch_client.



25
26
27
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 25

def cloud_watch_client
  @cloud_watch_client
end

#cloud_watch_log_clientObject (readonly)

Returns the value of attribute cloud_watch_log_client.



25
26
27
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 25

def cloud_watch_log_client
  @cloud_watch_log_client
end

#descriptorObject (readonly)

Returns the value of attribute descriptor.



25
26
27
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 25

def descriptor
  @descriptor
end

#ec2_resourceObject (readonly)

Returns the value of attribute ec2_resource.



25
26
27
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 25

def ec2_resource
  @ec2_resource
end

#elb_clientObject (readonly)

Returns the value of attribute elb_client.



25
26
27
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 25

def elb_client
  @elb_client
end

Instance Method Details

#terminate_all_instancesObject



56
57
58
59
60
61
62
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 56

def terminate_all_instances
  get_all_instances.each do |i|
    next if i.nil?
    i.terminate
    i.wait_until_terminated
  end
end

#terminate_random_instanceObject



64
65
66
67
68
# File 'lib/ruby_aem_aws/component/publish_dispatcher.rb', line 64

def terminate_random_instance
  instance = get_random_instance
  instance.terminate
  instance.wait_until_terminated
end