public final class CacheScheduler extends Object
 CacheScheduler.Entry entry = cacheScheduler.schedule(namespace); // or scheduleAndWait(namespace, timeout)
 CacheState cacheState = entry.getCacheState();
 // cacheState could be either NoCache or VersionedCache.
 if (cacheState instanceof NoCache) {
   // the cache is not yet created, or already closed
 } else if (cacheState instanceof VersionedCache) {
   Map<String, String> cache = ((VersionedCache) cacheState).getCache(); // use the cache
   // Although VersionedCache implements AutoCloseable, versionedCache shouldn't be manually closed
   // when obtained from entry.getCacheState(). If the namespace updates should be ceased completely,
   // entry.close() (see below) should be called, it will close the last VersionedCache itself.
   // On scheduled updates, outdated VersionedCaches are also closed automatically.
 }
 ...
 entry.close(); // close the last VersionedCache and unschedule future updates
 | Modifier and Type | Class and Description | 
|---|---|
static interface  | 
CacheScheduler.CacheState  | 
class  | 
CacheScheduler.Entry<T extends ExtractionNamespace>  | 
class  | 
CacheScheduler.EntryImpl<T extends ExtractionNamespace>
This class effectively contains the whole state and most of the logic of  
CacheScheduler.Entry, need to be a separate class
 because the Entry must not be referenced from the runnable executed in cacheManager's ExecutorService,
 that would be a leak preventing the Entry to be collected by GC, and therefore CacheScheduler.EntryImpl.entryCleaner to be run by
 the JVM. | 
static class  | 
CacheScheduler.NoCache  | 
class  | 
CacheScheduler.VersionedCache  | 
| Constructor and Description | 
|---|
CacheScheduler(ServiceEmitter serviceEmitter,
              Map<Class<? extends ExtractionNamespace>,CacheGenerator<?>> namespaceGeneratorMap,
              NamespaceExtractionCacheManager cacheManager)  | 
| Modifier and Type | Method and Description | 
|---|---|
CacheScheduler.VersionedCache | 
createVersionedCache(CacheScheduler.EntryImpl<? extends ExtractionNamespace> entryId,
                    String version)
This method should be used from  
CacheGenerator.generateCache(T, io.druid.server.lookup.namespace.cache.CacheScheduler.EntryImpl<T>, java.lang.String, io.druid.server.lookup.namespace.cache.CacheScheduler) implementations, to obtain a CacheScheduler.VersionedCache to be returned. | 
long | 
getActiveEntries()  | 
<T extends ExtractionNamespace> | 
schedule(T namespace)  | 
CacheScheduler.Entry | 
scheduleAndWait(ExtractionNamespace namespace,
               long waitForFirstRunMs)  | 
@Inject public CacheScheduler(ServiceEmitter serviceEmitter, Map<Class<? extends ExtractionNamespace>,CacheGenerator<?>> namespaceGeneratorMap, NamespaceExtractionCacheManager cacheManager)
public CacheScheduler.VersionedCache createVersionedCache(@Nullable CacheScheduler.EntryImpl<? extends ExtractionNamespace> entryId, String version)
CacheGenerator.generateCache(T, io.druid.server.lookup.namespace.cache.CacheScheduler.EntryImpl<T>, java.lang.String, io.druid.server.lookup.namespace.cache.CacheScheduler) implementations, to obtain a CacheScheduler.VersionedCache to be returned.entryId - an object uniquely corresponding to the CacheScheduler.Entry, for which VersionedCache is
                createdversion - version, associated with the cachepublic long getActiveEntries()
@Nullable public CacheScheduler.Entry scheduleAndWait(ExtractionNamespace namespace, long waitForFirstRunMs) throws InterruptedException
InterruptedExceptionpublic <T extends ExtractionNamespace> CacheScheduler.Entry schedule(T namespace)
Copyright © 2011–2018. All rights reserved.