List of usage examples for com.amazonaws ClientConfiguration ClientConfiguration
public ClientConfiguration()
From source file:io.prestosql.plugin.hive.s3.PrestoS3FileSystem.java
License:Apache License
@Override public void initialize(URI uri, Configuration conf) throws IOException { requireNonNull(uri, "uri is null"); requireNonNull(conf, "conf is null"); super.initialize(uri, conf); setConf(conf);//from w w w .j a v a 2s. c o m this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority()); this.workingDirectory = new Path(PATH_SEPARATOR).makeQualified(this.uri, new Path(PATH_SEPARATOR)); HiveS3Config defaults = new HiveS3Config(); this.stagingDirectory = new File( conf.get(S3_STAGING_DIRECTORY, defaults.getS3StagingDirectory().toString())); this.maxAttempts = conf.getInt(S3_MAX_CLIENT_RETRIES, defaults.getS3MaxClientRetries()) + 1; this.maxBackoffTime = Duration .valueOf(conf.get(S3_MAX_BACKOFF_TIME, defaults.getS3MaxBackoffTime().toString())); this.maxRetryTime = Duration.valueOf(conf.get(S3_MAX_RETRY_TIME, defaults.getS3MaxRetryTime().toString())); int maxErrorRetries = conf.getInt(S3_MAX_ERROR_RETRIES, defaults.getS3MaxErrorRetries()); boolean sslEnabled = conf.getBoolean(S3_SSL_ENABLED, defaults.isS3SslEnabled()); Duration connectTimeout = Duration .valueOf(conf.get(S3_CONNECT_TIMEOUT, defaults.getS3ConnectTimeout().toString())); Duration socketTimeout = Duration .valueOf(conf.get(S3_SOCKET_TIMEOUT, defaults.getS3SocketTimeout().toString())); int maxConnections = conf.getInt(S3_MAX_CONNECTIONS, defaults.getS3MaxConnections()); this.multiPartUploadMinFileSize = conf.getLong(S3_MULTIPART_MIN_FILE_SIZE, defaults.getS3MultipartMinFileSize().toBytes()); this.multiPartUploadMinPartSize = conf.getLong(S3_MULTIPART_MIN_PART_SIZE, defaults.getS3MultipartMinPartSize().toBytes()); this.isPathStyleAccess = conf.getBoolean(S3_PATH_STYLE_ACCESS, defaults.isS3PathStyleAccess()); this.useInstanceCredentials = conf.getBoolean(S3_USE_INSTANCE_CREDENTIALS, defaults.isS3UseInstanceCredentials()); this.pinS3ClientToCurrentRegion = conf.getBoolean(S3_PIN_CLIENT_TO_CURRENT_REGION, defaults.isPinS3ClientToCurrentRegion()); verify((pinS3ClientToCurrentRegion && conf.get(S3_ENDPOINT) == null) || !pinS3ClientToCurrentRegion, "Invalid configuration: either endpoint can be set or S3 client can be pinned to the current region"); this.sseEnabled = conf.getBoolean(S3_SSE_ENABLED, defaults.isS3SseEnabled()); this.sseType = PrestoS3SseType.valueOf(conf.get(S3_SSE_TYPE, defaults.getS3SseType().name())); this.sseKmsKeyId = conf.get(S3_SSE_KMS_KEY_ID, defaults.getS3SseKmsKeyId()); this.s3AclType = PrestoS3AclType.valueOf(conf.get(S3_ACL_TYPE, defaults.getS3AclType().name())); String userAgentPrefix = conf.get(S3_USER_AGENT_PREFIX, defaults.getS3UserAgentPrefix()); ClientConfiguration configuration = new ClientConfiguration().withMaxErrorRetry(maxErrorRetries) .withProtocol(sslEnabled ? Protocol.HTTPS : Protocol.HTTP) .withConnectionTimeout(toIntExact(connectTimeout.toMillis())) .withSocketTimeout(toIntExact(socketTimeout.toMillis())).withMaxConnections(maxConnections) .withUserAgentPrefix(userAgentPrefix).withUserAgentSuffix(S3_USER_AGENT_SUFFIX); this.credentialsProvider = createAwsCredentialsProvider(uri, conf); this.s3 = createAmazonS3Client(conf, configuration); }
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 a v a 2 s. c om /* todo: play with timeouts, retry policy, gzip, keep-alive, etc. */ return clientConfig; }
From source file:io.relution.jenkins.awssqs.factories.SQSFactoryImpl.java
License:Apache License
private ClientConfiguration getClientConfiguration(final io.relution.jenkins.awssqs.interfaces.SQSQueue queue) { final ClientConfiguration config = new ClientConfiguration(); // Check to see if Jenkins is up yet Jenkins jenkins = Jenkins.getInstance(); ProxyConfiguration proxyConfig = jenkins.proxy; Proxy proxy = proxyConfig == null ? Proxy.NO_PROXY : proxyConfig.createProxy(queue.getEndpoint()); if (!proxy.equals(Proxy.NO_PROXY) && proxy.address() instanceof InetSocketAddress) { InetSocketAddress address = (InetSocketAddress) proxy.address(); config.setProxyHost(address.getHostName()); config.setProxyPort(address.getPort()); config.setNonProxyHosts("169.254.169.254"); if (null != proxyConfig.getUserName()) { config.setProxyUsername(proxyConfig.getUserName()); config.setProxyPassword(proxyConfig.getPassword()); }//from ww w.j a va2 s . c om io.relution.jenkins.awssqs.logging.Log.info("Proxy settings for SQS: %s:%s", config.getProxyHost(), config.getProxyPort()); } return config; }
From source file:io.relution.jenkins.scmsqs.factories.SQSFactoryImpl.java
License:Apache License
private ClientConfiguration getClientConfiguration(final SQSQueue queue) { final ClientConfiguration config = new ClientConfiguration(); // TODO Add support for proxy return config; }
From source file:jetbrains.buildServer.util.amazon.AWSClients.java
License:Apache License
@NotNull private static ClientConfiguration createClientConfiguration() { return new ClientConfiguration() .withUserAgent("JetBrains TeamCity " + ServerVersionHolder.getVersion().getDisplayVersion()); }
From source file:jp.aws.test.AmazonClientManager.java
License:Apache License
/** * ?// w w w . ja va 2 s.c o m */ public void validateCredentials() { if (s3Client == null || ec2Client == null) { Log.i(LOG_TAG, "Creating New Clients."); // ??? SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.context); String access_key = prefs.getString("prefs_account_access_key", ""); String secret_key = prefs.getString("prefs_account_secret_key", ""); // ? ClientConfiguration clientconfiguration = new ClientConfiguration(); clientconfiguration.setConnectionTimeout(this.connectionTimeout); // (ms) AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); s3Client = new AmazonS3Client(credentials, clientconfiguration); ec2Client = new AmazonEC2Client(credentials, clientconfiguration); // this.changeRegion(); } }
From source file:jp.classmethod.aws.gradle.AwsPluginExtension.java
License:Apache License
public <T extends AmazonWebServiceClient> T createClient(Class<T> serviceClass, String profileName, ClientConfiguration config) {//from w w w . j a va 2 s . c o m AWSCredentialsProvider credentialsProvider = newCredentialsProvider(profileName); ClientConfiguration configToUse = config == null ? new ClientConfiguration() : config; if (this.proxyHost != null && this.proxyPort > 0) { configToUse.setProxyHost(this.proxyHost); configToUse.setProxyPort(this.proxyPort); } return createClient(serviceClass, credentialsProvider, configToUse); }
From source file:jp.classmethod.aws.gradle.s3.AmazonS3PluginExtension.java
License:Apache License
@Override protected ClientConfiguration buildClientConfiguration() { ClientConfiguration clientConfiguration = new ClientConfiguration(); if (maxErrorRetry > 0) { clientConfiguration.setMaxErrorRetry(maxErrorRetry); }/*from w w w .j a v a 2 s .c om*/ return clientConfiguration; }
From source file:jp.primecloud.auto.aws.amazon.AmazonAwsClientFactory.java
License:Open Source License
protected ClientConfiguration createConfiguration() { ClientConfiguration configuration = new ClientConfiguration(); // Proxy//from w ww . j a v a 2 s . c o m if (proxyHost != null && proxyPort != null) { configuration.setProxyHost(proxyHost); configuration.setProxyPort(proxyPort); if (proxyUser != null && proxyPassword != null) { configuration.setProxyUsername(proxyUser); configuration.setProxyPassword(proxyPassword); } } // ??? configuration.setMaxErrorRetry(0); return configuration; }
From source file:KinesisStormClickstreamApp.SampleTopology.java
License:Open Source License
public static void main(String[] args) throws IllegalArgumentException, KeeperException, InterruptedException, AlreadyAliveException, InvalidTopologyException, IOException { String propertiesFile = null; String mode = null;// www. j av a 2 s .co m if (args.length != 2) { printUsageAndExit(); } else { propertiesFile = args[0]; mode = args[1]; } configure(propertiesFile); final KinesisSpoutConfig config = new KinesisSpoutConfig(streamName, zookeeperEndpoint) .withZookeeperPrefix(zookeeperPrefix).withInitialPositionInStream(initialPositionInStream) .withRegion(Regions.fromName(regionName)); final KinesisSpout spout = new KinesisSpout(config, new CustomCredentialsProviderChain(), new ClientConfiguration()); TopologyBuilder builder = new TopologyBuilder(); LOG.info("Using Kinesis stream: " + config.getStreamName()); // Using number of shards as the parallelism hint for the spout. builder.setSpout("Kinesis", spout, 2); builder.setBolt("Parse", new ParseReferrerBolt(), 6).shuffleGrouping("Kinesis"); builder.setBolt("Count", new RollingCountBolt(5, 2, elasticCacheRedisEndpoint), 6).fieldsGrouping("Parse", new Fields("referrer")); //builder.setBolt("Count", new CountReferrerBolt(), 12).fieldsGrouping("Parse", new Fields("referrer")); Config topoConf = new Config(); topoConf.setFallBackOnJavaSerialization(true); topoConf.setDebug(false); if (mode.equals("LocalMode")) { LOG.info("Starting sample storm topology in LocalMode ..."); new LocalCluster().submitTopology("test_spout", topoConf, builder.createTopology()); } else if (mode.equals("RemoteMode")) { topoConf.setNumWorkers(1); topoConf.setMaxSpoutPending(5000); LOG.info("Submitting sample topology " + topologyName + " to remote cluster."); StormSubmitter.submitTopology(topologyName, topoConf, builder.createTopology()); } else { printUsageAndExit(); } }