Package jmt.engine.QueueNet

Examples of jmt.engine.QueueNet.JobInfo


      }
    }

    //print
    ListIterator iterator = list.getJobList().listIterator();
    JobInfo current = null;
    String className;
    int classPr, jobID;

    String strategyType = "";

    switch (strategy) {
      case STRATEGY_HEAD:
        strategyType = "HEAD";
        break;
      case STRATEGY_TAIL:
        strategyType = "TAIL";
        break;
      case STRATEGY_HEAD_PRIORITY:
        strategyType = "HEAD_PR";
        break;
      case STRATEGY_TAIL_PRIORITY:
        strategyType = "TAIL_PR";
        break;
    }

    System.out.println(strategyType);

    //iterator starts from the first (i.e. the job with highest priority)
    while (iterator.hasNext()) {
      current = (JobInfo) iterator.next();

      jobID = current.getJob().getId();
      className = current.getJob().getJobClass().getName();
      classPr = current.getJob().getJobClass().getPriority();

      System.out.println("Job: " + jobID + " Class: " + className + " Priority: " + classPr);

    }
View Full Code Here


        // Resets ack count
        ackCount = 0;

        // Removes job from global node list
        JobInfoList info = getOwnerNode().getJobInfoList();
        JobInfo jobData = info.lookFor(job);
        if (jobData != null) {
          info.remove(jobData);
        }

        // Gets global jobInfoList
View Full Code Here

        //before the jobinfo objects weren't removed (often causing outOfMemory errors!!!)

        if (jobsList_node == null) {
          jobsList_node = this.getOwnerNode().getJobInfoList();
        }
        JobInfo jobInfo_node = jobsList_node.lookFor(job);
        if (jobInfo_node != null) {
          //removes job from the jobInfoList of the node
          jobsList_node.removeAfterDrop(jobInfo_node);
        }
        //end NEW
View Full Code Here

        if (job instanceof ForkJob) {
          ForkJob fJob = (ForkJob) job;

          // Removes job from global node list
          JobInfoList info = getOwnerNode().getJobInfoList();
          JobInfo jobData = info.lookFor(job);
          if (jobData != null) {
            info.remove(jobData);
          }

          // Removes job from system list
          GlobalJobInfoList global = getOwnerNode().getQueueNet().getJobInfoList();
          global.removeForkedJob(fJob);

          // Needed pieces
          int needed;
          if (jobs.containsKey(fJob.getForkedJob())) {
            needed = jobs.get(fJob.getForkedJob()).intValue();
          } else {
            needed = fJob.getForkedNumber();
            // As we are waiting for other fragments, adds merged job to global and local info list
            JobInfo merged = new JobInfo(fJob.getForkedJob());
            info.add(merged);
            jobsList.add(merged);
          }
          // Decrement needed as we received this job
          needed--;
View Full Code Here

    //list of jobs in queue
    List<JobInfo> list = queue.getJobList();

    if (list.size() == 0) {
      //empty list: add first
      queue.addFirst(new JobInfo(job), true);
      return;
    }

    //else creates an iterator and find the correct position
    //according to the job priority

    ListIterator<JobInfo> iterator = list.listIterator();
    JobInfo current = null;
    int currentJobPriority = 0;
    int index = -1;

    //iterator starts from the first (i.e. the job with highest priority)
    while (iterator.hasNext()) {
      index++;
      current = iterator.next();
      currentJobPriority = current.getJob().getJobClass().getPriority();

      if (priority > currentJobPriority) {
        //the job to be added must be inserted before the current job
        //(because has greater priority)

        //index is the position of the current element, which will be shifted together
        //with the following ones
        queue.add(index, new JobInfo(job), true);
        return;
      }
      //else if priority is lower than current, continue iteration
    }

    //exiting from the "while" means that the job to be inserted is the job with
    //lowest priority or has equal priority to the current last job but it is the last come

    //add last
    queue.addLast(new JobInfo(job), true);
    return;

  }
View Full Code Here

   * @param sourceSection Job source section.
   * @param sourceNode Job source node.
   * @param callingSection The section which calls this strategy.
   */
  public void put(Job job, JobInfoList queue, byte sourceSection, NetNode sourceNode, NodeSection callingSection) throws NetException {
    queue.addLast(new JobInfo(job));
    return;
  }
View Full Code Here

    //list of jobs in queue
    List<JobInfo> list = queue.getJobList();

    if (list.size() == 0) {
      //empty list: add first in general and class lists
      queue.addFirst(new JobInfo(job), false);
      return;
    }

    //else creates an iterator and find the correct position
    //according to the job priority

    ListIterator<JobInfo> iterator = list.listIterator();
    JobInfo current = null;
    int currentJobPriority = 0;
    int index = -1;

    //iterator starts from the first (i.e. the job with highest priority)
    while (iterator.hasNext()) {
      index++;
      current = iterator.next();
      currentJobPriority = current.getJob().getJobClass().getPriority();

      if (priority >= currentJobPriority) {
        //the job to be added must be inserted before the current job
        //(because has greater priority or has equal priority but it is the last come)

        //index is the position of the current element, which will be shifted together
        //with the following ones

        queue.add(index, new JobInfo(job), false);
        return;
      }
      //else if priority is lower than current, continue iteration
    }

    //exiting from the "while" means that the job to be inserted is the job with
    //lowest priority
    //add last
    queue.addLast(new JobInfo(job), false);
    return;
  }
View Full Code Here

   * @param sourceSection Job source section.
   * @param sourceNode Job source node.
   * @param callingSection The section which calls this strategy.
   */
  public void put(Job job, JobInfoList queue, byte sourceSection, NetNode sourceNode, NodeSection callingSection) {
    queue.addFirst(new JobInfo(job));
  }
View Full Code Here

    ListIterator<JobInfo> iterator = jobList.listIterator();

    Job nextJob = null;
    int nextJobPriority = 0;
    while (iterator.hasNext()) {
      JobInfo info = iterator.next();
      JobClass jobClass = info.getJob().getJobClass();
      if (nextJob == null || nextJobPriority < jobClass.getPriority()) {
        if (!blockingRegion.isBlocked(jobClass)) {
          nextJob = info.getJob();
          nextJobPriority = jobClass.getPriority();
        }
      }
    }
    return nextJob;
View Full Code Here

        //Secondly point to be noted is that I am
        //only dropping Jobs at Node level as the node section jobs
        //are automatically dropped but the node level jobs are
        //dropped manually.
        Job localJob = (Job) message.getData();
        JobInfo jobInfo = jobsList_node.lookFor(localJob);
        //remove only when you find a job in the list.
        if (jobInfo != null) {
          jobsList_node.remove(jobInfo);
        }

        //checks whether there are jobs in queue
        if (jobsList.size() == 0) {
          //no jobs in queue
          coolStart = true;
          break;
        }

        //search for the first job which is not blocked (if exists)
        // and forward it

        notBlockedJob = getNextNotBlockedJob();

        if (notBlockedJob != null) {
          JobClass jobClass = notBlockedJob.getJobClass();
          forward(notBlockedJob);
          blockingRegion.increaseOccupation(jobClass);
          break;
        } else {
          //all jobs in queue are blocked
          //nothing else to do
          break;
        }

      case NetEvent.EVENT_ACK:

        //checks whether there are jobs in queue
        if (jobsList.size() == 0) {
          //no jobs in queue
          coolStart = true;
          break;
        }

        //search for the first job which is not blocked (if exists)
        // and forward it

        notBlockedJob = getNextNotBlockedJob();

        if (notBlockedJob != null) {
          JobClass jobClass = notBlockedJob.getJobClass();
          forward(notBlockedJob);
          blockingRegion.increaseOccupation(jobClass);
          break;
        } else {
          //all jobs in queue are blocked
          //nothing else to do
          break;
        }

      case NetEvent.EVENT_JOB:

        //EVENT_JOB

        job = message.getJob();

        //no ack must be sent to the source of message (the redirecting queue of a node
        //inside the region)

        JobClass jobClass = job.getJobClass();

        //this job has been received by an internal node
        //the region input station will have to send it back
        NetNode realDestination = message.getSource();

        //adds a JobInfo object after modifying the job with redirection informations
        job.setOriginalDestinationNode(realDestination);
        jobsList.add(new JobInfo(job));

        //checks whether the region is blocked for this class
        if (blockingRegion.isBlocked(jobClass)) {
          //the region is already blocked
View Full Code Here

TOP

Related Classes of jmt.engine.QueueNet.JobInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.