Example usage for com.amazonaws ClientConfiguration ClientConfiguration

List of usage examples for com.amazonaws ClientConfiguration ClientConfiguration

Introduction

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

Prototype

public ClientConfiguration() 

Source Link

Usage

From source file:ec2watch.EC2Watch.java

License:Open Source License

private ClientConfiguration getClientConfig() {
    ClientConfiguration config = new ClientConfiguration();
    String proxyHost = System.getenv("PROXY_HOST");
    String proxyPort = System.getenv("PROXY_PORT");
    String proxyUser = System.getenv("PROXY_USER");
    String proxyPass = System.getenv("PROXY_PASSWORD");
    if (proxyHost != null && proxyPort != null) {
        config.setProxyHost(proxyHost);//from w w w . j  av  a 2  s. co  m
        config.setProxyPort(Integer.valueOf(proxyPort));
        if (proxyUser != null) {
            config.setProxyUsername(proxyUser);
        }
        if (proxyPass != null) {
            config.setProxyPassword(proxyPass);
        }
    }
    return config;
}

From source file:edu.upenn.library.fcrepo.connector.annex.S3AnnexResolverFactory.java

License:Apache License

@Override
public void initialize(Properties props) {
    this.accessKey = props.getProperty(ACCESS_KEY_PROPNAME);
    this.secretKey = props.getProperty(SECRET_KEY_PROPNAME);
    this.bucket = props.getProperty(BUCKET_PROPNAME);
    AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);

    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.setProtocol(Protocol.HTTP);
    S3ClientOptions clientOptions = new S3ClientOptions();
    clientOptions.setPathStyleAccess(true);

    conn = new AmazonS3Client(credentials, clientConfig);
    conn.setS3ClientOptions(clientOptions);
    conn.setEndpoint(props.getProperty(ENDPOINT_PROPNAME));
}

From source file:edu.utn.frba.grupo5303.serverenviolibre.repository.CalificacionDAODynamo.java

public CalificacionDAODynamo() {

    String regionName = "us-west-2";

    Region region = Region.getRegion(Regions.fromName(regionName));
    ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(20);

    ddb = new AmazonDynamoDBClient(new ProfileCredentialsProvider(), clientConfiguration);

    ddb.setRegion(region);//from   ww  w . ja v  a  2 s. com

    mapper = new DynamoDBMapper(ddb);
}

From source file:edu.utn.frba.grupo5303.serverenviolibre.repository.FacturasDAODynamo.java

public FacturasDAODynamo() {

    String regionName = "us-west-2";

    Region region = Region.getRegion(Regions.fromName(regionName));
    ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(20);

    ddb = new AmazonDynamoDBClient(new ProfileCredentialsProvider(), clientConfiguration);

    ddb.setRegion(region);// w w  w  . j  av  a 2  s.  c  om

    mapper = new DynamoDBMapper(ddb);
}

From source file:edu.utn.frba.grupo5303.serverenviolibre.repository.ImagenUsuarioDAODynamo.java

public ImagenUsuarioDAODynamo() {

    String regionName = "us-west-2";

    Region region = Region.getRegion(Regions.fromName(regionName));
    ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(20);

    ddb = new AmazonDynamoDBClient(new ProfileCredentialsProvider(), clientConfiguration);

    ddb.setRegion(region);/*from w  w  w.ja v a2s .  c  om*/

    mapper = new DynamoDBMapper(ddb);
}

From source file:edu.utn.frba.grupo5303.serverenviolibre.services.GeoPosicionamientoPublicacionesService.java

private void setupGeoDataManager() {
    String tableName = "Posicion";
    String regionName = "us-west-2";

    Region region = Region.getRegion(Regions.fromName(regionName));
    ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(20);

    AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(new ProfileCredentialsProvider(), clientConfiguration);
    ddb.setRegion(region);/*w  ww .  ja v a2 s  . c o  m*/

    config = new GeoDataManagerConfiguration(ddb, tableName);
    geoDataManager = new GeoDataManager(config);
}

From source file:edu.utn.frba.grupo5303.serverenviolibre.services.GeoPosicionamientoUsuariosService.java

private void setupGeoDataManager() {
    String tableName = "PosicionUsuarios";
    String regionName = "us-west-2";

    Region region = Region.getRegion(Regions.fromName(regionName));
    ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(20);

    AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(new ProfileCredentialsProvider(), clientConfiguration);
    ddb.setRegion(region);// www  .  j  a va  2  s  .c om

    config = new GeoDataManagerConfiguration(ddb, tableName);
    geoDataManager = new GeoDataManager(config);
}

From source file:eu.roschi.obdkinesis.HttpReferrerCounterApplication.java

License:Open Source License

/**
 * Start the Kinesis Client application.
 * /*w  ww . ja v  a 2  s. co m*/
 * @param args Expecting 4 arguments: Application name to use for the Kinesis Client Application, Stream name to
 *        read from, DynamoDB table name to persist counts into, and the AWS region in which these resources
 *        exist or should be created.
 */
public static void main(String[] args) throws UnknownHostException {

    if (args.length != 2) {
        System.err.println("Using default values");
        COMPUTE_RANGE_FOR_COUNTS_IN_MILLIS = 30000;
        COMPUTE_INTERVAL_IN_MILLIS = 2000;
    } else {
        COMPUTE_RANGE_FOR_COUNTS_IN_MILLIS = Integer.parseInt(args[0]);
        COMPUTE_INTERVAL_IN_MILLIS = Integer.parseInt(args[1]);
        System.err.println(
                "Using values " + Integer.parseInt(args[0]) + " width " + Integer.parseInt(args[1]) + " rate");
    }
    String applicationName = "obd_kinesis";
    String streamName = "obd_input_stream";
    String countsTableName = "obd_kinesis_count";
    Region region = SampleUtils.parseRegion("us-west-2");

    AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
    ClientConfiguration clientConfig = SampleUtils.configureUserAgentForSample(new ClientConfiguration());
    AmazonKinesis kinesis = new AmazonKinesisClient(credentialsProvider, clientConfig);
    kinesis.setRegion(region);
    AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(credentialsProvider, clientConfig);
    dynamoDB.setRegion(region);

    // Creates a stream to write to, 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));

    DynamoDBUtils dynamoDBUtils = new DynamoDBUtils(dynamoDB);
    dynamoDBUtils.createCountTableIfNotExists(countsTableName);
    LOG.info(String.format("%s DynamoDB table is ready for use", countsTableName));

    String workerId = String.valueOf(UUID.randomUUID());
    LOG.info(String.format("Using working id: %s", workerId));
    KinesisClientLibConfiguration kclConfig = new KinesisClientLibConfiguration(applicationName, streamName,
            credentialsProvider, workerId);
    kclConfig.withCommonClientConfig(clientConfig);
    kclConfig.withRegionName(region.getName());
    kclConfig.withInitialPositionInStream(InitialPositionInStream.LATEST);

    // Persist counts to DynamoDB
    DynamoDBCountPersister persister = new DynamoDBCountPersister(
            dynamoDBUtils.createMapperForTable(countsTableName));

    IRecordProcessorFactory recordProcessor = new CountingRecordProcessorFactory<HttpReferrerPair>(
            HttpReferrerPair.class, persister, COMPUTE_RANGE_FOR_COUNTS_IN_MILLIS, COMPUTE_INTERVAL_IN_MILLIS);

    Worker worker = new Worker(recordProcessor, kclConfig);

    int exitCode = 0;
    try {
        worker.run();
    } catch (Throwable t) {
        LOG.error("Caught throwable while processing data.", t);
        exitCode = 1;
    }
    System.exit(exitCode);
}

From source file:eu.roschi.obdkinesis.WebServer.java

License:Open Source License

/**
 * Start an embedded web server.//  w w  w  .j  a v  a  2  s .co  m
 * 
 * @param args Expecting 4 arguments: Port number, File path to static content, the name of the
 *        DynamoDB table where counts are persisted to, and the AWS region in which these resources
 *        exist or should be created.
 * @throws Exception Error starting the web server.
 */
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.err.println("Usage: " + WebServer.class + " <directory for static content>");
        System.exit(1);
    }
    Server server = new Server(8080);
    String wwwroot = args[0];
    String countsTableName = "obd_kinesis_count";
    Region region = SampleUtils.parseRegion("us-west-2");

    // Servlet context
    ServletContextHandler context = new ServletContextHandler(
            ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY);
    context.setContextPath("/api");

    // Static resource context
    ResourceHandler resources = new ResourceHandler();
    resources.setDirectoriesListed(false);
    resources.setWelcomeFiles(new String[] { "graph.html" });
    resources.setResourceBase(wwwroot);

    // Create the servlet to handle /GetCounts
    AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
    ClientConfiguration clientConfig = SampleUtils.configureUserAgentForSample(new ClientConfiguration());
    AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(credentialsProvider, clientConfig);
    dynamoDB.setRegion(region);
    DynamoDBUtils dynamoDBUtils = new DynamoDBUtils(dynamoDB);
    context.addServlet(
            new ServletHolder(new GetCountsServlet(dynamoDBUtils.createMapperForTable(countsTableName))),
            "/GetCounts/*");

    HandlerList handlers = new HandlerList();
    handlers.addHandler(context);
    handlers.addHandler(resources);
    handlers.addHandler(new DefaultHandler());

    server.setHandler(handlers);
    server.start();
    server.join();
}

From source file:fi.yle.tools.aws.maven.S3Utils.java

License:Apache License

static ClientConfiguration getClientConfiguration(ProxyInfoProvider proxyInfoProvider) {
    ClientConfiguration clientConfiguration = new ClientConfiguration();

    if (proxyInfoProvider != null) {
        ProxyInfo proxyInfo = proxyInfoProvider.getProxyInfo("s3");
        if (proxyInfo != null) {
            clientConfiguration.withProxyHost(proxyInfo.getHost()).withProxyPort(proxyInfo.getPort());
        }//from  w  ww .j a va 2  s.c  om
    }

    return clientConfiguration;
}