Free cookie consent management tool by TermsFeed Policy Generator

Changeset 419 for trunk/sources


Ignore:
Timestamp:
08/01/08 17:59:19 (16 years ago)
Author:
gkronber
Message:

worked on #211 need to patch the operator-graph of an agent before execution (replacing the OperatorLinks with their targets).

work in progress...

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Core/OperatorLink.cs

    r418 r419  
    1111    public long Id {
    1212      get { return id; }
    13     } 
     13    }
    1414
    1515    private IOperator myOperator;
     
    2121    public OperatorLink() : base() { } // for cloning and persistence
    2222
    23     public OperatorLink(long id, IOperator op): base() {
     23    public OperatorLink(long id, IOperator op)
     24      : base() {
    2425      this.id = id;
    2526      this.myOperator = op;
     
    3031      throw new NotSupportedException();
    3132    }
    32 
    33     //public override void AddConstraint(IConstraint constraint) {
    34     //  throw new NotSupportedException();
    35     //}
    36 
    37     //public override void AddVariable(IVariable variable) {
    38     //  throw new NotSupportedException();
    39     //}
    40 
    41     //public override void AddVariableInfo(IVariableInfo variableInfo) {
    42     //  throw new NotSupportedException();
    43     //}
    4433
    4534    public override IOperation Apply(IScope scope) {
     
    7463      base.Populate(node, restoredObjects);
    7564    }
    76 
    77     //public override void RemoveConstraint(IConstraint constraint) {
    78     //  throw new NotSupportedException();
    79     //}
    80 
    81     //public override void RemoveVariable(string name) {
    82     //  throw new NotSupportedException();
    83     //}
    84 
    85     //public override void RemoveVariableInfo(string formalName) {
    86     //  throw new NotSupportedException();
    87     //}
    8865  }
    8966}
  • trunk/sources/HeuristicLab.CEDMA.DB/Database.cs

    r417 r419  
    5555            }
    5656            using(DbCommand cmd = cnn.CreateCommand()) {
    57               cmd.CommandText = "CREATE TABLE Agent (ID integer primary key autoincrement, ProjectId integer, ParentAgentId integer, Name text, Status text default "+ProcessStatus.Unknown+", CreationTime DateTime, RawData Blob)";
     57              cmd.CommandText = "CREATE TABLE Agent (ID integer primary key autoincrement, ProjectId integer, ParentAgentId integer, Name text, Status text default " + ProcessStatus.Unknown + ", CreationTime DateTime, RawData Blob)";
    5858              cmd.Transaction = t;
    5959              cmd.ExecuteNonQuery();
     
    365365            agent.Status = status;
    366366            agent.Id = r.GetInt32(0);
    367             agent.Name = r.IsDBNull(1)?"":r.GetString(1);
     367            agent.Name = r.IsDBNull(1) ? "" : r.GetString(1);
    368368            agent.RawData = (byte[])r.GetValue(2);
    369369            agents.Add(agent);
     
    389389                agent.ParentAgentId = null;
    390390                agent.Id = r.GetInt32(0);
    391                 agent.Name = r.IsDBNull(1)?"-":r.GetString(1);
     391                agent.Name = r.IsDBNull(1) ? "-" : r.GetString(1);
    392392                agent.Status = (ProcessStatus)Enum.Parse(typeof(ProcessStatus), r.GetString(2));
    393393                agent.RawData = (byte[])r.GetValue(3);
     
    421421                agent.ParentAgentId = parentAgentId;
    422422                agent.Id = r.GetInt32(0);
    423                 agent.Name = r.IsDBNull(1)?"-":r.GetString(1);
     423                agent.Name = r.IsDBNull(1) ? "-" : r.GetString(1);
    424424                agent.Status = (ProcessStatus)Enum.Parse(typeof(ProcessStatus), r.GetString(2));
    425425                agent.RawData = (byte[])r.GetValue(3);
     
    523523      return operators;
    524524    }
     525    public OperatorEntry GetOperator(long id) {
     526      rwLock.EnterReadLock();
     527      try {
     528        using(DbConnection cnn = new SQLiteConnection(connectionString)) {
     529          cnn.Open();
     530          using(DbCommand c = cnn.CreateCommand()) {
     531            c.CommandText = "Select id, name, rawdata from Operator where id=@Id";
     532            DbParameter idParam = c.CreateParameter();
     533            idParam.ParameterName = "@Id";
     534            idParam.Value = id;
     535            c.Parameters.Add(idParam);
     536            using(DbDataReader r = c.ExecuteReader()) {
     537              r.Read();
     538              OperatorEntry op = new OperatorEntry();
     539              op.Id = r.GetInt32(0);
     540              op.Name = r.IsDBNull(1) ? "-" : r.GetString(1);
     541              op.RawData = (byte[])r.GetValue(2);
     542              return op;
     543            }
     544          }
     545        }
     546      } finally {
     547        rwLock.ExitReadLock();
     548      }
     549    }
    525550    #endregion
    526551
  • trunk/sources/HeuristicLab.CEDMA.Server/HeuristicLab.CEDMA.Server.csproj

    r403 r419  
    7171  </ItemGroup>
    7272  <ItemGroup>
     73    <ProjectReference Include="..\HeuristicLab.CEDMA.Core\HeuristicLab.CEDMA.Core.csproj">
     74      <Project>{C27DDF6C-84DF-45EF-B82F-57A28DD51166}</Project>
     75      <Name>HeuristicLab.CEDMA.Core</Name>
     76    </ProjectReference>
    7377    <ProjectReference Include="..\HeuristicLab.CEDMA.DB.Interfaces\HeuristicLab.CEDMA.DB.Interfaces.csproj">
    7478      <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project>
     
    9094      <Project>{545CE756-98D8-423B-AC2E-6E7D70926E5C}</Project>
    9195      <Name>HeuristicLab.Grid</Name>
     96    </ProjectReference>
     97    <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj">
     98      <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project>
     99      <Name>HeuristicLab.Operators</Name>
    92100    </ProjectReference>
    93101    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
  • trunk/sources/HeuristicLab.CEDMA.Server/RunScheduler.cs

    r403 r419  
    3131using System.Diagnostics;
    3232using HeuristicLab.Data;
     33using HeuristicLab.CEDMA.Core;
     34using HeuristicLab.Operators;
    3335
    3436namespace HeuristicLab.CEDMA.Server {
     
    7375        scope.AddVariable(new Variable("CedmaServerUri", new StringData(serverUri)));
    7476        IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(entry.RawData);
    75         AtomicOperation op = new AtomicOperation(opGraph.InitialOperator, scope);
     77
     78        foreach(IOperator op in opGraph.Operators) {
     79          PatchLinks(op);
     80        }
     81
     82        AtomicOperation operation = new AtomicOperation(opGraph.InitialOperator, scope);
    7683        WaitHandle wHandle;
    7784        lock(remoteCommLock) {
    78           wHandle = jobManager.BeginExecuteOperation(op.Scope, op);
     85          wHandle = jobManager.BeginExecuteOperation(operation.Scope, operation);
    7986          database.UpdateAgent(entry.Id, ProcessStatus.Active);
    8087        }
     
    8289        Job job = new Job();
    8390        job.AgentId = entry.Id;
    84         job.Operation = op;
     91        job.Operation = operation;
    8592        job.WaitHandle = wHandle;
    8693
     
    9097        }
    9198      }
     99    }
     100
     101    private void PatchLinks(IOperator op) {
     102      if(op is OperatorLink) {
     103        OperatorLink link = op as OperatorLink;
     104        OperatorEntry targetEntry = database.GetOperator(link.Id);
     105        IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
     106        ReplaceOperatorInGraph(link, target);
     107      } else if(op is CombinedOperator) {
     108        CombinedOperator combinedOp = op as CombinedOperator;
     109        foreach(IOperator internalOp in combinedOp.OperatorGraph.Operators) {
     110          PatchLinks(internalOp);
     111        }
     112      }
     113    }
     114
     115    private void ReplaceOperatorInGraph(OperatorLink link, IOperator target) {
     116      throw new NotImplementedException();
    92117    }
    93118
Note: See TracChangeset for help on using the changeset viewer.