Package org.globus.workspace.async

Examples of org.globus.workspace.async.AsyncRequest


        nics = dataConvert.getNICs(nicsAsString);
        AsyncRequestStatus status = AsyncRequestStatus.valueOf(rs.getString("status"));

        //public AsyncRequest(String id, boolean spotinstances, Double spotPrice, boolean persistent, Caller caller, String groupID, VirtualMachine[] bindings, Context context, NIC[] requestedNics, String sshKeyName, Calendar creationTime) {
        //AsyncRequest testRequest = new AsyncRequest(testID, testSpotinstances, testMaxBid, false, null, testGroupID, null, null, null, null, null);
        AsyncRequest asyncRequest = new AsyncRequest(id, isSpotInstance, maxBid, isPersistent, caller, groupID, null, context, nics, sshKeyName, creationTime);

        asyncRequest.setStatus(status);
        return asyncRequest;
    }
View Full Code Here


        DataConvert dataConvert = new DataConvert(this.locator.getReprFactory());
        NIC[] testNICs = dataConvert.getNICs(testVM);
        logger.debug("Nics: " + testNICs[0]);

        //public AsyncRequest(String id, boolean spotinstances, Double spotPrice, boolean persistent, Caller caller, String groupID, VirtualMachine[] bindings, Context context, NIC[] requestedNics, String sshKeyName, Calendar creationTime) {
        AsyncRequest testRequest = new AsyncRequest(testID, testSpotinstances, testMaxBid, testIsPersistent, testCaller, testGroupID, testBindings, context, testNICs, testSshKeyName, testCreationTime);
        testRequest.addAllocatedVM(testAllocatedVM);
        asyncRequestMap.addOrReplace(testRequest);

        String secondID = "this-is-the-other-one";
        double secondMaxBid = 4.5;
        VirtualMachine[] secondBindings = new VirtualMachine[1];
        VirtualMachine secondVM = new VirtualMachine();
        secondVM.setID(52);
        secondBindings[0] = secondVM;

        AsyncRequest secondRequest = new AsyncRequest(secondID, testSpotinstances, secondMaxBid, testIsPersistent, testCaller, testGroupID, secondBindings, context, testNICs, testSshKeyName, testCreationTime);

        allRequests = asyncRequestMap.getAll();
        assert(allRequests != null);
        logger.debug("You have " + allRequests.size() + " requests.");
        assert(allRequests.size() == 1);

        // Note, the persistence layer just dumps the context, so we don't test for it

        AsyncRequest gotRequest = asyncRequestMap.getByID(testID);
        assertEquals(testID, gotRequest.getId());
        assertEquals(testMaxBid, gotRequest.getMaxBid());
        assertEquals(testSpotinstances, gotRequest.isSpotRequest());
        assertEquals(testGroupID, gotRequest.getGroupID());
        assertEquals(testIsPersistent, gotRequest.isPersistent());
        assertEquals(testCaller, gotRequest.getCaller());
        assertEquals(testSshKeyName, gotRequest.getSshKeyName());
        assertEquals(testCreationTime, gotRequest.getCreationTime());
        assertEquals(testVM.getID(), gotRequest.getBindings()[0].getID());
        assertEquals(testNICs[0].getIpAddress(), gotRequest.getRequestedNics()[0].getIpAddress());
        assertEquals(testAllocatedVM, gotRequest.getAllocatedVMs()[0]);
        assertEquals(AsyncRequestStatus.OPEN, gotRequest.getStatus());


        //Now Mutate the Map
        asyncRequestMap.addOrReplace(secondRequest);

        gotRequest.setStatus(AsyncRequestStatus.ACTIVE);
        asyncRequestMap.addOrReplace(gotRequest);

        AsyncRequest gotSecondRequest = asyncRequestMap.getByID(secondID);
        AsyncRequest updatedRequest = asyncRequestMap.getByID(testID);
        assertEquals(AsyncRequestStatus.ACTIVE, updatedRequest.getStatus());
        assertEquals(testAllocatedVM, updatedRequest.getAllocatedVMs()[0]);

        asyncRequestMap.addOrReplace(updatedRequest);
        AsyncRequest updatedRequest1 = asyncRequestMap.getByID(testID);
        assertEquals(testAllocatedVM, updatedRequest1.getAllocatedVMs()[0]);
        assertEquals(0, gotSecondRequest.getAllocatedVMs().length);
    }
View Full Code Here

        }

        VM vm = this.dataConvert.getVM(resource);
       
        if(VMConstants.LIFE_CYCLE_SPOT.equals(vm.getLifeCycle())){
            AsyncRequest request = asyncHome.getRequestFromVM(Integer.valueOf(vm.getID()));
            if(request != null){
                ((_VM)vm).setSpotInstanceRequestID(request.getId());
            }
        }
       
        return vm;
    }
View Full Code Here

                   CreationException,
                   MetadataException,
                   ResourceRequestDeniedException,
                   SchedulingException {

        AsyncRequest siRequest = this.creation.addAsyncRequest(req, caller);
       
        try {
            return dataConvert.getSpotRequest(siRequest);
        } catch (CannotTranslateException e) {
            throw new MetadataException("Could not translate request from internal representation to RM API representation.", e);
View Full Code Here

            throws DoesNotExistException, ManageException, AuthorizationException {
       
        SpotRequestInfo[] result = new SpotRequestInfo[ids.length];
       
        for (int i = 0; i < ids.length; i++) {
            AsyncRequest siReq = asyncHome.getRequest(ids[i]);
           
            authorizeCaller(caller, siReq);
           
            result[i] = getSpotRequest(siReq);
        }
View Full Code Here

    public SpotRequestInfo[] cancelSpotInstanceRequests(String[] ids, Caller caller)
            throws DoesNotExistException, AuthorizationException, ManageException {
        SpotRequestInfo[] result = new SpotRequestInfo[ids.length];
       
        for (int i = 0; i < ids.length; i++) {
            AsyncRequest siReq = asyncHome.getRequest(ids[i]);
           
            authorizeCaller(caller, siReq);
           
            result[i] = getSpotRequest(asyncHome.cancelRequest(ids[i]));
        }
View Full Code Here

   
    public RequestInfo addBackfillRequest(AsyncCreateRequest req, Caller caller)
            throws AuthorizationException, CoSchedulingException,
            CreationException, MetadataException,
            ResourceRequestDeniedException, SchedulingException {
        AsyncRequest backfillRequest = this.creation.addAsyncRequest(req, caller);
       
        try {
            return dataConvert.getRequestInfo(backfillRequest);
        } catch (CannotTranslateException e) {
            throw new MetadataException("Could not translate request from internal representation to RM API representation.", e);
View Full Code Here

    public RequestInfo[] cancelBackfillRequests(String[] ids, Caller caller)
            throws DoesNotExistException, AuthorizationException,
            ManageException {

        for (int i = 0; i < ids.length; i++) {
            AsyncRequest backfillReq = this.asyncHome.getRequest(ids[i]);
            authorizeCaller(caller, backfillReq);
        }

        AsyncRequest[] reqs = this.asyncHome.cancelRequests(ids);
View Full Code Here

            throws DoesNotExistException, ManageException,
            AuthorizationException {
        RequestInfo[] result = new RequestInfo[ids.length];
       
        for (int i = 0; i < ids.length; i++) {
            AsyncRequest backfillReq = asyncHome.getRequest(ids[i]);
           
            authorizeCaller(caller, backfillReq);
           
            result[i] = getRequestInfo(backfillReq);
        }
View Full Code Here

        MaximizeUtilizationPricingModel pricingModel = new MaximizeUtilizationPricingModel();

       
        //case 1
        LinkedList<AsyncRequest> requests = new LinkedList<AsyncRequest>();
        requests.add(new AsyncRequest("a", 2.0, getBindings(1)));
    
        Double nextPrice = pricingModel.getNextPrice(0, requests, null);
        assertEquals(new Double(2.0+0.1), nextPrice);
        assertTrue(PricingModelTestUtils.checkPricingModelConstraints(pricingModel.getMinPrice(), nextPrice, 0, requests));
       
        //case 2
        requests = new LinkedList<AsyncRequest>();
        requests.add(new AsyncRequest("a", 4.0, getBindings(1)));
        requests.add(new AsyncRequest("b", 2.0, getBindings(4)))
        requests.add(new AsyncRequest("c", 3.5, getBindings(4)));    
       
        nextPrice = pricingModel.getNextPrice(0, requests, null);
        assertEquals(new Double(4.0+0.1), nextPrice);
        assertTrue(PricingModelTestUtils.checkPricingModelConstraints(pricingModel.getMinPrice(), nextPrice, 0, requests));
    }   
View Full Code Here

TOP

Related Classes of org.globus.workspace.async.AsyncRequest

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.