Example usage for com.amazonaws ClientConfiguration DEFAULT_USER_AGENT

List of usage examples for com.amazonaws ClientConfiguration DEFAULT_USER_AGENT

Introduction

In this page you can find the example usage for com.amazonaws ClientConfiguration DEFAULT_USER_AGENT.

Prototype

String DEFAULT_USER_AGENT

To view the source code for com.amazonaws ClientConfiguration DEFAULT_USER_AGENT.

Click Source Link

Document

The default HTTP user agent header for AWS Java SDK clients.

Usage

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  w w w  .  j  a va 2s  .c  om*/
 * @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  w  ww . j  a  v  a 2  s . com*/
 * @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.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);/*from  w  ww  .  j  a  v a2s.co  m*/
    userAgent.append("/");
    userAgent.append(VERSION);

    config.setUserAgent(userAgent.toString());

    return config;
}

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.
 * /*w  w  w.j a  va 2 s. com*/
 * @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);/* ww w  .  j a  v  a 2  s .  co  m*/
    userAgent.append("/");
    userAgent.append(VERSION);

    config.setUserAgent(userAgent.toString());

    return config;
}

From source file:com.zanox.vertx.mods.KinesisMessageProcessor.java

License:Apache License

private AmazonKinesisAsyncClient createClient() {

    // Building Kinesis configuration
    int connectionTimeout = getOptionalIntConfig(CONNECTION_TIMEOUT,
            ClientConfiguration.DEFAULT_CONNECTION_TIMEOUT);
    int maxConnection = getOptionalIntConfig(MAX_CONNECTION, ClientConfiguration.DEFAULT_MAX_CONNECTIONS);

    // TODO: replace default retry policy
    RetryPolicy retryPolicy = ClientConfiguration.DEFAULT_RETRY_POLICY;
    int socketTimeout = getOptionalIntConfig(SOCKET_TIMEOUT, ClientConfiguration.DEFAULT_SOCKET_TIMEOUT);
    boolean useReaper = getOptionalBooleanConfig(USE_REAPER, ClientConfiguration.DEFAULT_USE_REAPER);
    String userAgent = getOptionalStringConfig(USER_AGENT, ClientConfiguration.DEFAULT_USER_AGENT);

    streamName = getMandatoryStringConfig(STREAM_NAME);
    partitionKey = getMandatoryStringConfig(PARTITION_KEY);
    region = getMandatoryStringConfig(REGION);

    logger.info(" --- Stream name: " + streamName);
    logger.info(" --- Partition key: " + partitionKey);
    logger.info(" --- Region: " + region);

    ClientConfiguration clientConfiguration = new ClientConfiguration();
    clientConfiguration.setConnectionTimeout(connectionTimeout);
    clientConfiguration.setMaxConnections(maxConnection);
    clientConfiguration.setRetryPolicy(retryPolicy);
    clientConfiguration.setSocketTimeout(socketTimeout);
    clientConfiguration.setUseReaper(useReaper);
    clientConfiguration.setUserAgent(userAgent);

    /*//from www . ja v  a  2 s . c  o  m
    AWS credentials provider chain that looks for credentials in this order:
       Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
       Java System Properties - aws.accessKeyId and aws.secretKey
       Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI
       Instance profile credentials delivered through the Amazon EC2 metadata service
    */

    AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain();

    // Configuring Kinesis-client with configuration
    AmazonKinesisAsyncClient kinesisAsyncClient = new AmazonKinesisAsyncClient(awsCredentialsProvider,
            clientConfiguration);
    Region awsRegion = RegionUtils.getRegion(region);
    kinesisAsyncClient.setRegion(awsRegion);

    return kinesisAsyncClient;
}

From source file:io.radiowitness.kinesis.consumer.KclConfigFactory.java

License:Open Source License

private String userAgent() {
    StringBuilder userAgent = new StringBuilder(ClientConfiguration.DEFAULT_USER_AGENT);

    userAgent.append(" ");
    userAgent.append(config.getAppName());
    userAgent.append(" ");
    userAgent.append(config.getAppVersion());

    return userAgent.toString();
}

From source file:io.radiowitness.kinesis.producer.KinesisClientFactory.java

License:Open Source License

private ClientConfiguration clientConfig() {
    ClientConfiguration clientConfig = new ClientConfiguration();
    StringBuilder userAgent = new StringBuilder(ClientConfiguration.DEFAULT_USER_AGENT);

    userAgent.append(" ");
    userAgent.append(config.getAppName());
    userAgent.append(" ");
    userAgent.append(config.getAppVersion());

    clientConfig.setUserAgent(userAgent.toString());
    clientConfig.setMaxConnections(1);//from w w  w  .j  av  a  2 s  .c  om

    /*
    todo:
      play with timeouts, retry policy, gzip, keep-alive, etc.
     */

    return clientConfig;
}