Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add s3 storage option #2418

Open
wants to merge 1 commit into
base: s3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@
import org.commonjava.maven.galley.transport.htcli.UploadMetadataGenTransferDecorator;
import org.commonjava.storage.pathmapped.config.DefaultPathMappedStorageConfig;
import org.commonjava.storage.pathmapped.config.PathMappedStorageConfig;
import org.commonjava.storage.pathmapped.core.S3PhysicalStore;
import org.commonjava.storage.pathmapped.pathdb.datastax.CassandraPathDB;
import org.commonjava.storage.pathmapped.metrics.MeasuredPathDB;
import org.commonjava.storage.pathmapped.spi.PathDB;
import org.commonjava.storage.pathmapped.spi.PhysicalStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.S3Exception;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -236,7 +239,21 @@ protected boolean isMetricEnabled( String metricName )
}

File legacyBaseDir = config.getLegacyStorageBasedir();
PhysicalStore physicalStore = new LegacyReadonlyPhysicalStore( storeRoot, legacyBaseDir );
String storageType = config.getStorageType();
PhysicalStore physicalStore;
if (DefaultStorageProviderConfiguration.STORAGE_NFS.equals( storageType )) {
physicalStore = new LegacyReadonlyPhysicalStore( storeRoot, legacyBaseDir );
} else {
try {
S3Client s3Client = S3Client.builder().build();
String bucketName = config.getBucketName();
physicalStore = new S3PhysicalStore( s3Client, bucketName );
} catch ( S3Exception e ) {
logger.error( "Ran into error during storage init e: ", e);
throw e;
}

}

logger.info( "Create cacheProviderFactory, pathDB: {}, physicalStore: {}", pathDB, physicalStore );
PathMappedCacheProviderConfig cacheProviderConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public class DefaultStorageProviderConfiguration

public static final String STORAGE_DIR = "indy.storage.dir";

public static final String STORAGE_S3 = "s3";

public static final String STORAGE_NFS = "nfs";

public static final String DEFAULT_STORAGE = STORAGE_NFS;

public static final String NFS_STORAGE_DIR = "indy.storage.nfs.dir";

private File storageBasedir;
Expand All @@ -46,6 +52,10 @@ public class DefaultStorageProviderConfiguration

private File nfsStoreBasedir;

private String storageType;

private String bucketName;

private boolean storageTimeoutEnabled = true;

private boolean physicalFileExistenceCheckEnabled = false;
Expand Down Expand Up @@ -220,6 +230,31 @@ public void setLegacyStorageBasedir( File legacyStorageBasedir )
this.legacyStorageBasedir = legacyStorageBasedir;
}

public String getStorageType()
{
if (storageType == null) {
return DEFAULT_STORAGE;
}
return storageType;
}

@ConfigName( "storage.type" )
public void setStorageType( String storageType )
{
this.storageType = storageType;
}

public String getBucketName()
{
return bucketName;
}

@ConfigName( "storage.bucket.name" )
public void setBucketName( String bucketName )
{
this.bucketName = bucketName;
}

public boolean isStorageTimeoutEnabled()
{
return storageTimeoutEnabled;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<otelInstrumentationVersion>1.19.0-alpha</otelInstrumentationVersion>
<cassandraUnitVersion>3.7.1.0</cassandraUnitVersion>
<datastaxVersion>3.11.3</datastaxVersion>
<pathmappedStorageVersion>2.6</pathmappedStorageVersion>
<pathmappedStorageVersion>2.7-SNAPSHOT</pathmappedStorageVersion>
<o11yphantVersion>1.9.1</o11yphantVersion>
<swaggerVersion>1.6.6</swaggerVersion>
<agroalVersion>1.16</agroalVersion>
Expand Down
Loading