Skip to content

Commit

Permalink
Renamed AsyncExecutorBuilder to AsyncExecutorContainer
Browse files Browse the repository at this point in the history
Signed-off-by: Raghuvansh Raj <[email protected]>
  • Loading branch information
raghuvanshraj committed Jul 12, 2023
1 parent 13559da commit 7ebc460
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.core.common.Strings;
import org.opensearch.repositories.s3.S3ClientSettings.IrsaCredentials;
import org.opensearch.repositories.s3.async.AsyncExecutorBuilder;
import org.opensearch.repositories.s3.async.AsyncExecutorContainer;
import org.opensearch.repositories.s3.async.AsyncTransferEventLoopGroup;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
Expand Down Expand Up @@ -102,8 +102,8 @@ public synchronized void refreshAndClearCache(Map<String, S3ClientSettings> clie
*/
public AmazonAsyncS3Reference client(
RepositoryMetadata repositoryMetadata,
AsyncExecutorBuilder priorityExecutorBuilder,
AsyncExecutorBuilder normalExecutorBuilder
AsyncExecutorContainer priorityExecutorBuilder,
AsyncExecutorContainer normalExecutorBuilder
) {
final S3ClientSettings clientSettings = settings(repositoryMetadata);
{
Expand Down Expand Up @@ -164,8 +164,8 @@ S3ClientSettings settings(RepositoryMetadata repositoryMetadata) {
// proxy for testing
synchronized AmazonAsyncS3WithCredentials buildClient(
final S3ClientSettings clientSettings,
AsyncExecutorBuilder priorityExecutorBuilder,
AsyncExecutorBuilder normalExecutorBuilder
AsyncExecutorContainer priorityExecutorBuilder,
AsyncExecutorContainer normalExecutorBuilder
) {
setDefaultAwsProfilePath();
final S3AsyncClientBuilder builder = S3AsyncClient.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* An encapsulation for the {@link AsyncTransferEventLoopGroup}, and the stream reader and future completion executor services
*/
public class AsyncExecutorBuilder {
public class AsyncExecutorContainer {

private final ExecutorService futureCompletionExecutor;
private final ExecutorService streamReader;
Expand All @@ -26,7 +26,7 @@ public class AsyncExecutorBuilder {
* @param streamReader An {@link ExecutorService} to read streams for upload
* @param asyncTransferEventLoopGroup A {@link AsyncTransferEventLoopGroup} which encapsulates the netty {@link io.netty.channel.EventLoopGroup} for async uploads
*/
public AsyncExecutorBuilder(
public AsyncExecutorContainer(
ExecutorService futureCompletionExecutor,
ExecutorService streamReader,
AsyncTransferEventLoopGroup asyncTransferEventLoopGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.opensearch.cluster.metadata.RepositoryMetadata;
import org.opensearch.common.settings.MockSecureSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.repositories.s3.async.AsyncExecutorBuilder;
import org.opensearch.repositories.s3.async.AsyncExecutorContainer;
import org.opensearch.repositories.s3.async.AsyncTransferEventLoopGroup;
import org.opensearch.test.OpenSearchTestCase;

Expand All @@ -35,7 +35,7 @@ public void testCachedClientsAreReleased() {
final Settings settings = Settings.builder().put("endpoint", "http://first").put("region", "us-east-2").build();
final RepositoryMetadata metadata1 = new RepositoryMetadata("first", "s3", settings);
final RepositoryMetadata metadata2 = new RepositoryMetadata("second", "s3", settings);
final AsyncExecutorBuilder asyncExecutorBuilder = new AsyncExecutorBuilder(
final AsyncExecutorContainer asyncExecutorContainer = new AsyncExecutorContainer(
Executors.newSingleThreadExecutor(),
Executors.newSingleThreadExecutor(),
new AsyncTransferEventLoopGroup(1)
Expand All @@ -44,12 +44,12 @@ public void testCachedClientsAreReleased() {
final S3ClientSettings otherClientSettings = s3AsyncService.settings(metadata2);
assertSame(clientSettings, otherClientSettings);
final AmazonAsyncS3Reference reference = SocketAccess.doPrivileged(
() -> s3AsyncService.client(metadata1, asyncExecutorBuilder, asyncExecutorBuilder)
() -> s3AsyncService.client(metadata1, asyncExecutorContainer, asyncExecutorContainer)
);
reference.close();
s3AsyncService.close();
final AmazonAsyncS3Reference referenceReloaded = SocketAccess.doPrivileged(
() -> s3AsyncService.client(metadata1, asyncExecutorBuilder, asyncExecutorBuilder)
() -> s3AsyncService.client(metadata1, asyncExecutorContainer, asyncExecutorContainer)
);
assertNotSame(referenceReloaded, reference);
referenceReloaded.close();
Expand All @@ -70,7 +70,7 @@ public void testCachedClientsWithCredentialsAreReleased() {
final Settings settings = Settings.builder().put("endpoint", "http://first").put("region", "us-east-2").build();
final RepositoryMetadata metadata1 = new RepositoryMetadata("first", "s3", settings);
final RepositoryMetadata metadata2 = new RepositoryMetadata("second", "s3", settings);
final AsyncExecutorBuilder asyncExecutorBuilder = new AsyncExecutorBuilder(
final AsyncExecutorContainer asyncExecutorContainer = new AsyncExecutorContainer(
Executors.newSingleThreadExecutor(),
Executors.newSingleThreadExecutor(),
new AsyncTransferEventLoopGroup(1)
Expand All @@ -79,12 +79,12 @@ public void testCachedClientsWithCredentialsAreReleased() {
final S3ClientSettings otherClientSettings = s3AsyncService.settings(metadata2);
assertSame(clientSettings, otherClientSettings);
final AmazonAsyncS3Reference reference = SocketAccess.doPrivileged(
() -> s3AsyncService.client(metadata1, asyncExecutorBuilder, asyncExecutorBuilder)
() -> s3AsyncService.client(metadata1, asyncExecutorContainer, asyncExecutorContainer)
);
reference.close();
s3AsyncService.close();
final AmazonAsyncS3Reference referenceReloaded = SocketAccess.doPrivileged(
() -> s3AsyncService.client(metadata1, asyncExecutorBuilder, asyncExecutorBuilder)
() -> s3AsyncService.client(metadata1, asyncExecutorContainer, asyncExecutorContainer)
);
assertNotSame(referenceReloaded, reference);
referenceReloaded.close();
Expand Down

0 comments on commit 7ebc460

Please sign in to comment.