List of usage examples for com.amazonaws ClientConfiguration ClientConfiguration
public ClientConfiguration()
From source file:com.intuit.tank.vmManager.environment.amazon.AmazonS3.java
License:Open Source License
/** * //from w w w. ja va 2 s. c om */ public AmazonS3() { try { CloudCredentials creds = new TankConfig().getVmManagerConfig() .getCloudCredentials(CloudProvider.amazon); ClientConfiguration config = new ClientConfiguration(); if (StringUtils.isNotBlank(System.getProperty("http.proxyHost"))) { try { config.setProxyHost(System.getProperty("http.proxyHost")); if (StringUtils.isNotBlank(System.getProperty("http.proxyPort"))) { config.setProxyPort(Integer.valueOf(System.getProperty("http.proxyPort"))); } } catch (NumberFormatException e) { LOG.error("invalid proxy setup."); } } if (StringUtils.isNotBlank(creds.getKeyId()) && StringUtils.isNotBlank(creds.getKey())) { BasicAWSCredentials credentials = new BasicAWSCredentials(creds.getKeyId(), creds.getKey()); this.s3Client = new AmazonS3Client(credentials, config); } else { this.s3Client = new AmazonS3Client(config); } } catch (Exception ex) { LOG.error(ex.getMessage()); throw new RuntimeException(ex); } }
From source file:com.intuit.tank.vmManager.environment.amazon.CloudwatchInstance.java
License:Open Source License
/** * /*from www. j av a 2 s . co m*/ * @param request * @param vmRegion */ public CloudwatchInstance(VMRegion vmRegion) { // In case vmRegion is passed as null, use default region from settings file if (vmRegion == null) { vmRegion = config.getVmManagerConfig().getDefaultRegion(); } try { CloudCredentials creds = config.getVmManagerConfig().getCloudCredentials(CloudProvider.amazon); AWSCredentials credentials = new BasicAWSCredentials(creds.getKeyId(), creds.getKey()); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setMaxConnections(2); if (StringUtils.isNotBlank(creds.getProxyHost())) { try { clientConfig.setProxyHost(creds.getProxyHost()); if (StringUtils.isNotBlank(creds.getProxyPort())) { clientConfig.setProxyPort(Integer.valueOf(creds.getProxyPort())); } } catch (NumberFormatException e) { logger.error("invalid proxy setup."); } } if (StringUtils.isNotBlank(creds.getKeyId()) && StringUtils.isNotBlank(creds.getKey())) { asynchCloudWatchClient = new AmazonCloudWatchAsyncClient(credentials, clientConfig, Executors.newFixedThreadPool(2)); asyncSnsClient = new AmazonSNSAsyncClient(credentials, clientConfig, Executors.newFixedThreadPool(2)); } else { asynchCloudWatchClient = new AmazonCloudWatchAsyncClient(clientConfig); asyncSnsClient = new AmazonSNSAsyncClient(clientConfig); } asynchCloudWatchClient.setRegion(Region.getRegion(Regions.fromName(vmRegion.getRegion()))); asyncSnsClient.setRegion(Region.getRegion(Regions.fromName(vmRegion.getRegion()))); } catch (Exception ex) { logger.error(ex.getMessage()); throw new RuntimeException(ex); } }
From source file:com.ivona.services.tts.IvonaSpeechCloudClient.java
License:Open Source License
/** * Default Constructor./*from w w w . j ava 2s . co m*/ */ public IvonaSpeechCloudClient() { this(new DefaultAWSCredentialsProviderChain(), new ClientConfiguration()); }
From source file:com.ivona.services.tts.IvonaSpeechCloudClient.java
License:Open Source License
/** * Constructor which allows custom AWSCredentials to be passed. * * @param awsCredentials// w ww.ja v a 2 s . c om */ public IvonaSpeechCloudClient(AWSCredentials awsCredentials) { this(awsCredentials, new ClientConfiguration()); }
From source file:com.ivona.services.tts.IvonaSpeechCloudClient.java
License:Open Source License
/** * Constructor which allows custom AWSCredentialsProvider to be passed. * * @param awsCredentialsProvider// w w w . ja v a 2 s .c o m */ public IvonaSpeechCloudClient(AWSCredentialsProvider awsCredentialsProvider) { this(awsCredentialsProvider, new ClientConfiguration()); }
From source file:com.kinesis.datavis.utils.DeleteSampleResources.java
License:Open Source License
public static void main(String[] args) { if (args.length != 4) { System.err.println("Usage: " + DeleteSampleResources.class.getSimpleName() + " <application name> <stream name> <DynamoDB table name> <region>"); System.exit(1);//from ww w. ja v a2 s . c om } String applicationName = args[0]; String streamName = args[1]; String countsTableName = args[2]; Region region = AppUtils.parseRegion(args[3]); AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); ClientConfiguration clientConfig = AppUtils.configureUserAgentForSample(new ClientConfiguration()); AmazonKinesis kinesis = new AmazonKinesisClient(credentialsProvider, clientConfig); kinesis.setRegion(region); AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(credentialsProvider, clientConfig); dynamoDB.setRegion(region); StreamUtils streamUtils = new StreamUtils(kinesis); DynamoDBUtils dynamoDBUtils = new DynamoDBUtils(dynamoDB); LOG.info("Removing Amazon Kinesis and DynamoDB resources used by the sample application..."); streamUtils.deleteStream(streamName); // The Kinesis Client Library creates a table to manage shard leases and uses the application name for its name. dynamoDBUtils.deleteTable(applicationName); dynamoDBUtils.deleteTable(countsTableName); }
From source file:com.kinesis.datavis.writer.BidRequestStreamWriter.java
License:Open Source License
/** * Start a number of threads and send randomly generated {@link }s to a Kinesis Stream until the * program is terminated./*from w w w . j a va 2 s . c o m*/ * * @param args Expecting 3 arguments: A numeric value indicating the number of threads to use to send * data to Kinesis and the name of the stream to send records to, and the AWS region in which these resources * exist or should be created. * @throws InterruptedException If this application is interrupted while sending records to Kinesis. */ public static void main(String[] args) throws InterruptedException { int numberOfThreads = Integer.parseInt(args[0]); AppProperties appProps = new AppProperties("bidrq", args[1]); String streamName = appProps.streamName(); Region region = AppUtils.parseRegion(appProps.getRegion()); AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); ClientConfiguration clientConfig = AppUtils.configureUserAgentForSample(new ClientConfiguration()); AmazonKinesis kinesis = new AmazonKinesisClient(credentialsProvider, clientConfig); kinesis.setRegion(region); // The more resources we declare the higher write IOPS we need on our DynamoDB table. // We write a record for each resource every interval. // If interval = 500ms, resource count = 7 we need: (1000/500 * 7) = 14 write IOPS minimum. List<String> resources = new ArrayList<>(); resources.add("300x200"); resources.add("500x200"); resources.add("400x600"); resources.add("800x600"); List<String> bidRequestIds = new ArrayList<>(); // bidRequestIds.add(UUID.randomUUID().toString()); // bidRequestIds.add(UUID.randomUUID().toString()); // bidRequestIds.add(UUID.randomUUID().toString()); // bidRequestIds.add("11111111111"); // bidRequestIds.add("22222222222"); // bannerIds.add("33333333333"); // bidRequestIds.add("44444444444"); bidRequestIds.add("92b9b9d9-2d6d-454a-b80a-d6a318aca9ec"); BidRequestFactory bdFactory = new BidRequestFactory(bidRequestIds, resources); // Creates a stream to write to with 2 shards if it doesn't exist StreamUtils streamUtils = new StreamUtils(kinesis); streamUtils.createStreamIfNotExists(streamName, 2); LOG.info(String.format("%s stream is ready for use", streamName)); final BidRequestPutter putter = new BidRequestPutter(bdFactory, kinesis, streamName); GeneralStreamWriter streamWriter = new GeneralStreamWriter(numberOfThreads, putter); streamWriter.doWrite(); }
From source file:com.kinesis.utils.ConfigurationUtils.java
License:Open Source License
public static ClientConfiguration getClientConfigWithUserAgent() { final ClientConfiguration config = new ClientConfiguration(); final StringBuilder userAgent = new StringBuilder(ClientConfiguration.DEFAULT_USER_AGENT); // Separate fields of the user agent with a space userAgent.append(" "); // Append the application name followed by version number of the sample userAgent.append(APPLICATION_NAME);//ww w . ja v a 2 s . com userAgent.append("/"); userAgent.append(VERSION); config.setUserAgent(userAgent.toString()); return config; }
From source file:com.kitac.kinesissamples.consumer.communication.DynamoDBManager.java
License:Open Source License
private DynamoDBManager() { config = new ClientConfiguration(); /* TODO: ClientConfiguration setting code is here. */ AmazonDynamoDBClient client = new AmazonDynamoDBClient( // For use IAM role, specify DefaultAWSCredentialsProviderChain instance. new DefaultAWSCredentialsProviderChain(), config); client.setRegion(Regions.AP_NORTHEAST_1); dynamoDBConnection = new DynamoDB(client); }
From source file:com.liferay.portal.store.s3.S3Store.java
License:Open Source License
protected ClientConfiguration getClientConfiguration() { ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setConnectionTimeout(_s3StoreConfiguration.connectionTimeout()); clientConfiguration.setMaxErrorRetry(_s3StoreConfiguration.httpClientMaxErrorRetry()); clientConfiguration.setMaxConnections(_s3StoreConfiguration.httpClientMaxConnections()); configureProxySettings(clientConfiguration); return clientConfiguration; }