Package org.nimbustools.api.repr

Examples of org.nimbustools.api.repr.RequestInfo


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


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

        Double previousPrice = rm.getSpotPrice();

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

        AsyncCreateRequest backfillRequest = this.populator().getBackfillRequest("backfill", 10);
        RequestInfo backfillResult = rm.addBackfillRequest(backfillRequest, superuser);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB  (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024)
        //
        // Current SI Requests________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request  | reqVMs | allocVMs | Status |
        // | backfill   |   10   |    8     | ACTIVE |
        // -------------------------------------------
        // Requested SI VMs (alive requests): 0
        // Spot price: MINIUM_PRICE (since requestedVMs < availableVMs)

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

        //Verify there are no spot instance requests
        SpotRequestInfo[] spotRequestByCaller = rm.getSpotRequestsByCaller(superuser);
        assertEquals(0, spotRequestByCaller.length);
        spotRequestByCaller = rm.getSpotRequestsByCaller(caller);
        assertEquals(0, spotRequestByCaller.length);

        //Check backfill request state
        RequestInfo[] backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);
        String[] vmIdsBefore = backfillRequestsByCaller[0].getVMIds();
        assertEquals(8, vmIdsBefore.length);
        assertEquals(RequestState.STATE_Active, backfillRequestsByCaller[0].getState().getStateStr());

        //New spot price is equal to minimum price (since there are still available resources)
        assertEquals(MINIMUM_PRICE,  rm.getSpotPrice());

        final Double bid = previousPrice + 1;
        SpotCreateRequest requestSI = this.populator().getBasicRequestSI("singleRequest", 1, bid, false);

        logger.debug("Submitting basic SI request: singleRequest");

        //Request spot instances
        SpotRequestInfo result = rm.requestSpotInstances(requestSI, caller);

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

        //Check result
        //note: cannot check state at this point, because it can either be
        //OPEN (not scheduled yet) or ACTIVE (already scheduled)
        assertEquals(bid, result.getSpotPrice());
        assertTrue(!result.isPersistent());

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB  (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024)
        //
        // Current SI Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | singleReq  |    1   |    1     |  previousPrice+1 | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request  | reqVMs | allocVMs | Status |
        // | backfill   |   10   |    7     | ACTIVE |
        // -------------------------------------------
        // Requested SI VMs (alive requests): 1
        // Spot price: MINIUM_PRICE (since requestedVMs < availableVMs)

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);
        String[] vmIdsAfter = backfillRequestsByCaller[0].getVMIds();
        assertEquals(7, vmIdsAfter.length);
        assertEquals(RequestState.STATE_Active, backfillRequestsByCaller[0].getState().getStateStr());

        //This check is to ensure that the VMs now are the same as before (ie. VMs were not restarted)
        Integer equalVms = 0;
        for (String vmIdBefore : vmIdsBefore) {
            for (String vmIdAfter : vmIdsAfter) {
                if(vmIdAfter.equals(vmIdBefore)){
                    equalVms++;
                    break;
                }
            }
        }
        assertEquals(new Integer(7), equalVms);

        //New spot price is equal to minimum price (since there are still available resources)
        assertEquals(MINIMUM_PRICE,  rm.getSpotPrice());

        spotRequestByCaller = rm.getSpotRequestsByCaller(caller);
        assertEquals(1, spotRequestByCaller.length);

        //Let's assume the request was already scheduled, so the state should be ACTIVE
        SpotRequestInfo request = rm.getSpotRequest(result.getRequestID(), caller);
        assertEquals(RequestState.STATE_Active, request.getState().getStateStr());
        assertEquals(1, request.getVMIds().length);

        logger.debug("Cancelling basic SI request: singleRequest");

        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());

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB
        // Available basic SI VMs: 8 (128MB x 8 = 1024)
        //
        // Current Requests______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        |   Status  | Persistent |
        // | singleReq  |    1   |    1     |  previousPrice+1 | CANCELLED |    false   |
        // ------------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request  | reqVMs | allocVMs | Status |
        // | backfill   |   10   |    7     | ACTIVE |
        // -------------------------------------------
        // Requested SI VMs (alive requests): 1
        // Spot price: MINIUM_PRICE (since requestedVMs < availableVMs)

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);
        assertEquals(7, backfillRequestsByCaller[0].getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfillRequestsByCaller[0].getState().getStateStr());

        //Check if request was really cancelled
        request = rm.getSpotRequest(result.getRequestID(), caller);
        assertEquals(RequestState.STATE_Canceled, request.getState().getStateStr());
        assertEquals(1, request.getVMIds().length);

        Double higherBid = previousPrice + 2;
        requestSI = this.populator().getBasicRequestSI("higherRequest", 7, higherBid, false);

        logger.debug("Submitting basic SI request: higherRequest");

        //Request spot instances
        SpotRequestInfo result2 = rm.requestSpotInstances(requestSI, caller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB
        // Available basic SI VMs: 8 (128MB x 8 = 1024)
        //
        // Current Requests______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        |   Status  | Persistent |
        // | singleReq  |    1   |    1     |  previousPrice+1 | CANCELLED |    false   |
        // | higherReq  |    7   |    7     |  previousPrice+2 | ACTIVE    |    false   |
        // ------------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request  | reqVMs | allocVMs | Status |
        // | backfill   |   10   |    0     | OPEN   |
        // -------------------------------------------
        // Requested SI VMs (alive requests): 8
        // Spot price: bid (previousPrice+1)

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to bid
        assertEquals(bid,  rm.getSpotPrice());

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);
        assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());

        //Check if request was really cancelled
        request = rm.getSpotRequest(result.getRequestID(), caller);
        assertEquals(RequestState.STATE_Canceled, request.getState().getStateStr());
        assertEquals(1, request.getVMIds().length);

        //Check if submitted request is active
        request = rm.getSpotRequest(result2.getRequestID(), caller);
        assertEquals(RequestState.STATE_Active, request.getState().getStateStr());
        assertEquals(7, request.getVMIds().length);

        requestSI = this.populator().getBasicRequestSI("higherRequest2", 1, higherBid, false);

        logger.debug("Submitting basic SI request: higherRequest2");

        //Request spot instances
        SpotRequestInfo result3 = rm.requestSpotInstances(requestSI, caller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB
        // Available basic SI VMs: 8 (128MB x 8 = 1024)
        //
        // Current Requests______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        |   Status  | Persistent |
        // | singleReq  |    1   |    0     |  previousPrice+1 | CANCELLED |    false   |
        // | higherReq  |    7   |    7     |  previousPrice+2 | ACTIVE    |    false   |
        // | higherReq2 |    1   |    1     |  previousPrice+2 | ACTIVE    |    false   |
        // ------------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request  | reqVMs | allocVMs | Status |
        // | backfill   |   10   |    0     | OPEN   |
        // -------------------------------------------
        // Requested SI VMs (alive requests): 8
        // Spot price: higherBid (previousPrice+2)

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to higherBid
        assertEquals(higherBid,  rm.getSpotPrice());

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);
        assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());

        //Check if request has no VMs
        request = rm.getSpotRequest(result.getRequestID(), caller);
        assertEquals(RequestState.STATE_Canceled, request.getState().getStateStr());
        assertEquals(0, request.getVMIds().length);

        //Check if previous submitted request is active
        request = rm.getSpotRequest(result2.getRequestID(), caller);
        assertEquals(RequestState.STATE_Active, request.getState().getStateStr());
        assertEquals(7, request.getVMIds().length);

        //Check if submitted request is active
        request = rm.getSpotRequest(result3.getRequestID(), caller);
        assertEquals(RequestState.STATE_Active, request.getState().getStateStr());
        assertEquals(1, request.getVMIds().length);

        logger.debug("Trashing higherRequest VMs");

        request = rm.getSpotRequest(result2.getRequestID(), caller);
        rm.trash(request.getGroupID(), Manager.GROUP, caller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB
        // Available basic SI VMs: 8 (128MB x 8 = 1024)
        //
        // Current Requests______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        |   Status  | Persistent |
        // | singleReq  |    1   |    0     |  previousPrice+1 | CANCELLED |    false   |
        // | higherReq  |    7   |    0     |  previousPrice+2 | CLOSED    |    false   |
        // | higherReq2 |    1   |    1     |  previousPrice+2 | ACTIVE    |    false   |
        // ------------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request  | reqVMs | allocVMs | Status |
        // | backfill   |   10   |    7     | ACTIVE |
        // -------------------------------------------
        // Requested SI VMs (alive requests): 1
        // Spot price: MINIUM_PRICE (since requestedVMs < availableVMs)

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to minimum price (since there are still available resources)
        assertEquals(MINIMUM_PRICE,  rm.getSpotPrice());

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(1, backfillRequestsByCaller.length);
        assertEquals(7, backfillRequestsByCaller[0].getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfillRequestsByCaller[0].getState().getStateStr());

        //Check if request has no VMs
        request = rm.getSpotRequest(result.getRequestID(), caller);
        assertEquals(RequestState.STATE_Canceled, request.getState().getStateStr());
        assertEquals(0, request.getVMIds().length);

        //Check if previous submitted request is closed
        request = rm.getSpotRequest(result2.getRequestID(), caller);
        assertEquals(RequestState.STATE_Closed, request.getState().getStateStr());
        assertEquals(0, request.getVMIds().length);

        //Check if submitted request is active
        request = rm.getSpotRequest(result3.getRequestID(), caller);
        assertEquals(RequestState.STATE_Active, request.getState().getStateStr());
        assertEquals(1, request.getVMIds().length);

        logger.debug("Cancelling backfill request.");

        RequestInfo[] cancelledBackfillReqs = rm.cancelBackfillRequests(new String[]{backfillResult.getRequestID()}, superuser);
        assertEquals(1, cancelledBackfillReqs.length);
        assertEquals(RequestState.STATE_Canceled, cancelledBackfillReqs[0].getState().getStateStr());
        assertEquals(backfillResult.getRequestID(), cancelledBackfillReqs[0].getRequestID());

        logger.debug("Waiting for termination.");
        Thread.sleep(2100);

        //Check backfill request state
        RequestInfo backfillReq = rm.getBackfillRequest(backfillResult.getRequestID(), superuser);
        assertEquals(0, backfillReq.getVMIds().length);
        assertEquals(RequestState.STATE_Canceled, backfillReq.getState().getStateStr());

        logger.debug("Trashing higherRequest2 VMs");

        request = rm.getSpotRequest(result3.getRequestID(), caller);
        rm.trash(request.getVMIds()[0], Manager.INSTANCE, caller);
View Full Code Here

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

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

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

        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);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB  (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024)
        //
        // Current SI Requests________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    3     | ACTIVE |
        // |  backfill2  |   5    |    5     | ACTIVE |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 0
        // Spot price: MINIUM_PRICE (since requestedVMs < availableVMs)

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

        //Verify there are no spot instance requests
        SpotRequestInfo[] spotRequestByCaller = rm.getSpotRequestsByCaller(superuser);
        assertEquals(0, spotRequestByCaller.length);
        spotRequestByCaller = rm.getSpotRequestsByCaller(caller1);
        assertEquals(0, spotRequestByCaller.length);
        spotRequestByCaller = rm.getSpotRequestsByCaller(caller2);
        assertEquals(0, spotRequestByCaller.length);
        spotRequestByCaller = rm.getSpotRequestsByCaller(caller3);
        assertEquals(0, spotRequestByCaller.length);

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

        backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
        assertEquals(3, backfill1Result.getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfill1Result.getState().getStateStr());

        backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
        assertEquals(5, backfill2Result.getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());

        //New spot price is equal to minimum price (since there are still available resources)
        assertEquals(MINIMUM_PRICE,  rm.getSpotPrice());

        Double previousPrice = rm.getSpotPrice();

        final Double lowBid = previousPrice + 1;
        final Double mediumBid = previousPrice + 2;
        final Double highBid = previousPrice + 3;

        SpotCreateRequest lowReq1 = this.populator().getBasicRequestSI("lowReq1", 1, lowBid, false);
        SpotCreateRequest lowReq2 = this.populator().getBasicRequestSI("lowReq2", 3, lowBid, true);
        SpotCreateRequest lowReq3 = this.populator().getBasicRequestSI("lowReq3", 1, lowBid, false);
        SpotCreateRequest mediumReq1 = this.populator().getBasicRequestSI("mediumReq1", 3, mediumBid, false);
        SpotCreateRequest mediumReq2 = this.populator().getBasicRequestSI("mediumReq2", 5, mediumBid, true);
        SpotCreateRequest highReq = this.populator().getBasicRequestSI("highReq", 10, highBid, false);

        logger.debug("Submitting SI requests: lowReq1, lowReq2, mediumReq1");

        //Submit 3 SI Requests
        String lowReq1Id = rm.requestSpotInstances(lowReq1, caller1).getRequestID();
        String lowReq2Id = rm.requestSpotInstances(lowReq2, caller1).getRequestID();
        String medReq1Id = rm.requestSpotInstances(mediumReq1, caller2).getRequestID();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   1    |    1     |  previousPrice+1 | ACTIVE |    false   |
        // | lowReq2    |   3    |    3     |  previousPrice+1 | ACTIVE |    true    |
        // | mediumReq1 |   3    |    3     |  previousPrice+2 | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    1     | ACTIVE |
        // |  backfill2  |   5    |    0     | OPEN   |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 7
        // Spot price: MINIMUM_PRICE (since requestedVMs < availableVMs)

        Calendar ts2 = Calendar.getInstance();

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to minimum price
        assertEquals(MINIMUM_PRICE,  rm.getSpotPrice());

        //Check if all submitted requests are active
        SpotRequestInfo[] caller1Reqs = rm.getSpotRequestsByCaller(caller1);
        for (SpotRequestInfo caller1Req : caller1Reqs) {
            assertEquals(RequestState.STATE_Active, caller1Req.getState().getStateStr());
        }
        SpotRequestInfo[] caller2Reqs = rm.getSpotRequestsByCaller(caller2);
        assertEquals(RequestState.STATE_Active, caller2Reqs[0].getState().getStateStr());

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

        backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
        assertEquals(1, backfill1Result.getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfill1Result.getState().getStateStr());

        backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
        assertEquals(0, backfill2Result.getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfill2Result.getState().getStateStr());

        logger.debug("Submitting SI request: lowReq3");

        //Submit another SI Request
        String lowReq3Id = rm.requestSpotInstances(lowReq3, caller2).getRequestID();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   1    |    1     |  previousPrice+1 | ACTIVE |    false   |
        // | lowReq2    |   3    |    3     |  previousPrice+1 | ACTIVE |    true    |
        // | mediumReq1 |   3    |    3     |  previousPrice+2 | ACTIVE |    false   |
        // | lowReq3    |   1    |    1     |  previousPrice+1 | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    0     | OPEN   |
        // |  backfill2  |   5    |    0     | OPEN   |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 8
        // Spot price: lowBid (previousPrice+1)

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to lower bid
        assertEquals(lowBid,  rm.getSpotPrice());

        //Check if submitted request is active
        assertEquals(RequestState.STATE_Active, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(2, backfillRequestsByCaller.length);
        assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());
        assertEquals(0, backfillRequestsByCaller[1].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[1].getState().getStateStr());

        logger.debug("Submitting SI request: mediumReq2");

        //Submit another medium-bid SI Request
        String medReq2Id = rm.requestSpotInstances(mediumReq2, caller2).getRequestID();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   1    |    0     |  previousPrice+1 | CLOSED |    false   |
        // | lowReq2    |   3    |    0     |  previousPrice+1 | OPEN   |    true    |
        // | mediumReq1 |   3    |    3     |  previousPrice+2 | ACTIVE |    false   |
        // | lowReq3    |   1    |    0     |  previousPrice+1 | CLOSED |    false   |
        // | mediumReq2 |   5    |    5     |  previousPrice+2 | ACTIVE |    true    |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    0     | OPEN   |
        // |  backfill2  |   5    |    0     | OPEN   |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 11
        // Spot price: mediumBid (previousPrice+2)

        Calendar ts4 = Calendar.getInstance();

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to medium bid
        assertEquals(mediumBid,  rm.getSpotPrice());

        //Check if submitted request is active
        assertEquals(RequestState.STATE_Active, rm.getSpotRequest(medReq2Id, caller2).getState().getStateStr());

        //Check if previous medium-bid request is still active
        assertEquals(RequestState.STATE_Active, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());

        //Check if persistent lower-bid requests are open
        assertEquals(RequestState.STATE_Open, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());

        //Check if non-persistent lower-bid requests are closed
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(2, backfillRequestsByCaller.length);
        assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());
        assertEquals(0, backfillRequestsByCaller[1].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[1].getState().getStateStr());

        logger.debug("Submitting SI request: highReq");

        //Submit a higher-bid SI Request
        String highReqId = rm.requestSpotInstances(highReq, caller3).getRequestID();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   1    |    0     |  previousPrice+1 | CLOSED |    false   |
        // | lowReq2    |   3    |    0     |  previousPrice+1 | OPEN   |    true    |
        // | mediumReq1 |   3    |    0     |  previousPrice+2 | CLOSED |    false   |
        // | lowReq3    |   1    |    0     |  previousPrice+1 | CLOSED |    false   |
        // | mediumReq2 |   5    |    0     |  previousPrice+2 | OPEN   |    true    |
        // | highReq    |  10    |    8     |  previousPrice+3 | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    0     | OPEN   |
        // |  backfill2  |   5    |    0     | OPEN   |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 18
        // Spot price: highBid (previousPrice+3)

        Calendar ts5 = Calendar.getInstance();

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to high bid
        assertEquals(highBid,  rm.getSpotPrice());

        //Check if submitted request is active
        assertEquals(RequestState.STATE_Active, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());

        //Check if persistent requests are open
        assertEquals(RequestState.STATE_Open, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());
        assertEquals(RequestState.STATE_Open, rm.getSpotRequest(medReq2Id, caller2).getState().getStateStr());

        //Check if non-persistent requests are closed
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());

        //Check backfill request state
        backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
        assertEquals(2, backfillRequestsByCaller.length);
        assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());
        assertEquals(0, backfillRequestsByCaller[1].getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[1].getState().getStateStr());

        rm.cancelSpotInstanceRequests(new String[]{lowReq2Id}, caller1);
        rm.cancelSpotInstanceRequests(new String[]{highReqId}, caller3);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests_______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status    | Persistent |
        // | lowReq1    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | lowReq2    |   3    |    0     |  previousPrice+1 | CANCELLED |    true    |
        // | mediumReq1 |   3    |    0     |  previousPrice+2 | CLOSED    |    false   |
        // | lowReq3    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | mediumReq2 |   5    |    0     |  previousPrice+2 | OPEN      |    true    |
        // | highReq    |  10    |    8     |  previousPrice+3 | CANCELLED |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    0     | OPEN   |
        // |  backfill2  |   5    |    0     | OPEN   |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 15
        // Spot price: highBid (previousPrice+3)

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to minimum price
        assertEquals(highBid,  rm.getSpotPrice());

        //Check if requests were cancelled
        assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());
        assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());

        //Check if canceled request has allocated VMs
        SpotRequestInfo highReq1 = rm.getSpotRequest(highReqId, caller3);
        assertEquals(RequestState.STATE_Canceled, highReq1.getState().getStateStr());
        assertEquals(8, highReq1.getVMIds().length);

        //Check if persistent request is open
        SpotRequestInfo medReq2 = rm.getSpotRequest(medReq2Id, caller2);
        assertEquals(RequestState.STATE_Open, medReq2.getState().getStateStr());
        assertEquals(0, medReq2.getVMIds().length);

        //Check if non-persistent requests are closed
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());

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

        backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
        assertEquals(0, backfill1Result.getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfill1Result.getState().getStateStr());

        backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
        assertEquals(0, backfill2Result.getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfill2Result.getState().getStateStr());

        //Trash 5 VMs from highReq
        for (int i = 0; i < 5; i++) {
            rm.trash(highReq1.getVMIds()[i], Manager.INSTANCE, caller3);
        }

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests_______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status    | Persistent |
        // | lowReq1    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | lowReq2    |   3    |    0     |  previousPrice+1 | CANCELLED |    true    |
        // | mediumReq1 |   3    |    0     |  previousPrice+2 | CLOSED    |    false   |
        // | lowReq3    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | mediumReq2 |   5    |    5     |  previousPrice+2 | ACTIVE    |    true    |
        // | highReq    |  10    |    3     |  previousPrice+3 | CANCELLED |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    0     | OPEN   |
        // |  backfill2  |   5    |    0     | OPEN   |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 8
        // Spot price: mediumBid (previousPrice+2)

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to minimum price
        assertEquals(mediumBid,  rm.getSpotPrice());

        //Check if requests were cancelled
        assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());
        assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());

        //Check if canceled request has allocated VMs
        highReq1 = rm.getSpotRequest(highReqId, caller3);
        assertEquals(RequestState.STATE_Canceled, highReq1.getState().getStateStr());
        assertEquals(3, highReq1.getVMIds().length);

        //Check if persistent request is active
        medReq2 = rm.getSpotRequest(medReq2Id, caller2);
        assertEquals(RequestState.STATE_Active, medReq2.getState().getStateStr());
        assertEquals(5, medReq2.getVMIds().length);

        //Check if non-persistent requests are closed
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());

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

        backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
        assertEquals(0, backfill1Result.getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfill1Result.getState().getStateStr());

        backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
        assertEquals(0, backfill2Result.getVMIds().length);
        assertEquals(RequestState.STATE_Open, backfill2Result.getState().getStateStr());

        rm.trash(highReq1.getGroupID(), Manager.GROUP, caller3);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests_______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status    | Persistent |
        // | lowReq1    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | lowReq2    |   3    |    0     |  previousPrice+1 | CANCELLED |    true    |
        // | mediumReq1 |   3    |    0     |  previousPrice+2 | CLOSED    |    false   |
        // | lowReq3    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | mediumReq2 |   5    |    5     |  previousPrice+2 | ACTIVE    |    true    |
        // | highReq    |  10    |    0     |  previousPrice+3 | CANCELLED |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests__________________________
        // |   Request   | reqVMs | allocVMs | Status |
        // |  backfill1  |   3    |    2     | ACTIVE |
        // |  backfill2  |   5    |    1     | ACTIVE |
        // --------------------------------------------
        // Requested SI VMs (alive requests): 5
        // Spot price: MINIMUM_PRICE

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //New spot price is equal to minimum price
        assertEquals(MINIMUM_PRICE,  rm.getSpotPrice());

        //Check if requests were cancelled
        assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());
        assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());

        //Check if persistent request is active
        medReq2 = rm.getSpotRequest(medReq2Id, caller2);
        assertEquals(RequestState.STATE_Active, medReq2.getState().getStateStr());
        assertEquals(5, medReq2.getVMIds().length);

        //Check if non-persistent requests are closed
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
        assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());

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

        backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
        assertEquals(2, backfill1Result.getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfill1Result.getState().getStateStr());

        backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
        assertEquals(1, backfill2Result.getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());

        rm.cancelBackfillRequests(new String[]{backfill1Result.getRequestID()}, superuser);
        rm.trash(backfill1Result.getGroupID(), Manager.GROUP, superuser);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests_______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status    | Persistent |
        // | lowReq1    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | lowReq2    |   3    |    0     |  previousPrice+1 | CANCELLED |    true    |
        // | mediumReq1 |   3    |    0     |  previousPrice+2 | CLOSED    |    false   |
        // | lowReq3    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | mediumReq2 |   5    |    5     |  previousPrice+2 | ACTIVE    |    true    |
        // | highReq    |  10    |    0     |  previousPrice+3 | CANCELLED |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests______________________________
        // |   Request   | reqVMs | allocVMs | Status    |
        // |  backfill1  |   3    |    0     | CANCELLED |
        // |  backfill2  |   5    |    3     | ACTIVE    |
        // -----------------------------------------------
        // Requested SI VMs (alive requests): 5
        // Spot price: MINIMUM_PRICE

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

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

        backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
        assertEquals(0, backfill1Result.getVMIds().length);
        assertEquals(RequestState.STATE_Canceled, backfill1Result.getState().getStateStr());

        backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
        assertEquals(3, backfill2Result.getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());

        rm.cancelSpotInstanceRequests(new String[]{medReq2Id}, caller2);
        rm.trash(medReq2.getGroupID(), Manager.GROUP, caller2);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 8 (128MB x 8 = 1024MB)
        //
        // Current Requests_______________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status    | Persistent |
        // | lowReq1    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | lowReq2    |   3    |    0     |  previousPrice+1 | CANCELLED |    true    |
        // | mediumReq1 |   3    |    0     |  previousPrice+2 | CLOSED    |    false   |
        // | lowReq3    |   1    |    0     |  previousPrice+1 | CLOSED    |    false   |
        // | mediumReq2 |   5    |    0     |  previousPrice+2 | CANCELLED |    true    |
        // | highReq    |  10    |    0     |  previousPrice+3 | CANCELLED |    false   |
        // ---------------------------------------------------------------------------
        // Backfill Requests______________________________
        // |   Request   | reqVMs | allocVMs | Status    |
        // |  backfill1  |   3    |    0     | CANCELLED |
        // |  backfill2  |   5    |    5     | ACTIVE    |
        // -----------------------------------------------
        // Requested SI VMs (alive requests): 0
        // Spot price: MINIMUM_PRICE

        logger.debug("Waiting 10 seconds for resources to be pre-empted.");
        Thread.sleep(10000);

        //Check if persistent request was cancelled
        medReq2 = rm.getSpotRequest(medReq2Id, caller2);
        assertEquals(RequestState.STATE_Canceled, medReq2.getState().getStateStr());
        assertEquals(0, medReq2.getVMIds().length);

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

        backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
        assertEquals(0, backfill1Result.getVMIds().length);
        assertEquals(RequestState.STATE_Canceled, backfill1Result.getState().getStateStr());

        backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
        assertEquals(5, backfill2Result.getVMIds().length);
        assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());

        //Expected prices from full history

        Double[] prices = new Double[]{MINIMUM_PRICE, lowBid, mediumBid, highBid, mediumBid, MINIMUM_PRICE};
View Full Code Here

TOP

Related Classes of org.nimbustools.api.repr.RequestInfo

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.