com.amazonaws.client.builder.ExecutorFactory Java Examples

The following examples show how to use com.amazonaws.client.builder.ExecutorFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CopyMapper.java    From circus-train with Apache License 2.0 6 votes vote down vote up
/**
 * Implementation of the Mapper::setup() method. This extracts the S3MapReduceCp options specified in the Job's
 * configuration, to set up the Job.
 *
 * @param context Mapper's context.
 * @throws IOException On IO failure.
 * @throws InterruptedException If the job is interrupted.
 */
@Override
public void setup(Context context) throws IOException, InterruptedException {
  conf = new S3MapReduceCpConfiguration(context.getConfiguration());

  ignoreFailures = conf.getBoolean(ConfigurationVariable.IGNORE_FAILURES);

  targetFinalPath = new Path(conf.get(S3MapReduceCpConstants.CONF_LABEL_TARGET_FINAL_PATH));

  AwsS3ClientFactory awsS3ClientFactory = new AwsS3ClientFactory();
  transferManager = TransferManagerBuilder
      .standard()
      .withMinimumUploadPartSize(conf.getLong(ConfigurationVariable.MINIMUM_UPLOAD_PART_SIZE))
      .withMultipartUploadThreshold(conf.getLong(ConfigurationVariable.MULTIPART_UPLOAD_THRESHOLD))
      .withS3Client(awsS3ClientFactory.newInstance(conf))
      .withShutDownThreadPools(true)
      .withExecutorFactory(new ExecutorFactory() {
        @Override
        public ExecutorService newExecutor() {
          return Executors.newFixedThreadPool(conf.getInt(ConfigurationVariable.NUMBER_OF_UPLOAD_WORKERS));
        }
      })
      .build();
}
 
Example #2
Source File: AwsClientTracing.java    From zipkin-aws with Apache License 2.0 6 votes vote down vote up
public <Builder extends AwsClientBuilder, Client> Client build(
    AwsClientBuilder<Builder, Client> builder
) {
  if (builder == null) throw new NullPointerException("builder == null");
  if (builder instanceof AwsAsyncClientBuilder) {
    ExecutorFactory executorFactory = ((AwsAsyncClientBuilder) builder).getExecutorFactory();
    if (executorFactory == null) {
      ClientConfiguration clientConfiguration = builder.getClientConfiguration();
      if (clientConfiguration == null) {
        clientConfiguration = defaultClientConfigurationFactory.getConfig();
      }
      ((AwsAsyncClientBuilder) builder).setExecutorFactory(
          new TracingExecutorFactory(currentTraceContext, clientConfiguration)
      );
    } else {
      ((AwsAsyncClientBuilder) builder).setExecutorFactory(
          new TracingExecutorFactoryWrapper(currentTraceContext, executorFactory)
      );
    }
  }
  builder.withRequestHandlers(new TracingRequestHandler(httpTracing));
  return builder.build();
}
 
Example #3
Source File: AwsClientTracing.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
TracingExecutorFactoryWrapper(
    CurrentTraceContext currentTraceContext,
    ExecutorFactory delegate
) {
  this.currentTraceContext = currentTraceContext;
  this.delegate = delegate;
}
 
Example #4
Source File: AmazonWebserviceClientFactoryBean.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected T createInstance() throws Exception {

	String builderName = this.clientClass.getName() + "Builder";
	Class<?> className = ClassUtils.resolveClassName(builderName,
			ClassUtils.getDefaultClassLoader());

	Method method = ClassUtils.getStaticMethod(className, "standard");
	Assert.notNull(method, "Could not find standard() method in class:'"
			+ className.getName() + "'");

	AwsClientBuilder<?, T> builder = (AwsClientBuilder<?, T>) ReflectionUtils
			.invokeMethod(method, null);

	if (this.executor != null) {
		AwsAsyncClientBuilder<?, T> asyncBuilder = (AwsAsyncClientBuilder<?, T>) builder;
		asyncBuilder.withExecutorFactory((ExecutorFactory) () -> this.executor);
	}

	if (this.credentialsProvider != null) {
		builder.withCredentials(this.credentialsProvider);
	}

	if (this.customRegion != null) {
		builder.withRegion(this.customRegion.getName());
	}
	else if (this.regionProvider != null) {
		builder.withRegion(this.regionProvider.getRegion().getName());
	}
	else {
		builder.withRegion(Regions.DEFAULT_REGION);
	}
	return builder.build();
}
 
Example #5
Source File: S3Accessor.java    From datacollector with Apache License 2.0 4 votes vote down vote up
ExecutorFactory createExecutorFactory(int threads) {
  return () -> Executors.newFixedThreadPool(threads);
}