Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/09/11 01:47:51 (13 years ago)
Author:
ascheibe
Message:

#1233 server can now control the slave heartbeat interval

Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Convert.cs

    r6768 r6893  
    217217        OperatingSystem = source.OperatingSystem,
    218218        LastHeartbeat = source.LastHeartbeat,
    219         CpuUtilization = source.CpuUtilization
     219        CpuUtilization = source.CpuUtilization,
     220        HbInterval = source.HbInterval
    220221      };
    221222    }
     
    241242        target.LastHeartbeat = source.LastHeartbeat;
    242243        target.CpuUtilization = source.CpuUtilization;
     244        target.HbInterval = source.HbInterval;
    243245      }
    244246    }
     
    248250    public static DT.SlaveGroup ToDto(DB.SlaveGroup source) {
    249251      if (source == null) return null;
    250       return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId };
     252      return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval };
    251253    }
    252254    public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) {
     
    257259    public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) {
    258260      if ((source != null) && (target != null)) {
    259         target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
     261        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval;
    260262      }
    261263    }
     
    265267    public static DT.Resource ToDto(DB.Resource source) {
    266268      if (source == null) return null;
    267       return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId };
     269      return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval };
    268270    }
    269271    public static DB.Resource ToEntity(DT.Resource source) {
     
    274276    public static void ToEntity(DT.Resource source, DB.Resource target) {
    275277      if ((source != null) && (target != null)) {
    276         target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
     278        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval;
    277279      }
    278280    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Heartbeat.cs

    r6743 r6893  
    4040    [DataMember]
    4141    public float CpuUtilization { get; set; }
     42    [DataMember]
     43    public int HbInterval { get; set; }
    4244
    4345    public override string ToString() {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Resource.cs

    r6717 r6893  
    3030    public Guid? ParentResourceId { get; set; }
    3131
     32    [DataMember]
     33    public int HbInterval { get; set; }
     34
    3235    public Resource() { }
    3336  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r6764 r6893  
    446446
    447447    #region Slave Methods
     448    public int GetNewHeartbeatInterval(Guid slaveId) {
     449      authen.AuthenticateForAnyRole(HiveRoles.Slave);
     450      Slave s = dao.GetSlave(slaveId);
     451      if (s != null) {
     452        return s.HbInterval;
     453      } else {
     454        return -1;
     455      }
     456    }
     457
    448458    public Guid AddSlave(Slave slave) {
    449459      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     
    486496      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    487497      trans.UseTransaction(() => {
    488         dao.UpdateSlaveGroup(slaveGroup);
    489       });
     498        UpdateSlaveHBs(slaveGroup);
     499      });
     500    }
     501
     502    private void UpdateSlaveHBs(Resource r) {
     503      foreach (Resource resource in dao.GetChildResources(r.Id)) {
     504        if (resource is SlaveGroup) {
     505          resource.HbInterval = r.HbInterval;
     506          dao.UpdateSlaveGroup(resource as SlaveGroup);
     507          UpdateSlaveHBs(resource);
     508        } else if (resource is Slave) {
     509          resource.HbInterval = r.HbInterval;
     510          dao.UpdateSlave(resource as Slave);
     511        }
     512      }
    490513    }
    491514
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r6764 r6893  
    4545        actions.Add(new MessageContainer(MessageContainer.MessageType.SayHello));
    4646      } else {
     47        Slave s = dao.GetSlave(heartbeat.SlaveId);
     48        if (s != null) {
     49          if (heartbeat.HbInterval != s.HbInterval) {
     50            actions.Add(new MessageContainer(MessageContainer.MessageType.NewHBInterval));
     51          }
     52        }
     53
    4754        // update slave data
    4855        slave.FreeCores = heartbeat.FreeCores;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/MessageContainer.cs

    r6743 r6893  
    4848      ShutdownSlave,  // slave should shutdown immediately without submitting results
    4949      SayHello,  // Slave should say hello, because job is unknown to the server
     50      NewHBInterval,
    5051    };
    5152
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r6743 r6893  
    203203    [OperationContract]
    204204    void TriggerEventManager(bool force);
     205
     206    [OperationContract]
     207    int GetNewHeartbeatInterval(Guid slaveId);
    205208    #endregion
    206209
Note: See TracChangeset for help on using the changeset viewer.