Class: TaskJuggler::ReportServerRecord

Inherits:
Object
  • Object
show all
Includes:
MessageHandler
Defined in:
lib/taskjuggler/daemon/ProjectServer.rb

Overview

This class stores the information about a ReportServer that was created by the ProjectServer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MessageHandler

#critical, #debug, #error, #fatal, #info, #warning

Constructor Details

#initialize(tag) ⇒ ReportServerRecord

Returns a new instance of ReportServerRecord.



419
420
421
422
423
424
425
426
427
428
# File 'lib/taskjuggler/daemon/ProjectServer.rb', line 419

def initialize(tag)
  # A random tag to uniquely identify the entry.
  @tag = tag
  # The URI of the ReportServer process.
  @uri = nil
  # The authentication key of the ReportServer.
  @authKey = nil
  # The DRbObject of the ReportServer.
  @reportServer = nil
end

Instance Attribute Details

#authKeyObject

Returns the value of attribute authKey.



417
418
419
# File 'lib/taskjuggler/daemon/ProjectServer.rb', line 417

def authKey
  @authKey
end

#tagObject (readonly)

Returns the value of attribute tag.



416
417
418
# File 'lib/taskjuggler/daemon/ProjectServer.rb', line 416

def tag
  @tag
end

#uriObject

Returns the value of attribute uri.



417
418
419
# File 'lib/taskjuggler/daemon/ProjectServer.rb', line 417

def uri
  @uri
end

Instance Method Details

#pingObject

Send a ping to the ReportServer process to check that it is still functioning properly. If not, it has probably terminated and we can remove it from the list of active ReportServers.



433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/taskjuggler/daemon/ProjectServer.rb', line 433

def ping
  return true unless @uri

  debug('', "Sending ping to ReportServer #{@uri}")
  begin
    @reportServer = DRbObject.new(nil, @uri) unless @reportServer
    @reportServer.ping(@authKey)
  rescue => exception
    # TjRuntimeError exceptions are simply passed through.
    if exception.is_a?(TjRuntimeError)
      raise TjRuntimeError, $!
    end

    # ReportServer processes terminate on request of their clients. Not
    # responding to a ping is a normal event.
    debug('', "ReportServer (#{@uri}) has terminated")
    return false
  end
  true
end