Sha256: 6d198c7cd213295aa7d23a4da61d3413d6cf6c387efb803675e8e346343e7e02

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8

module Eurydice
  module Pelops
    class Cluster
      def initialize(cluster, driver=::Pelops::Pelops)
        @cluster = cluster
        @driver = driver
      end
    
      def connected?
        @driver.create_cluster_manager(@cluster).cassandra_version
        true
      rescue Exception => e
        false
      end
    
      def keyspace(keyspace_name, options={})
        pool_name = options.fetch(:pool_name, "eurydice_#{keyspace_name}_pool")
        create = options.fetch(:create, true)
        @driver.add_pool(pool_name, @cluster, keyspace_name)
        keyspace = Keyspace.new(keyspace_name, @cluster, pool_name, @driver)
        keyspace.create! if create && !keyspace.exists?
        keyspace
      end
    
      def keyspaces
        keyspace_manager.keyspace_names.map { |ks_def| ks_def.name }
      end
      
      def nodes
        @cluster.nodes.map { |n| n.address }
      end
    
    private
  
      def keyspace_manager
        @keyspace_manager ||= @driver.create_keyspace_manager(@cluster)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
eurydice-1.2.5-java lib/eurydice/pelops/cluster.rb
eurydice-1.2.4-java lib/eurydice/pelops/cluster.rb
eurydice-1.2.3-java lib/eurydice/pelops/cluster.rb
eurydice-1.2.2-java lib/eurydice/pelops/cluster.rb
eurydice-1.2.1-java lib/eurydice/pelops/cluster.rb
eurydice-1.2.0-java lib/eurydice/pelops/cluster.rb
eurydice-1.1.1.b1-java lib/eurydice/pelops/cluster.rb
eurydice-1.1.0.b4-java lib/eurydice/pelops/cluster.rb
eurydice-1.1.0.b3-java lib/eurydice/pelops/cluster.rb
eurydice-1.1.0.b2-java lib/eurydice/pelops/cluster.rb
eurydice-1.0.3-java lib/eurydice/pelops/cluster.rb
eurydice-1.0.2-java lib/eurydice/pelops/cluster.rb
eurydice-1.0.1-java lib/eurydice/pelops/cluster.rb
eurydice-1.0.0-java lib/eurydice/pelops/cluster.rb