class TaskJuggler::ProjectRecord

The ProjectRecord objects are used to manage the loaded projects. There is one entry for each project in the @projects list.

Attributes

authKey[RW]
files[RW]
id[RW]
modified[RW]
readySince[RW]
reloading[RW]
state[RW]
tag[R]
uri[RW]

Public Class Methods

new(tag) click to toggle source
# File lib/taskjuggler/daemon/ProjectBroker.rb, line 583
def initialize(tag)
  # Before we know the project ID we use this tag to uniquely identify the
  # project.
  @tag = tag
  # Array of [ workingDir, tjp file, ... tji files ]
  @files = nil
  # The authentication key for the ProjectServer process.
  @authKey = nil
  # The DRb URI where the ProjectServer process is listening.
  @uri = nil
  # The ID of the project.
  @id = nil
  # The state of the project. :new, :loading, :ready, :failed
  # and :obsolete are supported.
  @state = :new
  # A time stamp when the project became ready for service.
  @readySince = nil
  # True if any of the input files have been modified after the load.
  @modified = false
  # True if the reload has already been triggered.
  @reloading = false

  @projectServer = nil
end

Public Instance Methods

ping() click to toggle source
# File lib/taskjuggler/daemon/ProjectBroker.rb, line 608
def ping
  return true unless @uri

  debug('', "Sending ping to ProjectServer #{@uri}")
  begin
    @projectServer = DRbObject.new(nil, @uri) unless @projectServer
    @projectServer.ping(@authKey)
  rescue
    warning('ping_failed', "Ping failed: #{$!}")
    return false
  end
  true
end
terminateServer() click to toggle source

Call this function to terminate the ProjectServer.

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 623
def terminateServer
  return unless @uri

  begin
    debug('', "Sending termination request to ProjectServer #{@uri}")
    @projectServer = DRbObject.new(nil, @uri) unless @projectServer
    @projectServer.terminate(@authKey)
  rescue
    error('proj_serv_term_failed',
          "Termination of ProjectServer failed: #{$!}")
  end
  @uri = nil
end
to_s(format, index) click to toggle source

This is used to generate the status table.

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 638
def to_s(format, index)
  sprintf(format, index, @id, @state, @modified ? '*' : ' ',
          @readySince ? @readySince.to_s('%Y-%m-%d %H:%M:%S') : '')
end