use of ai.verta.modeldb.artifactStore.storageservice.ArtifactStoreService in project modeldb by VertaAI.
the class ServiceSet method initializeArtifactStore.
private static ArtifactStoreService initializeArtifactStore(MDBArtifactStoreConfig mdbArtifactStoreConfig) throws ModelDBException, IOException {
// ------------- Start Initialize Cloud storage base on configuration ------------------
ArtifactStoreService artifactStoreService;
if (mdbArtifactStoreConfig.getArtifactEndpoint() != null) {
System.getProperties().put("artifactEndpoint.storeArtifact", mdbArtifactStoreConfig.getArtifactEndpoint().getStoreArtifact());
System.getProperties().put("artifactEndpoint.getArtifact", mdbArtifactStoreConfig.getArtifactEndpoint().getGetArtifact());
}
if (mdbArtifactStoreConfig.getNFS() != null && mdbArtifactStoreConfig.getNFS().getArtifactEndpoint() != null) {
System.getProperties().put("artifactEndpoint.storeArtifact", mdbArtifactStoreConfig.getNFS().getArtifactEndpoint().getStoreArtifact());
System.getProperties().put("artifactEndpoint.getArtifact", mdbArtifactStoreConfig.getNFS().getArtifactEndpoint().getGetArtifact());
}
switch(mdbArtifactStoreConfig.getArtifactStoreType()) {
case "S3":
if (!mdbArtifactStoreConfig.S3.getS3presignedURLEnabled()) {
System.setProperty(ModelDBConstants.CLOUD_BUCKET_NAME, mdbArtifactStoreConfig.S3.getCloudBucketName());
System.getProperties().put(SCAN_PACKAGES, "ai.verta.modeldb.artifactStore.storageservice.s3");
startSpringServer();
artifactStoreService = App.getInstance().applicationContext.getBean(S3Service.class);
} else {
artifactStoreService = new S3Service(mdbArtifactStoreConfig.S3.getCloudBucketName());
System.getProperties().put(SCAN_PACKAGES, "dummyPackageName");
startSpringServer();
}
break;
case "NFS":
String rootDir = mdbArtifactStoreConfig.getNFS().getNfsRootPath();
LOGGER.trace("NFS server root path {}", rootDir);
System.getProperties().put("file.upload-dir", rootDir);
System.getProperties().put(SCAN_PACKAGES, "ai.verta.modeldb.artifactStore.storageservice.nfs");
startSpringServer();
artifactStoreService = App.getInstance().applicationContext.getBean(NFSService.class);
break;
default:
throw new ModelDBException("Configure valid artifact store name in config.yaml file.");
}
// ------------- Finish Initialize Cloud storage base on configuration ------------------
LOGGER.info("ArtifactStore service initialized and resolved storage dependency before server start");
return artifactStoreService;
}
Aggregations