From eb96f93759fb14a834afc73adbd46d79d0d68839 Mon Sep 17 00:00:00 2001 From: Jia Zhai Date: Tue, 19 Mar 2019 21:08:59 +0800 Subject: [PATCH] fix s3 spport for s3 api (#3845) --- .../jcloud/impl/BlobStoreManagedLedgerOffloader.java | 6 +++--- .../impl/BlobStoreManagedLedgerOffloaderTest.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloader.java b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloader.java index b8c2727220e13..96409b29d791a 100644 --- a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloader.java +++ b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloader.java @@ -67,6 +67,8 @@ import org.jclouds.io.Payloads; import org.jclouds.osgi.ProviderRegistry; import org.jclouds.s3.reference.S3Constants; +import org.jclouds.osgi.ApiRegistry; +import org.jclouds.s3.S3ApiMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -120,6 +122,7 @@ private static Pair createBlobStore(String driver, overrides.setProperty(Constants.PROPERTY_SO_TIMEOUT, "25000"); overrides.setProperty(Constants.PROPERTY_MAX_RETRIES, Integer.toString(100)); + ApiRegistry.registerApi(new S3ApiMetadata()); ProviderRegistry.registerProvider(new AWSS3ProviderMetadata()); ProviderRegistry.registerProvider(new GoogleCloudStorageProviderMetadata()); @@ -186,9 +189,6 @@ public static BlobStoreManagedLedgerOffloader create(TieredStorageConfigurationD OrderedScheduler scheduler) throws IOException { String driver = conf.getManagedLedgerOffloadDriver(); - if ("s3".equals(driver.toLowerCase())) { - driver = "aws-s3"; - } if (!driverSupported(driver)) { throw new IOException( "Not support this kind of driver as offload backend: " + driver); diff --git a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java index 47cd590b72d44..7f80397613ec2 100644 --- a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java +++ b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderTest.java @@ -239,6 +239,17 @@ public void testGcsSmallBlockSizeConfigured() throws Exception { } } + @Test + public void testS3DriverConfiguredWell() throws Exception { + TieredStorageConfigurationData conf = new TieredStorageConfigurationData(); + conf.setManagedLedgerOffloadDriver("s3"); + conf.setS3ManagedLedgerOffloadBucket(BUCKET); + conf.setS3ManagedLedgerOffloadServiceEndpoint("http://fake.s3.end.point"); + + // should success and no exception thrown. + BlobStoreManagedLedgerOffloader.create(conf, scheduler); + } + @Test public void testOffloadAndRead() throws Exception { ReadHandle toWrite = buildReadHandle(DEFAULT_BLOCK_SIZE, 3);