Package org.apache.oodt.cas.resource.structs

Examples of org.apache.oodt.cas.resource.structs.ResourceNode


        assertNotNull(resNodes);
        assertEquals(1, resNodes.size());
    }

    public void testGetNodeById() {
        ResourceNode node = null;

        try {
            node = assgnMon.getNodeById("localhost");
        } catch (MonitorException e) {
            fail(e.getMessage());
        }

        assertNotNull(node);
        assertEquals("localhost", node.getNodeId());
    }
View Full Code Here


        assertNotNull(resNodes);

        boolean hasNode1 = false;

        for (Iterator i = resNodes.iterator(); i.hasNext();) {
            ResourceNode node = (ResourceNode) i.next();
            assertNotNull(node);
            if (node.getNodeId().equals("localhost")) {
                hasNode1 = true;
                assertEquals(node.getIpAddr().toExternalForm(),
                        "http://localhost:2001");
            }
            assertEquals(node.getCapacity(), 8);
        }

        assertTrue(hasNode1);
    }
View Full Code Here

    public void testNodeModification() throws MonitorException,
            MalformedURLException {
        List<ResourceNode> nodes = new Vector<ResourceNode>(this.assgnMon
                .getNodes());
        ResourceNode test1 = new ResourceNode("Test1", new URL(
                "http://localhost:1111"), 9);
        ResourceNode test2 = new ResourceNode("Test2", new URL(
                "http://localhost:2222"), 9);
        ResourceNode test3 = new ResourceNode("Test3", new URL(
                "http://localhost:3333"), 9);
        this.assgnMon.addNode(test1);
        nodes.add(test1);
        this.assgnMon.addNode(test2);
        nodes.add(test2);
View Full Code Here

     * (non-Javadoc)
     *
     * @see gov.nasa.jpl.oodt.cas.resource.monitor.Monitor#getLoad(gov.nasa.jpl.oodt.cas.resource.structs.ResourceNode)
     */
    public int getLoad(ResourceNode node) throws MonitorException {
        ResourceNode resource = (ResourceNode) nodesMap.get(node.getNodeId());
        Integer i = (Integer) loadMap.get(node.getNodeId());
        return (resource.getCapacity() - i.intValue());
    }
View Full Code Here

     * (non-Javadoc)
     *
     * @see gov.nasa.jpl.oodt.cas.resource.monitor.Monitor#getNodeByURL(java.net.URL)
     */
    public ResourceNode getNodeByURL(URL ipAddr) throws MonitorException {
        ResourceNode targetResource = null;
        List<ResourceNode> nodes = this.getNodes();
        for (int i = 0; i < nodes.size(); i++) {
            if (((ResourceNode) nodes.get(i)).getIpAddr() == ipAddr) {
                targetResource = (ResourceNode) nodes.get(i);
                break;
View Full Code Here

    public synchronized boolean schedule(JobSpec spec)
            throws SchedulerException {
        String queueName = spec.getJob().getQueueName();
        int load = spec.getJob().getLoadValue().intValue();

        ResourceNode node = nodeAvailable(spec);

        if (node != null) {
            try {
                myMonitor.assignLoad(node, load);
                queueManager.usedNode(queueName, node.getNodeId());
               
                // assign via batch system
                LOG.log(Level.INFO, "Assigning job: ["
                        + spec.getJob().getName() + "] to node: ["
                        + node.getNodeId() + "]");
                try {
                    myBatchmgr.executeRemotely(spec, node);
                } catch (JobExecutionException e) {
                    LOG.log(Level.WARNING, "Exception executing job: ["
                            + spec.getJob().getId() + "] to node: ["
                            + node.getIpAddr() + "]: Message: "
                            + e.getMessage());
                    try {
                        // queue the job back up
                        LOG.log(Level.INFO, "Requeueing job: ["
                                + spec.getJob().getId() + "]");
                        myJobQueue.requeueJob(spec);

                        // make sure to decrement the load
                        myMonitor.reduceLoad(node, load);
                    } catch (Exception ignore) {
                    }
                }
            } catch (MonitorException e) {
                LOG.log(Level.WARNING, "Exception assigning load to resource "
                        + "node: [" + node.getNodeId() + "]: load: [" + load
                        + "]: Message: " + e.getMessage());
                throw new SchedulerException(e.getMessage());
            }
        } else {
            // could not find resource, push onto JobQueue
View Full Code Here

        String queueName = spec.getJob().getQueueName();
          int load = spec.getJob().getLoadValue().intValue();
 
          for (String nodeId : queueManager.getNodes(queueName)) {
              int nodeLoad = -1;
              ResourceNode resNode = null;
 
              try {
                  resNode = myMonitor.getNodeById(nodeId);
                  nodeLoad = myMonitor.getLoad(resNode);
              } catch (MonitorException e) {
                  LOG
                          .log(Level.WARNING, "Exception getting load on "
                                  + "node: [" + resNode.getNodeId()
                                  + "]: Message: " + e.getMessage());
                  throw new SchedulerException(e.getMessage());
              }
 
              if (load <= nodeLoad) {
View Full Code Here

        List resNodes = scheduler.getMonitor().getNodes();
        return XmlRpcStructFactory.getXmlRpcResourceNodeList(resNodes);
    }

    public Hashtable getNodeById(String nodeId) throws MonitorException {
        ResourceNode node = scheduler.getMonitor().getNodeById(nodeId);
        return XmlRpcStructFactory.getXmlRpcResourceNode(node);

    }
View Full Code Here

            LOG.log(Level.WARNING, "Attempt to kill job: [" + jobId
                    + "]: cannot find execution node"
                    + " (has the job already finished?)");
            return false;
        }
        ResourceNode node = scheduler.getMonitor().getNodeById(resNodeId);
        return scheduler.getBatchmgr().killJob(jobId, node);
    }
View Full Code Here

    } else
        return false;     
    }
   
    public String getNodeLoad(String nodeId) throws MonitorException{
      ResourceNode node = this.scheduler.getMonitor().getNodeById(nodeId);
      int capacity = node.getCapacity();
      int load = (this.scheduler.getMonitor().getLoad(node)) * -1 + capacity;
      return load + "/" + capacity;
    }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.resource.structs.ResourceNode

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.