[ 
https://issues.apache.org/jira/browse/ACCUMULO-4837?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Keith Turner resolved ACCUMULO-4837.
------------------------------------
    Resolution: Duplicate

https://github.com/apache/accumulo/issues/1124

> Allow short service names in addition to class names.
> -----------------------------------------------------
>
>                 Key: ACCUMULO-4837
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-4837
>             Project: Accumulo
>          Issue Type: Improvement
>            Reporter: Keith Turner
>            Priority: Major
>
> In 2.0.0-SNAPSHOT the cache implementation was made configurable.  Currently 
> to configure it, you set a property like the following.
> {noformat}
>  
> tserver.cache.manager.class=org.apache.accumulo.core.file.blockfile.cache.tinylfu.TinyLfuBlockCacheManager
> {noformat}
> I would much rather be able to provide a short service name like the 
> following when configuring the cache.  However I do not want the list to be 
> predefined, I will want the user to be able to provide implementations.
> {noformat}
>   tserver.cache.implementation=tinylfu
> {noformat}
> What is a good way to do this? Is there a good reason not do this and just 
> stick with class names only?  I was also thinking it may be nice to have a 
> shell command for listing services, but this could be done independently.
> One way I thought of doing this is having an interface like the the following 
> that services (balancer, compaction strategy, cache, etc) could implement.
> {code:java}
> public interface AccumuloService {
>   /**
>    * A human readable, short, unique identification that can be specified in 
> configuration to identify a service implementation.
>    */
>   public String getName();
>   public static <C extends AccumuloService> C load(String configId, Class<C> 
> serviceType, ClassLoader classLoader) {
>     ServiceLoader<C> services = ServiceLoader.load(serviceType, classLoader);
>     for (C service : services) {
>       if(service.getName().equals(configId) || 
> service.getClass().getName().equals(configId)) {
>         return service;
>       }
>     }
>     return null;
>   }
> }
> {code}
> Then the cache implementation could provide a name
> {code:java}
> //assume BlockCacheManager implements AccumuloService
> public class TinyLfuBlockCacheManager extends BlockCacheManager {
>   private static final Logger LOG = 
> LoggerFactory.getLogger(TinyLfuBlockCacheManager.class);
>   @Override
>   protected TinyLfuBlockCache createCache(Configuration conf, CacheType type) 
> {
>     LOG.info("Creating {} cache with configuration {}", type, conf);
>     return new TinyLfuBlockCache(conf, type);
>   }
>   @Override
>   public String getName() {
>     return "tinylfu";
>   }
> }
> {code}
> The code to load a block cache impl would look like the following :
> {code:java}
>     String impl = conf.get(Property.TSERV_CACHE_MANAGER_IMPL);
>     BlockCacheManager bcm = AccumuloService.load(impl, 
> BlockCacheManager.class, AccumuloVFSClassLoader.getClassLoader());
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to