Java 类com.amazonaws.services.autoscaling.model.BlockDeviceMapping 实例源码

项目:cmn-project    文件:ASGroupHelper.java   
public void createLaunchConfig(ASGroup asGroup) throws Exception {
    String launchConfigName = env.name + "-" + asGroup.id + "-" + Randoms.alphaNumeric(6);

    LaunchConfig launchConfig = asGroup.launchConfig;

    CreateLaunchConfigurationRequest request = new CreateLaunchConfigurationRequest()
        .withLaunchConfigurationName(launchConfigName)
        .withKeyName(launchConfig.keyPair.remoteKeyPair.getKeyName())
        .withInstanceType(launchConfig.instanceType)
        .withImageId(launchConfig.ami.imageId())
        .withSecurityGroups(launchConfig.securityGroup.remoteSecurityGroup.getGroupId())
        .withUserData(Encodings.base64(userData(asGroup)));

    if (EBS.enableEBSOptimized(launchConfig.instanceType)) {    // this is not necessary since m4/c4 are EBS optimized enable by default, but there is bug in AWS console, we need to set this in order to display correct value
        request.withEbsOptimized(true);
    }

    if (asGroup.subnet.type == SubnetType.PUBLIC) {
        request.withAssociatePublicIpAddress(true);
    }

    if (launchConfig.instanceProfile != null)
        request.withIamInstanceProfile(launchConfig.instanceProfile.remoteInstanceProfile.getInstanceProfileName());

    if (launchConfig.ebs.rootVolumeSize != null) {
        request.getBlockDeviceMappings().add(new BlockDeviceMapping()
            .withDeviceName("/dev/sda1")
            .withEbs(new Ebs().withVolumeSize(launchConfig.ebs.rootVolumeSize).withVolumeType(launchConfig.ebs.type)));
    }

    launchConfig.remoteLaunchConfig = AWS.as.createLaunchConfig(request);
}
项目:incubator-gobblin    文件:GobblinAWSClusterLauncher.java   
private String launchClusterMaster(String uuid, String keyName, String securityGroups,
    AvailabilityZone availabilityZone) {

  // Get cloud-init script to launch cluster master
  final String userData = CloudInitScriptBuilder.buildClusterMasterCommand(this.clusterName,
      this.nfsParentDir,
      this.sinkLogRootDir,
      this.awsConfDir,
      this.appWorkDir,
      this.masterS3ConfUri,
      this.masterS3ConfFiles,
      this.masterS3JarsUri,
      this.masterS3JarsFiles,
      this.masterJarsDir,
      this.masterJvmMemory,
      this.masterJvmArgs,
      this.gobblinVersion);

  // Create launch config for Cluster master
  this.masterLaunchConfigName = MASTER_LAUNCH_CONFIG_NAME_PREFIX + uuid;
  this.awsSdkClient.createLaunchConfig(this.masterLaunchConfigName,
      this.masterAmiId,
      this.masterInstanceType,
      keyName,
      securityGroups,
      Optional.<String>absent(),
      Optional.<String>absent(),
      Optional.<BlockDeviceMapping>absent(),
      Optional.<String>absent(),
      Optional.<InstanceMonitoring>absent(),
      userData);

  // Create ASG for Cluster master
  // TODO: Make size configurable when we have support multi-master
  this.masterAutoScalingGroupName = MASTER_ASG_NAME_PREFIX + uuid;
  final int minNumMasters = 1;
  final int maxNumMasters = 1;
  final int desiredNumMasters = 1;
  final Tag clusterNameTag = new Tag().withKey(CLUSTER_NAME_ASG_TAG).withValue(this.clusterName);
  final Tag clusterUuidTag = new Tag().withKey(CLUSTER_ID_ASG_TAG).withValue(uuid);
  final Tag asgTypeTag = new Tag().withKey(ASG_TYPE_ASG_TAG).withValue(ASG_TYPE_MASTER);
  this.awsSdkClient.createAutoScalingGroup(this.masterAutoScalingGroupName,
      this.masterLaunchConfigName,
      minNumMasters,
      maxNumMasters,
      desiredNumMasters,
      Optional.of(availabilityZone.getZoneName()),
      Optional.<Integer>absent(),
      Optional.<Integer>absent(),
      Optional.<String>absent(),
      Optional.<String>absent(),
      Optional.<String>absent(), Lists.newArrayList(clusterNameTag, clusterUuidTag, asgTypeTag));

  LOGGER.info("Waiting for cluster master to launch");
  this.masterPublicIp = getMasterPublicIp();
  LOGGER.info("Master public ip: "+ this.masterPublicIp);

  return uuid;
}
项目:incubator-gobblin    文件:GobblinAWSClusterLauncher.java   
private void launchWorkUnitRunners(String uuid, String keyName,
    String securityGroups,
    AvailabilityZone availabilityZone) {

  // Get cloud-init script to launch cluster worker
  final String userData = CloudInitScriptBuilder.buildClusterWorkerCommand(this.clusterName,
      this.nfsParentDir,
      this.sinkLogRootDir,
      this.awsConfDir,
      this.appWorkDir,
      this.masterPublicIp,
      this.workerS3ConfUri,
      this.workerS3ConfFiles,
      this.workerS3JarsUri,
      this.workerS3JarsFiles,
      this.workerJarsDir,
      this.workerJvmMemory,
      this.workerJvmArgs,
      this.gobblinVersion);

  // Create launch config for Cluster worker
  this.workerLaunchConfigName = WORKERS_LAUNCH_CONFIG_PREFIX + uuid;
  this.awsSdkClient.createLaunchConfig(this.workerLaunchConfigName,
      this.workerAmiId,
      this.workerInstanceType,
      keyName,
      securityGroups,
      Optional.<String>absent(),
      Optional.<String>absent(),
      Optional.<BlockDeviceMapping>absent(),
      Optional.<String>absent(),
      Optional.<InstanceMonitoring>absent(),
      userData);

  // Create ASG for Cluster workers
  this.workerAutoScalingGroupName = WORKERS_ASG_NAME_PREFIX + uuid;
  final Tag clusterNameTag = new Tag().withKey(CLUSTER_NAME_ASG_TAG).withValue(this.clusterName);
  final Tag clusterUuidTag = new Tag().withKey(CLUSTER_ID_ASG_TAG).withValue(uuid);
  final Tag asgTypeTag = new Tag().withKey(ASG_TYPE_ASG_TAG).withValue(ASG_TYPE_WORKERS);
  this.awsSdkClient.createAutoScalingGroup(this.workerAutoScalingGroupName,
      this.workerLaunchConfigName,
      this.minWorkers,
      this.maxWorkers,
      this.desiredWorkers,
      Optional.of(availabilityZone.getZoneName()),
      Optional.<Integer>absent(),
      Optional.<Integer>absent(),
      Optional.<String>absent(),
      Optional.<String>absent(),
      Optional.<String>absent(),
      Lists.newArrayList(clusterNameTag, clusterUuidTag, asgTypeTag));
}
项目:incubator-gobblin    文件:AWSSdkClient.java   
/***
 * Create a launch configuration that can be later used to create {@link AmazonAutoScaling} groups
 *
 * @param launchConfigName Desired launch config name
 * @param imageId AMI image id to use
 * @param instanceType EC2 instance type to use
 * @param keyName Key name
 * @param securityGroups Security groups to apply
 * @param kernelId Optional kernel id
 * @param ramdiskId Optional ram disk id
 * @param blockDeviceMapping Optional EBS device mapping
 * @param iamInstanceProfile Optional IAM instance profile
 * @param instanceMonitoring Optional instance monitoring
 * @param userData User data (eg. shell script to execute at instance boot under this launch config)
 */
public void createLaunchConfig(String launchConfigName,
    String imageId,
    String instanceType,
    String keyName,
    String securityGroups,
    Optional<String> kernelId,
    Optional<String> ramdiskId,
    Optional<BlockDeviceMapping> blockDeviceMapping,
    Optional<String> iamInstanceProfile,
    Optional<InstanceMonitoring> instanceMonitoring,
    String userData) {

  final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();

  CreateLaunchConfigurationRequest createLaunchConfigurationRequest = new CreateLaunchConfigurationRequest()
      .withLaunchConfigurationName(launchConfigName)
      .withImageId(imageId)
      .withInstanceType(instanceType)
      .withSecurityGroups(SPLITTER.splitToList(securityGroups))
      .withKeyName(keyName)
      .withUserData(userData);
  if (kernelId.isPresent()) {
    createLaunchConfigurationRequest = createLaunchConfigurationRequest
        .withKernelId(kernelId.get());
  }
  if (ramdiskId.isPresent()) {
    createLaunchConfigurationRequest = createLaunchConfigurationRequest
        .withRamdiskId(ramdiskId.get());
  }
  if (blockDeviceMapping.isPresent()) {
    createLaunchConfigurationRequest = createLaunchConfigurationRequest
        .withBlockDeviceMappings(blockDeviceMapping.get());
  }
  if (iamInstanceProfile.isPresent()) {
    createLaunchConfigurationRequest = createLaunchConfigurationRequest
        .withIamInstanceProfile(iamInstanceProfile.get());
  }
  if (instanceMonitoring.isPresent()) {
    createLaunchConfigurationRequest = createLaunchConfigurationRequest
        .withInstanceMonitoring(instanceMonitoring.get());
  }

  autoScaling.createLaunchConfiguration(createLaunchConfigurationRequest);

  LOGGER.info("Created Launch Configuration: " + launchConfigName);
}
项目:sequenceiq-samples    文件:AwsLaunchConfiguration.java   
public List<BlockDeviceMapping> getBlockDeviceMappings() {
    return blockDeviceMappings;
}
项目:sequenceiq-samples    文件:AwsLaunchConfiguration.java   
public void setBlockDeviceMappings(List<BlockDeviceMapping> blockDeviceMappings) {
    this.blockDeviceMappings = blockDeviceMappings;
}