Java 类com.amazonaws.services.elastictranscoder.model.CreatePipelineResult 实例源码

项目:amediamanager    文件:ElasticTranscoderPipelineResource.java   
private String provisionPipeline() {
    String pipelineId = config.getProperty(ConfigProps.TRANSCODE_PIPELINE);

    if (pipelineId == null) {
        LOG.info("Provisioning ETS Pipeline.");
        state = ProvisionState.PROVISIONING;
        Notifications notifications = new Notifications()
            .withError(config.getProperty(ConfigProps.TRANSCODE_TOPIC))
            .withCompleted(config.getProperty(ConfigProps.TRANSCODE_TOPIC))
            .withProgressing("")
            .withWarning("");

        CreatePipelineRequest pipelineRequest = new CreatePipelineRequest()
            .withName("amm-reinvent-pipeline-" + UUID.randomUUID().toString().replace("-", "").substring(0, 18).toUpperCase())
            .withRole(config.getProperty(ConfigProps.TRANSCODE_ROLE))
            .withInputBucket(config.getProperty(ConfigProps.S3_UPLOAD_BUCKET))
            .withOutputBucket(config.getProperty(ConfigProps.S3_UPLOAD_BUCKET))
            .withNotifications(notifications);

        try {
            CreatePipelineResult pipelineResult = transcoderClient.createPipeline(pipelineRequest);
            pipelineId = pipelineResult.getPipeline().getId();
            LOG.info("Pipeline {} created. Persisting to configuration provider.", pipelineId);
            config.getConfigurationProvider().persistNewProperty(ConfigProps.TRANSCODE_PIPELINE, pipelineId);
        } catch (AmazonServiceException e) {
            LOG.error("Failed creating pipeline {}", pipelineRequest.getName(), e);
            state = ProvisionState.UNPROVISIONED;
        }
    }
    return pipelineId;
}
项目:s3_video    文件:AWSAdapter.java   
public String createPipeLineIfNotExist(String pipelineName, String regionName, 
                                     String inputBucketName, String outputBucketName,
                                     String iamRole,
                                     String topicArn,
                                     String storageClass) throws TranscodeException {
    //http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/pipeline-settings.html     
    try {
        transcoderClient.setRegion(Region.getRegion(Regions.fromName(regionName)));         

        ListPipelinesResult pipelinesResult = transcoderClient.listPipelines();
        List<Pipeline> pipelines = pipelinesResult.getPipelines();
        boolean isPipelineExist = false;
        String existingPipelineId = null;
        for (Pipeline p : pipelines){
            if (p.getName().equals(pipelineName)){
                isPipelineExist = true;
                existingPipelineId = p.getId();
            }
        }

        if (!isPipelineExist){
            Notifications notifications = new Notifications()
                .withCompleted(topicArn)
                .withError(topicArn)
                .withWarning(topicArn)
                .withProgressing(topicArn);

            PipelineOutputConfig pipelineOutputConfig = new PipelineOutputConfig();
            pipelineOutputConfig.setStorageClass(storageClass);
            pipelineOutputConfig.setBucket(outputBucketName);

            CreatePipelineRequest createPipelineRequest = new CreatePipelineRequest()
                                                                .withName(pipelineName)
                                                                .withInputBucket(inputBucketName)
                                                                .withRole(iamRole)
                                                                .withContentConfig(pipelineOutputConfig)
                                                                .withThumbnailConfig(pipelineOutputConfig)
                                                                .withNotifications(notifications);

            CreatePipelineResult result = transcoderClient.createPipeline(createPipelineRequest);
            return result.getPipeline().getId();
        } else {
            logger.debug(String.format("pipleline with name %s already exist", pipelineName));
            return existingPipelineId;
        }
    } catch (IllegalArgumentException ie) {
        logger.error("Couldn't get the region", ie);
        throw new TranscodeException(ie.getMessage());
    }
}