Free cookie consent management tool by TermsFeed Policy Generator

Changeset 504 for trunk


Ignore:
Timestamp:
08/12/08 15:38:27 (16 years ago)
Author:
gkronber
Message:

reenabled waiting/running/finished counters (#197 Use SQLite backend to store waiting engines and results instead of in-memory dictionaries)

Location:
trunk/sources/HeuristicLab.Grid
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Grid/Database.cs

    r502 r504  
    274274    }
    275275
     276    internal long GetJobCount(JobState status) {
     277      rwLock.EnterReadLock();
     278      try {
     279        using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
     280          cnn.Open();
     281          DbCommand c = cnn.CreateCommand();
     282          c.CommandText = "Select Count(id) from Job where Status=@Status";
     283          DbParameter stateParameter = c.CreateParameter();
     284          stateParameter.ParameterName = "@Status";
     285          stateParameter.Value = status.ToString();
     286          c.Parameters.Add(stateParameter);
     287          return (long)c.ExecuteScalar();
     288        }
     289      } finally {
     290        rwLock.ExitReadLock();
     291      }
     292    }
     293
    276294    /// <summary>
    277295    /// Does nothing right now (= running jobs that disappear are never restarted).
  • trunk/sources/HeuristicLab.Grid/EngineStore.cs

    r502 r504  
    6464        database = new Database(connectionString);
    6565      }
     66
     67      // init counters
     68      waitingJobs = (int)database.GetJobCount(JobState.Waiting);
     69      runningJobs = (int)database.GetJobCount(JobState.Busy);
     70      results = (int)database.GetJobCount(JobState.Finished);
    6671    }
    6772
     
    7479        guid = nextWaitingJob.Guid;
    7580        engine = nextWaitingJob.RawData;
     81        runningJobs++;
     82        waitingJobs--;
    7683        return true;
    7784      }
     
    8289      // add the new result
    8390      database.SetJobResult(guid, result);
     91      results++;
    8492    }
    8593
    8694    internal void AddEngine(Guid guid, byte[] engine) {
    87       database.InsertJob(guid, HeuristicLab.Grid.JobState.Waiting, engine);
     95      database.InsertJob(guid, JobState.Waiting, engine);
     96      waitingJobs++;
    8897    }
    8998
    9099    internal byte[] GetResult(Guid guid) {
    91       if(JobState(guid) == HeuristicLab.Grid.JobState.Finished) {
     100      if(GetJobState(guid) == JobState.Finished) {
    92101        JobEntry entry = database.GetJob(guid);
    93102        return entry.RawData;
     
    100109    }
    101110
    102     internal JobState JobState(Guid guid) {
     111    internal JobState GetJobState(Guid guid) {
    103112      return database.GetJobState(guid);
    104113    }
  • trunk/sources/HeuristicLab.Grid/GridServer.cs

    r501 r504  
    3636
    3737    public JobState JobState(Guid guid) {
    38       return engineStore.JobState(guid);
     38      return engineStore.GetJobState(guid);
    3939    }
    4040
Note: See TracChangeset for help on using the changeset viewer.