Package jmt.engine.QueueNet

Examples of jmt.engine.QueueNet.NetNode


        findNodes();
      }
      //the empirical distribution returns the position of the chosen output node
      int nodePos = (int) distribution.nextRand(param);

      NetNode node = this.nodes[nodePos];

      // Controls if a closed class job is put into a sink - Bertoli Marco
      if (jobClass.getType() == CLOSED_CLASS) {
        // when reaches maxSinkTry, aborts this strategy returning null
        int tries = 0;
        while (node.isSink()) {
          if (tries++ >= maxSinkTry) {
            return null;
          }
          // Try to find a node different from a sink
          nodePos = (int) distribution.nextRand(param);
View Full Code Here


   */
  @Override
  public NetNode getOutNode(NodeList Nodes, JobClass jobClass) {
    int outNodes = Nodes.size();
    // Find output node
    NetNode output;
    if (outNodes > 1) {
      output = Nodes.get((int) Math.floor(randomEngine.raw() * outNodes));
    } else {
      output = Nodes.getFirst();
    }

    // Check to avoid discarding closed classes into a sink
    if (jobClass.getType() == CLOSED_CLASS && output.isSink()) {
      NetNode[] validOutputs = new NetNode[outNodes];
      outNodes = 0; // Here outNodes is used as a counter to valid elements into valisOutputs array
      for (int i = 0; i < Nodes.size(); i++) {
        if (!Nodes.get(i).isSink()) {
          validOutputs[outNodes++] = Nodes.get(i);
View Full Code Here

    // Checks null values to avoid problems under linux
    if (measure.getNodeName() == null || measure.getNodeName().equals("")) {
      // aggregate measure
      elem.setAttribute("station", "");
    } else {
      NetNode node = measure.getNetwork().getNode(measure.getNodeName());
      if (node.isBlockingRegionInputStation()) {
        elem.setAttribute("station", node.getBlockingRegionInputStation().getName());
        elem.setAttribute("nodeType", SimConstants.NODE_TYPE_REGION);
      } else {
        // class measure
        elem.setAttribute("station", measure.getNodeName());
        elem.setAttribute("nodeType", SimConstants.NODE_TYPE_STATION);
View Full Code Here

   * @param jobClass class ofcurrent job to be routed
   * @return The selected node.
   */
  @Override
  public NetNode getOutNode(NodeList Nodes, JobClass jobClass) {
    NetNode out;
    if (Nodes.size() == 0) {
      return null;
    } else {

      if (Counter == Nodes.size()) {
        Counter = 0;
      }
      out = Nodes.get(Counter++);

      // Skips sinks for closed classes
      if (jobClass.getType() == CLOSED_CLASS) {
        int totalLoops = 0; // Counts whenever a full loop has been performed
        while (out.isSink()) {
          if (Counter == Nodes.size()) {
            Counter = 0;
            if (totalLoops++ > 0) {
              return null;
            }
View Full Code Here

        //auto-connect the node, to avoid problems in job info lists refreshing
        //(otherwise a node with no connections presents problems)
        inputStation.getNode().connect(inputStation.getNode());

        NetNode inputSt = inputStation.getNode();
        if (inputStation.getInput() != null) {
          inputStation.getNode().addSection(inputStation.getInput());
        }
        if (inputStation.getService() != null) {
          inputStation.getNode().addSection(inputStation.getService());
        }
        if (inputStation.getOutput() != null) {
          inputStation.getNode().addSection(inputStation.getOutput());
        }
        inputStation.getNode().initializeSections();

        //sets the input station of the blocking region
        br.setInputStation(inputSt);

        //sets blocking region behaviour for inner nodes
        String[] regNodes = br.getRegionNodeNames();
        for (String regNode : regNodes) {
          NetNode innerNode = br.getRegionNode(regNode);

          //at the moment inner stations must have a Queue-type input section
          //and a Router-type output section
          //other not compliant sections will cause a NetException

          //nodes which receive jobs from the outside must
          //have redirecting queue behaviour turned on
          NodeSection input = innerNode.getSection(NodeSection.INPUT);
          if (input instanceof Queue) {
            ((Queue) input).redirectionTurnON(br);
          } else {
            throw new NetException("Error in creating blocking region: " + "inner station " + innerNode.getName()
                + " has a not compliant input section.");
          }

          //nodes which sends jobs outside the region must have border router behaviour
          NodeSection output = innerNode.getSection(NodeSection.OUTPUT);
          if (output instanceof Router) {
            ((Router) output).borderRouterTurnON(br);
          } else {
            throw new NetException("Error in creating blocking region: " + "inner station " + innerNode.getName()
                + " has a not compliant output section.");
          }
        }
        if (regionMeasures.size() > 0) {
          //adds measures in blocking region input station
View Full Code Here

   * Preload jobs in a queue
   */
  public void preload_station(String stationName, int[] jobs) {

    //find the node
    NetNode node = NetSystem.getNode(stationName);

    if (node != null) {
      try {
        //retrieves the input section of the node
        NodeSection section = node.getSection(NodeSection.INPUT);
        if (section instanceof Queue) {
          //preload jobs for each class
          ((Queue) section).preloadJobs(jobs);
        }
      } catch (NetException e) {
View Full Code Here

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

     * @param inSec input section of the node
     * @param serSec service section of the node
     * @param outSec output section of the node
     */
    public SimNode(String name, InputSection inSec, ServiceSection serSec, OutputSection outSec) {
      this.node = new NetNode(name);
      this.input = inSec;
      this.service = serSec;
      this.output = outSec;
      //
      nodeInit = true;
View Full Code Here

     * @deprecated
     * @param nodeName
     */
    @Deprecated
    public SimNode(String nodeName) {
      this.node = new NetNode(nodeName);
      input = null;
      service = null;
      output = null;
      nodeInit = false;
    }
View Full Code Here

      String thisName = mediator.getStationDefinition().getStationName(thisKey);
      tm.put(thisName, thisKey);
    }
    //performs the server mapping
    for (int i = 0; i < nodeList.size(); i++) {
      NetNode temp = nodeList.get(i);
      NodeSection serviceSection = null;
      try {
        serviceSection = temp.getSection(NodeSection.SERVICE);
      } catch (NetException ne) {
      }
      if (serviceSection instanceof Server || serviceSection instanceof PSServer) {
        serverMap.put(tm.get(temp.getName()), temp);
      }
    }
    tm.clear();
    //performs the class mapping
    for (int j = 0; j < classes.size(); j++) {
      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

TOP

Related Classes of jmt.engine.QueueNet.NetNode

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.