Package jmt.engine.QueueNet

Examples of jmt.engine.QueueNet.JobClass


      for (int i = 0; i < measures.size(); i++) {
        ms = measures.get(i);

        //NEW
        //@author Stefano Omini
        JobClass jClass;
        if (ms.getjClass() != "") {
          //measure relative to a specified class
          String[] jName = { ms.getjClass() };
          int[] position = findClassPosition(jName);
          jClass = classes[position[0]];
View Full Code Here


  private int[] findClassPosition(String[] names) {
    int[] classPos = new int[names.length];
    for (int i = 0; i < names.length; i++) {
      String name = names[i];
      for (int j = 0; j < classes.length; j++) {
        JobClass aClass = classes[j];
        if (name.equals(aClass.getName())) {
          classPos[i] = j;
        }
      }
    }
    return classPos;
View Full Code Here

   * accesses to the reference station)
   */

  private void scaleMeasureWithVisitRatio() {
    //retrieves JobClass object using its name
    JobClass jobClass = network.getJobClass(jobClassName);
    double visitRatio = 1.0;
    //current measure node
    NetNode thisNode = network.getNode(nodeName);

    // If measure is class specific
    if (jobClass != null) {
      //reference node for this job class
      String referenceNodeName = jobClass.getReferenceNodeName();
      NetNode referenceNode = network.getNode(referenceNodeName);
      int visitsReferenceNode, visitsThisNode;
      try {
        //visits to the reference node
        NodeSection refOutputSection = referenceNode.getSection(NodeSection.OUTPUT);
        visitsReferenceNode = refOutputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobClass);

        //visits to this node node
        NodeSection thisNodeInputSection = thisNode.getSection(NodeSection.INPUT);

        visitsThisNode = thisNodeInputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobClass);

        // the reference source generates a certain number of jobs
        // - some of them have reached this station
        // - other have been dropped before enetering this station or
        // elsewhere in the network
        int droppedJobs = network.getDroppedJobs(jobClass);

        if (thisNodeInputSection instanceof BlockingQueue) {

          // if the input section is a BlockingQueue,
          // remove (from the total number of visits)
          // the jobs dropped by the BlockingQueue itself,
          // because they have been counted
          // in arrived jobs
          visitsThisNode -= ((BlockingQueue) thisNode.getSection(NodeSection.INPUT)).getDroppedJobPerClass(jobClass.getId());

        }

        //visit ratio
        //
        // we must consider only not dropped jobs:
        // --> visit ratio = visits to this node / (visits to ref node - dropped jobs)
        visitRatio = (double) (visitsThisNode) / (visitsReferenceNode - droppedJobs);

        //System.out.println("refNode: " + Integer.toString(visitsReferenceNode));
        //System.out.println("thisNode: " + Integer.toString(visitsThisNode));
        //System.out.println("dropped: " + droppedJobs);
        //System.out.println("visit ratio: " + Double.toString(visitRatio));

      } catch (NetException ne) {
        visitRatio = 1;
        logger.error("Error in computing visit ratio.");
        ne.printStackTrace();
      }
    }
    // Measure is class-independent --> Bertoli Marco
    else {
      try {
        Iterator<JobClass> it = network.getJobClasses().listIterator();
        double ratioSum = 0.0, weight = 0.0;
        while (it.hasNext()) {
          JobClass jobC = it.next();
          //reference node for this job class
          String referenceNodeName = jobC.getReferenceNodeName();
          NetNode referenceNode = network.getNode(referenceNodeName);
          int visitsReferenceNode, visitsThisNode;
          //visits to the reference node
          NodeSection refOutputSection = referenceNode.getSection(NodeSection.OUTPUT);
          visitsReferenceNode = refOutputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobC);

          //visits to this node node
          NodeSection thisNodeInputSection = thisNode.getSection(NodeSection.INPUT);

          visitsThisNode = thisNodeInputSection.getIntSectionProperty(NodeSection.PROPERTY_ID_ARRIVED_JOBS, jobC);

          int droppedJobs = network.getDroppedJobs(jobC);

          if (thisNodeInputSection instanceof BlockingQueue) {
            visitsThisNode -= ((BlockingQueue) thisNode.getSection(NodeSection.INPUT)).getDroppedJobPerClass(jobC.getId());

          }
          double currVisitRatio = (double) (visitsThisNode) / (visitsReferenceNode - droppedJobs);

          // Uses new calculated visit ratio to compute a weighted visit ratio
View Full Code Here

    }

    try {
      //add class
      JobClass[] classes = new JobClass[1];
      classes[0] = new JobClass("prima");
      Simulation sim = new Simulation(-1, testName);
      sim.addClasses(classes);

      //terminal
      RandomStrategy[] rrs_term = new RandomStrategy[1];
View Full Code Here

      Object thisKey = classes.get(j);
      String thisName = mediator.getClassDefinition().getClassName(thisKey);
      tm.put(thisName, thisKey);
    }
    for (int i = 0; i < classList.size(); i++) {
      JobClass temp = classList.get(i);
      classMap.put(tm.get(temp.getName()), temp);
    }
    //set the initialized state
    initialized = true;
  }
View Full Code Here

  private static final int STRATEGY_TAIL = 1;
  private static final int STRATEGY_HEAD_PRIORITY = 2;
  private static final int STRATEGY_TAIL_PRIORITY = 3;

  public static void test1(int strategy) {
    JobClass class1, class2, class3;

    try {
      class1 = new JobClass("high  ", 3, JobClass.CLOSED_CLASS, null);
      class2 = new JobClass("medium", 2, JobClass.CLOSED_CLASS, null);
      class3 = new JobClass("low   ", 1, JobClass.CLOSED_CLASS, null);

    } catch (NetException ne) {
      ne.printStackTrace();
      return;
    }
View Full Code Here

    }

    try {
      //add class
      JobClass[] classes = new JobClass[1];
      classes[0] = new JobClass("prima");

      long simTime = 200;
      Simulation sim = new Simulation(-1, "SimulationWithTimer", simTime);

      sim.addClasses(classes);
View Full Code Here

      serviceWeigth = (double) numberOfServers / jobs.size();
    }
    queueWeight = 1.0 - serviceWeigth;

    // Updates utilization measures
    JobClass jobClass = jobData.getJob().getJobClass();
    queueList.psUpdateUtilization(jobClass, queueWeight, NetSystem.getTime());
    serviceList.psUpdateUtilization(jobClass, serviceWeigth, NetSystem.getTime());

    // Update busy time measures and throughputs
    if (event == PSEvent.JOB_OUT) {
View Full Code Here

        //the terminal creates all the jobs requested by each class.
        //for each job created, it sends to itself a message with delay 0

        //log.write(NetLog.LEVEL_RELEASE, null, this, NetLog.EVENT_START);
        ListIterator<JobClass> jobClasses = getJobClasses().listIterator();
        JobClass jobClass;

        //generator of random numbers (uses the same engine of
        //distributions and strategies) used to mix the order of
        //leaving jobs, otherwise they leave in order of class
        //(i.e. c1, c1, c1, ...c2, c2, c2, ... c3....)
        RandomEngine randomEng = RandomEngine.makeDefault();

        //delay used to mix leaving order
        double mixRandomDelay = 0.0;

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

          //NEW
          //@author Stefano Omini
          if (jobClass.getType() == JobClass.OPEN_CLASS) {
            //open class: no jobs to be generated
            continue;
          }
          //end NEW

          c = jobClass.getId();

          if (jobsPerClass != null) {

            //terminal of a closed system
            //generates all the jobs
View Full Code Here

        //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

        if (outNode == null) {
          return MSG_NOT_PROCESSED;
View Full Code Here

TOP

Related Classes of jmt.engine.QueueNet.JobClass

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.