Package jmt.engine.QueueNet

Examples of jmt.engine.QueueNet.Job


    switch (message.getEvent()) {

      case NetEvent.EVENT_JOB:

        Job job = message.getJob();

        //EVENT_JOB
        //if the router is not busy, an output node is chosen using
        //the routing strategy and a message containing the job is sent to it.

        JobClass jobClass = job.getJobClass();

        //choose the outNode using the corresponding routing strategy
        NetNode outNode = routingStrategies[jobClass.getId()].getOutNode(this, jobClass);
        // Bertoli Marco: sanity checks with closed classes and sinks were moved inside
        // routing strategies
View Full Code Here


    List<JobInfo> jobList = jobsList.getJobList();

    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()) {
View Full Code Here

   * @param message message to be processed.
   * @throws NetException
   */
  @Override
  protected int process(NetMessage message) throws NetException {
    Job job;
    Job notBlockedJob;

    switch (message.getEvent()) {

      case NetEvent.EVENT_START:

        //the input station receives the "start" event because it has no nodes in input
        //then it's marked as reference node

        //NEW
        //@author Stefano Omini

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

        //get the first job which is not blocked (if exists)

        notBlockedJob = getNextNotBlockedJob();

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

        //the BlockingQueue has almost the same behaviour with the events
        //EVENT_JOB_OUT_OF_REGION and EVENT_ACK

      case NetEvent.EVENT_JOB_OUT_OF_REGION:

        //FCR Bug fix:
        //The dropping of the job was post poned as the time
        //spent in the Queuing station was not taken in consideration.
        //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);
        }
View Full Code Here

   * @param message message to be processed.
   * @throws jmt.common.exception.NetException
   */
  @Override
  protected int process(NetMessage message) throws jmt.common.exception.NetException {
    Job job;
    switch (message.getEvent()) {

      case NetEvent.EVENT_START:

        //EVENT_START
        //If there are jobs in queue, the first (chosen using the specified
        //get strategy) is forwarded and coolStart becomes false.

        if (queueJobInfoList.size() > 0) {
          //the first job is forwarded to service section
          forward(getStrategy.get(queueJobInfoList));
          coolStart = false;
        }

        break;

      case NetEvent.EVENT_ACK:

        //EVENT_ACK
        //If there are waiting requests, the first is taken (if the source node of this request
        //is the owner node of this section, an ack message is sent).
        //The job contained is put into the queue using the specified put strategy.
        //
        //At this point, if there are jobs in queue, the first is taken (using the
        //specified get strategy) and forwarded. Otherwise, if there are no jobs, coolStart
        //is set true.

        // if there is a waiting request send ack to the first node
        //(note that with infinite queue there are no waitinq requests)
        if (waitingRequests.size() != 0) {
          WaitingRequest wr;
          wr = (WaitingRequest) waitingRequests.removeFirst();

          // If the source is not the owner node sends ack if blocking is enabled. Otherwise
          // ack was already sent.
          if (!isMyOwnerNode(wr.getNode()) && block[wr.getJob().getJobClass().getId()]) {
            send(NetEvent.EVENT_ACK, wr.getJob(), 0.0, wr.getSection(), wr.getNode());
          }

          //the class ID of this job
          int c = wr.getJob().getJobClass().getId();
          //the job is put into the queue according to its own class put strategy
          putStrategy[c].put(wr.getJob(), queueJobInfoList, message.getSourceSection(), message.getSource(), this);
        }

        // if there is at least one job, sends it
        if (queueJobInfoList.size() > 0) {
          // Gets job using a specific strategy and sends job
          Job jobSent = getStrategy.get(queueJobInfoList);
          forward(jobSent);
        } else {
          // else set coolStart to true
          coolStart = true;

View Full Code Here

      randomClassIndex = (int) Math.floor((randomEng.raw()) * classNumber);

      if (residualClassJobs[randomClassIndex] > 0) {
        //other jobs to be added
        Job newJob = new Job(jobClasses.get(randomClassIndex));
        JobInfo newJobInfo = new JobInfo(newJob);
       
        // Signals to node jobInfoList otherwise measures and Load dependent code are wrong
        this.getOwnerNode().getJobInfoList().add(newJobInfo);
        // Adds this job to the queue jobinfolist
View Full Code Here

  @Override
  protected int process(NetMessage message) throws NetException {
    switch (message.getEvent()) {
      case NetEvent.EVENT_JOB:
        // Sends the message to the real destination and wait for the ack
        Job job = message.getJob();
        //this is the real destination, i.e. the internal node that at first
        //had redirected the job to the input station
        NetNode realDestinationNode = job.getOriginalDestinationNode();
        send(job, 0.0, realDestinationNode);

        waitingAcks++;
        return MSG_PROCESSED;
      case NetEvent.EVENT_ACK:
View Full Code Here

    //end NEW
  }

  @Override
  protected int process(NetMessage message) throws jmt.common.exception.NetException {
    Job job;
    double delay;
    int c;
    switch (message.getEvent()) {

      case NetEvent.EVENT_START:

        //case EVENT_START:
        //the random source creates all the jobs requested by each class.
        //for each job created, it sends to itself a message whose delay is the time of
        //departure of the job, calculated using the strategy of the corresponding class

        //log.write(NetLog.LEVEL_RELEASE, null, this, NetLog.EVENT_START);

        ListIterator<JobClass> jobClasses = getJobClasses().listIterator();
        JobClass jobClass;

        while (jobClasses.hasNext()) {
          jobClass = jobClasses.next();

          //NEW
          //@author Stefano Omini
          if (jobClass.getType() == JobClass.CLOSED_CLASS) {
            //closed class: no arrivals
            continue;
          }
          //end NEW

          c = jobClass.getId();

          // Calculates the delay of departure (1/lambda)
          if (strategy[c] != null) {
            job = new Job(jobClass);
            delay = strategy[c].wait(this);
            sendMe(job, delay);
            //log.write(NetLog.LEVEL_DEBUG, job, this, NetLog.JOB_CREATED);
          }

        }
        break;

      case NetEvent.EVENT_ACK:

        //case EVENT_ACK:
        //if there are waiting jobs, takes the first, set its bornTime and
        //forwards it to the service section.
        //then it creates a new job and sends to itself a message whose delay is the time of
        //departure of that job.
        //otherwise, if there are no waiting jobs, sets coolstart=true

        if (waitingJobs.size() != 0) {
          job = waitingJobs.removeFirst();
          c = job.getJobClass().getId();
          job.born();

          //NEW
          //@author Stefano Omini, Bertoli Marco

          // in RandomSource the job is created (--> SystemEnteringTime is initialized)
          // but then is delayed as long as the random interarrival time ("delay")
          //
          // to compute system response time, the job starting time must be
          // reset (otherwise it will correspond to the creation time and not to the
          // leaving time, which is "delay" seconds after)

          // Signals to global jobInfoList new added job
          this.getOwnerNode().getQueueNet().getJobInfoList().addJob(job);

          //end NEW

          sendForward(job, 0.0);

          //log.write(NetLog.LEVEL_DEBUG, job, this, NetLog.JOB_OUT);

          // Create a new job and send it to me delayed
          job = new Job(getJobClasses().get(c));
          delay = strategy[c].wait(this);
          sendMe(job, delay);

          //log.write(NetLog.LEVEL_DEBUG, job, this, NetLog.JOB_CREATED);

        } else {
          coolStart = true;
        }
        break;

      case NetEvent.EVENT_JOB:

        //case EVENT_JOB
        //if coolStart=false adds the job to the list of waiting jobs.
        //
        //if coolStart=true (no waiting jobs)  the job is forwarded, an ack message
        //is sent to the source of the message and a new job is created (the random source
        //sends to itself a message, whose delay is the time of departure of the new job).

        //log.write(NetLog.LEVEL_DEBUG, message.getJob(), this, NetLog.JOB_IN);

        // Gets the job from the message
        job = message.getJob();

        if (coolStart) {
          // Gets the class of the job
          c = job.getJobClass().getId();

          //no control is made on the number of jobs created
          //it's an open class
          job.born();

          //NEW
          //@author Stefano Omini, Bertoli Marco

          // in RandomSource the job is created (--> SystemEnteringTime is initialized)
          // but then is delayed as long as the random interarrival time ("delay")
          //
          // to compute system response time, the job starting time must be
          // reset (otherwise it will correspond to the creation time and not to the
          // leaving time, which is "delay" seconds after)

          // Signals to global jobInfoList new added job
          this.getOwnerNode().getQueueNet().getJobInfoList().addJob(job);

          //end NEW

          sendForward(job, 0.0);
          send(NetEvent.EVENT_ACK, job, 0.0, message.getSourceSection(), message.getSource());

          //log.write(NetLog.LEVEL_DEBUG, job, this, NetLog.JOB_OUT);

          job = new Job(job.getJobClass());
          delay = strategy[c].wait(this);
          sendMe(job, delay);

          // Sets coolStart to false, next job should wait ack
          coolStart = false;
View Full Code Here

TOP

Related Classes of jmt.engine.QueueNet.Job

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.