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

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


            throws SchedulerException {
        String queueName = spec.getJob().getQueueName();
        int load = spec.getJob().getLoadValue().intValue();

        Vector queueNodes = (Vector) queues.get(queueName);
        ResourceNode node = nodeAvailable(spec);

        if (node != null) {
            try {
                myMonitor.assignLoad(node, load);
                queueNodes.remove(node.getNodeId());
                queueNodes.add(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.addJob(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


        Vector queueNodes = (Vector) queues.get(queueName);
        for (int i = 0; i < queueNodes.size(); i++) {
            String nodeId = (String) queueNodes.get(i);
            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

        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 ResourceNode getNodeById(String nodeId) throws MonitorException {
      lastMethodCallDetails = new MethodCallDetails("getNodeById",
            Lists.newArrayList((Object) nodeId));
      try {
         return new ResourceNode(nodeId, new URL("http://localhost:9999"), 5);
      } catch (Exception e) {
         throw new MonitorException(e);
      }
   }
View Full Code Here

        mockGmetad.remove();
    }

    public void testGetLoad() {
        try {
            ResourceNode resourceNode = new ResourceNode();
            resourceNode.setId("localhost");
            assertEquals(1, gangliaResourceMonitor.getLoad(resourceNode));
        } catch (Exception e) {
          e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

      }
    }
   
    public void testGetNodeById(){
      try{
        ResourceNode node = gangliaResourceMonitor.getNodeById("localhost");
        assertNotNull(node);
        assertEquals("localhost", node.getNodeId());
        node = gangliaResourceMonitor.getNodeById("localhost2");
        assertNotNull(node);
        assertEquals("localhost2", node.getNodeId());
        node = gangliaResourceMonitor.getNodeById("remotenode");
        assertNotNull(node);
        assertEquals("remotenode", node.getNodeId());
      }
      catch(Exception e){
        e.printStackTrace();
        fail(e.getMessage());
      }
View Full Code Here

      cmdLineUtility.run(("--url http://localhost:9000"
            + " --operation --addNode --capacity " + capacity + " --nodeId "
            + nodeId + " --ipAddr " + ipAddr).split(" "));
      MethodCallDetails methodCallDetails = client.getLastMethodCallDetails();
      assertEquals("addNode", methodCallDetails.getMethodName());
      ResourceNode actualNode = (ResourceNode) methodCallDetails.getArgs().get(0);
      ResourceNode expectedNode = new ResourceNode(nodeId, new URL(ipAddr), capacity);
      assertEquals(expectedNode.getIpAddr(), actualNode.getIpAddr());
      assertEquals(expectedNode.getCapacity(), actualNode.getCapacity());
      assertEquals(expectedNode.getNodeId(), actualNode.getNodeId());
   }
View Full Code Here

  }

  private ResourceNode nodeFromMap(Map<String, String> map)
      throws MalformedURLException {
    if (map == null) return null;
    ResourceNode node = new ResourceNode();
    System.out.println("MAP IS "+map);
    System.out.println("Setting hostname to "+map.get(NAME));
    node.setId(map.get(NAME));
    node.setIpAddr(new URL("http://" + map.get(NAME) + ":" + DEFAULT_PORT));
    return node;
  }
View Full Code Here

        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

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.