Class TaskJuggler::ProjectRecord
In: lib/taskjuggler/daemon/ProjectBroker.rb
Parent: Monitor

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

Methods

new   ping   terminateServer   to_s  

Attributes

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

Public Class methods

[Source]

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 574
    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

      @log = LogFile.instance
      @projectServer = nil
    end

Public Instance methods

[Source]

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 600
    def ping
      return true unless @uri

      @log.debug("Sending ping to ProjectServer #{@uri}")
      begin
        @projectServer = DRbObject.new(nil, @uri) unless @projectServer
        @projectServer.ping(@authKey)
      rescue
        @log.error("Ping failed: #{$!}")
        return false
      end
      true
    end

Call this function to terminate the ProjectServer.

[Source]

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

      begin
        @log.debug("Sending termination request to ProjectServer #{@uri}")
        @projectServer = DRbObject.new(nil, @uri) unless @projectServer
        @projectServer.terminate(@authKey)
      rescue
        @log.error("Termination of ProjectServer failed: #{$!}")
      end
      @uri = nil
    end

This is used to generate the status table.

[Source]

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

[Validate]