Class: TinyPresto::Cluster
- Inherits:
-
Object
- Object
- TinyPresto::Cluster
- Defined in:
- lib/tiny-presto/cluster.rb
Overview
Represents a Presto cluster
Instance Method Summary collapse
-
#initialize(image = 'trinodb/trino', tag = 'latest') ⇒ Cluster
constructor
A new instance of Cluster.
-
#run ⇒ Object
Launch Presto cluster running on Docker container.
-
#stop ⇒ Object
Kill Presto cluster process.
Constructor Details
#initialize(image = 'trinodb/trino', tag = 'latest') ⇒ Cluster
Returns a new instance of Cluster.
9 10 11 12 |
# File 'lib/tiny-presto/cluster.rb', line 9 def initialize(image = 'trinodb/trino', tag = 'latest') @tag = tag @image_name = "#{image}:#{@tag}" end |
Instance Method Details
#run ⇒ Object
Launch Presto cluster running on Docker container
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tiny-presto/cluster.rb', line 15 def run # Ensure to pull the specified image Docker::Image.create('fromImage' => @image_name) @container = Docker::Container.create( 'Image' => @image_name, 'HostConfig' => { 'PortBindings' => { '8080/tcp' => [ { 'HostPort' => '8080' } ] } } ) @container.start @container end |
#stop ⇒ Object
Kill Presto cluster process
35 36 37 |
# File 'lib/tiny-presto/cluster.rb', line 35 def stop @container.stop end |