Example usage for com.amazonaws ClientConfiguration setUserAgentPrefix

List of usage examples for com.amazonaws ClientConfiguration setUserAgentPrefix

Introduction

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

Prototype

public void setUserAgentPrefix(String prefix) 

Source Link

Document

Sets the HTTP user agent prefix to send with all requests.

Usage

From source file:com.ibm.stocator.fs.cos.COSAPIClient.java

License:Apache License

/**
 * Initializes connection management/*from w ww .  j a v  a2 s  . c o m*/
 *
 * @param conf Hadoop configuration
 * @param clientConf client SDK configuration
 */
private void initConnectionSettings(Configuration conf, ClientConfiguration clientConf) throws IOException {
    clientConf.setMaxConnections(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, MAXIMUM_CONNECTIONS, DEFAULT_MAXIMUM_CONNECTIONS));
    clientConf.setClientExecutionTimeout(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, CLIENT_EXEC_TIMEOUT, DEFAULT_CLIENT_EXEC_TIMEOUT));
    clientConf.setMaxErrorRetry(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, MAX_ERROR_RETRIES, DEFAULT_MAX_ERROR_RETRIES));
    clientConf.setConnectionTimeout(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, ESTABLISH_TIMEOUT, DEFAULT_ESTABLISH_TIMEOUT));
    clientConf
            .setSocketTimeout(Utils.getInt(conf, FS_COS, FS_ALT_KEYS, SOCKET_TIMEOUT, DEFAULT_SOCKET_TIMEOUT));
    clientConf.setRequestTimeout(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT));
    int sockSendBuffer = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, SOCKET_SEND_BUFFER,
            DEFAULT_SOCKET_SEND_BUFFER);
    int sockRecvBuffer = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, SOCKET_RECV_BUFFER,
            DEFAULT_SOCKET_RECV_BUFFER);
    clientConf.setSocketBufferSizeHints(sockSendBuffer, sockRecvBuffer);
    String signerOverride = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, SIGNING_ALGORITHM, "");
    if (!signerOverride.isEmpty()) {
        LOG.debug("Signer override = {}", signerOverride);
        clientConf.setSignerOverride(signerOverride);
    }

    String userAgentPrefix = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, USER_AGENT_PREFIX,
            DEFAULT_USER_AGENT_PREFIX);
    String userAgentName = singletoneInitTimeData.getUserAgentName();
    if (!userAgentPrefix.equals(DEFAULT_USER_AGENT_PREFIX)) {
        userAgentName = userAgentPrefix + " " + userAgentName;
    }
    clientConf.setUserAgentPrefix(userAgentName);
}

From source file:org.apache.flink.streaming.connectors.kinesis.proxy.DynamoDBStreamsProxy.java

License:Apache License

/**
 * Creates an AmazonDynamoDBStreamsAdapterClient.
 * Uses it as the internal client interacting with the DynamoDB streams.
 *
 * @param configProps configuration properties
 * @return an AWS DynamoDB streams adapter client
 *//* ww w.ja v a 2 s  .  co m*/
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
    ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
    setAwsClientConfigProperties(awsClientConfig, configProps);

    AWSCredentialsProvider credentials = getCredentialsProvider(configProps);
    awsClientConfig.setUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(),
            EnvironmentInformation.getRevisionInformation().commitId));

    AmazonDynamoDBStreamsAdapterClient adapterClient = new AmazonDynamoDBStreamsAdapterClient(credentials,
            awsClientConfig);

    if (configProps.containsKey(AWS_ENDPOINT)) {
        adapterClient.setEndpoint(configProps.getProperty(AWS_ENDPOINT));
    } else {
        adapterClient.setRegion(Region.getRegion(Regions.fromName(configProps.getProperty(AWS_REGION))));
    }

    return adapterClient;
}