|
56 | 56 | import org.commonjava.maven.galley.transport.htcli.UploadMetadataGenTransferDecorator;
|
57 | 57 | import org.commonjava.storage.pathmapped.config.DefaultPathMappedStorageConfig;
|
58 | 58 | import org.commonjava.storage.pathmapped.config.PathMappedStorageConfig;
|
| 59 | +import org.commonjava.storage.pathmapped.core.S3PhysicalStore; |
59 | 60 | import org.commonjava.storage.pathmapped.pathdb.datastax.CassandraPathDB;
|
60 | 61 | import org.commonjava.storage.pathmapped.metrics.MeasuredPathDB;
|
61 | 62 | import org.commonjava.storage.pathmapped.spi.PathDB;
|
62 | 63 | import org.commonjava.storage.pathmapped.spi.PhysicalStore;
|
63 | 64 | import org.slf4j.Logger;
|
64 | 65 | import org.slf4j.LoggerFactory;
|
| 66 | +import software.amazon.awssdk.services.s3.S3Client; |
| 67 | +import software.amazon.awssdk.services.s3.model.S3Exception; |
65 | 68 |
|
66 | 69 | import javax.annotation.PostConstruct;
|
67 | 70 | import javax.enterprise.context.ApplicationScoped;
|
@@ -236,7 +239,21 @@ protected boolean isMetricEnabled( String metricName )
|
236 | 239 | }
|
237 | 240 |
|
238 | 241 | File legacyBaseDir = config.getLegacyStorageBasedir();
|
239 |
| - PhysicalStore physicalStore = new LegacyReadonlyPhysicalStore( storeRoot, legacyBaseDir ); |
| 242 | + String storageType = config.getStorageType(); |
| 243 | + PhysicalStore physicalStore; |
| 244 | + if (DefaultStorageProviderConfiguration.STORAGE_NFS.equals( storageType )) { |
| 245 | + physicalStore = new LegacyReadonlyPhysicalStore( storeRoot, legacyBaseDir ); |
| 246 | + } else { |
| 247 | + try { |
| 248 | + S3Client s3Client = S3Client.builder().build(); |
| 249 | + String bucketName = config.getBucketName(); |
| 250 | + physicalStore = new S3PhysicalStore( s3Client, bucketName ); |
| 251 | + } catch ( S3Exception e ) { |
| 252 | + logger.error( "Ran into error during storage init e: ", e); |
| 253 | + throw e; |
| 254 | + } |
| 255 | + |
| 256 | + } |
240 | 257 |
|
241 | 258 | logger.info( "Create cacheProviderFactory, pathDB: {}, physicalStore: {}", pathDB, physicalStore );
|
242 | 259 | PathMappedCacheProviderConfig cacheProviderConfig =
|
|
0 commit comments