Chapter 09/circuit-oneops-1-master/components/cookbooks/couchbase/libraries/component/cbcluster_component.rb
#Custom formula to compute data availability for a bucket
Custom formula to compute data availability for a bucket
Custom formula to compute data availability for a bucket
def bucket_data_availability(bucket)
        return_value=nil
        healthy_nodes=@cluster.healthy_nodes
        failover_nodes=@cluster.failover_nodes
        bucket_info=@cluster.bucket_info(bucket)
        bucket_nodes_size=bucket_info.nodes_size
        bucket_replica_count=bucket_info.replica
        Chef::Log.info "data_availability:start: node_size = #{bucket_nodes_size}, replica_count = #{bucket_replica_count}, healthy_nodes = #{healthy_nodes}, failover_nodes = #{failover_nodes}"
        data_percent_per_node = 1.0 / bucket_nodes_size
        replica_data_percent_per_node = data_percent_per_node * bucket_replica_count
        replica_data_percent_per_node_with_failover = 0
        if (0 < failover_nodes)
          replica_data_percent_per_node_with_failover = replica_data_percent_per_node / (bucket_nodes_size - failover_nodes)
        end
        availability = (data_percent_per_node + replica_data_percent_per_node_with_failover) * healthy_nodes
        if (availability > 1)
          availability = 1
        end
        return_value = "#{'%.2f' % (availability * 100)}"
        Chef::Log.info "data_availability:end: return_value = #{return_value}"
        return return_value
      end
def bucket_data_availability ( bucket ) return_value = nil healthy_nodes = @cluster . healthy_nodes failover_nodes = @cluster . failover_nodes bucket_info = @cluster . bucket_info ( bucket ) bucket_nodes_size = bucket_info . nodes_size bucket_replica_count = bucket_info . replica Chef :: Log . info "data_availability:start: node_size = #{bucket_nodes_size}, replica_count = #{bucket_replica_count}, healthy_nodes = #{healthy_nodes}, failover_nodes = #{failover_nodes}" data_percent_per_node = 1.0 / bucket_nodes_size replica_data_percent_per_node = data_percent_per_node * bucket_replica_count replica_data_percent_per_node_with_failover = 0 if ( 0 < failover_nodes ) replica_data_percent_per_node_with_failover = replica_data_percent_per_node / ( bucket_nodes_size - failover_nodes ) end availability = ( data_percent_per_node + replica_data_percent_per_node_with_failover ) * healthy_nodes if ( availability > 1 ) availability = 1 end return_value = "#{'%.2f' % (availability * 100)}" Chef :: Log . info "data_availability:end: return_value = #{return_value}" return return_value end
Custom formula to compute data availability for a bucket
Custom formula to compute data availability for a bucket
#puts "data_availability:start: node_size = #{bucket_nodes_size}, replica_count = #{bucket_replica_count}, healthy_nodes = #{healthy_nodes}, failover_nodes = #{failover_nodes}"
bucket
<not_specific>