Search in sources :

Example 41 with Singleton

use of javax.inject.Singleton in project apollo by spotify.

the class EnvironmentModule method environmentFactory.

@Provides
@Singleton
EnvironmentFactory environmentFactory(Config configNode, ApolloConfig apolloConfig, Closer closer, Injector injector, IncomingRequestAwareClient incomingRequestAwareClient) {
    final String backend = apolloConfig.backend();
    final Client unawareClient = incomingRequestAwareClient.asUnawareClient();
    return EnvironmentFactoryBuilder.newBuilder(backend, unawareClient, closer, injector::getInstance).withStaticConfig(configNode).build();
}
Also used : Client(com.spotify.apollo.Client) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 42 with Singleton

use of javax.inject.Singleton in project TeamCityApp by vase4kin.

the class AppModule method providesCryptoManager.

@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
@Provides
@Singleton
protected CryptoManager providesCryptoManager() {
    KeyChain keyChain = new SharedPrefsBackedKeyChain(mApplication.getApplicationContext(), CryptoConfig.KEY_256);
    Crypto crypto = AndroidConceal.get().createDefaultCrypto(keyChain);
    return new CryptoManagerImpl(crypto);
}
Also used : Crypto(com.facebook.crypto.Crypto) SharedPrefsBackedKeyChain(com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain) CryptoManagerImpl(com.github.vase4kin.teamcityapp.crypto.CryptoManagerImpl) KeyChain(com.facebook.crypto.keychain.KeyChain) SharedPrefsBackedKeyChain(com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain) VisibleForTesting(android.support.annotation.VisibleForTesting) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 43 with Singleton

use of javax.inject.Singleton in project kiwix-android by kiwix.

the class TestNetworkModule method provideMockWebServer.

@Provides
@Singleton
MockWebServer provideMockWebServer() {
    MockWebServer mockWebServer = new MockWebServer();
    Thread thread = new Thread() {

        @Override
        public void run() {
            try {
                mockWebServer.start();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    thread.start();
    return mockWebServer;
}
Also used : MockWebServer(okhttp3.mockwebserver.MockWebServer) IOException(java.io.IOException) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 44 with Singleton

use of javax.inject.Singleton in project presto by prestodb.

the class RaptorModule method createDBI.

@ForMetadata
@Singleton
@Provides
public IDBI createDBI(@ForMetadata ConnectionFactory connectionFactory, TypeManager typeManager) {
    DBI dbi = new DBI(connectionFactory);
    dbi.registerMapper(new TableColumn.Mapper(typeManager));
    dbi.registerMapper(new Distribution.Mapper(typeManager));
    createTablesWithRetry(dbi);
    return dbi;
}
Also used : Distribution(com.facebook.presto.raptor.metadata.Distribution) IDBI(org.skife.jdbi.v2.IDBI) DBI(org.skife.jdbi.v2.DBI) TableColumn(com.facebook.presto.raptor.metadata.TableColumn) Singleton(javax.inject.Singleton) ForMetadata(com.facebook.presto.raptor.metadata.ForMetadata) Provides(com.google.inject.Provides)

Example 45 with Singleton

use of javax.inject.Singleton in project presto by prestodb.

the class StorageModule method createOrcFileTailSource.

@Singleton
@Provides
public OrcFileTailSource createOrcFileTailSource(OrcCacheConfig orcCacheConfig, MBeanExporter exporter) {
    int expectedFileTailSizeInBytes = toIntExact(orcCacheConfig.getExpectedFileTailSize().toBytes());
    boolean dwrfStripeCacheEnabled = orcCacheConfig.isDwrfStripeCacheEnabled();
    OrcFileTailSource orcFileTailSource = new StorageOrcFileTailSource(expectedFileTailSizeInBytes, dwrfStripeCacheEnabled);
    if (orcCacheConfig.isFileTailCacheEnabled()) {
        Cache<OrcDataSourceId, OrcFileTail> cache = CacheBuilder.newBuilder().maximumWeight(orcCacheConfig.getFileTailCacheSize().toBytes()).weigher((id, tail) -> ((OrcFileTail) tail).getTotalSize()).expireAfterAccess(orcCacheConfig.getFileTailCacheTtlSinceLastAccess().toMillis(), TimeUnit.MILLISECONDS).recordStats().build();
        CacheStatsMBean cacheStatsMBean = new CacheStatsMBean(cache);
        orcFileTailSource = new CachingOrcFileTailSource(orcFileTailSource, cache);
        exporter.export(generatedNameOf(CacheStatsMBean.class, connectorId + "_OrcFileTail"), cacheStatsMBean);
    }
    return orcFileTailSource;
}
Also used : Module(com.google.inject.Module) CacheStatsMBean(com.facebook.presto.hive.CacheStatsMBean) StripeMetadataSource(com.facebook.presto.orc.StripeMetadataSource) ShardOrganizer(com.facebook.presto.raptor.storage.organization.ShardOrganizer) StripeId(com.facebook.presto.orc.StripeReader.StripeId) OrcCacheConfig(com.facebook.presto.orc.cache.OrcCacheConfig) RowGroupIndex(com.facebook.presto.orc.metadata.RowGroupIndex) ExportBinder.newExporter(org.weakref.jmx.guice.ExportBinder.newExporter) CachingOrcFileTailSource(com.facebook.presto.orc.cache.CachingOrcFileTailSource) ShardManager(com.facebook.presto.raptor.metadata.ShardManager) DatabaseShardRecorder(com.facebook.presto.raptor.metadata.DatabaseShardRecorder) StripeMetadataSourceFactory(com.facebook.presto.orc.StripeMetadataSourceFactory) StripeStreamId(com.facebook.presto.orc.StripeReader.StripeStreamId) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Ticker(com.google.common.base.Ticker) DwrfAwareStripeMetadataSourceFactory(com.facebook.presto.orc.DwrfAwareStripeMetadataSourceFactory) List(java.util.List) CachingStripeMetadataSource(com.facebook.presto.orc.CachingStripeMetadataSource) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) BackupManager(com.facebook.presto.raptor.backup.BackupManager) AssignmentLimiter(com.facebook.presto.raptor.metadata.AssignmentLimiter) ShardCleanerConfig(com.facebook.presto.raptor.metadata.ShardCleanerConfig) Slice(io.airlift.slice.Slice) MetadataConfig(com.facebook.presto.raptor.metadata.MetadataConfig) Singleton(javax.inject.Singleton) ShardCompactor(com.facebook.presto.raptor.storage.organization.ShardCompactor) Binder(com.google.inject.Binder) OrcFileTail(com.facebook.presto.orc.metadata.OrcFileTail) Objects.requireNonNull(java.util.Objects.requireNonNull) ShardCompactionManager(com.facebook.presto.raptor.storage.organization.ShardCompactionManager) Math.toIntExact(java.lang.Math.toIntExact) OrcFileTailSource(com.facebook.presto.orc.cache.OrcFileTailSource) OrcDataSourceId(com.facebook.presto.orc.OrcDataSourceId) ObjectNames.generatedNameOf(org.weakref.jmx.ObjectNames.generatedNameOf) StorageStripeMetadataSource(com.facebook.presto.orc.StorageStripeMetadataSource) ShardCleaner(com.facebook.presto.raptor.metadata.ShardCleaner) OrganizationJobFactory(com.facebook.presto.raptor.storage.organization.OrganizationJobFactory) Scopes(com.google.inject.Scopes) ShardOrganizationManager(com.facebook.presto.raptor.storage.organization.ShardOrganizationManager) ShardRecorder(com.facebook.presto.raptor.metadata.ShardRecorder) TimeUnit(java.util.concurrent.TimeUnit) StorageOrcFileTailSource(com.facebook.presto.orc.cache.StorageOrcFileTailSource) Provides(com.google.inject.Provides) DatabaseShardManager(com.facebook.presto.raptor.metadata.DatabaseShardManager) ConfigBinder.configBinder(com.facebook.airlift.configuration.ConfigBinder.configBinder) JobFactory(com.facebook.presto.raptor.storage.organization.JobFactory) TemporalFunction(com.facebook.presto.raptor.storage.organization.TemporalFunction) Cache(com.google.common.cache.Cache) MBeanExporter(org.weakref.jmx.MBeanExporter) CachingOrcFileTailSource(com.facebook.presto.orc.cache.CachingOrcFileTailSource) OrcDataSourceId(com.facebook.presto.orc.OrcDataSourceId) CachingOrcFileTailSource(com.facebook.presto.orc.cache.CachingOrcFileTailSource) OrcFileTailSource(com.facebook.presto.orc.cache.OrcFileTailSource) StorageOrcFileTailSource(com.facebook.presto.orc.cache.StorageOrcFileTailSource) StorageOrcFileTailSource(com.facebook.presto.orc.cache.StorageOrcFileTailSource) CacheStatsMBean(com.facebook.presto.hive.CacheStatsMBean) OrcFileTail(com.facebook.presto.orc.metadata.OrcFileTail) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Singleton (javax.inject.Singleton)168 Provides (dagger.Provides)98 Provides (com.google.inject.Provides)57 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)21 Named (javax.inject.Named)17 OkHttpClient (okhttp3.OkHttpClient)17 Cache (okhttp3.Cache)10 List (java.util.List)9 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)8 Binder (com.google.inject.Binder)8 Module (com.google.inject.Module)8 CachingStripeMetadataSource (com.facebook.presto.orc.CachingStripeMetadataSource)7 DwrfAwareStripeMetadataSourceFactory (com.facebook.presto.orc.DwrfAwareStripeMetadataSourceFactory)7 OrcDataSourceId (com.facebook.presto.orc.OrcDataSourceId)7 StorageStripeMetadataSource (com.facebook.presto.orc.StorageStripeMetadataSource)7 StripeMetadataSource (com.facebook.presto.orc.StripeMetadataSource)7 StripeMetadataSourceFactory (com.facebook.presto.orc.StripeMetadataSourceFactory)7 CachingOrcFileTailSource (com.facebook.presto.orc.cache.CachingOrcFileTailSource)7 OrcCacheConfig (com.facebook.presto.orc.cache.OrcCacheConfig)7 OrcFileTailSource (com.facebook.presto.orc.cache.OrcFileTailSource)7