Created
November 29, 2021 23:11
-
-
Save umeshdangat/4343274949a221ed5832bed9a1213b7d to your computer and use it in GitHub Desktop.
Guice Named Annotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
com.google.inject.CreationException: Unable to create injector, see the following errors: | |
1) [Guice/MissingImplementation]: No implementation for ContentDownloader was bound. | |
Did you mean? | |
ContentDownloader annotated with @Named("contentDownloaderNoTar") bound at ArchiverModule.providesContentDownloaderNoTar(ArchiverModule.java:94) | |
\_ installed by: LuceneServerModule -> ArchiverModule | |
ContentDownloader annotated with @Named("contentDownloaderWithTar") bound at ArchiverModule.providesContentDownloaderWithTar(ArchiverModule.java:112) | |
\_ installed by: LuceneServerModule -> ArchiverModule | |
Requested by: | |
1 : BackupDiffManager.<init>(BackupDiffManager.java:191) | |
\_ for 1st parameter | |
at ArchiverModule.providesIncArchiver(ArchiverModule.java:183) | |
\_ for 3rd parameter | |
at ArchiverModule.providesIncArchiver(ArchiverModule.java:183) | |
\_ installed by: LuceneServerModule -> ArchiverModule | |
Learn more: | |
https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION | |
2) [Guice/MissingImplementation]: No implementation for Path was bound. | |
Requested by: | |
1 : BackupDiffManager.<init>(BackupDiffManager.java:191) | |
\_ for 4th parameter | |
at ArchiverModule.providesIncArchiver(ArchiverModule.java:183) | |
\_ for 3rd parameter | |
at ArchiverModule.providesIncArchiver(ArchiverModule.java:183) | |
\_ installed by: LuceneServerModule -> ArchiverModule | |
Learn more: | |
https://github.com/google/guice/wiki/MISSING_IMPLEMENTATION | |
2 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/java/com/yelp/nrtsearch/ArchiverModule.java b/src/main/java/com/yelp/nrtsearch/ArchiverModule.java | |
index e3f1a61..b4ccad0 100644 | |
--- a/src/main/java/com/yelp/nrtsearch/ArchiverModule.java | |
+++ b/src/main/java/com/yelp/nrtsearch/ArchiverModule.java | |
@@ -40,31 +40,6 @@ public class ArchiverModule extends AbstractModule { | |
@Override | |
protected void configure() { | |
- bind(ContentDownloader.class) | |
- .annotatedWith(Names.named("contentDownloaderNoTar")) | |
- .toProvider(ContentDownloaderNoTar.class) | |
- .asEagerSingleton(); | |
- bind(ContentDownloader.class) | |
- .annotatedWith(Names.named("contentDownloaderWithTar")) | |
- .toProvider(ContentDownloaderWithTar.class) | |
- .asEagerSingleton(); | |
- bind(FileCompressAndUploader.class) | |
- .annotatedWith(Names.named("fileCompressAndUploaderNoTar")) | |
- .toProvider(FileCompressAndUploaderNoTar.class) | |
- .asEagerSingleton(); | |
- bind(FileCompressAndUploader.class) | |
- .annotatedWith(Names.named("fileCompressAndUploaderWithTar")) | |
- .toProvider(FileCompressAndUploaderWithTar.class) | |
- .asEagerSingleton(); | |
- bind(Archiver.class) | |
- .annotatedWith(Names.named("legacyArchiver")) | |
- .toProvider(LegacyArchiverProvider.class) | |
- .asEagerSingleton(); | |
- bind(BackupDiffManager.class).toProvider(BackupDiffManagerProvider.class).asEagerSingleton(); | |
- bind(Archiver.class) | |
- .annotatedWith(Names.named("incArchiver")) | |
- .toProvider(IncArchiverProvider.class) | |
- .asEagerSingleton(); | |
} | |
@Inject | |
@@ -110,141 +85,121 @@ public class ArchiverModule extends AbstractModule { | |
} | |
} | |
- private static class ContentDownloaderNoTar implements Provider<ContentDownloader> { | |
- private static final int NUM_S3_THREADS = 20; | |
- | |
- @Inject AmazonS3 s3; | |
- @Inject LuceneServerConfiguration luceneServerConfiguration; | |
- | |
- public ContentDownloader get() { | |
- return new ContentDownloaderImpl( | |
- new NoTarImpl(), | |
- TransferManagerBuilder.standard() | |
- .withS3Client(s3) | |
- .withExecutorFactory(() -> Executors.newFixedThreadPool(NUM_S3_THREADS)) | |
- .withShutDownThreadPools(false) | |
- .build(), | |
- luceneServerConfiguration.getBucketName(), | |
- true); | |
- } | |
+ @Named("contentDownloaderNoTar") | |
+ @Inject | |
+ @Singleton | |
+ @Provides | |
+ public ContentDownloader providesContentDownloaderNoTar( | |
+ AmazonS3 s3, LuceneServerConfiguration luceneServerConfiguration) { | |
+ final int NUM_S3_THREADS = 20; | |
+ return new ContentDownloaderImpl( | |
+ new NoTarImpl(), | |
+ TransferManagerBuilder.standard() | |
+ .withS3Client(s3) | |
+ .withExecutorFactory(() -> Executors.newFixedThreadPool(jjNUM_S3_THREADS)) | |
+ .withShutDownThreadPools(false) | |
+ .build(), | |
+ luceneServerConfiguration.getBucketName(), | |
+ true); | |
} | |
- private static class ContentDownloaderWithTar implements Provider<ContentDownloader> { | |
- private static final int NUM_S3_THREADS = 20; | |
- | |
- @Inject AmazonS3 s3; | |
- @Inject LuceneServerConfiguration luceneServerConfiguration; | |
- | |
- public ContentDownloader get() { | |
- return new ContentDownloaderImpl( | |
- new TarImpl(Tar.CompressionMode.LZ4), | |
- TransferManagerBuilder.standard() | |
- .withS3Client(s3) | |
- .withExecutorFactory(() -> Executors.newFixedThreadPool(NUM_S3_THREADS)) | |
- .withShutDownThreadPools(false) | |
- .build(), | |
- luceneServerConfiguration.getBucketName(), | |
- true); | |
- } | |
+ @Named("contentDownloaderWithTar") | |
+ @Inject | |
+ @Singleton | |
+ @Provides | |
+ public ContentDownloader providesContentDownloaderWithTar( | |
+ AmazonS3 s3, LuceneServerConfiguration luceneServerConfiguration) { | |
+ final int NUM_S3_THREADS = 20; | |
+ return new ContentDownloaderImpl( | |
+ new TarImpl(Tar.CompressionMode.LZ4), | |
+ TransferManagerBuilder.standard() | |
+ .withS3Client(s3) | |
+ .withExecutorFactory(() -> Executors.newFixedThreadPool(NUM_S3_THREADS)) | |
+ .withShutDownThreadPools(false) | |
+ .build(), | |
+ luceneServerConfiguration.getBucketName(), | |
+ true); | |
} | |
- private static class FileCompressAndUploaderNoTar implements Provider<FileCompressAndUploader> { | |
- private static final int NUM_S3_THREADS = 20; | |
- | |
- @Inject AmazonS3 s3; | |
- @Inject LuceneServerConfiguration luceneServerConfiguration; | |
- | |
- public FileCompressAndUploader get() { | |
- return new FileCompressAndUploader( | |
- new NoTarImpl(), | |
- TransferManagerBuilder.standard() | |
- .withS3Client(s3) | |
- .withExecutorFactory(() -> Executors.newFixedThreadPool(NUM_S3_THREADS)) | |
- .withShutDownThreadPools(false) | |
- .build(), | |
- luceneServerConfiguration.getBucketName()); | |
- } | |
+ @Named("fileCompressAndUploaderNoTar") | |
+ @Inject | |
+ @Singleton | |
+ @Provides | |
+ public FileCompressAndUploader providesFileCompressAndUploaderNoTar( | |
+ AmazonS3 s3, LuceneServerConfiguration luceneServerConfiguration) { | |
+ final int NUM_S3_THREADS = 20; | |
+ return new FileCompressAndUploader( | |
+ new NoTarImpl(), | |
+ TransferManagerBuilder.standard() | |
+ .withS3Client(s3) | |
+ .withExecutorFactory(() -> Executors.newFixedThreadPool(NUM_S3_THREADS)) | |
+ .withShutDownThreadPools(false) | |
+ .build(), | |
+ luceneServerConfiguration.getBucketName()); | |
} | |
- private static class FileCompressAndUploaderWithTar implements Provider<FileCompressAndUploader> { | |
- private static final int NUM_S3_THREADS = 20; | |
- | |
- @Inject AmazonS3 s3; | |
- @Inject LuceneServerConfiguration luceneServerConfiguration; | |
- | |
- public FileCompressAndUploader get() { | |
- return new FileCompressAndUploader( | |
- new TarImpl(Tar.CompressionMode.LZ4), | |
- TransferManagerBuilder.standard() | |
- .withS3Client(s3) | |
- .withExecutorFactory(() -> Executors.newFixedThreadPool(NUM_S3_THREADS)) | |
- .withShutDownThreadPools(false) | |
- .build(), | |
- luceneServerConfiguration.getBucketName()); | |
- } | |
+ @Named("fileCompressAndUploaderWithTar") | |
+ @Inject | |
+ @Singleton | |
+ @Provides | |
+ public FileCompressAndUploader providesFileCompressAndUploaderWithTar( | |
+ AmazonS3 s3, LuceneServerConfiguration luceneServerConfiguration) { | |
+ final int NUM_S3_THREADS = 20; | |
+ return new FileCompressAndUploader( | |
+ new TarImpl(Tar.CompressionMode.LZ4), | |
+ TransferManagerBuilder.standard() | |
+ .withS3Client(s3) | |
+ .withExecutorFactory(() -> Executors.newFixedThreadPool(NUM_S3_THREADS)) | |
+ .withShutDownThreadPools(false) | |
+ .build(), | |
+ luceneServerConfiguration.getBucketName()); | |
} | |
- private static class BackupDiffManagerProvider implements Provider<BackupDiffManager> { | |
- @Inject | |
- @Named("fileCompressAndUploaderNoTar") | |
- FileCompressAndUploader fileCompressAndUploader; | |
- | |
- @Inject | |
- @Named("contentDownloaderNoTar") | |
- ContentDownloader contentDownloader; | |
- | |
- @Inject AmazonS3 s3; | |
- @Inject LuceneServerConfiguration luceneServerConfiguration; | |
- | |
- @Override | |
- public BackupDiffManager get() { | |
- return new BackupDiffManager( | |
- contentDownloader, | |
- fileCompressAndUploader, | |
- new VersionManager(s3, luceneServerConfiguration.getBucketName()), | |
- Paths.get(luceneServerConfiguration.getArchiveDirectory())); | |
- } | |
+ @Named("legacyArchiver") | |
+ @Inject | |
+ @Singleton | |
+ @Provides | |
+ public Archiver providesLegacyArchiver( | |
+ AmazonS3 s3, LuceneServerConfiguration luceneServerConfiguration, Tar tar) { | |
+ Path archiveDir = Paths.get(luceneServerConfiguration.getArchiveDirectory()); | |
+ return new ArchiverImpl( | |
+ s3, | |
+ luceneServerConfiguration.getBucketName(), | |
+ archiveDir, | |
+ tar, | |
+ luceneServerConfiguration.getDownloadAsStream()); | |
} | |
- private static class LegacyArchiverProvider implements Provider<Archiver> { | |
- @Inject AmazonS3 s3; | |
- @Inject LuceneServerConfiguration luceneServerConfiguration; | |
- @Inject Tar tar; | |
- | |
- @Override | |
- public Archiver get() { | |
- Path archiveDir = Paths.get(luceneServerConfiguration.getArchiveDirectory()); | |
- return new ArchiverImpl( | |
- s3, | |
- luceneServerConfiguration.getBucketName(), | |
- archiveDir, | |
- tar, | |
- luceneServerConfiguration.getDownloadAsStream()); | |
- } | |
+ @Named("incArchiver") | |
+ @Inject | |
+ @Singleton | |
+ @Provides | |
+ public Archiver providesIncArchiver( | |
+ AmazonS3 s3, | |
+ LuceneServerConfiguration luceneServerConfiguration, | |
+ BackupDiffManager backupDiffManager, | |
+ @Named("fileCompressAndUploaderWithTar") FileCompressAndUploader fileCompressAndUploader, | |
+ @Named("contentDownloaderWithTar") ContentDownloader contentDownloader) { | |
+ return new IndexArchiver( | |
+ backupDiffManager, | |
+ fileCompressAndUploader, | |
+ contentDownloader, | |
+ new VersionManager(s3, luceneServerConfiguration.getBucketName()), | |
+ Paths.get(luceneServerConfiguration.getArchiveDirectory())); | |
} | |
- private static class IncArchiverProvider implements Provider<Archiver> { | |
- @Inject BackupDiffManager backupDiffManager; | |
- | |
- @Inject | |
- @Named("fileCompressAndUploaderWithTar") | |
- FileCompressAndUploader fileCompressAndUploader; | |
- | |
- @Inject | |
- @Named("contentDownloaderWithTar") | |
- ContentDownloader contentDownloader; | |
- | |
- @Inject LuceneServerConfiguration luceneServerConfiguration; | |
- @Inject AmazonS3 s3; | |
- | |
- @Override | |
- public Archiver get() { | |
- return new IndexArchiver( | |
- backupDiffManager, | |
- fileCompressAndUploader, | |
- contentDownloader, | |
- new VersionManager(s3, luceneServerConfiguration.getBucketName()), | |
- Paths.get(luceneServerConfiguration.getArchiveDirectory())); | |
- } | |
+ @Inject | |
+ @Singleton | |
+ @Provides | |
+ public Archiver providesBackupDiffManager( | |
+ AmazonS3 s3, | |
+ LuceneServerConfiguration luceneServerConfiguration, | |
+ @Named("fileCompressAndUploaderNoTar") FileCompressAndUploader fileCompressAndUploader, | |
+ @Named("contentDownloaderNoTar") ContentDownloader contentDownloader) { | |
+ return new BackupDiffManager( | |
+ contentDownloader, | |
+ fileCompressAndUploader, | |
+ new VersionManager(s3, luceneServerConfiguration.getBucketName()), | |
+ Paths.get(luceneServerConfiguration.getArchiveDirectory())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment