Changeset 2025


Ignore:
Timestamp:
06/05/09 14:40:53 (12 years ago)
Author:
kgrading
Message:

added calendar behavior in the whole application (#669)

Location:
trunk/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Communication/3.2/WcfService.cs

    r1959 r2025  
    7676    public void Connect() {
    7777      try {
     78        if (String.Empty.Equals(ServerIP) || ServerPort == 0) {
     79          Logging.Instance.Info(this.ToString(), "No Server IP or Port set!");
     80          return;
     81        }
    7882        proxy = new ClientFacadeClient(
    7983          WcfSettings.GetStreamedBinding(),
     
    118122          ServerChanged(this, new EventArgs());
    119123    }
     124
     125    public void SetIPAndPort(String serverIP, int serverPort) {
     126      this.ServerIP = serverIP;
     127      this.ServerPort = serverPort;
     128    }
    120129   
    121130    /// <summary>
     
    159168          if (!res.Success) {
    160169            Logging.Instance.Error(this.ToString(), "Login Failed! " + res.StatusMessage);
    161             HandleNetworkError(null);
     170            HandleNetworkError(new Exception(res.StatusMessage));
    162171          } else {
    163172            ConnState = NetworkEnum.WcfConnState.Loggedin;
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/ConfigurationManager/UptimeManager.cs

    r2021 r2025  
    7272    }
    7373
    74     public bool isOnline(DateTime time) {
     74    public bool isOnline() {
    7575      foreach (Appointment app in Appointments)
    76         if ((time >= app.StartDate) &&
    77             (time <= app.EndDate))
     76        if ((DateTime.Now >= app.StartDate) &&
     77            (DateTime.Now <= app.EndDate))
    7878          return true;
    7979      return false;
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs

    r1990 r2025  
    8686      //Recover Server IP and Port from the Settings Framework
    8787      ConnectionContainer cc = ConfigManager.Instance.GetServerIPAndPort();     
    88       if (cc.IPAdress != String.Empty && cc.Port != 0) {
    89         wcfService.Connect(cc.IPAdress, cc.Port);
    90       }
    91    
     88      if (cc.IPAdress != String.Empty && cc.Port != 0)
     89        wcfService.SetIPAndPort(cc.IPAdress, cc.Port);
     90
     91      if (UptimeManager.Instance.isOnline())
     92        wcfService.Connect();
     93         
    9294      //Initialize the heartbeat
    9395      beat = new Heartbeat { Interval = 10000 };
     
    122124          break;
    123125        //Job has been successfully aborted
    124         case MessageContainer.MessageType.JobAborted:
    125           //todo: thread this
     126
     127
     128        case MessageContainer.MessageType.JobAborted:         
     129        //todo: thread this
    126130          Debug.WriteLine("Job aborted, he's dead");
    127131          lock (engines) {           
     
    138142          }
    139143          break;
     144       
     145       
    140146        //Request a Snapshot from the Execution Engine
    141147        case MessageContainer.MessageType.RequestSnapshot:
     
    145151            Logging.Instance.Error(this.ToString(), "RequestSnapshot: Engine doesn't exist");
    146152          break;
     153       
     154       
    147155        //Snapshot is ready and can be sent back to the Server
    148156        case MessageContainer.MessageType.SnapshotReady:
    149157          ThreadPool.QueueUserWorkItem(new WaitCallback(GetSnapshot), container.JobId);         
    150158          break;
     159       
     160       
    151161        //Pull a Job from the Server
    152162        case MessageContainer.MessageType.FetchJob:
     
    156166          }         
    157167          break;         
     168       
     169       
    158170        //A Job has finished and can be sent back to the server
    159171        case MessageContainer.MessageType.FinishedJob:
    160172          ThreadPool.QueueUserWorkItem(new WaitCallback(GetFinishedJob), container.JobId);         
    161173          break;     
     174       
     175       
     176        case MessageContainer.MessageType.UptimeLimitDisconnect:
     177          Logging.Instance.Info(this.ToString(), "Uptime Limit reached, storing jobs and sending them back");
     178          WcfService.Instance.Disconnect();
     179          break;
     180       
     181       
    162182        //Hard shutdown of the client
    163183        case MessageContainer.MessageType.Shutdown:
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Heartbeat.cs

    r1936 r2025  
    3939  /// </summary>
    4040  public class Heartbeat {
     41
     42    private bool offline;
     43
    4144    public double Interval { get; set; }   
    4245    private Timer heartbeatTimer = null;
     
    7275    void heartbeatTimer_Elapsed(object sender, ElapsedEventArgs e) {
    7376      Console.WriteLine("tick"); 
    74       ClientInfo info = ConfigManager.Instance.GetClientInfo();
    75       // Todo: remove tempfix for free cores.
     77      ClientInfo info = ConfigManager.Instance.GetClientInfo();     
    7678
    7779      PerformanceCounter counter = new PerformanceCounter("Memory", "Available Bytes", true);
    7880      int mb = (int)(counter.NextValue() / 1024 / 1024);
    79 
    80      
    8181
    8282      HeartBeatData heartBeatData = new HeartBeatData {
     
    8484        FreeCores = info.NrOfCores - ConfigManager.Instance.GetUsedCores(),
    8585        FreeMemory = mb,
    86         JobProgress = ConfigManager.Instance.GetProgressOfAllJobs()
     86        JobProgress = ConfigManager.Instance.GetProgressOfAllJobs()     
    8787      };
     88     
     89      DateTime lastFullHour = DateTime.Parse(DateTime.Now.Hour.ToString() + ":00");
     90      TimeSpan span = DateTime.Now - lastFullHour;
     91      if (span.TotalSeconds < (Interval/1000)) {
     92        if (UptimeManager.Instance.isOnline()) {
     93          //That's quiet simple: Just reconnect and you're good for new jobs
     94          if (wcfService.ConnState != NetworkEnum.WcfConnState.Connected) {
     95            Logging.Instance.Info(this.ToString(), "Client goes online according to timetable");
     96            wcfService.Connect();
     97          }
     98        } else {
     99          //We have quit a lot of work to do here: snapshot all jobs, submit them back, then disconnect and then pray to god that nothing goes wrong
     100          MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.UptimeLimitDisconnect);                 
     101        }       
     102      }
    88103      if (wcfService.ConnState == NetworkEnum.WcfConnState.Failed) {
    89104        wcfService.Connect();
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/JobStorage/JobStorageManager.cs

    r1959 r2025  
    4747          String filename = storedJobsList[index-1].ServerIP + "." + storedJobsList[index-1].ServerPort + "." + storedJobsList[index-1].JobID.ToString();         
    4848          Logging.Instance.Info("JobStorrageManager", "Sending stored job " + storedJobsList[index - 1].JobID + " to the server");
    49           byte[] job = File.ReadAllBytes(path + filename + ".dat");
    50 
    51           if (WcfService.Instance.IsJobStillNeeded(storedJobsList[index - 1].JobID).StatusMessage == ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT) {
    52             ResponseResultReceived res = WcfService.Instance.SendStoredJobResultsSync(ConfigManager.Instance.GetClientInfo().Id, storedJobsList[index - 1].JobID, job, 1.00, null, true);
    53             if (!res.Success)
    54               Logging.Instance.Error("JobStorageManager", "sending of job failed: " + res.StatusMessage);
    55             else
    56               Logging.Instance.Info("JobStorrageManager", "Sending of job " + storedJobsList[index - 1].JobID + " done");     
     49          try {
     50            byte[] job = File.ReadAllBytes(path + filename + ".dat");
     51            if (WcfService.Instance.IsJobStillNeeded(storedJobsList[index - 1].JobID).StatusMessage == ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT) {
     52              ResponseResultReceived res = WcfService.Instance.SendStoredJobResultsSync(ConfigManager.Instance.GetClientInfo().Id, storedJobsList[index - 1].JobID, job, 1.00, null, true);
     53              if (!res.Success)
     54                Logging.Instance.Error("JobStorageManager", "sending of job failed: " + res.StatusMessage);
     55              else
     56                Logging.Instance.Info("JobStorrageManager", "Sending of job " + storedJobsList[index - 1].JobID + " done");
     57            }
     58            ClientStatusInfo.JobsProcessed++;
     59            storedJobsList.Remove(storedJobsList[index - 1]);
     60            File.Delete(path + filename + ".dat");
    5761          }
    58           ClientStatusInfo.JobsProcessed++;
    59                  
    60          
    61 
    62           storedJobsList.Remove(storedJobsList[index - 1]);
    63           File.Delete(path + filename + ".dat");       
     62          catch (Exception e) {
     63            Logging.Instance.Error("JobStorrageManager", "Job not on hdd but on list - deleting job from list", e);
     64            storedJobsList.Remove(storedJobsList[index - 1]);
    6465          }
     66     
     67         }
    6568        }
    6669    }
  • trunk/sources/HeuristicLab.Hive.Contracts/3.2/MessageContainer.cs

    r1655 r2025  
    3333  public class MessageContainer {
    3434
    35     public enum MessageType { FetchJob, AbortJob, JobAborted, RequestSnapshot, FinishedJob, NoMessage, SnapshotReady, Shutdown, JobFailed };
     35    public enum MessageType { FetchJob, AbortJob, JobAborted, RequestSnapshot, FinishedJob, NoMessage, SnapshotReady, Shutdown, JobFailed, UptimeLimitDisconnect };
    3636
    3737    public MessageType Message { get; set; }
Note: See TracChangeset for help on using the changeset viewer.