Class: TaskJuggler::ProjectRecord

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MessageHandler

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

Constructor Details

#initialize(tag) ⇒ ProjectRecord

Returns a new instance of ProjectRecord.



584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 584

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

Instance Attribute Details

#authKeyObject

Returns the value of attribute authKey.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def authKey
  @authKey
end

#filesObject

Returns the value of attribute files.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def files
  @files
end

#idObject

Returns the value of attribute id.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def id
  @id
end

#modifiedObject

Returns the value of attribute modified.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def modified
  @modified
end

#readySinceObject

Returns the value of attribute readySince.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def readySince
  @readySince
end

#reloadingObject

Returns the value of attribute reloading.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def reloading
  @reloading
end

#stateObject

Returns the value of attribute state.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def state
  @state
end

#tagObject (readonly)

Returns the value of attribute tag.



582
583
584
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 582

def tag
  @tag
end

#uriObject

Returns the value of attribute uri.



580
581
582
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 580

def uri
  @uri
end

Instance Method Details

#pingObject



609
610
611
612
613
614
615
616
617
618
619
620
621
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 609

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

#terminateServerObject

Call this function to terminate the ProjectServer.



624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 624

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) ⇒ Object

This is used to generate the status table.



639
640
641
642
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 639

def to_s(format, index)
  sprintf(format, index, @id, @state, @modified ? '*' : ' ',
          @readySince ? @readySince.to_s('%Y-%m-%d %H:%M:%S') : '')
end