public static BenderConfig load(AmazonS3ClientFactory s3ClientFactory, AmazonS3URI s3Uri) { AmazonS3Client s3 = s3ClientFactory.newInstance(); S3Object s3object = s3.getObject(s3Uri.getBucket(), s3Uri.getKey()); StringWriter writer = new StringWriter(); try { IOUtils.copy(s3object.getObjectContent(), writer, "UTF-8"); } catch (IOException e) { throw new ConfigurationException("Unable to read file from s3", e); } BenderConfig config = load(s3Uri.getKey().toString(), writer.toString()); config.setConfigFile(s3Uri.getURI().toString()); return config; }
public static BenderConfig load(AmazonS3ClientFactory s3ClientFactory, AmazonS3URI s3Uri) { AmazonS3Client s3 = s3ClientFactory.newInstance(); S3Object s3object = s3.getObject(s3Uri.getBucket(), s3Uri.getKey()); StringWriter writer = new StringWriter(); try { IOUtils.copy(s3object.getObjectContent(), writer, "UTF-8"); } catch (IOException e) { throw new ConfigurationException("Unable to read file from s3", e); } BenderConfig config = load(s3Uri.getKey().toString(), writer.toString()); config.setConfigFile(s3Uri.getURI().toString()); return config; }
public S3EventIterator(LambdaContext context, List<S3EventNotificationRecord> records, AmazonS3ClientFactory s3ClientFactory) { this.records = records; this.context = context; this.client = s3ClientFactory.newInstance(); this.config = new RetryConfigBuilder() .retryOnSpecificExceptions(SocketTimeoutException.class, UncheckedIOException.class) .withMaxNumberOfTries(3).withDelayBetweenTries(100, ChronoUnit.MILLIS) .withExponentialBackoff().build(); }
public S3EventIterator(LambdaContext context, List<S3EventNotificationRecord> records, AmazonS3ClientFactory s3ClientFactory) { this.records = records; this.context = context; this.client = s3ClientFactory.newInstance(); this.config = new RetryConfigBuilder() .retryOnSpecificExceptions(SocketTimeoutException.class, UncheckedIOException.class) .withMaxNumberOfTries(3).withDelayBetweenTries(100, ChronoUnit.MILLIS) .withExponentialBackoff().build(); }
@Override public void setConf(AbstractConfig config) { this.config = (GeoIpOperationConfig) config; AmazonS3Client client = this.s3Factory.newInstance(); AmazonS3URI uri = new AmazonS3URI(this.config.getGeoLiteDb()); GetObjectRequest req = new GetObjectRequest(uri.getBucket(), uri.getKey()); S3Object obj = client.getObject(req); try { this.databaseReader = new DatabaseReader.Builder(obj.getObjectContent()).withCache(new CHMCache()).build(); } catch (IOException e) { throw new ConfigurationException("Unable to read " + this.config.getGeoLiteDb(), e); } } }
@Override public void setConf(AbstractConfig config) { this.config = (GeoIpOperationConfig) config; AmazonS3Client client = this.s3Factory.newInstance(); AmazonS3URI uri = new AmazonS3URI(this.config.getGeoLiteDb()); GetObjectRequest req = new GetObjectRequest(uri.getBucket(), uri.getKey()); S3Object obj = client.getObject(req); try { this.databaseReader = new DatabaseReader.Builder(obj.getObjectContent()).withCache(new CHMCache()).build(); } catch (IOException e) { throw new ConfigurationException("Unable to read " + this.config.getGeoLiteDb(), e); } } }