List of usage examples for com.amazonaws Protocol HTTP
Protocol HTTP
To view the source code for com.amazonaws Protocol HTTP.
Click Source Link
From source file:com.netflix.spinnaker.clouddriver.aws.security.AWSProxy.java
License:Apache License
public void apply(ClientConfiguration clientConfiguration) { clientConfiguration.setProxyHost(proxyHost); clientConfiguration.setProxyPort(Integer.parseInt(proxyPort)); clientConfiguration.setProxyUsername(proxyUsername); clientConfiguration.setProxyPassword(proxyPassword); Protocol awsProtocol = Protocol.HTTP; if ("HTTPS".equalsIgnoreCase(protocol)) { awsProtocol = Protocol.HTTPS;//from w w w. j a v a2 s. c o m } clientConfiguration.setProtocol(awsProtocol); if (isNTLMProxy()) { clientConfiguration.setProxyDomain(proxyDomain); clientConfiguration.setProxyWorkstation(proxyWorkstation); } }
From source file:com.neu.Spark.MainFrame.java
/** * Creates new form MainFrame/*ww w .j a v a 2s. c o m*/ */ public MainFrame() { initComponents(); AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); conn = new AmazonS3Client(credentials); conn.setEndpoint("s3.amazonaws.com"); }
From source file:com.tango.BucketSyncer.StorageClients.S3Client.java
License:Apache License
public void createClient(MirrorOptions options) { ClientConfiguration clientConfiguration = new ClientConfiguration().withProtocol(Protocol.HTTP) .withMaxConnections(options.getMaxConnections()); if (options.getHasProxy()) { clientConfiguration = clientConfiguration.withProxyHost(options.getProxyHost()) .withProxyPort(options.getProxyPort()); }// w w w .ja va 2 s.c o m this.s3Client = new AmazonS3Client(options, clientConfiguration); if (options.hasEndpoint()) { s3Client.setEndpoint(options.getEndpoint()); } }
From source file:com.yahoo.ycsb.db.S3Client.java
License:Open Source License
/** * Initialize any state for the storage./*from w ww .ja v a2 s .c o m*/ * Called once per S3 instance; If the client is not null it is re-used. */ @Override public void init() throws DBException { final int count = INIT_COUNT.incrementAndGet(); synchronized (S3Client.class) { Properties propsCL = getProperties(); int recordcount = Integer.parseInt(propsCL.getProperty("recordcount")); int operationcount = Integer.parseInt(propsCL.getProperty("operationcount")); int numberOfOperations = 0; if (recordcount > 0) { if (recordcount > operationcount) { numberOfOperations = recordcount; } else { numberOfOperations = operationcount; } } else { numberOfOperations = operationcount; } if (count <= numberOfOperations) { String accessKeyId = null; String secretKey = null; String endPoint = null; String region = null; String maxErrorRetry = null; String maxConnections = null; String protocol = null; BasicAWSCredentials s3Credentials; ClientConfiguration clientConfig; if (s3Client != null) { System.out.println("Reusing the same client"); return; } try { InputStream propFile = S3Client.class.getClassLoader().getResourceAsStream("s3.properties"); Properties props = new Properties(System.getProperties()); props.load(propFile); accessKeyId = props.getProperty("s3.accessKeyId"); if (accessKeyId == null) { accessKeyId = propsCL.getProperty("s3.accessKeyId"); } System.out.println(accessKeyId); secretKey = props.getProperty("s3.secretKey"); if (secretKey == null) { secretKey = propsCL.getProperty("s3.secretKey"); } System.out.println(secretKey); endPoint = props.getProperty("s3.endPoint"); if (endPoint == null) { endPoint = propsCL.getProperty("s3.endPoint", "s3.amazonaws.com"); } System.out.println(endPoint); region = props.getProperty("s3.region"); if (region == null) { region = propsCL.getProperty("s3.region", "us-east-1"); } System.out.println(region); maxErrorRetry = props.getProperty("s3.maxErrorRetry"); if (maxErrorRetry == null) { maxErrorRetry = propsCL.getProperty("s3.maxErrorRetry", "15"); } maxConnections = props.getProperty("s3.maxConnections"); if (maxConnections == null) { maxConnections = propsCL.getProperty("s3.maxConnections"); } protocol = props.getProperty("s3.protocol"); if (protocol == null) { protocol = propsCL.getProperty("s3.protocol", "HTTPS"); } sse = props.getProperty("s3.sse"); if (sse == null) { sse = propsCL.getProperty("s3.sse", "false"); } String ssec = props.getProperty("s3.ssec"); if (ssec == null) { ssec = propsCL.getProperty("s3.ssec", null); } else { ssecKey = new SSECustomerKey(ssec); } } catch (Exception e) { System.err.println("The file properties doesn't exist " + e.toString()); e.printStackTrace(); } try { System.out.println("Inizializing the S3 connection"); s3Credentials = new BasicAWSCredentials(accessKeyId, secretKey); clientConfig = new ClientConfiguration(); clientConfig.setMaxErrorRetry(Integer.parseInt(maxErrorRetry)); if (protocol.equals("HTTP")) { clientConfig.setProtocol(Protocol.HTTP); } else { clientConfig.setProtocol(Protocol.HTTPS); } if (maxConnections != null) { clientConfig.setMaxConnections(Integer.parseInt(maxConnections)); } s3Client = new AmazonS3Client(s3Credentials, clientConfig); s3Client.setRegion(Region.getRegion(Regions.fromName(region))); s3Client.setEndpoint(endPoint); System.out.println("Connection successfully initialized"); } catch (Exception e) { System.err.println("Could not connect to S3 storage: " + e.toString()); e.printStackTrace(); throw new DBException(e); } } else { System.err.println("The number of threads must be less or equal than the operations"); throw new DBException(new Error("The number of threads must be less or equal than the operations")); } } }
From source file:com.yahoo.ycsb.utils.connection.S3Connection.java
License:Open Source License
public S3Connection(String bucket, String region, String endPoint) throws ClientException { super(bucket, region, endPoint); logger.debug("S3Client.establishConnection(" + region + "," + endPoint + ") bucket: " + bucket); org.apache.log4j.Logger.getLogger("com.amazonaws").setLevel(Level.OFF); /*if (S3Connection.init == true) { init();//from www . j a v a2 s . c om S3Connection.init = false; }*/ this.bucket = bucket; this.region = region; try { BasicAWSCredentials s3Credentials = new BasicAWSCredentials(accessKeyId, secretKey); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setMaxErrorRetry(Integer.parseInt(maxErrorRetry)); if (protocol.equals("HTTP")) { clientConfig.setProtocol(Protocol.HTTP); } else { clientConfig.setProtocol(Protocol.HTTPS); } if (maxConnections != null) { clientConfig.setMaxConnections(Integer.parseInt(maxConnections)); } logger.debug("Inizializing the S3 connection..."); awsClient = new AmazonS3Client(s3Credentials, clientConfig); awsClient.setRegion(Region.getRegion(Regions.fromName(region))); awsClient.setEndpoint(endPoint); logger.debug("Connection successfully initialized"); } catch (Exception e) { logger.error("Could not connect to S3 storage: " + e.toString()); e.printStackTrace(); throw new ClientException(e); } }
From source file:de.taimos.pipeline.aws.ProxyConfiguration.java
License:Apache License
static void configure(EnvVars vars, ClientConfiguration config) { useJenkinsProxy(config);/*from w ww. j a v a2 s . c om*/ if (config.getProtocol() == Protocol.HTTP) { configureHTTP(vars, config); } else { configureHTTPS(vars, config); } configureNonProxyHosts(vars, 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:io.confluent.connect.s3.util.S3ProxyConfig.java
License:Open Source License
public static Protocol extractProtocol(String protocol) { if (StringUtils.isBlank(protocol)) { return Protocol.HTTPS; }//from w ww.j a v a 2 s. c o m return "http".equals(protocol.trim().toLowerCase(Locale.ROOT)) ? Protocol.HTTP : Protocol.HTTPS; }
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);/* w w w .j a v a 2 s . co 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:org.apache.druid.storage.s3.S3StorageDruidModule.java
License:Apache License
@Nullable private static Protocol parseProtocol(@Nullable String protocol) { if (protocol == null) { return null; }// w w w . ja v a2s . co m if (protocol.equalsIgnoreCase("http")) { return Protocol.HTTP; } else if (protocol.equalsIgnoreCase("https")) { return Protocol.HTTPS; } else { throw new IAE("Unknown protocol[%s]", protocol); } }