Class: ProcessorPool
- Inherits:
-
Object
- Object
- ProcessorPool
- Defined in:
- lib/processor_pool.rb
Constant Summary collapse
- VERSION =
'1.0.0'
Instance Attribute Summary collapse
-
#started ⇒ Object
readonly
Returns the value of attribute started.
Class Method Summary collapse
-
.check_other_processors_in_pool ⇒ Object
check all of the registered processors in pool, except ourselves.
-
.establish_connection_with_s3 ⇒ Object
Establish connection with s3 and user defined details.
-
.get_instance_data ⇒ Object
determine which server pool to use by making a REST query to get the instance metadata.
-
.register_self_to_pool ⇒ Object
make ourselves available in the pool, if not yet registered.
-
.start(access_key_id, secret_access_key) ⇒ Object
Initiates the S3 connection.
Instance Attribute Details
#started ⇒ Object (readonly)
Returns the value of attribute started.
8 9 10 |
# File 'lib/processor_pool.rb', line 8 def started @started end |
Class Method Details
.check_other_processors_in_pool ⇒ Object
check all of the registered processors in pool, except ourselves
51 52 53 54 55 |
# File 'lib/processor_pool.rb', line 51 def check_other_processors_in_pool processors.each {|p| p.unregister if p.not_equal?(current_processor) && !p.active? } end |
.establish_connection_with_s3 ⇒ Object
Establish connection with s3 and user defined details
37 38 39 40 41 42 43 |
# File 'lib/processor_pool.rb', line 37 def establish_connection_with_s3 AWS::S3::Base.establish_connection!( :access_key_id => access_key_id, :secret_access_key => secret_access_key, :persistent => false ) end |
.get_instance_data ⇒ Object
determine which server pool to use by making a REST query to get the instance metadata
32 33 34 35 |
# File 'lib/processor_pool.rb', line 32 def get_instance_data @@server_pool_bucket = ProcessorInstanceInfo.server_pool_bucket @@host_name = ProcessorInstanceInfo.host_name end |
.register_self_to_pool ⇒ Object
make ourselves available in the pool, if not yet registered
45 46 47 48 49 |
# File 'lib/processor_pool.rb', line 45 def register_self_to_pool if !processors.include?(current_processor) current_processor.register end end |
.start(access_key_id, secret_access_key) ⇒ Object
Initiates the S3 connection
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/processor_pool.rb', line 14 def start(access_key_id, secret_access_key) raise MissingInformation.new(:access_key_id) unless access_key_id raise MissingInformation.new(:secret_access_key) unless secret_access_key get_instance_data establish_connection_with_s3 current_processor = Processor.new(@@server_pool_bucket, @@host_name) processors = Processors.registered(@@server_pool_bucket) register_self_to_pool check_other_processors_in_pool @started = true # Require sinatra for the user to use require "sinatra" end |