@Test @SuppressWarnings(value = { "static-access" }) public void testGetCostEstimationForDeploymentAndEvent() throws Exception { DeploymentRest deploymentRest = new DeploymentRest(); PaaSEnergyModeller energyModeller = mock(PaaSEnergyModeller.class); deploymentRest.energyModeller = energyModeller; PriceModellerClient priceModellerClient = mock(PriceModellerClient.class); deploymentRest.priceModellerClient = priceModellerClient; EnergyModellerQueueController emController = mock(EnergyModellerQueueController.class); deploymentRest.energyModellerQueueController = emController; DeploymentDAO deploymentDAO = mock(DeploymentDAO.class); deploymentRest.deploymentDAO = deploymentDAO; VM vm = new VM(); vm.setId(2); vm.setProviderVmId("abab"); vm.setCpuActual(1); vm.setRamActual(10); vm.setDiskActual(1); Deployment deployment = new Deployment(); deployment.setSchema(2); deployment.addVM(vm); when(deploymentDAO.getById(2)).thenReturn(deployment); List<String> ids = new ArrayList<String>(); ids.add("2"); when(energyModeller.estimate(null, "app-name", "2", ids, "loquesea", Unit.ENERGY, 0l)).thenReturn(22.0); when(energyModeller.estimate(null, "app-name", "2", ids, "loquesea", Unit.POWER, 0l)).thenReturn(23.0); EnergyModellerMessage secMessage = new EnergyModellerMessage(); secMessage.setValue("10"); String secKey = EnergyModellerQueueController.generateKey("app-name", "loquesea", "2", ids, EnergyModellerQueueController.SEC); when(emController.getPredictionMessage(secKey)).thenReturn(secMessage); LinkedList<VMinfo> vmInfos = new LinkedList<VMinfo>(); for(VM vmFromList : deployment.getVms()) { VMinfo vmInfo = new VMinfo(vmFromList.getRamActual(), vmFromList.getCpuActual(), vmFromList.getDiskActual() * 1024l, 10l); vmInfos.add(vmInfo); } when(priceModellerClient.getEventPredictedChargesOfApp(eq(2), any(vmInfos.getClass()), eq(22.0), eq(deployment.getSchema()))).thenReturn(1.1d); Response response = deploymentRest.getCostEstimation("app-name", "2", "loquesea"); assertEquals(200, response.getStatus()); String xml = (String) response.getEntity(); JAXBContext jaxbContext = JAXBContext.newInstance(Cost.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Cost cost = (Cost) jaxbUnmarshaller.unmarshal(new StringReader(xml)); assertEquals("/applications/app-name/deployments/2/events/loquesea/cost-estimation", cost.getHref()); assertEquals(1.1d, cost.getCharges().doubleValue(), 0.0001); assertEquals("Energy estimation in WATTHOURS", cost.getEnergyDescription()); assertEquals("Power estimation in WATTS", cost.getPowerDescription()); assertEquals(23.0d, cost.getPowerValue(), 0.0001); assertEquals(22.0d, cost.getEnergyValue().doubleValue(), 0.0001); assertEquals("Charges estimation in EUROS", cost.getChargesDescription()); assertEquals(2, cost.getLinks().size()); assertEquals("/applications/app-name/deployments/2", cost.getLinks().get(0).getHref()); assertEquals("parent", cost.getLinks().get(0).getRel()); assertEquals(MediaType.APPLICATION_XML, cost.getLinks().get(0).getType()); assertEquals("/applications/app-name/deployments/2/events/loquesea/cost-estimation", cost.getLinks().get(1).getHref()); assertEquals("self", cost.getLinks().get(1).getRel()); assertEquals(MediaType.APPLICATION_XML, cost.getLinks().get(1).getType()); }
@GET @Path("{deployment_id}/events/{event_id}/cost-estimation") @Produces(MediaType.APPLICATION_XML) public Response getCostEstimation(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("event_id") String eventId) throws InterruptedException { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/events/" + eventId + "/cost-estimation"); energyModeller = getEnergyModeller(); int deploymentIdInt = Integer.parseInt(deploymentId); Deployment deployment = deploymentDAO.getById(deploymentIdInt); List<String> ids = getVmsIds(deployment); String providerId = deployment.getProviderId(); logger.debug("Connecting to Energy Modeller"); double energyEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.ENERGY, 0l); double powerEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.POWER, 0l); String secKey = "none"; if(ids != null && ids.size() > 0) { List<String> vmIds = new ArrayList<String>(); vmIds.add(ids.get(0)); secKey = EnergyModellerQueueController.generateKey(applicationName, eventId, deploymentId, vmIds, EnergyModellerQueueController.SEC); } logger.info("secKey: " + secKey); Thread.sleep(1000l); EnergyModellerMessage emMessageSec = getEnergyModellerQueueController().getPredictionMessage(secKey); logger.info("############################################################################################"); logger.info("Message recevied by energy modeller in cost-estimation: " + emMessageSec); Cost cost = new Cost(); cost.setEnergyValue(energyEstimated); cost.setPowerValue(powerEstimated); if(emMessageSec != null) { logger.info("Parsing duration value of: " + emMessageSec.getValue()); long duration = (long) Double.parseDouble(emMessageSec.getValue()); LinkedList<VMinfo> vmInfos = new LinkedList<VMinfo>(); for(VM vm : deployment.getVms()) { VMinfo vmInfo = new VMinfo(vm.getRamActual(), vm.getCpuActual(), vm.getDiskActual(), duration); vmInfos.add(vmInfo); } if(priceModellerClient == null) { priceModellerClient = PriceModellerClient.getInstance(); } System.out.println("######## deploymentId: " + deploymentIdInt + " energyEstimated: " + energyEstimated + " schema: " + deployment.getSchema() + " duration: " + duration); double charges = priceModellerClient.getEventPredictedChargesOfApp(deploymentIdInt, vmInfos, energyEstimated, deployment.getSchema()); cost.setCharges(charges); } else { cost.setCharges(-1.0d); } String xml = XMLBuilder.getCostEstimationForAnEventInADeploymentXMLInfo(cost, applicationName, deploymentId, eventId); return buildResponse(Status.OK, xml); }
DeploymentRest extends AbstractRest { @GET @Path("{deployment_id}/events/{event_id}/cost-estimation") @Produces(MediaType.APPLICATION_XML) public Response getCostEstimation(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("event_id") String eventId) throws InterruptedException { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/events/" + eventId + "/cost-estimation"); energyModeller = getEnergyModeller(); int deploymentIdInt = Integer.parseInt(deploymentId); Deployment deployment = deploymentDAO.getById(deploymentIdInt); List<String> ids = getVmsIds(deployment); String providerId = deployment.getProviderId(); logger.debug("Connecting to Energy Modeller"); double energyEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.ENERGY, 0l); double powerEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.POWER, 0l); String secKey = "none"; if(ids != null && ids.size() > 0) { List<String> vmIds = new ArrayList<String>(); vmIds.add(ids.get(0)); secKey = EnergyModellerQueueController.generateKey(applicationName, eventId, deploymentId, vmIds, EnergyModellerQueueController.SEC); } logger.info("secKey: " + secKey); Thread.sleep(1000l); EnergyModellerMessage emMessageSec = getEnergyModellerQueueController().getPredictionMessage(secKey); logger.info("############################################################################################"); logger.info("Message recevied by energy modeller in cost-estimation: " + emMessageSec); Cost cost = new Cost(); cost.setEnergyValue(energyEstimated); cost.setPowerValue(powerEstimated); if(emMessageSec != null) { logger.info("Parsing duration value of: " + emMessageSec.getValue()); long duration = (long) Double.parseDouble(emMessageSec.getValue()); LinkedList<VMinfo> vmInfos = new LinkedList<VMinfo>(); for(VM vm : deployment.getVms()) { VMinfo vmInfo = new VMinfo(vm.getRamActual(), vm.getCpuActual(), vm.getDiskActual(), duration); vmInfos.add(vmInfo); } if(priceModellerClient == null) { priceModellerClient = PriceModellerClient.getInstance(); } System.out.println("######## deploymentId: " + deploymentIdInt + " energyEstimated: " + energyEstimated + " schema: " + deployment.getSchema() + " duration: " + duration); double charges = priceModellerClient.getEventPredictedChargesOfApp(deploymentIdInt, vmInfos, energyEstimated, deployment.getSchema()); cost.setCharges(charges); } else { cost.setCharges(-1.0d); } String xml = XMLBuilder.getCostEstimationForAnEventInADeploymentXMLInfo(cost, applicationName, deploymentId, eventId); return buildResponse(Status.OK, xml); } }
DeploymentRest extends AbstractRest { @GET @Path("{deployment_id}/events/{event_id}/cost-estimation") @Produces(MediaType.APPLICATION_XML) public Response getCostEstimation(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("event_id") String eventId) throws InterruptedException { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/events/" + eventId + "/cost-estimation"); energyModeller = getEnergyModeller(); int deploymentIdInt = Integer.parseInt(deploymentId); Deployment deployment = deploymentDAO.getById(deploymentIdInt); List<String> ids = getVmsIds(deployment); String providerId = deployment.getProviderId(); logger.debug("Connecting to Energy Modeller"); double energyEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.ENERGY, 0l); double powerEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.POWER, 0l); String secKey = "none"; if(ids != null && ids.size() > 0) { List<String> vmIds = new ArrayList<String>(); vmIds.add(ids.get(0)); secKey = EnergyModellerQueueController.generateKey(applicationName, eventId, deploymentId, vmIds, EnergyModellerQueueController.SEC); } logger.info("secKey: " + secKey); Thread.sleep(1000l); EnergyModellerMessage emMessageSec = getEnergyModellerQueueController().getPredictionMessage(secKey); logger.info("############################################################################################"); logger.info("Message recevied by energy modeller in cost-estimation: " + emMessageSec); Cost cost = new Cost(); cost.setEnergyValue(energyEstimated); cost.setPowerValue(powerEstimated); if(emMessageSec != null) { logger.info("Parsing duration value of: " + emMessageSec.getValue()); long duration = (long) Double.parseDouble(emMessageSec.getValue()); LinkedList<VMinfo> vmInfos = new LinkedList<VMinfo>(); for(VM vm : deployment.getVms()) { VMinfo vmInfo = new VMinfo(vm.getRamActual(), vm.getCpuActual(), vm.getDiskActual(), duration); vmInfos.add(vmInfo); } if(priceModellerClient == null) { priceModellerClient = PriceModellerClient.getInstance(); } System.out.println("######## deploymentId: " + deploymentIdInt + " energyEstimated: " + energyEstimated + " schema: " + deployment.getSchema() + " duration: " + duration); double charges = priceModellerClient.getEventPredictedChargesOfApp(deploymentIdInt, vmInfos, energyEstimated, deployment.getSchema()); cost.setCharges(charges); } else { cost.setCharges(-1.0d); } String xml = XMLBuilder.getCostEstimationForAnEventInADeploymentXMLInfo(cost, applicationName, deploymentId, eventId); return buildResponse(Status.OK, xml); }  }
DeploymentRest extends AbstractRest { @GET @Path("{deployment_id}/events/{event_id}/cost-estimation") @Produces(MediaType.APPLICATION_XML) public Response getCostEstimation(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("event_id") String eventId) throws InterruptedException { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/events/" + eventId + "/cost-estimation"); energyModeller = getEnergyModeller(); int deploymentIdInt = Integer.parseInt(deploymentId); Deployment deployment = deploymentDAO.getById(deploymentIdInt); List<String> ids = getVmsIds(deployment); String providerId = deployment.getProviderId(); logger.debug("Connecting to Energy Modeller"); double energyEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.ENERGY, 0l); double powerEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.POWER, 0l); String secKey = "none"; if(ids != null && ids.size() > 0) { List<String> vmIds = new ArrayList<String>(); vmIds.add(ids.get(0)); secKey = EnergyModellerQueueController.generateKey(applicationName, eventId, deploymentId, vmIds, EnergyModellerQueueController.SEC); } logger.info("secKey: " + secKey); Thread.sleep(1000l); EnergyModellerMessage emMessageSec = getEnergyModellerQueueController().getPredictionMessage(secKey); logger.info("############################################################################################"); logger.info("Message recevied by energy modeller in cost-estimation: " + emMessageSec); Cost cost = new Cost(); cost.setEnergyValue(energyEstimated); cost.setPowerValue(powerEstimated); if(emMessageSec != null) { logger.info("Parsing duration value of: " + emMessageSec.getValue()); long duration = (long) Double.parseDouble(emMessageSec.getValue()); LinkedList<VMinfo> vmInfos = new LinkedList<VMinfo>(); for(VM vm : deployment.getVms()) { VMinfo vmInfo = new VMinfo(vm.getRamActual(), vm.getCpuActual(), vm.getDiskActual(), duration); vmInfos.add(vmInfo); } if(priceModellerClient == null) { priceModellerClient = PriceModellerClient.getInstance(); } System.out.println("######## deploymentId: " + deploymentIdInt + " energyEstimated: " + energyEstimated + " schema: " + deployment.getSchema() + " duration: " + duration); double charges = priceModellerClient.getEventPredictedChargesOfApp(deploymentIdInt, vmInfos, energyEstimated, deployment.getSchema()); cost.setCharges(charges); } else { cost.setCharges(-1.0d); } String xml = XMLBuilder.getCostEstimationForAnEventInADeploymentXMLInfo(cost, applicationName, deploymentId, eventId); return buildResponse(Status.OK, xml); }  @GET @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getDeployments(@PathParam("application_name") String applicationName, @DefaultValue("")@QueryParam("status") String status); @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getDeploymentsJSON(@PathParam("application_name") String applicationName, @DefaultValue("")@QueryParam("status") String status); @POST @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response postDeployment(@PathParam("application_name") String applicationName, @QueryParam("negotiation") String negotiation,  @QueryParam("schema") String schema, String payload); @POST @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_JSON) Response postDeploymentJSON(@PathParam("application_name") String applicationName, @QueryParam("negotiation") String negotiation,  @QueryParam("schema") String schema, String payload); @OPTIONS @Path("{deployment_id}") Response optionsForSpecificDeployment(); @GET @Path("{deployment_id}") @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getDeployment(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}") @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/agreement") @Produces(MediaType.APPLICATION_XML) Response getDeploymentAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/ovf") @Produces(MediaType.APPLICATION_XML) Response getDeploymentOvf(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @PUT @Path("{deployment_id}/agreement") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response putDeploymentAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @DELETE @Path("{deployment_id}") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) Response deleteDeployment(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/cost-consumption") @Produces(MediaType.APPLICATION_XML) Response getCost(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/energy-consumption") @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getEnergyConsumptionXML(@PathParam("application_name") String applicationName, 
										 @PathParam("deployment_id") String deploymentId,
										 @QueryParam("startTime") String startTime,
			                             @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/energy-consumption") @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getEnergyConsumptionJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @QueryParam("startTime") String startTime,
            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/power-consumption") @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getPowerConsumptionXML(@PathParam("application_name") String applicationName, 
										@PathParam("deployment_id") String deploymentId,
										@QueryParam("startTime") String startTime,
			                            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/power-consumption") @Produces(MediaType.APPLICATION_JSON + ";qs=0,5") Response getPowerConsumptionJSON(@PathParam("application_name") String applicationName, 
										@PathParam("deployment_id") String deploymentId,
										@QueryParam("startTime") String startTime,
			                            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/energy-estimation") @Produces(MediaType.APPLICATION_XML) Response getEnergyEstimation(@PathParam("application_name") String applicationName, 
										@PathParam("deployment_id") String deploymentId,
										@QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/power-estimation") @Produces(MediaType.APPLICATION_XML) Response getPowerEstimation(@PathParam("application_name") String applicationName, 
									   @PathParam("deployment_id") String deploymentId,
										@QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/events/{event_id}/energy-estimation") @Produces(MediaType.APPLICATION_XML) Response getEnergyEstimationForEvent(@PathParam("application_name") String applicationName, 
												@PathParam("deployment_id") String deploymentId, 
												@PathParam("event_id") String eventId,
												@QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/events/{event_id}/power-estimation") @Produces(MediaType.APPLICATION_XML) Response getPowerEstimationForEvent(@PathParam("application_name") String applicationName, 
											   @PathParam("deployment_id") String deploymentId, 
											   @PathParam("event_id") String eventId,
											   @QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/events/{event_id}/energy-consumption") @Produces(MediaType.APPLICATION_XML) Response getEnergyMeasurementForEvent(@PathParam("application_name") String applicationName, 
												 @PathParam("deployment_id") String deploymentId, 
												 @PathParam("event_id") String eventId,
												 @QueryParam("startTime") String startTime,
					                             @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/events/{event_id}/power-consumption") @Produces(MediaType.APPLICATION_XML) Response getPowerConsumptionForEvent(@PathParam("application_name") String applicationName, 
												@PathParam("deployment_id") String deploymentId, 
												@PathParam("event_id") String eventId,
					                            @QueryParam("startTime") String startTime,
					                            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/predicted-price-for-next-period") @Produces(MediaType.APPLICATION_XML) Response getPredictedPriceForNextPeriod(@PathParam("application_name") String applicationName, 
			                          @PathParam("deployment_id") String deploymentId,
			                          @QueryParam("duration") String duration); @GET @Path("{deployment_id}/events/{event_id}/cost-estimation") @Produces(MediaType.APPLICATION_XML) Response getCostEstimation(@PathParam("application_name") String applicationName, 
			                          @PathParam("deployment_id") String deploymentId,
			                          @PathParam("event_id") String eventId); @GET @Path("{deployment_id}/sla-limits") @Produces(MediaType.APPLICATION_XML) Response getSLALimits(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @POST @Path("{deployment_id}/renegotiate") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response renegotiateWithPayload(@PathParam("application_name") String applicationName,@PathParam("deployment_id") String deploymentId, String payload); @GET @Path("{deployment_id}/renegotiate") @Produces(MediaType.APPLICATION_XML) Response renegotiate(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/predict-price-next-hour") @Produces(MediaType.APPLICATION_XML) Response predictPriceNextHour(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); }
DeploymentRest extends AbstractRest { @GET @Path("{deployment_id}/events/{event_id}/cost-estimation") @Produces(MediaType.APPLICATION_XML) public Response getCostEstimation(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @PathParam("event_id") String eventId) throws InterruptedException { logger.info("GET request to path: /applications/" + applicationName + "/deployments/" + deploymentId + "/events/" + eventId + "/cost-estimation"); energyModeller = getEnergyModeller(); int deploymentIdInt = Integer.parseInt(deploymentId); Deployment deployment = deploymentDAO.getById(deploymentIdInt); List<String> ids = getVmsIds(deployment); String providerId = deployment.getProviderId(); logger.debug("Connecting to Energy Modeller"); double energyEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.ENERGY, 0l); double powerEstimated = energyModeller.estimate(providerId, applicationName, deploymentId, ids, eventId, Unit.POWER, 0l); String secKey = "none"; if(ids != null && ids.size() > 0) { List<String> vmIds = new ArrayList<String>(); vmIds.add(ids.get(0)); secKey = EnergyModellerQueueController.generateKey(applicationName, eventId, deploymentId, vmIds, EnergyModellerQueueController.SEC); } logger.info("secKey: " + secKey); Thread.sleep(1000l); EnergyModellerMessage emMessageSec = getEnergyModellerQueueController().getPredictionMessage(secKey); logger.info("############################################################################################"); logger.info("Message recevied by energy modeller in cost-estimation: " + emMessageSec); Cost cost = new Cost(); cost.setEnergyValue(energyEstimated); cost.setPowerValue(powerEstimated); if(emMessageSec != null) { logger.info("Parsing duration value of: " + emMessageSec.getValue()); long duration = (long) Double.parseDouble(emMessageSec.getValue()); LinkedList<VMinfo> vmInfos = new LinkedList<VMinfo>(); for(VM vm : deployment.getVms()) { VMinfo vmInfo = new VMinfo(vm.getRamActual(), vm.getCpuActual(), vm.getDiskActual(), duration); vmInfos.add(vmInfo); } if(priceModellerClient == null) { priceModellerClient = PriceModellerClient.getInstance(); } System.out.println("######## deploymentId: " + deploymentIdInt + " energyEstimated: " + energyEstimated + " schema: " + deployment.getSchema() + " duration: " + duration); double charges = priceModellerClient.getEventPredictedChargesOfApp(deploymentIdInt, vmInfos, energyEstimated, deployment.getSchema()); cost.setCharges(charges); } else { cost.setCharges(-1.0d); } String xml = XMLBuilder.getCostEstimationForAnEventInADeploymentXMLInfo(cost, applicationName, deploymentId, eventId); return buildResponse(Status.OK, xml); }  @GET @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getDeployments(@PathParam("application_name") String applicationName, @DefaultValue("")@QueryParam("status") String status); @GET @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getDeploymentsJSON(@PathParam("application_name") String applicationName, @DefaultValue("")@QueryParam("status") String status); @POST @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response postDeployment(@PathParam("application_name") String applicationName, @QueryParam("negotiation") String negotiation,  @QueryParam("schema") String schema, String payload); @POST @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_JSON) Response postDeploymentJSON(@PathParam("application_name") String applicationName, @QueryParam("negotiation") String negotiation,  @QueryParam("schema") String schema, String payload); @OPTIONS @Path("{deployment_id}") Response optionsForSpecificDeployment(); @GET @Path("{deployment_id}") @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getDeployment(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}") @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getDeploymentJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/agreement") @Produces(MediaType.APPLICATION_XML) Response getDeploymentAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/ovf") @Produces(MediaType.APPLICATION_XML) Response getDeploymentOvf(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @PUT @Path("{deployment_id}/agreement") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response putDeploymentAgreement(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @DELETE @Path("{deployment_id}") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) Response deleteDeployment(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/cost-consumption") @Produces(MediaType.APPLICATION_XML) Response getCost(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/energy-consumption") @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getEnergyConsumptionXML(@PathParam("application_name") String applicationName, 
										 @PathParam("deployment_id") String deploymentId,
										 @QueryParam("startTime") String startTime,
			                             @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/energy-consumption") @Produces(MediaType.APPLICATION_JSON + ";qs=0.5") Response getEnergyConsumptionJSON(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId, @QueryParam("startTime") String startTime,
            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/power-consumption") @Produces(MediaType.APPLICATION_XML + ";qs=1") Response getPowerConsumptionXML(@PathParam("application_name") String applicationName, 
										@PathParam("deployment_id") String deploymentId,
										@QueryParam("startTime") String startTime,
			                            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/power-consumption") @Produces(MediaType.APPLICATION_JSON + ";qs=0,5") Response getPowerConsumptionJSON(@PathParam("application_name") String applicationName, 
										@PathParam("deployment_id") String deploymentId,
										@QueryParam("startTime") String startTime,
			                            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/energy-estimation") @Produces(MediaType.APPLICATION_XML) Response getEnergyEstimation(@PathParam("application_name") String applicationName, 
										@PathParam("deployment_id") String deploymentId,
										@QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/power-estimation") @Produces(MediaType.APPLICATION_XML) Response getPowerEstimation(@PathParam("application_name") String applicationName, 
									   @PathParam("deployment_id") String deploymentId,
										@QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/events/{event_id}/energy-estimation") @Produces(MediaType.APPLICATION_XML) Response getEnergyEstimationForEvent(@PathParam("application_name") String applicationName, 
												@PathParam("deployment_id") String deploymentId, 
												@PathParam("event_id") String eventId,
												@QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/events/{event_id}/power-estimation") @Produces(MediaType.APPLICATION_XML) Response getPowerEstimationForEvent(@PathParam("application_name") String applicationName, 
											   @PathParam("deployment_id") String deploymentId, 
											   @PathParam("event_id") String eventId,
											   @QueryParam("duration") String durationQuery); @GET @Path("{deployment_id}/events/{event_id}/energy-consumption") @Produces(MediaType.APPLICATION_XML) Response getEnergyMeasurementForEvent(@PathParam("application_name") String applicationName, 
												 @PathParam("deployment_id") String deploymentId, 
												 @PathParam("event_id") String eventId,
												 @QueryParam("startTime") String startTime,
					                             @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/events/{event_id}/power-consumption") @Produces(MediaType.APPLICATION_XML) Response getPowerConsumptionForEvent(@PathParam("application_name") String applicationName, 
												@PathParam("deployment_id") String deploymentId, 
												@PathParam("event_id") String eventId,
					                            @QueryParam("startTime") String startTime,
					                            @QueryParam("endTime") String endTime); @GET @Path("{deployment_id}/predicted-price-for-next-period") @Produces(MediaType.APPLICATION_XML) Response getPredictedPriceForNextPeriod(@PathParam("application_name") String applicationName, 
			                          @PathParam("deployment_id") String deploymentId,
			                          @QueryParam("duration") String duration); @GET @Path("{deployment_id}/events/{event_id}/cost-estimation") @Produces(MediaType.APPLICATION_XML) Response getCostEstimation(@PathParam("application_name") String applicationName, 
			                          @PathParam("deployment_id") String deploymentId,
			                          @PathParam("event_id") String eventId); @GET @Path("{deployment_id}/sla-limits") @Produces(MediaType.APPLICATION_XML) Response getSLALimits(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @POST @Path("{deployment_id}/renegotiate") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) Response renegotiateWithPayload(@PathParam("application_name") String applicationName,@PathParam("deployment_id") String deploymentId, String payload); @GET @Path("{deployment_id}/renegotiate") @Produces(MediaType.APPLICATION_XML) Response renegotiate(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId); @GET @Path("{deployment_id}/predict-price-next-hour") @Produces(MediaType.APPLICATION_XML) Response predictPriceNextHour(@PathParam("application_name") String applicationName, @PathParam("deployment_id") String deploymentId);  }