title: Presto Plugins: Single JAR vs Multiple JARs
body: <ul>
  <li><p>My <a href="https://prestodb.io/docs/current/develop.html" rel="nofollow noreferrer"><code>Presto</code> <strong>plugin</strong></a> has 2 components: some <a href="https://prestodb.io/docs/current/develop/functions.html" rel="nofollow noreferrer"><code>UDF</code>s</a> (for basic <code>MD5</code> / <code>SHA1</code> <em>hashing</em>) and an <a href="https://prestodb.io/docs/current/develop/event-listener.html" rel="nofollow noreferrer"><code>EventListener</code></a> (for <em>logging</em> queries using <code>FluentD</code> logger)</p></li>
  <li><p>During development (<em>single-node</em> <code>Presto</code> cluster), I added them under a single <a href="https://github.com/prestodb/presto/blob/master/presto-spi/src/main/java/com/facebook/presto/spi/Plugin.java" rel="nofollow noreferrer"><em>Plugin class</em></a>, bundled a single <code>JAR</code> and faced no problem</p></li>
  <li><p>During <em>deployment</em> I found a pitfall: the <strong><code>UDF</code>s must be registered with all nodes</strong> whereas (my particular) <strong><code>EventListener</code> must be registered only with master node</strong></p></li>
  </ul>
  
  <hr>
  
  <p>Now I have two options</p>
  
  <p><strong>1. Bundle them together in single JAR</strong></p>
  
  <p>We can control <em>registration</em> of <code>UDF</code>s / <code>EventListener</code>s via external <strong>config file</strong> (different configs for master &amp; slave nodes). As more <code>UDF</code>s, <code>EventListener</code>s and other <code>SPI</code>s are added, a single <code>JAR</code> paired with tweaked config file with achieve the desired result.</p>
  
  <p><strong>2. Bundle them as separate JARs</strong></p>
  
  <p>We can create different <em>Plugin classes</em> for <code>UDF</code>s / <code>EventListener</code> and provide corresponding <strong>classpaths in <code>META-INF.services/com.facebook.spi.Plugin</code></strong> file through <code>Jenkins</code>. We'll then have different <code>JAR</code>s for different <em>components</em>: one JAR for all <code>UDF</code>s, one <code>JAR</code> for all <code>EventListener</code>s etc. However as more functionalities are added in future, we might end up having lots of different <code>JAR</code>s.</p>
  
  <hr>
  
  <p>My questions are</p>
  
  <ul>
  <li>What are the pros and cons of both techniques?</li>
  <li>Is there an alternate approach?</li>
  </ul>
  
  <hr>
  
  <p>I'm currently on <code>Presto 0.194</code> but will soon be upgrading to <code>Presto 0.206</code></p>