org.jclouds.virtualbox.functions
Class MastersLoadingCache

java.lang.Object
  extended by com.google.common.cache.AbstractCache<K,V>
      extended by com.google.common.cache.AbstractLoadingCache<Image,Master>
          extended by org.jclouds.virtualbox.functions.MastersLoadingCache
All Implemented Interfaces:
com.google.common.base.Function<Image,Master>, com.google.common.cache.Cache<Image,Master>, com.google.common.cache.LoadingCache<Image,Master>

@Singleton
public class MastersLoadingCache
extends com.google.common.cache.AbstractLoadingCache<Image,Master>

A LoadingCache for masters. If the requested master has been previously created this returns it, if not it coordinates its creation including downloading isos and creating cache/config directories. This also implements Supplier in order to provide jetty with the current image (only one master can be created at a time).

Author:
dralves

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.common.cache.AbstractCache
com.google.common.cache.AbstractCache.SimpleStatsCounter, com.google.common.cache.AbstractCache.StatsCounter
 
Field Summary
static String HOST_ONLY_IFACE_NAME
           
protected  Logger logger
           
static int MASTER_PORT
           
 
Constructor Summary
MastersLoadingCache(String version, String installationKeySequence, String preconfigurationUrl, String workingDir, com.google.common.base.Function<MasterSpec,org.virtualbox_4_1.IMachine> masterLoader, com.google.common.base.Supplier<Map<Image,YamlImage>> yamlMapper, com.google.common.base.Supplier<org.virtualbox_4_1.VirtualBoxManager> manager, com.google.common.base.Function<URI,File> isoDownloader)
           
 
Method Summary
 void createCacheDirStructure()
           
 Master get(Image key)
           
 Master getIfPresent(Object key)
           
 
Methods inherited from class com.google.common.cache.AbstractLoadingCache
apply, getAll, getUnchecked, refresh
 
Methods inherited from class com.google.common.cache.AbstractCache
asMap, cleanUp, get, getAllPresent, invalidate, invalidateAll, invalidateAll, put, putAll, size, stats
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.common.cache.LoadingCache
asMap
 
Methods inherited from interface com.google.common.cache.Cache
cleanUp, get, getAllPresent, invalidate, invalidateAll, invalidateAll, put, putAll, size, stats
 
Methods inherited from interface com.google.common.base.Function
equals
 

Field Detail

MASTER_PORT

public static final int MASTER_PORT
See Also:
Constant Field Values

HOST_ONLY_IFACE_NAME

public static final String HOST_ONLY_IFACE_NAME
See Also:
Constant Field Values

logger

@Named(value="jclouds.compute")
protected Logger logger
Constructor Detail

MastersLoadingCache

@Inject
public MastersLoadingCache(String version,
                                  @Named(value="jclouds.virtualbox.installationkeysequence")
                                  String installationKeySequence,
                                  @Named(value="jclouds.virtualbox.preconfigurationurl")
                                  String preconfigurationUrl,
                                  @Named(value="jclouds.virtualbox.workingdir")
                                  String workingDir,
                                  com.google.common.base.Function<MasterSpec,org.virtualbox_4_1.IMachine> masterLoader,
                                  com.google.common.base.Supplier<Map<Image,YamlImage>> yamlMapper,
                                  com.google.common.base.Supplier<org.virtualbox_4_1.VirtualBoxManager> manager,
                                  com.google.common.base.Function<URI,File> isoDownloader)
Method Detail

createCacheDirStructure

@PostConstruct
public void createCacheDirStructure()

get

public Master get(Image key)
           throws ExecutionException
Throws:
ExecutionException

getIfPresent

public Master getIfPresent(Object key)


Copyright © 2009-2012 jclouds. All Rights Reserved.