Package org.jclouds.aws.ec2.domain

Examples of org.jclouds.aws.ec2.domain.SpotInstanceRequest$Builder


      for (String region : Region.DEFAULT_REGIONS) {
         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceServices()
                  .describeSpotInstanceRequestsInRegion(region));
         assertNotNull(allResults);
         if (allResults.size() >= 1) {
            SpotInstanceRequest request = allResults.last();
            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceServices()
                     .describeSpotInstanceRequestsInRegion(region, request.getId()));
            assertNotNull(result);
            SpotInstanceRequest compare = result.last();
            assertEquals(compare, request);
         }
      }

   }
View Full Code Here


      for (SpotInstanceRequest request : requests)
         verifySpotInstance(request);
   }

   private void verifySpotInstance(SpotInstanceRequest request) {
      SpotInstanceRequest spot = refresh(request);
      assertNotNull(spot);
      assertEquals(spot, request);
      assert activeTester.apply(request) : refresh(request);
      System.out.println(System.currentTimeMillis() - start);
      spot = refresh(request);
      assert spot.getInstanceId() != null : spot;
      instance = getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(spot.getRegion(),
               spot.getInstanceId())));
      assertEquals(instance.getSpotInstanceRequestId(), spot.getId());
   }
View Full Code Here

   public void testApplyInputStream() {

      InputStream is = getClass().getResourceAsStream("/request_spot_instances-ebs.xml");

      SpotInstanceRequest expected = SpotInstanceRequest
            .builder()
            .region("us-east-1")
            .id("sir-228e6406")
            .spotPrice(0.001f)
            .type(Type.ONE_TIME)
            .state(State.OPEN)
            .rawState("open")
            .launchSpecification(
                  LaunchSpecification.builder().imageId("ami-595a0a1c").securityGroupIdToName("sg-83e1c4ea", "default")
                        .instanceType("m1.large").mapNewVolumeToDevice("/dev/sda1", 1, true)
                        .mapEBSSnapshotToDevice("/dev/sda2", "snap-1ea27576", 1, true)
                        .mapEphemeralDeviceToDevice("/dev/sda3", "vre1").monitoringEnabled(false)
                        .iamInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver")
                        .iamInstanceProfileName("Webserver").build())
            .createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-03-08T03:30:36.000Z"))
            .productDescription("Linux/UNIX").build();
      SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
      addDefaultRegionToHandler(handler);
      SpotInstanceRequest result = factory.create(handler).parse(is);
      assertEquals(result.toString(), expected.toString());
      assertEquals(result.getState(), State.OPEN);
      assertEquals(result.getRawState(), "open");
      assertEquals(result.getLaunchSpecification().getIAMInstanceProfile().get().getArn().get(),
            "arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
      assertEquals(result.getLaunchSpecification().getIAMInstanceProfile().get().getName().get(), "Webserver");
   }
View Full Code Here

   public void testApplyInputStream1() {

      InputStream is = getClass().getResourceAsStream("/describe_spot_instance.xml");

      SpotInstanceRequest expected = SpotInstanceRequest
            .builder()
            .region("us-east-1")
            .id("sir-1ede0012")
            .instanceId("i-ef308e8e")
            .spotPrice(0.300000f)
            .type(Type.ONE_TIME)
            .state(State.ACTIVE)
            .rawState("active")
            .launchedAvailabilityZone("us-east-1b")
            .launchSpecification(
                  LaunchSpecification.builder().imageId("ami-8e1fece7")
                        .securityGroupIdToName("sg-83e1c4eb", "jclouds#adriancole-ec2unssh#us-east-1")
                        .instanceType("t1.micro").monitoringEnabled(false).keyName("jclouds#adriancole-ec2unssh")
                        .build())
            .createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-07-29T05:27:39.000Z"))
            .productDescription("Linux/UNIX")
            .tag("Name", "ec2-o")
            .tag("Spot", "spot-value")
            .tag("Empty", "")
            .build();
      SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
      addDefaultRegionToHandler(handler);
      SpotInstanceRequest result = factory.create(handler).parse(is);
      assertEquals(result.toString(), expected.toString());
      assertEquals(result.getState(), State.ACTIVE);
      assertEquals(result.getRawState(), "active");
   }
View Full Code Here

@Test(groups = "unit", testName = "SpotInstanceRequestToAWSRunningInstanceTest")
public class SpotInstanceRequestToAWSRunningInstanceTest {

   public void testConvert() {

      SpotInstanceRequest input = SpotInstanceRequest
            .builder()
            .region("us-east-1")
            .id("sir-228e6406")
            .spotPrice(0.001f)
            .type(Type.ONE_TIME)
View Full Code Here

   @Override
   public RunningInstance getRunningInstanceInRegion(String region, String id) {
      if (id.indexOf("sir-") != 0)
         return super.getRunningInstanceInRegion(region, id);
      SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(
               region, id));
      if (spot.getState() == SpotInstanceRequest.State.ACTIVE)
         return super.getRunningInstanceInRegion(region, spot.getInstanceId());
      else
         return spotConverter.apply(spot);
   }
View Full Code Here

   @Override
   public RunningInstance getRunningInstanceInRegion(String region, String id) {
      if (id.indexOf("sir-") != 0)
         return super.getRunningInstanceInRegion(region, id);
      SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(
               region, id));
      if (spot.getState() == SpotInstanceRequest.State.ACTIVE)
         return super.getRunningInstanceInRegion(region, spot.getInstanceId());
      else
         return spotConverter.apply(spot);
   }
View Full Code Here

   public void testApplyInputStream() {

      InputStream is = getClass().getResourceAsStream("/request_spot_instances-ebs.xml");

      SpotInstanceRequest expected = SpotInstanceRequest
            .builder()
            .region("us-east-1")
            .id("sir-228e6406")
            .spotPrice(0.001f)
            .type(Type.ONE_TIME)
            .state(State.OPEN)
            .rawState("open")
            .launchSpecification(
                  LaunchSpecification.builder().imageId("ami-595a0a1c").securityGroupIdToName("sg-83e1c4ea", "default")
                        .instanceType("m1.large").mapNewVolumeToDevice("/dev/sda1", 1, true)
                        .mapEBSSnapshotToDevice("/dev/sda2", "snap-1ea27576", 1, true)
                        .mapEphemeralDeviceToDevice("/dev/sda3", "vre1").monitoringEnabled(false)
                        .iamInstanceProfileArn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver")
                        .iamInstanceProfileName("Webserver").build())
            .createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-03-08T03:30:36.000Z"))
            .productDescription("Linux/UNIX").build();
      SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
      addDefaultRegionToHandler(handler);
      SpotInstanceRequest result = factory.create(handler).parse(is);
      assertEquals(result.toString(), expected.toString());
      assertEquals(result.getState(), State.OPEN);
      assertEquals(result.getRawState(), "open");
      assertEquals(result.getLaunchSpecification().getIAMInstanceProfile().get().getArn().get(),
            "arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver");
      assertEquals(result.getLaunchSpecification().getIAMInstanceProfile().get().getName().get(), "Webserver");
   }
View Full Code Here

   public void testApplyInputStream1() {

      InputStream is = getClass().getResourceAsStream("/describe_spot_instance.xml");

      SpotInstanceRequest expected = SpotInstanceRequest
            .builder()
            .region("us-east-1")
            .id("sir-1ede0012")
            .instanceId("i-ef308e8e")
            .spotPrice(0.300000f)
            .type(Type.ONE_TIME)
            .state(State.ACTIVE)
            .rawState("active")
            .launchedAvailabilityZone("us-east-1b")
            .launchSpecification(
                  LaunchSpecification.builder().imageId("ami-8e1fece7")
                        .securityGroupIdToName("sg-83e1c4eb", "jclouds#adriancole-ec2unssh#us-east-1")
                        .instanceType("t1.micro").monitoringEnabled(false).keyName("jclouds#adriancole-ec2unssh")
                        .build())
            .createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-07-29T05:27:39.000Z"))
            .productDescription("Linux/UNIX")
            .tag("Name", "ec2-o")
            .tag("Spot", "spot-value")
            .tag("Empty", "")
            .build();
      SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
      addDefaultRegionToHandler(handler);
      SpotInstanceRequest result = factory.create(handler).parse(is);
      assertEquals(result.toString(), expected.toString());
      assertEquals(result.getState(), State.ACTIVE);
      assertEquals(result.getRawState(), "active");
   }
View Full Code Here

@Test(groups = "unit", testName = "SpotInstanceRequestToAWSRunningInstanceTest")
public class SpotInstanceRequestToAWSRunningInstanceTest {

   public void testConvert() {

      SpotInstanceRequest input = SpotInstanceRequest
            .builder()
            .region("us-east-1")
            .id("sir-228e6406")
            .spotPrice(0.001f)
            .type(Type.ONE_TIME)
View Full Code Here

TOP

Related Classes of org.jclouds.aws.ec2.domain.SpotInstanceRequest$Builder

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.