List of usage examples for com.amazonaws ClientConfiguration setUserAgent
@Deprecated public void setUserAgent(String userAgent)
From source file:br.com.ingenieux.jenkins.plugins.awsebdeployment.Deployer.java
License:Apache License
private void initAWS() { log("Creating S3 and AWSEB Client (AWS Access Key Id: %s, region: %s)", context.getAwsAccessKeyId(), context.getAwsRegion());/*from w ww . ja v a 2 s. c o m*/ AWSCredentialsProvider credentials = new AWSCredentialsProviderChain(new StaticCredentialsProvider( new BasicAWSCredentials(context.getAwsAccessKeyId(), context.getAwsSecretSharedKey()))); Region region = Region.getRegion(Regions.fromName(context.getAwsRegion())); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setUserAgent("ingenieux CloudButler/" + getVersion()); s3 = region.createClient(AmazonS3Client.class, credentials, clientConfig); awseb = region.createClient(AWSElasticBeanstalkClient.class, credentials, clientConfig); }
From source file:com.alertlogic.aws.analytics.poc.Utils.java
License:Open Source License
/** * Creates a new client configuration with a uniquely identifiable value for this sample application. * /*from ww w . j ava 2s .co m*/ * @param clientConfig The client configuration to copy. * @return A new client configuration based on the provided one with its user agent overridden. */ public static ClientConfiguration configureUserAgentForSample(ClientConfiguration clientConfig) { ClientConfiguration newConfig = new ClientConfiguration(clientConfig); StringBuilder userAgent = new StringBuilder(ClientConfiguration.DEFAULT_USER_AGENT); // Separate regions of the UserAgent with a space userAgent.append(" "); // Append the repository name followed by version number of the sample userAgent.append("alertlogic-aws-analytics-poc/1.0.0"); newConfig.setUserAgent(userAgent.toString()); return newConfig; }
From source file:com.alertlogic.aws.kinesis.test1.utils.SampleUtils.java
License:Open Source License
/** * Creates a new client configuration with a uniquely identifiable value for this sample application. * /*from ww w. j a v a 2 s . co m*/ * @param clientConfig The client configuration to copy. * @return A new client configuration based on the provided one with its user agent overridden. */ public static ClientConfiguration configureUserAgentForSample(ClientConfiguration clientConfig) { ClientConfiguration newConfig = new ClientConfiguration(clientConfig); StringBuilder userAgent = new StringBuilder(ClientConfiguration.DEFAULT_USER_AGENT); // Separate regions of the UserAgent with a space userAgent.append(" "); // Append the repository name followed by version number of the sample userAgent.append("amazon-kinesis-data-visualization-sample/1.1.1"); newConfig.setUserAgent(userAgent.toString()); return newConfig; }
From source file:com.amazon.kinesis.streaming.agent.AgentContext.java
License:Open Source License
public ClientConfiguration getAwsClientConfiguration() { ClientConfiguration config = new ClientConfiguration(); config.setUserAgent(userAgent(config)); config.setMaxConnections(maxConnections()); config.setConnectionTimeout(connectionTimeoutMillis()); config.setSocketTimeout(socketTimeoutMillis()); config.setUseTcpKeepAlive(useTcpKeepAlive()); config.setConnectionTTL(connectionTTLMillis()); config.setUseGzip(useHttpGzip());//from w ww . jav a2s . c om return config; }
From source file:com.calamp.services.kinesis.events.utils.ConfigurationUtils.java
License:Open Source License
public static ClientConfiguration getClientConfigWithUserAgent(boolean isUnordered) { String APPLICATION_NAME = isUnordered ? APPLICATION_NAME_UNORD : APPLICATION_NAME_ORD; 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);// www. j a v a 2s.c o m userAgent.append("/"); userAgent.append(VERSION); config.setUserAgent(userAgent.toString()); return config; }
From source file:com.gu.logback.appender.kinesis.BaseKinesisAppender.java
License:Open Source License
/** * Configures appender instance and makes it ready for use by the consumers. * It validates mandatory parameters and confirms if the configured stream is * ready for publishing data yet.//from w w w. java 2 s . co m * * Error details are made available through the fallback handler for this * appender * * @throws IllegalStateException if we encounter issues configuring this * appender instance */ @Override public void start() { if (layout == null) { initializationFailed = true; addError("Invalid configuration - No layout for appender: " + name); return; } if (streamName == null) { initializationFailed = true; addError("Invalid configuration - streamName cannot be null for appender: " + name); return; } ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setMaxErrorRetry(maxRetries); clientConfiguration.setRetryPolicy(new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY, maxRetries, true)); clientConfiguration.setUserAgent(AppenderConstants.USER_AGENT_STRING); BlockingQueue<Runnable> taskBuffer = new LinkedBlockingDeque<Runnable>(bufferSize); threadPoolExecutor = new ThreadPoolExecutor(threadCount, threadCount, AppenderConstants.DEFAULT_THREAD_KEEP_ALIVE_SEC, TimeUnit.SECONDS, taskBuffer, new BlockFastProducerPolicy()); threadPoolExecutor.prestartAllCoreThreads(); this.client = createClient(credentials, clientConfiguration, threadPoolExecutor); client.setRegion(findRegion()); if (!Validator.isBlank(endpoint)) { if (!Validator.isBlank(region)) { addError("Received configuration for both region as well as Amazon Kinesis endpoint. (" + endpoint + ") will be used as endpoint instead of default endpoint for region (" + region + ")"); } client.setEndpoint(endpoint); } validateStreamName(client, streamName); super.start(); }
From source file:com.gu.logback.appender.kinesis.KinesisAppender.java
License:Open Source License
/** * Configures this appender instance and makes it ready for use by the * consumers. It validates mandatory parameters and confirms if the configured * stream is ready for publishing data yet. * /*from www. ja v a 2 s . c o m*/ * Error details are made available through the fallback handler for this * appender * * @throws IllegalStateException * if we encounter issues configuring this appender instance */ @Override public void start() { if (layout == null) { initializationFailed = true; addError("Invalid configuration - No layout for appender: " + name); return; } if (streamName == null) { initializationFailed = true; addError("Invalid configuration - streamName cannot be null for appender: " + name); return; } ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setMaxErrorRetry(maxRetries); clientConfiguration.setRetryPolicy(new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY, maxRetries, true)); clientConfiguration.setUserAgent(AppenderConstants.USER_AGENT_STRING); BlockingQueue<Runnable> taskBuffer = new LinkedBlockingDeque<Runnable>(bufferSize); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(threadCount, threadCount, AppenderConstants.DEFAULT_THREAD_KEEP_ALIVE_SEC, TimeUnit.SECONDS, taskBuffer, new BlockFastProducerPolicy()); threadPoolExecutor.prestartAllCoreThreads(); kinesisClient = new AmazonKinesisAsyncClient(credentials, clientConfiguration, threadPoolExecutor); boolean regionProvided = !Validator.isBlank(region); if (!regionProvided) { region = AppenderConstants.DEFAULT_REGION; } kinesisClient.setRegion(Region.getRegion(Regions.fromName(region))); if (!Validator.isBlank(endpoint)) { if (regionProvided) { addError("Received configuration for both region as well as Amazon Kinesis endpoint. (" + endpoint + ") will be used as endpoint instead of default endpoint for region (" + region + ")"); } kinesisClient.setEndpoint(endpoint); } DescribeStreamResult describeResult = null; try { describeResult = kinesisClient.describeStream(streamName); String streamStatus = describeResult.getStreamDescription().getStreamStatus(); if (!StreamStatus.ACTIVE.name().equals(streamStatus) && !StreamStatus.UPDATING.name().equals(streamStatus)) { initializationFailed = true; addError( "Stream " + streamName + " is not ready (in active/updating status) for appender: " + name); } } catch (ResourceNotFoundException rnfe) { initializationFailed = true; addError("Stream " + streamName + " doesn't exist for appender: " + name, rnfe); } asyncCallHander = new AsyncPutCallStatsReporter(this); super.start(); }
From source file:com.kinesis.datavis.utils.AppUtils.java
License:Open Source License
/** * Creates a new client configuration with a uniquely identifiable value for this sample application. * /*from w ww .j a v a 2s.co m*/ * @param clientConfig The client configuration to copy. * @return A new client configuration based on the provided one with its user agent overridden. */ public static ClientConfiguration configureUserAgentForSample(ClientConfiguration clientConfig) { ClientConfiguration newConfig = new ClientConfiguration(clientConfig); StringBuilder userAgent = new StringBuilder(ClientConfiguration.DEFAULT_USER_AGENT); // Separate regions of the UserAgent with a space userAgent.append(" "); // Append the repository name followed by version number of the sample userAgent.append("amazon-kinesis-data-visualization-sample/1.1.2"); newConfig.setUserAgent(userAgent.toString()); return newConfig; }
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);/*from ww w.j a v a 2 s .c o m*/ userAgent.append("/"); userAgent.append(VERSION); config.setUserAgent(userAgent.toString()); return config; }
From source file:com.tcl.gateway.firehose.log4j.FirehoseAppender.java
License:Open Source License
/** * Configures this appender instance and makes it ready for use by the * consumers. It validates mandatory parameters and confirms if the configured * stream is ready for publishing data yet. * //from w w w . j ava2 s .co m * Error details are made available through the fallback handler for this * appender * * @throws IllegalStateException * if we encounter issues configuring this appender instance */ @Override public void activateOptions() { if (deliveryStreamName == null) { initializationFailed = true; error("Invalid configuration - streamName cannot be null for appender: " + name); } if (layout == null) { initializationFailed = true; error("Invalid configuration - No layout for appender: " + name); } ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration = setProxySettingsFromSystemProperties(clientConfiguration); clientConfiguration.setMaxErrorRetry(maxRetries); clientConfiguration.setRetryPolicy(new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY, maxRetries, true)); clientConfiguration.setUserAgent(AppenderConstants.USER_AGENT_STRING); final BlockingQueue<Runnable> taskBuffer = new LinkedBlockingDeque<Runnable>(bufferSize); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(threadCount, threadCount, AppenderConstants.DEFAULT_THREAD_KEEP_ALIVE_SEC, TimeUnit.SECONDS, taskBuffer, new BlockFastProducerPolicy()); threadPoolExecutor.prestartAllCoreThreads(); firehoseClient = new AmazonKinesisFirehoseAsyncClient(new CustomCredentialsProviderChain(), clientConfiguration, threadPoolExecutor); boolean regionProvided = !Validator.isBlank(region); if (!regionProvided) { region = AppenderConstants.DEFAULT_REGION; } if (!Validator.isBlank(endpoint)) { if (regionProvided) { LOGGER.warn("Received configuration for both region as well as Amazon Kinesis endpoint. (" + endpoint + ") will be used as endpoint instead of default endpoint for region (" + region + ")"); } firehoseClient.setEndpoint(endpoint); } else { firehoseClient.setRegion(Region.getRegion(Regions.fromName(region))); } DescribeDeliveryStreamResult describeResult = null; try { describeResult = firehoseClient.describeDeliveryStream( new DescribeDeliveryStreamRequest().withDeliveryStreamName(deliveryStreamName)); String streamStatus = describeResult.getDeliveryStreamDescription().getDeliveryStreamStatus(); if (!StreamStatus.ACTIVE.name().equals(streamStatus) && !StreamStatus.UPDATING.name().equals(streamStatus)) { initializationFailed = true; error("Delivery Stream " + deliveryStreamName + " is not ready (in active/updating status) for appender: " + name); } } catch (ResourceNotFoundException rnfe) { initializationFailed = true; error("Delivery Stream " + deliveryStreamName + " doesn't exist for appender: " + name, rnfe); } asyncCallHander = new AsyncPutCallStatsReporter(name); if (metric) { MetricRegistry registry = new MetricRegistry(); registry.register("Gauge", new Gauge<Integer>() { @Override public Integer getValue() { return taskBuffer.size(); } }); ConsoleReporter.forRegistry(registry).build().start(3, TimeUnit.SECONDS); } }