Changeset 1048


Ignore:
Timestamp:
05/23/13 22:25:55 (12 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gssim/trunk/src/gssim/schedframe/scheduling/queues/TaskQueue.java

    r5 r1048  
    44import grms.shared.constants.BrokerConstants; 
    55import org.qcg.broker.schemas.resreqs.ParentType; 
     6import org.qcg.broker.schemas.resreqs.Workflow; 
    67import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
    78//import org.qcg.broker.schemas.resreqs.types.WorkflowParentStatesType; 
     
    6061                        int previousTaskReadyCnt = 0; 
    6162                        Task task = this.get(i); 
     63                         
    6264                        if(task.getStatus() != (int)BrokerConstants.TASK_STATUS_UNSUBMITTED) 
    6365                                continue; 
    64                         try{             
    65                                 parCnt = task.getDescription().getWorkflow().getParentCount(); 
    66                         } catch(Exception e){ 
    67                                 parCnt = 0; 
    68                                 //e.printStackTrace(); 
     66                        //the following procedure supports only one nested structure 
     67                        Workflow w = task.getDescription().getWorkflow(); 
     68                        if (w == null){ 
     69                                readyTasks.add(task); 
     70                                continue; 
    6971                        } 
    70                         if(parCnt == 0) 
    71                         { 
    72                                 readyTasks.add(task); 
     72                        if(w.getAnd() != null) { 
     73                                parCnt = w.getAnd().getParentOpTypeItemCount(); 
     74                                if(parCnt == 0) 
     75                                { 
     76                                        readyTasks.add(task); 
     77                                } 
     78                                else 
     79                                { 
     80                                        for(int j = 0; j < parCnt; j++){ 
     81                                                ParentType par = w.getAnd().getParentOpTypeItem(j).getParent(); 
     82                                                if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){ 
     83                                                        if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){ 
     84                                                                break; 
     85                                                        } 
     86                                                } 
     87                                                previousTaskReadyCnt++; 
     88                                        } 
     89 
     90                                        if(previousTaskReadyCnt == parCnt) 
     91                                                readyTasks.add(task); 
     92                                } 
     93                        }  
     94                        else if(w.getOr() != null) { 
     95                                parCnt = w.getOr().getParentOpTypeItemCount(); 
     96                                if(parCnt == 0) 
     97                                { 
     98                                        readyTasks.add(task); 
     99                                } 
     100                                else 
     101                                { 
     102                                        for(int j = 0; j < parCnt; j++){ 
     103                                                ParentType par = w.getOr().getParentOpTypeItem(j).getParent(); 
     104                                                if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){ 
     105                                                        if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){ 
     106                                                                continue; 
     107                                                        } 
     108                                                } 
     109                                                previousTaskReadyCnt++; 
     110                                        } 
     111 
     112                                        if(previousTaskReadyCnt > 0) 
     113                                                readyTasks.add(task); 
     114                                } 
    73115                        } 
    74                         else 
    75                         { 
    76                                 for(int j = 0; j < parCnt; j++){ 
    77                                         ParentType par = task.getDescription().getWorkflow().getParent(j); 
    78                                         if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){ 
    79                                                 if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){ 
    80                                                         break; 
     116                         
     117                        else { 
     118                                parCnt = w.getParentCount(); 
     119                                if(parCnt == 0) 
     120                                { 
     121                                        readyTasks.add(task); 
     122                                } 
     123                                else 
     124                                { 
     125                                        for(int j = 0; j < parCnt; j++){ 
     126                                                ParentType par = w.getParent(j); 
     127                                                if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){ 
     128                                                        if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){ 
     129                                                                continue; 
     130                                                        } 
    81131                                                } 
     132                                                previousTaskReadyCnt++; 
    82133                                        } 
    83                                         previousTaskReadyCnt++; 
     134 
     135                                        if(previousTaskReadyCnt == parCnt) 
     136                                                readyTasks.add(task); 
    84137                                } 
    85                                  
    86 /*                               
    87                                 if(previousTaskReadyCnt == parCnt && task.getDescription().getWorkflow().getParentStates() == WorkflowParentStatesType.AND) 
    88                                         readyTasks.add(task); 
    89                                 else if(previousTaskReadyCnt > 0 && task.getDescription().getWorkflow().getParentStates() == WorkflowParentStatesType.OR) 
    90                                         readyTasks.add(task); 
    91                                          
    92                                 Because of schama changes above commented code was replaced by the following one.  
    93                                 I strongly believe that this new solution is equivalent. 
    94                                  
    95         */               
    96                                 if(previousTaskReadyCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null) 
    97                                         readyTasks.add(task); 
    98                                 else if(previousTaskReadyCnt > 0 && task.getDescription().getWorkflow().getOr() != null) 
    99                                         readyTasks.add(task); 
    100138                        } 
     139 
    101140                }                
    102141                return readyTasks; 
Note: See TracChangeset for help on using the changeset viewer.