Parent

Class/Module Index [+]

Quicksearch

Fluent::ForwardOutput::Node

Attributes

available[W]
host[R]
name[R]
port[R]
sockaddr[R]
standby[W]
weight[RW]

Public Class Methods

new(name, host, port, weight, standby, failure, phi_threshold, recover_sample_size, expire_dns_cache) click to toggle source
# File lib/fluent/plugin/out_forward.rb, line 330
def initialize(name, host, port, weight, standby, failure,
               phi_threshold, recover_sample_size, expire_dns_cache)
  @name = name
  @host = host
  @port = port
  @weight = weight
  @standby = standby
  @failure = failure
  @phi_threshold = phi_threshold
  @recover_sample_size = recover_sample_size
  @expire_dns_cache = expire_dns_cache
  @available = true

  @resolved_host = nil
  @resolved_time = 0
  resolved_host  # check dns
end

Public Instance Methods

available?() click to toggle source
# File lib/fluent/plugin/out_forward.rb, line 352
def available?
  @available
end
heartbeat(detect=true) click to toggle source
# File lib/fluent/plugin/out_forward.rb, line 418
def heartbeat(detect=true)
  now = Time.now.to_f
  @failure.add(now)
  #$log.trace "heartbeat from '#{@name}'", :host=>@host, :port=>@port, :available=>@available, :sample_size=>@failure.sample_size
  if detect && !@available && @failure.sample_size > @recover_sample_size
    @available = true
    $log.info "recovered forwarding server '#{@name}'", :host=>@host, :port=>@port
    return true
  else
    return nil
  end
end
resolved_host() click to toggle source
# File lib/fluent/plugin/out_forward.rb, line 360
def resolved_host
  case @expire_dns_cache
  when 0
    # cache is disabled
    return resolve_dns!

  when nil
    # persistent cache
    return @resolved_host ||= resolve_dns!

  else
    now = Engine.now
    rh = @resolved_host
    if !rh || now - @resolved_time >= @expire_dns_cache
      rh = @resolved_host = resolve_dns!
      @resolved_time = now
    end
    return rh
  end
end
standby?() click to toggle source
# File lib/fluent/plugin/out_forward.rb, line 356
def standby?
  @standby
end
tick() click to toggle source
# File lib/fluent/plugin/out_forward.rb, line 388
def tick
  now = Time.now.to_f
  if !@available
    if @failure.hard_timeout?(now)
      @failure.clear
    end
    return nil
  end

  if @failure.hard_timeout?(now)
    $log.info "detached forwarding server '#{@name}'", :host=>@host, :port=>@port, :hard_timeout=>true
    @available = false
    @resolved_host = nil  # expire cached host
    @failure.clear
    return true
  end

  phi = @failure.phi(now)
  #$log.trace "phi '#{@name}'", :host=>@host, :port=>@port, :phi=>phi
  if phi > @phi_threshold
    $log.info "detached forwarding server '#{@name}'", :host=>@host, :port=>@port, :phi=>phi
    @available = false
    @resolved_host = nil  # expire cached host
    @failure.clear
    return true
  else
    return false
  end
end
to_msgpack(out = '') click to toggle source
# File lib/fluent/plugin/out_forward.rb, line 431
def to_msgpack(out = '')
  [@host, @port, @weight, @available].to_msgpack(out)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.