Show
Ignore:
Timestamp:
03/02/10 11:28:24 (2 years ago)
Author:
romain.reuillon
Message:

Netlogo task, debug grouping

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/openmole/core/org.openmole.core.workflow.implementation/src/main/java/org/openmole/core/workflow/implementation/mole/execution/MoleExecution.java

    r3134 r3138  
    2828import java.util.logging.Level; 
    2929import java.util.logging.Logger; 
    30 import org.openmole.core.workflow.implementation.execution.jobgroup.JobCategorizer; 
    3130 
    3231import org.openmole.misc.exception.InternalProcessingError; 
     
    4140import org.openmole.core.workflow.implementation.job.JobBuild; 
    4241import org.openmole.core.workflow.implementation.job.MoleJobId; 
     42import org.openmole.core.workflow.implementation.mole.Mole; 
    4343import org.openmole.core.workflow.implementation.tools.LevelComputing; 
    4444import org.openmole.core.workflow.implementation.tools.RegistryWithTicket; 
    4545import org.openmole.core.workflow.model.capsule.IExplorationTaskCapsule; 
    46 import org.openmole.core.workflow.model.execution.batch.IJobGroupingStrategy; 
     46import org.openmole.core.workflow.model.job.IMoleJobGroupingStrategy; 
    4747import org.openmole.core.workflow.model.mole.execution.ISubMoleExecution; 
    4848import org.openmole.core.workflow.model.job.IContext; 
     
    6464    private static final Logger LOGGER = Logger.getLogger(MoleExecution.class.getName()); 
    6565     
    66     IMole mole; 
     66    Mole mole; 
    6767    BlockingQueue<Trio<IJob, IEnvironment<?>, IGenericTaskCapsule<?, ?>>> jobs = new LinkedBlockingQueue<Trio<IJob, IEnvironment<?>, IGenericTaskCapsule<?, ?>>>(); 
    6868    Map<IMoleJob, ISubMoleExecution> inProgress = Collections.synchronizedMap(new TreeMap<IMoleJob, ISubMoleExecution>()); 
     
    7272    IExecutionContext executionContext; 
    7373 
    74     Map<IGenericTaskCapsule<?, ?>, Duo<IJobGroupingStrategy, IExplorationTaskCapsule>> groupers = new HashMap<IGenericTaskCapsule<?, ?>, Duo<IJobGroupingStrategy, IExplorationTaskCapsule>>(); 
    7574    IRegistryWithTicket<IGenericTaskCapsule, JobCategorizer> categorizers = new RegistryWithTicket<IGenericTaskCapsule, JobCategorizer>(); 
    7675 
     
    7877    //transient Semaphore oneJobFinished; 
    7978 
    80     public MoleExecution(IMole mole, IContext rootContext, IExecutionContext executionContext) throws InternalProcessingError, UserBadDataError { 
     79    public MoleExecution(Mole mole, IContext rootContext, IExecutionContext executionContext) throws InternalProcessingError, UserBadDataError { 
    8180        this.mole = mole; 
    8281        this.localCommunication = new LocalCommunication(); 
     
    101100 
    102101    @Override 
    103     public synchronized void submit(IMoleJob job, IGenericTaskCapsule<?, ?> capsule, IExecutionContext execution, ISubMoleExecution subMole) throws UserBadDataError, InternalProcessingError { 
     102    public synchronized void submit(IMoleJob job, IGenericTaskCapsule<?, ?> capsule, IExecutionContext execution, ISubMoleExecution subMole) throws InternalProcessingError { 
    104103        ExecutionInfoRegistry.GetInstance().register(job, this); 
    105104        Activator.getEventDispatcher().registerListener(job, getLevel(), new MoleExecutionAdapter(this), MoleJob.stateChanged); 
     
    119118    } 
    120119 
    121     private synchronized JobBuild group(IMoleJob job, IGenericTaskCapsule<?, ?> capsule) throws UserBadDataError, InternalProcessingError { 
    122         if (groupers.containsKey(capsule)) { 
    123             Duo<IJobGroupingStrategy, IExplorationTaskCapsule> strategy = groupers.get(capsule); 
     120    private synchronized JobBuild group(IMoleJob job, IGenericTaskCapsule<?, ?> capsule) throws InternalProcessingError { 
     121         Duo<IMoleJobGroupingStrategy, IExplorationTaskCapsule> strategy = mole.getMoleJobGroupingStrategy(capsule); 
     122         
     123        if (strategy != null) { 
     124            
    124125            LevelComputing levelComputing = LevelComputing.getLevelComputing(this); 
    125126 
     
    127128            Integer levelOfCapsule = levelComputing.getLevel(capsule); 
    128129 
    129             if (levelOfExploration >= levelOfCapsule) { 
    130                 throw new UserBadDataError("Level of the exploration capsule is higher or the same than the one of the capsule, can't group."); 
     130            if (levelOfExploration != levelOfCapsule - 1) { 
     131                LOGGER.warning("The exploration capsule is not just under the capsule to group on, can't group."); 
     132                return new JobBuild(job); 
    131133            } 
    132134 
     
    158160            return group; 
    159161        } else { 
    160             JobBuild group = new JobBuild(1); 
    161             group.addJob(job); 
    162             return group; 
    163         } 
    164     } 
     162            return new JobBuild(job); 
     163        } 
     164    } 
     165 
     166 
    165167 
    166168    @Override 

logo cemagref

logo iscpif

logo lifegrid

logo region auvergne

logo patres project