Package org.nimbustools.api.services.rm

Examples of org.nimbustools.api.services.rm.Manager


    // -----------------------------------------------------------------------------------------

    @Test
    @DirtiesContext
    public void simpleBackfillTest() throws Exception {
        Manager rm = this.locator.getManager();
        Caller superuser = this.populator().getSuperuserCaller();

        logger.info(rm.getVMMReport());

        logger.debug("Submitting backfill requests..");

        AsyncCreateRequest backfill1 = this.populator().getBackfillRequest("backfill1", 3);
        RequestInfo backfill1Result = rm.addBackfillRequest(backfill1, superuser);
        AsyncCreateRequest backfill2 = this.populator().getBackfillRequest("backfill2", 5);
        RequestInfo backfill2Result = rm.addBackfillRequest(backfill2, superuser);

        logger.debug("Waiting 2 seconds for resources to be allocated.");
        Thread.sleep(2000);

        // Check backfill request state
        RequestInfo[] backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(2, backfillRequestsByCaller.length);

        logger.info(rm.getVMMReport());
    }
View Full Code Here


    }

    @Test
    @DirtiesContext
    public void simpleBackfillPreemptionTest() throws Exception {
        Manager rm = this.locator.getManager();
        Caller superuser = this.populator().getSuperuserCaller();

        logger.debug("Submitting backfill requests..");

        AsyncCreateRequest backfill1 = this.populator().getBackfillRequest("backfill1", 3);
        RequestInfo backfill1Result = rm.addBackfillRequest(backfill1, superuser);
        AsyncCreateRequest backfill2 = this.populator().getBackfillRequest("backfill2", 5);
        RequestInfo backfill2Result = rm.addBackfillRequest(backfill2, superuser);

        logger.debug("Waiting 2 seconds for resources to be allocated.");
        Thread.sleep(2000);

        // Check backfill request state
        RequestInfo[] backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(2, backfillRequestsByCaller.length);

        logger.info(rm.getVMMReport());

        // Three regular VMs should preempt
        Caller caller = this.populator().getCaller();
        CreateRequest req = this.populator().getCreateRequest("regular", 1200, 256 , 3);
        rm.create(req, caller);

        logger.debug("Waiting 2 seconds for resources to be allocated.");
        Thread.sleep(2000);

        logger.info(rm.getVMMReport());
    }
View Full Code Here

    public void multipleRequests() throws Exception {
        logger.debug("multipleRequests");
       
        Caller caller1 = this.populator().getCaller("CALLER1");
        Caller caller2 = this.populator().getCaller("CALLER2");
        Manager rm = this.locator.getManager();
       
        Double previousPrice = rm.getSpotPrice();
       
        final Double bid1 = previousPrice + 3;
        final Double bid2 = previousPrice + 1;
        final Double bid3 = previousPrice + 1;
        SpotCreateRequest req1 = this.populator().getBasicRequestSI("req1", 1, bid1, false);
        SpotCreateRequest req2 = this.populator().getBasicRequestSI("req1", 3, bid2, false);
        SpotCreateRequest req3 = this.populator().getBasicRequestSI("req1", 4, bid3, false);
       
        SpotRequestInfo result1 = rm.requestSpotInstances(req1, caller1);
        SpotRequestInfo result2 = rm.requestSpotInstances(req2, caller2);
        SpotRequestInfo result3 = rm.requestSpotInstances(req3, caller1);

        assertEquals(result1, rm.getSpotRequest(result1.getRequestID(), caller1));
        assertEquals(result2, rm.getSpotRequest(result2.getRequestID(), caller2));
        assertEquals(result3, rm.getSpotRequest(result3.getRequestID(), caller1));
       
        //New spot price is equal largest bid + 0.1 (since there are 0 resources)
        assertEquals(bid1 + 0.1,  rm.getSpotPrice());
       
        SpotRequestInfo[] spotRequestByCaller1 = rm.getSpotRequestsByCaller(caller1);
        assertEquals(2, spotRequestByCaller1.length);
       
        SpotRequestInfo[] spotRequestByCaller2 = rm.getSpotRequestsByCaller(caller2);
        assertEquals(1, spotRequestByCaller2.length);       
       
        //Cancel requests
        rm.cancelSpotInstanceRequests(new String[]{result1.getRequestID(), result3.getRequestID()}, caller1);
        SpotRequestInfo[] cancelledReqs = rm.cancelSpotInstanceRequests(new String[]{result2.getRequestID()}, caller2);
       
        //Check if requests were really cancelled
        assertEquals(RequestState.STATE_Canceled, cancelledReqs[0].getState().getStateStr());
        spotRequestByCaller1 = rm.getSpotRequestsByCaller(caller1);
        assertEquals(RequestState.STATE_Canceled, spotRequestByCaller1[0].getState().getStateStr());
        assertEquals(RequestState.STATE_Canceled, spotRequestByCaller1[1].getState().getStateStr());
    }
View Full Code Here

    // -----------------------------------------------------------------------------------------

    @Test
    @DirtiesContext
    public void singleInstancePreemption() throws Exception {
        Manager rm = this.locator.getManager();
        Caller superuser = this.populator().getSuperuserCaller();

        logger.info(rm.getVMMReport());

        logger.debug("Submitting backfill request");

        AsyncCreateRequest backfill1 = this.populator().getBackfillRequest("backfill1", 1);
        RequestInfo backfill1Result = rm.addBackfillRequest(backfill1, superuser);

        logger.debug("Waiting 2 seconds for resources to be allocated.");
        Thread.sleep(2000);

        // Check backfill request state
        RequestInfo[] backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);

        logger.info(rm.getVMMReport());

        // One regular VM that needs all the 512 RAM should preempt
        Caller caller = this.populator().getCaller();
        CreateRequest req = this.populator().getCreateRequest("regular", 1200, 512 , 1);
        rm.create(req, caller);

        logger.debug("Waiting 2 seconds for resources to be allocated.");
        Thread.sleep(2000);

        logger.info(rm.getVMMReport());
    }
View Full Code Here

    // -----------------------------------------------------------------------------------------

    @Test
    @DirtiesContext
    public void tooMuchMemory() throws Exception {
        final Manager rm = this.locator.getManager();
        final Caller caller = this.populator().getCaller();
        final CreateRequest request =
                this.populator().getCreateRequest("suite:issue26:tooMuchMemory", 240, 3584, 1);
        boolean impossibleMemory = false;
        try {
            final CreateResult result = rm.create(request, caller);
        } catch (ImpossibleAmountOfMemoryException e) {
            impossibleMemory = true;
        }
        assertTrue(impossibleMemory);
    }
View Full Code Here

    // -----------------------------------------------------------------------------------------

    @Test
    @DirtiesContext
    public void backfillWontDie() throws Exception {
        Manager rm = this.locator.getManager();
        Caller superuser = this.populator().getSuperuserCaller();

        logger.info(rm.getVMMReport());

        logger.debug("Submitting backfill request");

        AsyncCreateRequest backfill1 = this.populator().getBackfillRequest("backfill1", 1);
        RequestInfo backfill1Result = rm.addBackfillRequest(backfill1, superuser);

        logger.debug("Waiting 2 seconds for resources to be allocated.");
        Thread.sleep(2000);

        // Check backfill request state
        RequestInfo[] backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);

        logger.info(rm.getVMMReport());

        // Set the shutdown task to not work
        MockShutdownTrash.resetFailCount();
        MockShutdownTrash.setFail(true);
        logger.warn("Set to fail.");

        // One regular VM that needs all the 512 RAM will preempt
        Caller caller = this.populator().getCaller();
        CreateRequest req = this.populator().getCreateRequest("regular", 1200, 512 , 1);

        final long startMs = System.currentTimeMillis();

        boolean notEnoughMemory = false;
        try {
            rm.create(req, caller);
        } catch (NotEnoughMemoryException e) {
            notEnoughMemory = true;
        }

        final long endMs = System.currentTimeMillis();
View Full Code Here


        @Test
    @DirtiesContext
    public void backfillEventuallyDies() throws Exception {
        Manager rm = this.locator.getManager();
        Caller superuser = this.populator().getSuperuserCaller();

        logger.info(rm.getVMMReport());

        logger.debug("Submitting backfill request");

        AsyncCreateRequest backfill1 = this.populator().getBackfillRequest("backfill1", 1);
        RequestInfo backfill1Result = rm.addBackfillRequest(backfill1, superuser);

        logger.debug("Waiting 2 seconds for resources to be allocated.");
        Thread.sleep(2000);

        // Check backfill request state
        RequestInfo[] backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);

        logger.info(rm.getVMMReport());

        // Set the shutdown task to not work
        MockShutdownTrash.resetFailCount();
        MockShutdownTrash.setFail(true);
        logger.warn("Set to fail.");

        // One regular VM that needs all the 512 RAM will preempt
        Caller caller = this.populator().getCaller();
        CreateRequest req = this.populator().getCreateRequest("regular", 1200, 512 , 1);

        // In 10 seconds, trigger the shutdown task to start succeeding
        this.suiteExecutor.submit(new DestroyEnableFutureTask(10));

        final long startMs = System.currentTimeMillis();
        final CreateResult result = rm.create(req, caller);

        final long endMs = System.currentTimeMillis();
        final long totalSeconds = (endMs - startMs) / 1000;
        logger.info("Total seconds: " + totalSeconds);

        final VM[] vms = result.getVMs();
        assertEquals(1, vms.length);
        assertNotNull(vms[0]);
        logger.info("Leased vm '" + vms[0].getID() + '\'');

        assertTrue(rm.exists(vms[0].getID(), Manager.INSTANCE));

        // That should have only waited around ~10 seconds (+/- 2 seconds for sweeper)
        assertTrue(totalSeconds > 9);
        assertTrue(totalSeconds < 14);
    }
View Full Code Here

    @DirtiesContext
    public void singleRequest() throws Exception {
        logger.debug("singleRequest");

        Caller caller = this.populator().getCaller();
        Manager rm = this.locator.getManager();
       
        Double previousPrice = rm.getSpotPrice();
       
        final Double bid = previousPrice + 1;
        SpotCreateRequest requestSI = this.populator().getBasicRequestSI("suite:spotinstances:noresources:singleRequest", 1, bid, false);
       
        SpotRequestInfo result = rm.requestSpotInstances(requestSI, caller);

        //Check result
        assertEquals(RequestState.STATE_Open, result.getState().getStateStr());
        assertEquals(bid, result.getSpotPrice());
        assertTrue(!result.isPersistent());
       
        //New spot price is equal largest bid + 0.1 (since there are 0 resources)
        assertEquals(bid + 0.1,  rm.getSpotPrice());
       
        SpotRequestInfo[] spotRequestByCaller = rm.getSpotRequestsByCaller(caller);
        assertEquals(1, spotRequestByCaller.length);
        assertEquals(result, spotRequestByCaller[0]);
       
        assertEquals(result, rm.getSpotRequest(result.getRequestID(), caller));
       
        //Cancel request
        SpotRequestInfo[] cancelledReqs = rm.cancelSpotInstanceRequests(new String[]{result.getRequestID()}, caller);
        assertEquals(1, cancelledReqs.length);
        assertEquals(RequestState.STATE_Canceled, cancelledReqs[0].getState().getStateStr());
        assertEquals(result.getRequestID(), cancelledReqs[0].getRequestID());
       
        //Check if request was really cancelled
        SpotRequestInfo request = rm.getSpotRequest(result.getRequestID(), caller);
        assertEquals(RequestState.STATE_Canceled, request.getState().getStateStr());          
    }   
View Full Code Here

    // -----------------------------------------------------------------------------------------

    @Test
    @DirtiesContext
    public void memoryFreed() throws Exception {
        final Manager rm = this.locator.getManager();
        final Caller caller = this.populator().getCaller();
        final CreateRequest request =
                this.populator().getCreateRequest("memoryFreed", 240, 63, 1);
        final CreateResult result = rm.create(request, caller);
        final VM[] vms = result.getVMs();

        VmmNode node = getNodes()[0];
        assertFalse(node.isVacant());

        rm.trash(vms[0].getID(), Manager.INSTANCE, caller);
        node = getNodes()[0];

        assertTrue(node.isVacant());
    }
View Full Code Here

    }

    @Test
    @DirtiesContext
    public void badNetworkMemoryFreed() throws Exception {
        final Manager rm = this.locator.getManager();
        final Caller caller = this.populator().getCaller();
        final CreateRequest request =
                this.populator().getCreateRequest("badNetworkMemoryFreed", 240, 63, 1, null, "notarealnetwork");
        boolean gotError = false;
        try {
            rm.create(request, caller);

        } catch (ResourceRequestDeniedException e) {
            gotError = true;
            logger.error("Got error", e);
        }
View Full Code Here

TOP

Related Classes of org.nimbustools.api.services.rm.Manager

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.