Package org.nimbustools.api.repr

Examples of org.nimbustools.api.repr.SpotCreateRequest


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


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

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

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

        Double previousPrice = rm.getSpotPrice();

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

        SpotCreateRequest lowReq1 = this.populator().getBasicRequestSI("lowReq2", 3, lowBid, false);
        SpotCreateRequest lowReq2 = this.populator().getBasicRequestSI("lowReq3", 2, lowBid, true);
        SpotCreateRequest mediumReq = this.populator().getBasicRequestSI("mediumReq1", 3, mediumBid, false);

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

        //Submit 3 SI Requests
        String lowReq1Id = rm.requestSpotInstances(lowReq1, siCaller).getRequestID();
        String lowReq2Id = rm.requestSpotInstances(lowReq2, siCaller).getRequestID();
        String medReqId = rm.requestSpotInstances(mediumReq, siCaller).getRequestID();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 0MB
        // 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    |   3    |     3    | previousPrice+1  | ACTIVE |    false   |
        // | lowReq2    |   2    |     2    | previousPrice+1  | ACTIVE |    true    |
        // | mediumReq1 |   3    |     3    | previousPrice+3  | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 8
        // Spot price: lowBid (previousPrice+1)

        //Check available SI VMs
        assertEquals(8,  getAvailableResources());

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

        //Check if all submitted requests are active and fulfilled
        SpotRequestInfo lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq1SR.getState().getStateStr());
        assertEquals(3, lowReq1SR.getVMIds().length);

        SpotRequestInfo lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq2SR.getState().getStateStr());
        assertEquals(2, lowReq2SR.getVMIds().length);

        SpotRequestInfo medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Active, medReqSR.getState().getStateStr());
        assertEquals(3, medReqSR.getVMIds().length);

        logger.debug("Submitting WS request: wsReq1 (2 VMs, 120MB RAM each)");

        CreateRequest wsReq1 = this.populator().getCreateRequest("wsReq1", 1000, 120, 2);
        CreateResult wsReq1Result = rm.create(wsReq1, wsCaller);

        Long mark = System.currentTimeMillis();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 240MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 6 (128MB x 6 = 768)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     2    | previousPrice+1  | ACTIVE |    false   |
        // | lowReq2    |   2    |     1    | previousPrice+1  | ACTIVE |    true    |
        // | mediumReq1 |   3    |     3    | previousPrice+3  | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 7 (1 from lowReq1 was closed)
        // Spot price: lowBid (previousPrice+1)

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

        //Check available SI VMs
        assertEquals(6,  getAvailableResources());

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

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq1SR.getState().getStateStr());
        assertEquals(2, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq2SR.getState().getStateStr());
        assertEquals(1, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Active, medReqSR.getState().getStateStr());
        assertEquals(3, medReqSR.getVMIds().length);

        logger.debug("Submitting WS request: wsReq2 (2 VMs, 110MB RAM each)");

        CreateRequest wsReq2 = this.populator().getCreateRequest("wsReq2", TASK_TIME, 110, 2);
        rm.create(wsReq2, wsCaller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 460MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 4 (128MB x 4 = 512MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     1    | previousPrice+1  | ACTIVE |    false   |
        // | lowReq2    |   2    |     0    | previousPrice+1  | OPEN   |    true    |
        // | mediumReq1 |   3    |     3    | previousPrice+3  | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 6 (2 from lowReq1 were closed)
        // Spot price: lowBid (previousPrice+1)

        logger.debug("Waiting 4 seconds for SI VMs to be pre-empted.");
        Thread.sleep(4000);

        //Check available SI VMs
        assertEquals(4,  getAvailableResources());

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

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq1SR.getState().getStateStr());
        assertEquals(1, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Open, lowReq2SR.getState().getStateStr());
        assertEquals(0, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Active, medReqSR.getState().getStateStr());
        assertEquals(3, medReqSR.getVMIds().length);

        //Wait for wsReq2 to finish

        long elapsed = System.currentTimeMillis()-mark;
        long sleepTime = (TASK_TIME*1000 - elapsed) + BUFFER;
        if(sleepTime > 0){
            logger.debug("Waiting " + sleepTime + " milliseconds for wsReq2 to finish.");
            Thread.sleep(sleepTime);
        }

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 240MB
        // Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 6 (128MB x 6 = 768MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     1    | previousPrice+1  | ACTIVE |    false   |**
        // | lowReq2    |   2    |     2    | previousPrice+1  | ACTIVE |    true    |
        // | mediumReq1 |   3    |     3    | previousPrice+3  | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 6 (2 from lowReq1 were closed)
        // Spot price: lowBid (previousPrice+1)
        //
        // ** lowReq1 is not persistent, so no more VMs are allocated for this
        //    request (since 2 VMs were already finished (pre-empted))

        //Check available SI VMs
        assertEquals(6,  getAvailableResources());

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

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq1SR.getState().getStateStr());
        assertEquals(1, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq2SR.getState().getStateStr());
        assertEquals(2, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Active, medReqSR.getState().getStateStr());
        assertEquals(3, medReqSR.getVMIds().length);

        logger.debug("Submitting WS request: wsReq3 (2 VMs, 256MB RAM each)");

        CreateRequest wsReq3 = this.populator().getCreateRequest("wsReq3", 500, 256, 2);
        CreateResult wsReq3Result = rm.create(wsReq3, wsCaller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 752MB
        // Reserved capacity (for ordinary WS requests): 322MB (to ensure 70% max utilization)
        // Available basic SI VMs: 1 (128MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     0    | previousPrice+1  | CLOSED |    false   |
        // | lowReq2    |   2    |     0    | previousPrice+1  | OPEN   |    true    |
        // | mediumReq1 |   3    |     1    | previousPrice+3  | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 3
        // Spot price: lowBid (previousPrice+1)

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

        //Check available SI VMs
        assertEquals(1,  getAvailableResources());

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

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Closed, lowReq1SR.getState().getStateStr());
        assertEquals(0, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Open, lowReq2SR.getState().getStateStr());
        assertEquals(0, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Active, medReqSR.getState().getStateStr());
        assertEquals(1, medReqSR.getVMIds().length);

        logger.debug("Submitting WS request: wsReq4 (1 VM with 256MB RAM)");

        CreateRequest wsReq4 = this.populator().getCreateRequest("wsReq4", 500, 256, 1);
        CreateResult wsReq4Result = rm.create(wsReq4, wsCaller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 1008MB
        // Reserved capacity (for ordinary WS requests): 432MB (to ensure 70% max utilization)
        // Available basic SI VMs: 0
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     0    | previousPrice+1  | CLOSED |    false   |
        // | lowReq2    |   2    |     0    | previousPrice+1  | OPEN   |    true    |
        // | mediumReq1 |   3    |     0    | previousPrice+3  | CLOSED |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 2
        // Spot price: lowBid + 1

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

        //Check available SI VMs
        assertEquals(0,  getAvailableResources());

        //New spot price is equal to lower bid + 0.1 (since lower bid is the highest ALIVE bid)
        assertEquals(lowBid+0.1,  rm.getSpotPrice());

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Closed, lowReq1SR.getState().getStateStr());
        assertEquals(0, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Open, lowReq2SR.getState().getStateStr());
        assertEquals(0, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Closed, medReqSR.getState().getStateStr());
        assertEquals(0, medReqSR.getVMIds().length);

        logger.debug("Destroying wsReq3 VMs: 2 VMs, 256MB RAM each");

        rm.trash(wsReq3Result.getGroupID(), Manager.GROUP, wsCaller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 496MB
        // Reserved capacity (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 4 (128MB x 4 = 512MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     0    | previousPrice+1  | CLOSED |    false   |
        // | lowReq2    |   2    |     2    | previousPrice+1  | ACTIVE |    true    |
        // | mediumReq1 |   3    |     0    | previousPrice+3  | CLOSED |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 2
        // Spot price: MINIMUM_PRICE (since requestedVMs < availableVMs)

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

        //Check available SI VMs
        assertEquals(4,  getAvailableResources());

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

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Closed, lowReq1SR.getState().getStateStr());
        assertEquals(0, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq2SR.getState().getStateStr());
        assertEquals(2, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Closed, medReqSR.getState().getStateStr());
        assertEquals(0, medReqSR.getVMIds().length);

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

        SpotCreateRequest mediumReq2 = this.populator().getBasicRequestSI("mediumReq2", 1, mediumBid, false);
        String medReq2Id = rm.requestSpotInstances(mediumReq2, siCaller).getRequestID();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 496MB
        // Reserved capacity (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 4 (128MB x 4 = 512MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     0    | previousPrice+1  | CLOSED |    false   |
        // | lowReq2    |   2    |     2    | previousPrice+1  | ACTIVE |    true    |
        // | mediumReq1 |   3    |     0    | previousPrice+3  | CLOSED |    false   |
        // | mediumReq2 |   1    |     1    | previousPrice+3  | ACTIVE |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 3
        // Spot price: MINIMUM_PRICE (since requestedVMs < availableVMs)

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

        //Check available SI VMs
        assertEquals(4,  getAvailableResources());

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

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Closed, lowReq1SR.getState().getStateStr());
        assertEquals(0, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq2SR.getState().getStateStr());
        assertEquals(2, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Closed, medReqSR.getState().getStateStr());
        assertEquals(0, medReqSR.getVMIds().length);

        SpotRequestInfo medReq2SR = rm.getSpotRequest(medReq2Id, siCaller);
        assertEquals(RequestState.STATE_Active, medReq2SR.getState().getStateStr());
        assertEquals(1, medReq2SR.getVMIds().length);

        logger.debug("Shutting down VM from mediumReq2");

        rm.trash(medReq2SR.getVMIds()[0], Manager.INSTANCE, siCaller);

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
        // Used WS memory: 496MB
        // Reserved capacity (for ordinary WS requests): 256MB (minimum reserved capacity)
        // Available basic SI VMs: 4 (128MB x 4 = 512MB)
        //
        // Current Requests___________________________________________________________
        // |   Request  | reqVMs | allocVMs |       Bid        | Status | Persistent |
        // | lowReq1    |   3    |     0    | previousPrice+1  | CLOSED |    false   |
        // | lowReq2    |   2    |     2    | previousPrice+1  | ACTIVE |    true    |
        // | mediumReq1 |   3    |     0    | previousPrice+3  | CLOSED |    false   |
        // | mediumReq2 |   1    |     0    | previousPrice+3  | CLOSED |    false   |
        // ---------------------------------------------------------------------------
        // Requested SI VMs (alive requests): 2
        // Spot price: MINIMUM_PRICE (since requestedVMs < availableVMs)

        logger.debug("Waiting 10 seconds for VM to shutdown.");
        Thread.sleep(10000);

        //Check available SI VMs
        assertEquals(4,  getAvailableResources());

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

        lowReq1SR = rm.getSpotRequest(lowReq1Id, siCaller);
        assertEquals(RequestState.STATE_Closed, lowReq1SR.getState().getStateStr());
        assertEquals(0, lowReq1SR.getVMIds().length);

        lowReq2SR = rm.getSpotRequest(lowReq2Id, siCaller);
        assertEquals(RequestState.STATE_Active, lowReq2SR.getState().getStateStr());
        assertEquals(2, lowReq2SR.getVMIds().length);

        medReqSR = rm.getSpotRequest(medReqId, siCaller);
        assertEquals(RequestState.STATE_Closed, medReqSR.getState().getStateStr());
        assertEquals(0, medReqSR.getVMIds().length);

        medReq2SR = rm.getSpotRequest(medReq2Id, siCaller);
        assertEquals(RequestState.STATE_Closed, medReq2SR.getState().getStateStr());
        assertEquals(0, medReq2SR.getVMIds().length);

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

        Double highBid = previousPrice + 4;
        SpotCreateRequest highReq1 = this.populator().getBasicRequestSI("highBid1", 4, highBid, false);
        String highReq1Id = rm.requestSpotInstances(highReq1, siCaller).getRequestID();

        // Spot Instances Snapshot
        //
        // Total memory: 1280MB
View Full Code Here

            RequestSpotInstancesType req, Caller caller, Manager manager)
            throws RemoteException {
       
        final SpotRequestInfo result;
        try {
            SpotCreateRequest creq =
                    this.translateReqSpotInstances(req, caller);
            AddCustomizations.addAll((_CreateRequest)creq,
                                     this.repr, this.mdServer);
            result = manager.requestSpotInstances(creq, caller);
View Full Code Here

        final String reqiID = generateRequestID();
       
        AsyncRequest asyncReq;
               
        if(req instanceof SpotCreateRequest){
            SpotCreateRequest spotReq = (SpotCreateRequest)req;
            asyncReq = new AsyncRequest(reqiID, spotReq.getSpotPrice(), spotReq.isPersistent(),
                                        caller, groupID, bound, req.getContext(), req.getRequestedNics(),
                                        req.getSshKeyName(), Calendar.getInstance());  
        } else {
            asyncReq = new AsyncRequest(reqiID, caller, groupID, bound,
                                        req.getContext(), req.getRequestedNics(),
View Full Code Here

TOP

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

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.